diff options
Diffstat (limited to 'integration_tests/helpers.go')
-rw-r--r-- | integration_tests/helpers.go | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/integration_tests/helpers.go b/integration_tests/helpers.go index bdb781f..4881a4b 100644 --- a/integration_tests/helpers.go +++ b/integration_tests/helpers.go @@ -60,7 +60,7 @@ func resetTmpDir(plaintextNames bool) { } // mount CIPHERDIR "c" on PLAINDIR "p" -func mount(c string, p string, extraArgs ...string) { +func mount(c string, p string, extraArgs ...string) error { var args []string args = append(args, extraArgs...) args = append(args, "-nosyslog", "-q", "-wpanic") @@ -70,16 +70,27 @@ func mount(c string, p string, extraArgs ...string) { args = append(args, p) cmd := exec.Command(gocryptfsBinary, args...) cmd.Stderr = os.Stderr - if testing.Verbose() { - cmd.Stdout = os.Stdout - } - err := cmd.Run() + cmd.Stdout = os.Stdout + return cmd.Run() +} + +// mountOrExit calls mount() and exits on failure. +func mountOrExit(c string, p string, extraArgs ...string) { + err := mount(c, p, extraArgs...) if err != nil { - fmt.Println(err) + fmt.Printf("mount failed: %v", err) os.Exit(1) } } +// mountOrFatal calls mount() and calls t.Fatal() on failure. +func mountOrFatal(t *testing.T, c string, p string, extraArgs ...string) { + err := mount(c, p, extraArgs...) + if err != nil { + t.Fatal(fmt.Errorf("mount failed: %v", err)) + } +} + // unmount PLAINDIR "p" func unmount(p string) error { fu := exec.Command("fusermount", "-u", "-z", p) |