Commit ae87e918 authored by Jakob Unterwurzacher's avatar Jakob Unterwurzacher Committed by Han-Wen Nienhuys

tests: make RenameOpenDir more sensitive

The test seemed to pass because the inode number is overridden
in rawBridge.getattr, but looking at the permissions shows that
the wrong directory is stat()ed:

  $ go test ./fs -run TestPosix/RenameOpenDir -count 1  -v
  [...]
  17:49:46.454077 received ENODEV (unmount request), thread exiting
  17:49:46.454343 received ENODEV (unmount request), thread exiting
  --- PASS: TestPosix (0.01s)
      --- SKIP: TestPosix/RenameOpenDir (0.01s)
          test.go:392: got permissions 0755, want 0700. Known limitation - see https://github.com/hanwen/go-fuse/issues/55
  PASS
  ok    github.com/hanwen/go-fuse/v2/fs 0.016s

Also, add a log message whenever the inode number is overridden,
this should (probably) not happen during normal operation. And
it actually only happens once in the test suite (in RenameOpenDir):

  $ go test ./... -count 1 -v 2>&1 | grep "overriding ino"
  14:48:44.143694 warning: rawBridge.getattr: overriding ino 188663 with 186314

See https://github.com/hanwen/go-fuse/issues/55

Change-Id: I8b2ddb84c35a3b28b4f5e032e7113f8d484a5981
parent ee9c8261
...@@ -475,6 +475,9 @@ func (b *rawBridge) getattr(ctx context.Context, n *Inode, f FileHandle, out *fu ...@@ -475,6 +475,9 @@ func (b *rawBridge) getattr(ctx context.Context, n *Inode, f FileHandle, out *fu
} }
if errno == 0 { if errno == 0 {
if out.Ino != 0 && n.stableAttr.Ino > 1 && out.Ino != n.stableAttr.Ino {
b.logf("warning: rawBridge.getattr: overriding ino %d with %d", out.Ino, n.stableAttr.Ino)
}
out.Ino = n.stableAttr.Ino out.Ino = n.stableAttr.Ino
out.Mode = (out.Attr.Mode & 07777) | n.stableAttr.Mode out.Mode = (out.Attr.Mode & 07777) | n.stableAttr.Mode
b.setAttr(&out.Attr) b.setAttr(&out.Attr)
......
...@@ -424,8 +424,8 @@ func RenameOpenDir(t *testing.T, mnt string) { ...@@ -424,8 +424,8 @@ func RenameOpenDir(t *testing.T, mnt string) {
if err := os.Mkdir(mnt+"/dir1", 0755); err != nil { if err := os.Mkdir(mnt+"/dir1", 0755); err != nil {
t.Fatalf("Mkdir: %v", err) t.Fatalf("Mkdir: %v", err)
} }
// Different permissions so directories are easier to tell apart
if err := os.Mkdir(mnt+"/dir2", 0755); err != nil { if err := os.Mkdir(mnt+"/dir2", 0700); err != nil {
t.Fatalf("Mkdir: %v", err) t.Fatalf("Mkdir: %v", err)
} }
...@@ -445,7 +445,7 @@ func RenameOpenDir(t *testing.T, mnt string) { ...@@ -445,7 +445,7 @@ func RenameOpenDir(t *testing.T, mnt string) {
var st2 syscall.Stat_t var st2 syscall.Stat_t
if err := syscall.Fstat(fd, &st2); err != nil { if err := syscall.Fstat(fd, &st2); err != nil {
t.Fatalf("Fstat: %v", err) t.Skipf("Fstat failed: %v. Known limitation - see https://github.com/hanwen/go-fuse/issues/55", err)
} }
if st2.Mode&syscall.S_IFMT != syscall.S_IFDIR { if st2.Mode&syscall.S_IFMT != syscall.S_IFDIR {
t.Errorf("got mode %o, want %o", st2.Mode, syscall.S_IFDIR) t.Errorf("got mode %o, want %o", st2.Mode, syscall.S_IFDIR)
...@@ -453,6 +453,10 @@ func RenameOpenDir(t *testing.T, mnt string) { ...@@ -453,6 +453,10 @@ func RenameOpenDir(t *testing.T, mnt string) {
if st2.Ino != st1.Ino { if st2.Ino != st1.Ino {
t.Errorf("got ino %d, want %d", st2.Ino, st1.Ino) t.Errorf("got ino %d, want %d", st2.Ino, st1.Ino)
} }
if st2.Mode&0777 != st1.Mode&0777 {
t.Skipf("got permissions %#o, want %#o. Known limitation - see https://github.com/hanwen/go-fuse/issues/55",
st2.Mode&0777, st1.Mode&0777)
}
} }
// ReadDir creates 110 files one by one, checking that we get the expected // ReadDir creates 110 files one by one, checking that we get the expected
......
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