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
err = syscall.Lstat(tc.mnt+"/"+fn, &s)
if err != nil { if err != nil {
t.Fatalf("Lstat failed: %v", err) t.Fatalf("Lstat failed: %v", err)
} }
tc.pathFs.ForgetClientInodes() tc.pathFs.ForgetClientInodes()
}
err = syscall.Lstat(tc.mnt+"/file2", &s2) // 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"} {
fn = tc.mnt + "/" + fn
if err := os.Truncate(fn, int64(i)); err != nil {
t.Fatalf("Truncate", err)
}
}
for i, fn := range []string{"file1", "file2"} {
var s syscall.Stat_t
err = syscall.Lstat(tc.mnt+"/"+fn, &s)
if err != nil { if err != nil {
t.Fatalf("Lstat failed: %v", err) t.Fatalf("Lstat failed: %v", err)
} }
if s1.Ino == s2.Ino { if s.Size != int64(i) {
t.Error("After forget, we should not export links") 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