summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/example_filesystems/example_filesystems_test.go15
-rw-r--r--tests/test_helpers/helpers.go12
2 files changed, 15 insertions, 12 deletions
diff --git a/tests/example_filesystems/example_filesystems_test.go b/tests/example_filesystems/example_filesystems_test.go
index c4a0cad..d91a040 100644
--- a/tests/example_filesystems/example_filesystems_test.go
+++ b/tests/example_filesystems/example_filesystems_test.go
@@ -86,14 +86,15 @@ func TestExampleFSv04(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- err = test_helpers.Mount(cDir, pDir, "-extpass", "echo test")
+ err = test_helpers.Mount(cDir, pDir, false, "-extpass", "echo test")
if err == nil {
t.Errorf("Mounting deprecated FS should fail")
}
- test_helpers.MountOrFatal(t, cDir, pDir, "-masterkey", "74676e34-0b47c145-00dac61a-17a92316-"+
+ err = test_helpers.Mount(cDir, pDir, false, "-masterkey", "74676e34-0b47c145-00dac61a-17a92316-"+
"bb57044c-e205b71f-65f4fdca-7cabd4b3", "-diriv=false", "-emenames=false", "-gcmiv128=false")
- checkExampleFS(t, pDir, true)
- test_helpers.Unmount(pDir)
+ if err == nil {
+ t.Errorf("Mounting deprecated FS should fail")
+ }
err = os.Remove(pDir)
if err != nil {
t.Error(err)
@@ -109,7 +110,7 @@ func TestExampleFSv05(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- err = test_helpers.Mount(cDir, pDir, "-extpass", "echo test")
+ err = test_helpers.Mount(cDir, pDir, false, "-extpass", "echo test")
if err == nil {
t.Errorf("Mounting deprecated FS should fail")
}
@@ -132,7 +133,7 @@ func TestExampleFSv06(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- err = test_helpers.Mount(cDir, pDir, "-extpass", "echo test")
+ err = test_helpers.Mount(cDir, pDir, false, "-extpass", "echo test")
if err == nil {
t.Errorf("Mounting deprecated FS should fail")
}
@@ -157,7 +158,7 @@ func TestExampleFSv06PlaintextNames(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- err = test_helpers.Mount(cDir, pDir, "-extpass", "echo test")
+ err = test_helpers.Mount(cDir, pDir, false, "-extpass", "echo test")
if err == nil {
t.Errorf("Mounting deprecated FS should fail")
}
diff --git a/tests/test_helpers/helpers.go b/tests/test_helpers/helpers.go
index a3258fb..655df05 100644
--- a/tests/test_helpers/helpers.go
+++ b/tests/test_helpers/helpers.go
@@ -91,7 +91,7 @@ func InitFS(t *testing.T, extraArgs ...string) string {
// Mount CIPHERDIR "c" on PLAINDIR "p"
// Creates "p" if it does not exist.
-func Mount(c string, p string, extraArgs ...string) error {
+func Mount(c string, p string, showOutput bool, extraArgs ...string) error {
var args []string
args = append(args, extraArgs...)
args = append(args, "-nosyslog", "-q", "-wpanic")
@@ -108,15 +108,17 @@ func Mount(c string, p string, extraArgs ...string) error {
}
cmd := exec.Command(GocryptfsBinary, args...)
- cmd.Stderr = os.Stderr
- cmd.Stdout = os.Stdout
+ if showOutput {
+ cmd.Stderr = os.Stderr
+ 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...)
+ err := Mount(c, p, true, extraArgs...)
if err != nil {
fmt.Printf("mount failed: %v", err)
os.Exit(1)
@@ -125,7 +127,7 @@ func MountOrExit(c string, p string, extraArgs ...string) {
// 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...)
+ err := Mount(c, p, true, extraArgs...)
if err != nil {
t.Fatal(fmt.Errorf("mount failed: %v", err))
}