tests: use fuse-unmount.bash

...instead of having separate compatability logic.
This commit is contained in:
Jakob Unterwurzacher 2017-02-15 23:13:33 +01:00
parent ce2e610428
commit 6ac9dcaae0

View File

@ -10,7 +10,6 @@ import (
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
"runtime"
"syscall" "syscall"
"testing" "testing"
"time" "time"
@ -25,6 +24,9 @@ const testParentDir = "/tmp/gocryptfs-test-parent"
// GocryptfsBinary is the assumed path to the gocryptfs build. // GocryptfsBinary is the assumed path to the gocryptfs build.
const GocryptfsBinary = "../../gocryptfs" const GocryptfsBinary = "../../gocryptfs"
// UnmountScript is the fusermount/umount compatability wrapper script
const UnmountScript = "../fuse-unmount.bash"
// TmpDir is a unique temporary directory. "go test" runs package tests in parallel. We create a // TmpDir is a unique temporary directory. "go test" runs package tests in parallel. We create a
// unique TmpDir in init() so the tests do not interfere. // unique TmpDir in init() so the tests do not interfere.
var TmpDir string var TmpDir string
@ -175,12 +177,7 @@ func UnmountPanic(dir string) {
// UnmountErr tries to unmount "dir" and returns the resulting error. // UnmountErr tries to unmount "dir" and returns the resulting error.
func UnmountErr(dir string) error { func UnmountErr(dir string) error {
var cmd *exec.Cmd cmd := exec.Command(UnmountScript, "-u", "-z", dir)
if runtime.GOOS == "darwin" {
cmd = exec.Command("umount", dir)
} else {
cmd = exec.Command("fusermount", "-u", "-z", dir)
}
cmd.Stdout = os.Stdout cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr cmd.Stderr = os.Stderr
return cmd.Run() return cmd.Run()