btrfs_test.go 552 B

12345678910111213141516171819202122232425262728293031
  1. package btrfs
  2. import (
  3. "io/ioutil"
  4. "os"
  5. "os/exec"
  6. "strings"
  7. "testing"
  8. )
  9. func TestSetNOCOW(t *testing.T) {
  10. f, err := ioutil.TempFile(".", "etcdtest")
  11. if err != nil {
  12. t.Fatal("Failed creating temp dir")
  13. }
  14. name := f.Name()
  15. f.Close()
  16. defer os.Remove(name)
  17. if IsBtrfs(name) {
  18. SetNOCOWFile(name)
  19. cmd := exec.Command("lsattr", name)
  20. out, err := cmd.Output()
  21. if err != nil {
  22. t.Fatal("Failed executing lsattr")
  23. }
  24. if !strings.Contains(string(out), "---------------C") {
  25. t.Fatal("Failed setting NOCOW:\n", string(out))
  26. }
  27. }
  28. }