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