aboutsummaryrefslogtreecommitdiff
path: root/tests/example_filesystems
diff options
context:
space:
mode:
Diffstat (limited to 'tests/example_filesystems')
-rw-r--r--tests/example_filesystems/example_filesystems_test.go47
1 files changed, 20 insertions, 27 deletions
diff --git a/tests/example_filesystems/example_filesystems_test.go b/tests/example_filesystems/example_filesystems_test.go
index 6e0ab66..13aa941 100644
--- a/tests/example_filesystems/example_filesystems_test.go
+++ b/tests/example_filesystems/example_filesystems_test.go
@@ -15,20 +15,23 @@ import (
const statusTxtContent = "It works!\n"
-var opensslOpt = "-openssl=false"
+var opensslOpt string
func TestMain(m *testing.M) {
- test_helpers.ResetTmpDir(true)
- r := m.Run()
- opensslOpt = "-openssl=true"
- r2 := m.Run()
- os.Exit(r + r2)
+ for _, opensslOpt = range []string{"-openssl=false", "-openssl=true"} {
+ test_helpers.ResetTmpDir(true)
+ r := m.Run()
+ if r != 0 {
+ os.Exit(r)
+ }
+ }
+ os.Exit(0)
}
// This filesystem is not supported anymore.
func TestExampleFSv04(t *testing.T) {
cDir := "v0.4"
- pDir := test_helpers.TmpDir + cDir
+ pDir := test_helpers.TmpDir + "/" + cDir
err := test_helpers.Mount(cDir, pDir, false, "-extpass", "echo test", opensslOpt)
if err == nil {
t.Errorf("Mounting too old FS should fail")
@@ -38,7 +41,7 @@ func TestExampleFSv04(t *testing.T) {
// This filesystem is not supported anymore.
func TestExampleFSv05(t *testing.T) {
cDir := "v0.5"
- pDir := test_helpers.TmpDir + cDir
+ pDir := test_helpers.TmpDir + "/" + cDir
err := test_helpers.Mount(cDir, pDir, false, "-extpass", "echo test", opensslOpt)
if err == nil {
t.Errorf("Mounting too old FS should fail")
@@ -48,7 +51,7 @@ func TestExampleFSv05(t *testing.T) {
// This filesystem is not supported anymore.
func TestExampleFSv06(t *testing.T) {
cDir := "v0.6"
- pDir := test_helpers.TmpDir + cDir
+ pDir := test_helpers.TmpDir + "/" + cDir
err := test_helpers.Mount(cDir, pDir, false, "-extpass", "echo test", opensslOpt)
if err == nil {
t.Errorf("Mounting too old FS should fail")
@@ -58,7 +61,7 @@ func TestExampleFSv06(t *testing.T) {
// This filesystem is not supported anymore.
func TestExampleFSv06PlaintextNames(t *testing.T) {
cDir := "v0.6-plaintextnames"
- pDir := test_helpers.TmpDir + cDir
+ pDir := test_helpers.TmpDir + "/" + cDir
err := test_helpers.Mount(cDir, pDir, false, "-extpass", "echo test", opensslOpt)
if err == nil {
t.Errorf("Mounting too old FS should fail")
@@ -69,8 +72,8 @@ func TestExampleFSv06PlaintextNames(t *testing.T) {
// with password mount and -masterkey mount
// v0.7 adds 128 bit GCM IVs
func TestExampleFSv07(t *testing.T) {
- pDir := test_helpers.TmpDir + "TestExampleFsV07/"
cDir := "v0.7"
+ pDir := test_helpers.TmpDir + "/" + cDir
err := os.Mkdir(pDir, 0777)
if err != nil {
t.Fatal(err)
@@ -83,38 +86,31 @@ func TestExampleFSv07(t *testing.T) {
opensslOpt)
checkExampleFS(t, pDir, true)
test_helpers.Unmount(pDir)
- err = os.Remove(pDir)
- if err != nil {
- t.Error(err)
- }
}
// gocryptfs v0.7 filesystem created with "-plaintextnames"
func TestExampleFSv07PlaintextNames(t *testing.T) {
cDir := "v0.7-plaintextnames"
- pDir := test_helpers.TmpDir + cDir + ".mnt"
+ pDir := test_helpers.TmpDir + "/" + cDir + ".mnt"
test_helpers.MountOrFatal(t, cDir, pDir, "-extpass", "echo test", opensslOpt)
checkExampleFS(t, pDir, true)
test_helpers.Unmount(pDir)
-
+ // The actual unmount takes some time, this causes weird problems. Just don't
+ // reuse the mountpoint.
+ pDir = pDir + ".2"
test_helpers.MountOrFatal(t, cDir, pDir, "-plaintextnames", "-masterkey",
"6d96397b-585631e1-c7cba69d-61e738b6-4d5ad2c2-e21f0fb3-52f60d3a-b08526f7",
opensslOpt)
checkExampleFS(t, pDir, true)
test_helpers.Unmount(pDir)
-
- err := os.Remove(pDir)
- if err != nil {
- t.Error(err)
- }
}
// Test example_filesystems/v0.9
// (gocryptfs v0.9 introduced long file name support)
func TestExampleFSv09(t *testing.T) {
cDir := "v0.9"
- pDir := test_helpers.TmpDir + "TestExampleFsV09/"
+ pDir := test_helpers.TmpDir + "/" + cDir
err := os.Mkdir(pDir, 0777)
if err != nil {
t.Fatal(err)
@@ -122,13 +118,10 @@ func TestExampleFSv09(t *testing.T) {
test_helpers.MountOrFatal(t, cDir, pDir, "-extpass", "echo test", opensslOpt)
checkExampleFSLongnames(t, pDir)
test_helpers.Unmount(pDir)
+ pDir = pDir + ".2"
test_helpers.MountOrFatal(t, cDir, pDir, "-masterkey",
"1cafe3f4-bc316466-2214c47c-ecd89bf3-4e078fe4-f5faeea7-8b7cab02-884f5e1c",
opensslOpt)
checkExampleFSLongnames(t, pDir)
test_helpers.Unmount(pDir)
- err = os.Remove(pDir)
- if err != nil {
- t.Error(err)
- }
}