Ejemplo n.º 1
0
func TestEndToEndMkdirNoParentTimestamp(t *testing.T) {
	tc := NewTestCase(t)
	defer tc.Clean()

	tc.RunSuccess(WorkRequest{
		Argv: []string{"mkdir", "-p", tc.wd + "/dir"},
	})
	rootless := strings.TrimLeft(tc.wd, "/")
	beforeTime := tc.master.attributes.Get(rootless + "/dir").ChangeTime()
	var after *attr.FileAttr
	for i := 0; ; i++ {
		time.Sleep(10e6)
		subdir := fmt.Sprintf(tc.wd+"/dir/subdir%d", i)
		tc.RunSuccess(WorkRequest{
			Argv: []string{"mkdir", subdir},
		})
		after = tc.master.attributes.Get(strings.TrimLeft(subdir, "/"))
		if !after.ChangeTime().Equal(beforeTime) {
			break
		}
	}

	afterDir := tc.master.attributes.Get(rootless + "/dir")
	if afterDir.ChangeTime().Equal(beforeTime) {
		t.Errorf("Forgot to update parent timestamps")
	}
}
Ejemplo n.º 2
0
func GetattrForTest(t *testing.T, n string) *attr.FileAttr {
	t.Logf("test getattr %q", n)
	fi, _ := os.Lstat(n)

	var fa *fuse.Attr
	if fi != nil {
		fa = fuse.ToAttr(fi)
	}
	a := attr.FileAttr{
		Attr: fa,
	}
	if !a.Deletion() {
		a.ReadFromFs(n, crypto.MD5)
	}
	return &a
}