Commit 2001c7c2 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Fix TestLinkForget.

It was broken in 1b3f7953, which removed the possibility of
trivially inspecting go-fuse internal inode numbers.
parent 5d038d72
...@@ -345,20 +345,45 @@ func TestLinkForget(t *testing.T) { ...@@ -345,20 +345,45 @@ func TestLinkForget(t *testing.T) {
t.Fatalf("Link failed: %v", err) t.Fatalf("Link failed: %v", err)
} }
var s1, s2 syscall.Stat_t for _, fn := range []string{"file1", "file2"} {
err = syscall.Lstat(tc.mnt+"/file1", &s1) var s syscall.Stat_t
if err != nil { err = syscall.Lstat(tc.mnt+"/"+fn, &s)
t.Fatalf("Lstat failed: %v", err) if err != nil {
t.Fatalf("Lstat failed: %v", err)
}
tc.pathFs.ForgetClientInodes()
}
// Now, the backing files are still hardlinked, but go-fuse's
// view of them should not be because of the
// ForgetClientInodes call. To prove this, we swap out the
// files in the backing store, and prove that they are
// distinct by truncating to different lengths.
for _, fn := range []string{"file1", "file2"} {
fn = tc.orig + "/" + fn
if err := os.Remove(fn); err != nil {
t.Fatalf("Remove", err)
}
if err := ioutil.WriteFile(fn, []byte(c), 0644); err != nil {
t.Fatalf("WriteFile", err)
}
} }
for i, fn := range []string{"file1", "file2"} {
tc.pathFs.ForgetClientInodes() fn = tc.mnt + "/" + fn
if err := os.Truncate(fn, int64(i)); err != nil {
err = syscall.Lstat(tc.mnt+"/file2", &s2) t.Fatalf("Truncate", err)
if err != nil { }
t.Fatalf("Lstat failed: %v", err)
} }
if s1.Ino == s2.Ino {
t.Error("After forget, we should not export links") for i, fn := range []string{"file1", "file2"} {
var s syscall.Stat_t
err = syscall.Lstat(tc.mnt+"/"+fn, &s)
if err != nil {
t.Fatalf("Lstat failed: %v", err)
}
if s.Size != int64(i) {
t.Errorf("Lstat(%q): got size %d, want %d", fn, s.Size, i)
}
} }
} }
......
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