aboutsummaryrefslogtreecommitdiff
path: root/integration_tests/helpers.go
diff options
context:
space:
mode:
authorJakob Unterwurzacher2016-06-06 22:30:39 +0200
committerJakob Unterwurzacher2016-06-06 22:30:39 +0200
commitcc5d5a3fcdabca0ecd86646091c545509351dbbe (patch)
tree486f77b3688d96200f1dd94df0225dac26e3beeb /integration_tests/helpers.go
parent0c80cca674931c9dbfc69c25df24d53abbdd63a9 (diff)
tests: error out properly on mount failure
In TestMain we call os.Exit as before, but inside actual tests we now call t.Fatal().
Diffstat (limited to 'integration_tests/helpers.go')
-rw-r--r--integration_tests/helpers.go23
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)