summaryrefslogtreecommitdiff
path: root/internal/fusefrontend/openbackingdir_test.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2021-04-03 12:29:17 +0200
committerJakob Unterwurzacher2021-04-03 12:34:18 +0200
commit6aae2aad97aee1d269fdbafab6eafa6ff997a73a (patch)
treecbdf97289c85e010249e390b0c2dc97efc4f2416 /internal/fusefrontend/openbackingdir_test.go
parent6b28c0be2ce1a2a90a1d186adf91052d5192a55e (diff)
tests: fusefronted: fix TestOpenBackingDir
This test only worked accidentially, and would break once dirfd caching is added. fs.Mkdir(..., "dir1/dir2", ...) is illegal (child name cannot contain slashes).
Diffstat (limited to 'internal/fusefrontend/openbackingdir_test.go')
-rw-r--r--internal/fusefrontend/openbackingdir_test.go28
1 files changed, 15 insertions, 13 deletions
diff --git a/internal/fusefrontend/openbackingdir_test.go b/internal/fusefrontend/openbackingdir_test.go
index 6d799b7..ba4014f 100644
--- a/internal/fusefrontend/openbackingdir_test.go
+++ b/internal/fusefrontend/openbackingdir_test.go
@@ -15,22 +15,25 @@ import (
func TestOpenBackingDir(t *testing.T) {
cipherdir := test_helpers.InitFS(t)
+ t.Logf("cipherdir = %q", cipherdir)
args := Args{
Cipherdir: cipherdir,
}
- fs := newTestFS(args)
+ rn := newTestFS(args)
out := &fuse.EntryOut{}
- _, errno := fs.Mkdir(nil, "dir1", 0700, out)
+ child, errno := rn.Mkdir(nil, "dir1", 0700, out)
if errno != 0 {
t.Fatal(errno)
}
- _, errno = fs.Mkdir(nil, "dir1/dir2", 0700, out)
+ rn.AddChild("dir1", child, false)
+ dir1 := toNode(child.Operations())
+ _, errno = dir1.Mkdir(nil, "dir2", 0700, out)
if errno != 0 {
t.Fatal(errno)
}
- dirfd, cName, err := fs.openBackingDir("")
+ dirfd, cName, err := rn.openBackingDir("")
if err != nil {
t.Fatal(err)
}
@@ -40,8 +43,8 @@ func TestOpenBackingDir(t *testing.T) {
syscall.Close(dirfd)
// Again, but populate the cache for "" by looking up a non-existing file
- fs.Lookup(nil, "xyz1234", &fuse.EntryOut{})
- dirfd, cName, err = fs.openBackingDir("")
+ rn.Lookup(nil, "xyz1234", &fuse.EntryOut{})
+ dirfd, cName, err = rn.openBackingDir("")
if err != nil {
t.Fatal(err)
}
@@ -59,7 +62,7 @@ func TestOpenBackingDir(t *testing.T) {
}
syscall.Close(dirfd)
- dirfd, cName, err = fs.openBackingDir("dir1")
+ dirfd, cName, err = rn.openBackingDir("dir1")
if err != nil {
t.Fatal(err)
}
@@ -72,7 +75,7 @@ func TestOpenBackingDir(t *testing.T) {
}
syscall.Close(dirfd)
- dirfd, cName, err = fs.openBackingDir("dir1/dir2")
+ dirfd, cName, err = rn.openBackingDir("dir1/dir2")
if err != nil {
t.Fatal(err)
}
@@ -81,14 +84,13 @@ func TestOpenBackingDir(t *testing.T) {
}
err = syscallcompat.Faccessat(dirfd, cName, unix.R_OK)
if err != nil {
- t.Error(err)
+ t.Errorf("Faccessat(%d, %q): %v", dirfd, cName, err)
}
syscall.Close(dirfd)
n255 := strings.Repeat("n", 255)
- path := "dir1/" + n255
- fs.Mkdir(nil, path, 0700, out)
- dirfd, cName, err = fs.openBackingDir(path)
+ dir1.Mkdir(nil, n255, 0700, out)
+ dirfd, cName, err = rn.openBackingDir("dir1/" + n255)
if err != nil {
t.Fatal(err)
}
@@ -100,7 +102,7 @@ func TestOpenBackingDir(t *testing.T) {
}
err = syscallcompat.Faccessat(dirfd, cName, unix.R_OK)
if err != nil {
- t.Error(err)
+ t.Errorf("Faccessat(%d, %q): %v", dirfd, cName, err)
}
syscall.Close(dirfd)
}