Commit 4c2b5911 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Add failing test for rm -rf.

parent 426a23cf
package unionfs
import (
"exec"
"os"
"github.com/hanwen/go-fuse/fuse"
"io/ioutil"
......@@ -53,8 +54,9 @@ func setupUfs(t *testing.T) (workdir string, cleanup func()) {
NegativeTimeout: .5 * entryTtl,
}
state, _, err := fuse.MountFileSystem(wd+"/mount", ufs, opts)
state, conn, err := fuse.MountFileSystem(wd+"/mount", ufs, opts)
CheckSuccess(err)
conn.Debug = true
state.Debug = true
go state.Loop(false)
......@@ -672,6 +674,38 @@ func TestRemoveAll(t *testing.T) {
}
}
func TestRmRf(t *testing.T) {
t.Log("TestRemoveAll")
wd, clean := setupUfs(t)
defer clean()
err := os.MkdirAll(wd+"/ro/dir/subdir", 0755)
CheckSuccess(err)
contents := "hello"
fn := wd + "/ro/dir/subdir/y"
err = ioutil.WriteFile(fn, []byte(contents), 0644)
CheckSuccess(err)
cmd := exec.Command("/bin/rm", "-rf", wd + "/mount/dir")
err = cmd.Run()
if err != nil {
t.Fatal("rm -rf returned error:", err)
}
for _, f := range []string{"dir/subdir/y", "dir/subdir", "dir"} {
if fi, _ := os.Lstat(filepath.Join(wd, "mount", f)); fi != nil {
t.Errorf("file %s should have disappeared: %v", f, fi)
}
}
names, err := Readdirnames(wd + "/rw/DELETIONS")
CheckSuccess(err)
if len(names) != 3 {
t.Fatal("unexpected names", names)
}
}
func Readdirnames(dir string) ([]string, os.Error) {
f, err := os.Open(dir)
if err != nil {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment