From 255a71c9179b9ad32587b20c41f81dc0b8cc3f44 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sat, 20 Mar 2021 10:33:34 +0100 Subject: tests: MountOrFatal creates mnt dir itself Allows to drop a few Mkdir()s. --- tests/cli/cli_test.go | 20 ++------------------ tests/root_test/root_test.go | 4 ---- tests/test_helpers/mount_unmount.go | 1 + 3 files changed, 3 insertions(+), 22 deletions(-) diff --git a/tests/cli/cli_test.go b/tests/cli/cli_test.go index 9d25062..9248f5d 100644 --- a/tests/cli/cli_test.go +++ b/tests/cli/cli_test.go @@ -516,17 +516,13 @@ func TestMultipleOperationFlags(t *testing.T) { func TestNoexec(t *testing.T) { dir := test_helpers.InitFS(t) mnt := dir + ".mnt" - err := os.Mkdir(mnt, 0700) - if err != nil { - t.Fatal(err) - } test_helpers.MountOrFatal(t, dir, mnt, "-extpass=echo test", "-noexec") defer test_helpers.UnmountPanic(mnt) sh := mnt + "/x.sh" content := `#!/bin/bash echo hello ` - err = ioutil.WriteFile(sh, []byte(content), 0755) + err := ioutil.WriteFile(sh, []byte(content), 0755) if err != nil { t.Fatal(err) } @@ -633,11 +629,7 @@ func TestIdle(t *testing.T) { func TestNotIdle(t *testing.T) { dir := test_helpers.InitFS(t) mnt := dir + ".mnt" - err := os.Mkdir(mnt, 0700) - if err != nil { - t.Fatal(err) - } - err = test_helpers.Mount(dir, mnt, false, "-extpass", "echo test", "-i=100ms") + err := test_helpers.Mount(dir, mnt, false, "-extpass", "echo test", "-i=100ms") if err != nil { t.Fatal(err) } @@ -829,10 +821,6 @@ func TestInitNotEmpty(t *testing.T) { func TestSharedstorage(t *testing.T) { dir := test_helpers.InitFS(t) mnt := dir + ".mnt" - err := os.Mkdir(mnt, 0700) - if err != nil { - t.Fatal(err) - } test_helpers.MountOrFatal(t, dir, mnt, "-extpass=echo test", "-sharedstorage") defer test_helpers.UnmountPanic(mnt) foo1 := mnt + "/foo1" @@ -878,10 +866,6 @@ func TestMountCreat(t *testing.T) { dir := test_helpers.InitFS(t) mnt := dir + ".mnt" - err := os.Mkdir(mnt, 0700) - if err != nil { - t.Fatal(err) - } for j := 0; j < repeat; j++ { test_helpers.MountOrFatal(t, dir, mnt, "-extpass=echo test") diff --git a/tests/root_test/root_test.go b/tests/root_test/root_test.go index 079c03b..9a22add 100644 --- a/tests/root_test/root_test.go +++ b/tests/root_test/root_test.go @@ -191,10 +191,6 @@ func TestDiskFull(t *testing.T) { // Mount gocryptfs mnt := ext4mnt + "/b" - err = os.Mkdir(mnt, 0600) - if err != nil { - t.Fatal(err) - } test_helpers.MountOrFatal(t, cipherdir, mnt, "-extpass", "echo test") defer test_helpers.UnmountPanic(mnt) diff --git a/tests/test_helpers/mount_unmount.go b/tests/test_helpers/mount_unmount.go index 70b403f..8ff2564 100644 --- a/tests/test_helpers/mount_unmount.go +++ b/tests/test_helpers/mount_unmount.go @@ -113,6 +113,7 @@ func MountOrExit(c string, p string, extraArgs ...string) { } // MountOrFatal calls Mount() and calls t.Fatal() on failure. +// Creates plaindir `p` if it does not exist. // // Contrary to InitFS(), you MUST passt "-extpass=echo test" (or another way for // getting the master key) explicitly. -- cgit v1.2.3