aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Unterwurzacher2025-06-19 13:44:18 +0200
committerJakob Unterwurzacher2025-06-19 22:03:06 +0200
commit66bfd4d9fef5df871348964526b64b700ee6a19c (patch)
tree81058942ab04a0c793295341aee5fadb001adace
parent8f37c3bfe26876df449495bdf4dcedf6dd0b6859 (diff)
testing: reverse: factor out newReverseFS
Will be used soon in a new gitignore test. Relates-to: https://github.com/rfjakob/gocryptfs/issues/927
-rw-r--r--tests/reverse/main_test.go32
1 files changed, 20 insertions, 12 deletions
diff --git a/tests/reverse/main_test.go b/tests/reverse/main_test.go
index 2fc9e5e..142e3eb 100644
--- a/tests/reverse/main_test.go
+++ b/tests/reverse/main_test.go
@@ -40,23 +40,14 @@ func TestMain(m *testing.M) {
{false, true},
}
for i, tc := range testcases {
- argsA := []string{"-reverse"}
+ // Fill the global vars
plaintextnames, deterministic_names = tc.plaintextnames, tc.deterministic_names
- if tc.plaintextnames {
- argsA = append(argsA, "-plaintextnames")
- } else if tc.deterministic_names {
- argsA = append(argsA, "-deterministic-names")
- }
- dirA = test_helpers.InitFS(nil, argsA...)
- dirB = test_helpers.TmpDir + "/b"
+
+ dirA, dirB, _ = newReverseFS(nil)
dirC = test_helpers.TmpDir + "/c"
- if err := os.Mkdir(dirB, 0700); err != nil {
- panic(err)
- }
if err := os.Mkdir(dirC, 0700); err != nil {
panic(err)
}
- test_helpers.MountOrExit(dirA, dirB, "-reverse", "-extpass", "echo test")
test_helpers.MountOrExit(dirB, dirC, "-extpass", "echo test")
r = m.Run()
test_helpers.UnmountPanic(dirC)
@@ -73,3 +64,20 @@ func TestMain(m *testing.M) {
}
os.Exit(r)
}
+
+// newReverseFS creates and mounts a new, empty reverse filesystem.
+func newReverseFS(extraMountArgs []string) (backingDir, mntDir, ctlsockPath string) {
+ args := []string{"-reverse"}
+ if plaintextnames {
+ args = append(args, "-plaintextnames")
+ } else if deterministic_names {
+ args = append(args, "-deterministic-names")
+ }
+ backingDir = test_helpers.InitFS(nil, args...)
+ mntDir = backingDir + ".mnt"
+ ctlsockPath = mntDir + ".sock"
+ mountArgs := []string{"-reverse", "-extpass", "echo test", "-ctlsock", ctlsockPath}
+ mountArgs = append(mountArgs, extraMountArgs...)
+ test_helpers.MountOrExit(backingDir, mntDir, mountArgs...)
+ return
+}