diff options
| -rwxr-xr-x | benchmark-synthetic.bash (renamed from benchmark-builtin.bash) | 2 | ||||
| l--------- | tests/example_filesystems/abs (renamed from integration_tests/example_filesystems/abs) | 0 | ||||
| -rw-r--r-- | tests/example_filesystems/example_filesystems_test.go (renamed from integration_tests/example_filesystems_test.go) | 85 | ||||
| l--------- | tests/example_filesystems/rel (renamed from integration_tests/example_filesystems/rel) | 0 | ||||
| -rw-r--r-- | tests/example_filesystems/status.txt (renamed from integration_tests/example_filesystems/status.txt) | 0 | ||||
| -rw-r--r-- | tests/example_filesystems/v0.4/3-HZSwv99agoWgTErV0YFQ== (renamed from integration_tests/example_filesystems/v0.4/3-HZSwv99agoWgTErV0YFQ==) | bin | 56 -> 56 bytes | |||
| l--------- | tests/example_filesystems/v0.4/6hL2fPVB2aMSh4-UoDn5Kw== (renamed from integration_tests/example_filesystems/v0.4/6hL2fPVB2aMSh4-UoDn5Kw==) | 0 | ||||
| l--------- | tests/example_filesystems/v0.4/TBIgdfhDKwkXVTnWLVzFSg== (renamed from integration_tests/example_filesystems/v0.4/TBIgdfhDKwkXVTnWLVzFSg==) | 0 | ||||
| -rw-r--r-- | tests/example_filesystems/v0.4/gocryptfs.conf (renamed from integration_tests/example_filesystems/v0.4/gocryptfs.conf) | 0 | ||||
| l--------- | tests/example_filesystems/v0.5/AOtl_i4xQWDyG0_zUqntOw== (renamed from integration_tests/example_filesystems/v0.5/AOtl_i4xQWDyG0_zUqntOw==) | 0 | ||||
| l--------- | tests/example_filesystems/v0.5/Pf35wlWlf43N68EbhIgTcQ== (renamed from integration_tests/example_filesystems/v0.5/Pf35wlWlf43N68EbhIgTcQ==) | 0 | ||||
| -rw-r--r-- | tests/example_filesystems/v0.5/gocryptfs.conf (renamed from integration_tests/example_filesystems/v0.5/gocryptfs.conf) | 0 | ||||
| -rw-r--r-- | tests/example_filesystems/v0.5/gocryptfs.diriv (renamed from integration_tests/example_filesystems/v0.5/gocryptfs.diriv) | 0 | ||||
| -rw-r--r-- | tests/example_filesystems/v0.5/j2BpGUT5kOtia20PWQ2rEA== (renamed from integration_tests/example_filesystems/v0.5/j2BpGUT5kOtia20PWQ2rEA==) | bin | 56 -> 56 bytes | |||
| l--------- | tests/example_filesystems/v0.6-plaintextnames/abs (renamed from integration_tests/example_filesystems/v0.6-plaintextnames/abs) | 0 | ||||
| -rw-r--r-- | tests/example_filesystems/v0.6-plaintextnames/gocryptfs.conf (renamed from integration_tests/example_filesystems/v0.6-plaintextnames/gocryptfs.conf) | 0 | ||||
| l--------- | tests/example_filesystems/v0.6-plaintextnames/rel (renamed from integration_tests/example_filesystems/v0.6-plaintextnames/rel) | 0 | ||||
| -rw-r--r-- | tests/example_filesystems/v0.6-plaintextnames/status.txt (renamed from integration_tests/example_filesystems/v0.6-plaintextnames/status.txt) | bin | 56 -> 56 bytes | |||
| l--------- | tests/example_filesystems/v0.6/9pOs0yjJI5A67pv5CnqomQ== (renamed from integration_tests/example_filesystems/v0.6/9pOs0yjJI5A67pv5CnqomQ==) | 0 | ||||
| l--------- | tests/example_filesystems/v0.6/G79Zdu41H3bgwdaQlrz-dg== (renamed from integration_tests/example_filesystems/v0.6/G79Zdu41H3bgwdaQlrz-dg==) | 0 | ||||
| -rw-r--r-- | tests/example_filesystems/v0.6/RuYvQG_raW_-H_LcyJC4LQ== (renamed from integration_tests/example_filesystems/v0.6/RuYvQG_raW_-H_LcyJC4LQ==) | bin | 56 -> 56 bytes | |||
| -rw-r--r-- | tests/example_filesystems/v0.6/gocryptfs.conf (renamed from integration_tests/example_filesystems/v0.6/gocryptfs.conf) | 0 | ||||
| -rw-r--r-- | tests/example_filesystems/v0.6/gocryptfs.diriv (renamed from integration_tests/example_filesystems/v0.6/gocryptfs.diriv) | 0 | ||||
| l--------- | tests/example_filesystems/v0.7/4tRF1LdULRFLiXwfze671Q== (renamed from integration_tests/example_filesystems/v0.7/4tRF1LdULRFLiXwfze671Q==) | 0 | ||||
| -rw-r--r-- | tests/example_filesystems/v0.7/RWPXmXkRFrWw1aOpq7C-NQ== (renamed from integration_tests/example_filesystems/v0.7/RWPXmXkRFrWw1aOpq7C-NQ==) | bin | 60 -> 60 bytes | |||
| l--------- | tests/example_filesystems/v0.7/dwPcZNei4HN4qPA6FxoG_A== (renamed from integration_tests/example_filesystems/v0.7/dwPcZNei4HN4qPA6FxoG_A==) | 0 | ||||
| -rw-r--r-- | tests/example_filesystems/v0.7/gocryptfs.conf (renamed from integration_tests/example_filesystems/v0.7/gocryptfs.conf) | 0 | ||||
| -rw-r--r-- | tests/example_filesystems/v0.7/gocryptfs.diriv (renamed from integration_tests/example_filesystems/v0.7/gocryptfs.diriv) | 0 | ||||
| l--------- | tests/example_filesystems/v0.9/00msNUi5h5aKMX_f-4pBhA== (renamed from integration_tests/example_filesystems/v0.9/00msNUi5h5aKMX_f-4pBhA==) | 0 | ||||
| -rw-r--r-- | tests/example_filesystems/v0.9/R83PhW-BBA_q4rPYD7dEMg== (renamed from integration_tests/example_filesystems/v0.9/R83PhW-BBA_q4rPYD7dEMg==) | bin | 60 -> 60 bytes | |||
| -rw-r--r-- | tests/example_filesystems/v0.9/gocryptfs.conf (renamed from integration_tests/example_filesystems/v0.9/gocryptfs.conf) | 0 | ||||
| -rw-r--r-- | tests/example_filesystems/v0.9/gocryptfs.diriv (renamed from integration_tests/example_filesystems/v0.9/gocryptfs.diriv) | 0 | ||||
| -rw-r--r-- | tests/example_filesystems/v0.9/gocryptfs.longname.y4J-w3LBX165Mn_pGdDRY7Gb6EgHcTrdWjME3WGu-CQ= (renamed from integration_tests/example_filesystems/v0.9/gocryptfs.longname.y4J-w3LBX165Mn_pGdDRY7Gb6EgHcTrdWjME3WGu-CQ=) | bin | 60 -> 60 bytes | |||
| -rw-r--r-- | tests/example_filesystems/v0.9/gocryptfs.longname.y4J-w3LBX165Mn_pGdDRY7Gb6EgHcTrdWjME3WGu-CQ=.name (renamed from integration_tests/example_filesystems/v0.9/gocryptfs.longname.y4J-w3LBX165Mn_pGdDRY7Gb6EgHcTrdWjME3WGu-CQ=.name) | 0 | ||||
| l--------- | tests/example_filesystems/v0.9/hwE1RKIXtF8hmQMvEXSTtg== (renamed from integration_tests/example_filesystems/v0.9/hwE1RKIXtF8hmQMvEXSTtg==) | 0 | ||||
| -rw-r--r-- | tests/integration_tests/cli_test.go (renamed from integration_tests/cli_test.go) | 20 | ||||
| -rw-r--r-- | tests/integration_tests/main_test.go (renamed from integration_tests/main_test.go) | 94 | ||||
| -rw-r--r-- | tests/integration_tests/performance_test.go (renamed from integration_tests/performance_test.go) | 8 | ||||
| -rwxr-xr-x | tests/stress_tests/extractloop.bash (renamed from stress_tests/extractloop.bash) | 0 | ||||
| -rw-r--r-- | tests/stress_tests/extractloop.md5sums (renamed from stress_tests/extractloop.md5sums) | 0 | ||||
| l--------- | tests/stress_tests/fsstress-gocryptfs.bash (renamed from stress_tests/fsstress-gocryptfs.bash) | 0 | ||||
| -rwxr-xr-x | tests/stress_tests/fsstress-loopback.bash (renamed from stress_tests/fsstress-loopback.bash) | 0 | ||||
| -rw-r--r-- | tests/test_helpers/helpers.go (renamed from integration_tests/helpers.go) | 66 | 
43 files changed, 145 insertions, 130 deletions
| diff --git a/benchmark-builtin.bash b/benchmark-synthetic.bash index 145fcfd..8c5c9ce 100755 --- a/benchmark-builtin.bash +++ b/benchmark-synthetic.bash @@ -7,4 +7,4 @@ set -eu  source build.bash -go test ./integration_tests -bench=. -defaultonly +go test ./tests/integration_tests -bench=. -defaultonly diff --git a/integration_tests/example_filesystems/abs b/tests/example_filesystems/abs index e1740fa..e1740fa 120000 --- a/integration_tests/example_filesystems/abs +++ b/tests/example_filesystems/abs diff --git a/integration_tests/example_filesystems_test.go b/tests/example_filesystems/example_filesystems_test.go index 68191f8..7517bc5 100644 --- a/integration_tests/example_filesystems_test.go +++ b/tests/example_filesystems/example_filesystems_test.go @@ -1,4 +1,4 @@ -package integration_tests +package example_filesystems  // Mount example filesystems and check that the file "status.txt" is there @@ -7,10 +7,17 @@ import (  	"os"  	"path/filepath"  	"testing" + +	"github.com/rfjakob/gocryptfs/tests/test_helpers"  )  const statusTxtContent = "It works!\n" +func TestMain(m *testing.M) { +	test_helpers.ResetTmpDir(true) +	m.Run() +} +  // checkExampleFS - verify that "dir" contains the expected test files  func checkExampleFS(t *testing.T, dir string) {  	// Read regular file @@ -42,8 +49,8 @@ func checkExampleFS(t *testing.T, dir string) {  		t.Errorf("Unexpected link target: %s\n", target)  	}  	// Test directory operations -	testRename(t, dir) -	testMkdirRmdir(t, dir) +	test_helpers.TestRename(t, dir) +	test_helpers.TestMkdirRmdir(t, dir)  }  // checkExampleFSLongnames - verify that "dir" contains the expected test files @@ -70,19 +77,19 @@ func checkExampleFSLongnames(t *testing.T, dir string) {  // Test example_filesystems/v0.4  // with password mount and -masterkey mount  func TestExampleFSv04(t *testing.T) { -	pDir := tmpDir + "TestExampleFsV04/" -	cDir := "example_filesystems/v0.4" +	pDir := test_helpers.TmpDir + "TestExampleFsV04/" +	cDir := "v0.4"  	err := os.Mkdir(pDir, 0777)  	if err != nil {  		t.Fatal(err)  	} -	mountOrFatal(t, cDir, pDir, "-extpass", "echo test") +	test_helpers.MountOrFatal(t, cDir, pDir, "-extpass", "echo test")  	checkExampleFS(t, pDir) -	unmount(pDir) -	mountOrFatal(t, cDir, pDir, "-masterkey", "74676e34-0b47c145-00dac61a-17a92316-"+ +	test_helpers.Unmount(pDir) +	test_helpers.MountOrFatal(t, cDir, pDir, "-masterkey", "74676e34-0b47c145-00dac61a-17a92316-"+  		"bb57044c-e205b71f-65f4fdca-7cabd4b3", "-diriv=false", "-emenames=false", "-gcmiv128=false")  	checkExampleFS(t, pDir) -	unmount(pDir) +	test_helpers.Unmount(pDir)  	err = os.Remove(pDir)  	if err != nil {  		t.Error(err) @@ -92,19 +99,19 @@ func TestExampleFSv04(t *testing.T) {  // Test example_filesystems/v0.5  // with password mount and -masterkey mount  func TestExampleFSv05(t *testing.T) { -	pDir := tmpDir + "TestExampleFsV05/" -	cDir := "example_filesystems/v0.5" +	pDir := test_helpers.TmpDir + "TestExampleFsV05/" +	cDir := "v0.5"  	err := os.Mkdir(pDir, 0777)  	if err != nil {  		t.Fatal(err)  	} -	mountOrFatal(t, cDir, pDir, "-extpass", "echo test") +	test_helpers.MountOrFatal(t, cDir, pDir, "-extpass", "echo test")  	checkExampleFS(t, pDir) -	unmount(pDir) -	mountOrFatal(t, cDir, pDir, "-masterkey", "199eae55-36bff4af-83b9a3a2-4fa16f65-"+ +	test_helpers.Unmount(pDir) +	test_helpers.MountOrFatal(t, cDir, pDir, "-masterkey", "199eae55-36bff4af-83b9a3a2-4fa16f65-"+  		"1549ccdb-2d08d1f0-b1b26965-1b61f896", "-emenames=false", "-gcmiv128=false")  	checkExampleFS(t, pDir) -	unmount(pDir) +	test_helpers.Unmount(pDir)  	err = os.Remove(pDir)  	if err != nil {  		t.Error(err) @@ -114,19 +121,19 @@ func TestExampleFSv05(t *testing.T) {  // Test example_filesystems/v0.6  // with password mount and -masterkey mount  func TestExampleFSv06(t *testing.T) { -	pDir := tmpDir + "TestExampleFsV06/" -	cDir := "example_filesystems/v0.6" +	pDir := test_helpers.TmpDir + "TestExampleFsV06/" +	cDir := "v0.6"  	err := os.Mkdir(pDir, 0777)  	if err != nil {  		t.Fatal(err)  	} -	mountOrFatal(t, cDir, pDir, "-extpass", "echo test") +	test_helpers.MountOrFatal(t, cDir, pDir, "-extpass", "echo test")  	checkExampleFS(t, pDir) -	unmount(pDir) -	mountOrFatal(t, cDir, pDir, "-masterkey", "7bc8deb0-5fc894ef-a093da43-61561a81-"+ +	test_helpers.Unmount(pDir) +	test_helpers.MountOrFatal(t, cDir, pDir, "-masterkey", "7bc8deb0-5fc894ef-a093da43-61561a81-"+  		"0e8dee83-fdc056a4-937c37dd-9df5c520", "-gcmiv128=false")  	checkExampleFS(t, pDir) -	unmount(pDir) +	test_helpers.Unmount(pDir)  	err = os.Remove(pDir)  	if err != nil {  		t.Error(err) @@ -138,19 +145,19 @@ func TestExampleFSv06(t *testing.T) {  // v0.6 changed the file name handling a lot, hence the explicit test case for  // plaintextnames.  func TestExampleFSv06PlaintextNames(t *testing.T) { -	pDir := tmpDir + "TestExampleFsV06PlaintextNames/" -	cDir := "example_filesystems/v0.6-plaintextnames" +	pDir := test_helpers.TmpDir + "TestExampleFsV06PlaintextNames/" +	cDir := "v0.6-plaintextnames"  	err := os.Mkdir(pDir, 0777)  	if err != nil {  		t.Fatal(err)  	} -	mountOrFatal(t, cDir, pDir, "-extpass", "echo test") +	test_helpers.MountOrFatal(t, cDir, pDir, "-extpass", "echo test")  	checkExampleFS(t, pDir) -	unmount(pDir) -	mountOrFatal(t, cDir, pDir, "-masterkey", "f4690202-595e4593-64c4f7e0-4dddd7d1-"+ +	test_helpers.Unmount(pDir) +	test_helpers.MountOrFatal(t, cDir, pDir, "-masterkey", "f4690202-595e4593-64c4f7e0-4dddd7d1-"+  		"303147f9-0ca8aea2-966341a7-52ea8ae9", "-plaintextnames", "-gcmiv128=false")  	checkExampleFS(t, pDir) -	unmount(pDir) +	test_helpers.Unmount(pDir)  	err = os.Remove(pDir)  	if err != nil {  		t.Error(err) @@ -161,19 +168,19 @@ func TestExampleFSv06PlaintextNames(t *testing.T) {  // with password mount and -masterkey mount  // v0.7 adds 128 bit GCM IVs  func TestExampleFSv07(t *testing.T) { -	pDir := tmpDir + "TestExampleFsV07/" -	cDir := "example_filesystems/v0.7" +	pDir := test_helpers.TmpDir + "TestExampleFsV07/" +	cDir := "v0.7"  	err := os.Mkdir(pDir, 0777)  	if err != nil {  		t.Fatal(err)  	} -	mountOrFatal(t, cDir, pDir, "-extpass", "echo test") +	test_helpers.MountOrFatal(t, cDir, pDir, "-extpass", "echo test")  	checkExampleFS(t, pDir) -	unmount(pDir) -	mountOrFatal(t, cDir, pDir, "-masterkey", "ed7f6d83-40cce86c-0e7d79c2-a9438710-"+ +	test_helpers.Unmount(pDir) +	test_helpers.MountOrFatal(t, cDir, pDir, "-masterkey", "ed7f6d83-40cce86c-0e7d79c2-a9438710-"+  		"575221bf-30a0eb60-2821fa8f-7f3123bf")  	checkExampleFS(t, pDir) -	unmount(pDir) +	test_helpers.Unmount(pDir)  	err = os.Remove(pDir)  	if err != nil {  		t.Error(err) @@ -183,19 +190,19 @@ func TestExampleFSv07(t *testing.T) {  // Test example_filesystems/v0.9  // (gocryptfs v0.9 introduced long file name support)  func TestExampleFSv09(t *testing.T) { -	cDir := "example_filesystems/v0.9" -	pDir := tmpDir + "TestExampleFsV09/" +	cDir := "v0.9" +	pDir := test_helpers.TmpDir + "TestExampleFsV09/"  	err := os.Mkdir(pDir, 0777)  	if err != nil {  		t.Fatal(err)  	} -	mountOrFatal(t, cDir, pDir, "-extpass", "echo test") +	test_helpers.MountOrFatal(t, cDir, pDir, "-extpass", "echo test")  	checkExampleFSLongnames(t, pDir) -	unmount(pDir) -	mountOrFatal(t, cDir, pDir, "-masterkey", "1cafe3f4-bc316466-2214c47c-ecd89bf3-"+ +	test_helpers.Unmount(pDir) +	test_helpers.MountOrFatal(t, cDir, pDir, "-masterkey", "1cafe3f4-bc316466-2214c47c-ecd89bf3-"+  		"4e078fe4-f5faeea7-8b7cab02-884f5e1c")  	checkExampleFSLongnames(t, pDir) -	unmount(pDir) +	test_helpers.Unmount(pDir)  	err = os.Remove(pDir)  	if err != nil {  		t.Error(err) diff --git a/integration_tests/example_filesystems/rel b/tests/example_filesystems/rel index 8279c75..8279c75 120000 --- a/integration_tests/example_filesystems/rel +++ b/tests/example_filesystems/rel diff --git a/integration_tests/example_filesystems/status.txt b/tests/example_filesystems/status.txt index 68300b8..68300b8 100644 --- a/integration_tests/example_filesystems/status.txt +++ b/tests/example_filesystems/status.txt diff --git a/integration_tests/example_filesystems/v0.4/3-HZSwv99agoWgTErV0YFQ== b/tests/example_filesystems/v0.4/3-HZSwv99agoWgTErV0YFQ==Binary files differ index 5d0af82..5d0af82 100644 --- a/integration_tests/example_filesystems/v0.4/3-HZSwv99agoWgTErV0YFQ== +++ b/tests/example_filesystems/v0.4/3-HZSwv99agoWgTErV0YFQ== diff --git a/integration_tests/example_filesystems/v0.4/6hL2fPVB2aMSh4-UoDn5Kw== b/tests/example_filesystems/v0.4/6hL2fPVB2aMSh4-UoDn5Kw== index 31b9013..31b9013 120000 --- a/integration_tests/example_filesystems/v0.4/6hL2fPVB2aMSh4-UoDn5Kw== +++ b/tests/example_filesystems/v0.4/6hL2fPVB2aMSh4-UoDn5Kw== diff --git a/integration_tests/example_filesystems/v0.4/TBIgdfhDKwkXVTnWLVzFSg== b/tests/example_filesystems/v0.4/TBIgdfhDKwkXVTnWLVzFSg== index 7a15694..7a15694 120000 --- a/integration_tests/example_filesystems/v0.4/TBIgdfhDKwkXVTnWLVzFSg== +++ b/tests/example_filesystems/v0.4/TBIgdfhDKwkXVTnWLVzFSg== diff --git a/integration_tests/example_filesystems/v0.4/gocryptfs.conf b/tests/example_filesystems/v0.4/gocryptfs.conf index 354b4bb..354b4bb 100644 --- a/integration_tests/example_filesystems/v0.4/gocryptfs.conf +++ b/tests/example_filesystems/v0.4/gocryptfs.conf diff --git a/integration_tests/example_filesystems/v0.5/AOtl_i4xQWDyG0_zUqntOw== b/tests/example_filesystems/v0.5/AOtl_i4xQWDyG0_zUqntOw== index 7c52a28..7c52a28 120000 --- a/integration_tests/example_filesystems/v0.5/AOtl_i4xQWDyG0_zUqntOw== +++ b/tests/example_filesystems/v0.5/AOtl_i4xQWDyG0_zUqntOw== diff --git a/integration_tests/example_filesystems/v0.5/Pf35wlWlf43N68EbhIgTcQ== b/tests/example_filesystems/v0.5/Pf35wlWlf43N68EbhIgTcQ== index 596cc3d..596cc3d 120000 --- a/integration_tests/example_filesystems/v0.5/Pf35wlWlf43N68EbhIgTcQ== +++ b/tests/example_filesystems/v0.5/Pf35wlWlf43N68EbhIgTcQ== diff --git a/integration_tests/example_filesystems/v0.5/gocryptfs.conf b/tests/example_filesystems/v0.5/gocryptfs.conf index f839664..f839664 100644 --- a/integration_tests/example_filesystems/v0.5/gocryptfs.conf +++ b/tests/example_filesystems/v0.5/gocryptfs.conf diff --git a/integration_tests/example_filesystems/v0.5/gocryptfs.diriv b/tests/example_filesystems/v0.5/gocryptfs.diriv index 3670294..3670294 100644 --- a/integration_tests/example_filesystems/v0.5/gocryptfs.diriv +++ b/tests/example_filesystems/v0.5/gocryptfs.diriv diff --git a/integration_tests/example_filesystems/v0.5/j2BpGUT5kOtia20PWQ2rEA== b/tests/example_filesystems/v0.5/j2BpGUT5kOtia20PWQ2rEA==Binary files differ index 1ad2358..1ad2358 100644 --- a/integration_tests/example_filesystems/v0.5/j2BpGUT5kOtia20PWQ2rEA== +++ b/tests/example_filesystems/v0.5/j2BpGUT5kOtia20PWQ2rEA== diff --git a/integration_tests/example_filesystems/v0.6-plaintextnames/abs b/tests/example_filesystems/v0.6-plaintextnames/abs index e1740fa..e1740fa 120000 --- a/integration_tests/example_filesystems/v0.6-plaintextnames/abs +++ b/tests/example_filesystems/v0.6-plaintextnames/abs diff --git a/integration_tests/example_filesystems/v0.6-plaintextnames/gocryptfs.conf b/tests/example_filesystems/v0.6-plaintextnames/gocryptfs.conf index 257b7ee..257b7ee 100644 --- a/integration_tests/example_filesystems/v0.6-plaintextnames/gocryptfs.conf +++ b/tests/example_filesystems/v0.6-plaintextnames/gocryptfs.conf diff --git a/integration_tests/example_filesystems/v0.6-plaintextnames/rel b/tests/example_filesystems/v0.6-plaintextnames/rel index 8279c75..8279c75 120000 --- a/integration_tests/example_filesystems/v0.6-plaintextnames/rel +++ b/tests/example_filesystems/v0.6-plaintextnames/rel diff --git a/integration_tests/example_filesystems/v0.6-plaintextnames/status.txt b/tests/example_filesystems/v0.6-plaintextnames/status.txtBinary files differ index e5b62fb..e5b62fb 100644 --- a/integration_tests/example_filesystems/v0.6-plaintextnames/status.txt +++ b/tests/example_filesystems/v0.6-plaintextnames/status.txt diff --git a/integration_tests/example_filesystems/v0.6/9pOs0yjJI5A67pv5CnqomQ== b/tests/example_filesystems/v0.6/9pOs0yjJI5A67pv5CnqomQ== index 11b0234..11b0234 120000 --- a/integration_tests/example_filesystems/v0.6/9pOs0yjJI5A67pv5CnqomQ== +++ b/tests/example_filesystems/v0.6/9pOs0yjJI5A67pv5CnqomQ== diff --git a/integration_tests/example_filesystems/v0.6/G79Zdu41H3bgwdaQlrz-dg== b/tests/example_filesystems/v0.6/G79Zdu41H3bgwdaQlrz-dg== index b72a393..b72a393 120000 --- a/integration_tests/example_filesystems/v0.6/G79Zdu41H3bgwdaQlrz-dg== +++ b/tests/example_filesystems/v0.6/G79Zdu41H3bgwdaQlrz-dg== diff --git a/integration_tests/example_filesystems/v0.6/RuYvQG_raW_-H_LcyJC4LQ== b/tests/example_filesystems/v0.6/RuYvQG_raW_-H_LcyJC4LQ==Binary files differ index 5821d87..5821d87 100644 --- a/integration_tests/example_filesystems/v0.6/RuYvQG_raW_-H_LcyJC4LQ== +++ b/tests/example_filesystems/v0.6/RuYvQG_raW_-H_LcyJC4LQ== diff --git a/integration_tests/example_filesystems/v0.6/gocryptfs.conf b/tests/example_filesystems/v0.6/gocryptfs.conf index 1c72781..1c72781 100644 --- a/integration_tests/example_filesystems/v0.6/gocryptfs.conf +++ b/tests/example_filesystems/v0.6/gocryptfs.conf diff --git a/integration_tests/example_filesystems/v0.6/gocryptfs.diriv b/tests/example_filesystems/v0.6/gocryptfs.diriv index ec9f503..ec9f503 100644 --- a/integration_tests/example_filesystems/v0.6/gocryptfs.diriv +++ b/tests/example_filesystems/v0.6/gocryptfs.diriv diff --git a/integration_tests/example_filesystems/v0.7/4tRF1LdULRFLiXwfze671Q== b/tests/example_filesystems/v0.7/4tRF1LdULRFLiXwfze671Q== index f06d136..f06d136 120000 --- a/integration_tests/example_filesystems/v0.7/4tRF1LdULRFLiXwfze671Q== +++ b/tests/example_filesystems/v0.7/4tRF1LdULRFLiXwfze671Q== diff --git a/integration_tests/example_filesystems/v0.7/RWPXmXkRFrWw1aOpq7C-NQ== b/tests/example_filesystems/v0.7/RWPXmXkRFrWw1aOpq7C-NQ==Binary files differ index 6ddcd1e..6ddcd1e 100644 --- a/integration_tests/example_filesystems/v0.7/RWPXmXkRFrWw1aOpq7C-NQ== +++ b/tests/example_filesystems/v0.7/RWPXmXkRFrWw1aOpq7C-NQ== diff --git a/integration_tests/example_filesystems/v0.7/dwPcZNei4HN4qPA6FxoG_A== b/tests/example_filesystems/v0.7/dwPcZNei4HN4qPA6FxoG_A== index c0c731f..c0c731f 120000 --- a/integration_tests/example_filesystems/v0.7/dwPcZNei4HN4qPA6FxoG_A== +++ b/tests/example_filesystems/v0.7/dwPcZNei4HN4qPA6FxoG_A== diff --git a/integration_tests/example_filesystems/v0.7/gocryptfs.conf b/tests/example_filesystems/v0.7/gocryptfs.conf index 80c2673..80c2673 100644 --- a/integration_tests/example_filesystems/v0.7/gocryptfs.conf +++ b/tests/example_filesystems/v0.7/gocryptfs.conf diff --git a/integration_tests/example_filesystems/v0.7/gocryptfs.diriv b/tests/example_filesystems/v0.7/gocryptfs.diriv index 3adef3c..3adef3c 100644 --- a/integration_tests/example_filesystems/v0.7/gocryptfs.diriv +++ b/tests/example_filesystems/v0.7/gocryptfs.diriv diff --git a/integration_tests/example_filesystems/v0.9/00msNUi5h5aKMX_f-4pBhA== b/tests/example_filesystems/v0.9/00msNUi5h5aKMX_f-4pBhA== index c717734..c717734 120000 --- a/integration_tests/example_filesystems/v0.9/00msNUi5h5aKMX_f-4pBhA== +++ b/tests/example_filesystems/v0.9/00msNUi5h5aKMX_f-4pBhA== diff --git a/integration_tests/example_filesystems/v0.9/R83PhW-BBA_q4rPYD7dEMg== b/tests/example_filesystems/v0.9/R83PhW-BBA_q4rPYD7dEMg==Binary files differ index 1bc4a81..1bc4a81 100644 --- a/integration_tests/example_filesystems/v0.9/R83PhW-BBA_q4rPYD7dEMg== +++ b/tests/example_filesystems/v0.9/R83PhW-BBA_q4rPYD7dEMg== diff --git a/integration_tests/example_filesystems/v0.9/gocryptfs.conf b/tests/example_filesystems/v0.9/gocryptfs.conf index 4d9b089..4d9b089 100644 --- a/integration_tests/example_filesystems/v0.9/gocryptfs.conf +++ b/tests/example_filesystems/v0.9/gocryptfs.conf diff --git a/integration_tests/example_filesystems/v0.9/gocryptfs.diriv b/tests/example_filesystems/v0.9/gocryptfs.diriv index 47d97ee..47d97ee 100644 --- a/integration_tests/example_filesystems/v0.9/gocryptfs.diriv +++ b/tests/example_filesystems/v0.9/gocryptfs.diriv diff --git a/integration_tests/example_filesystems/v0.9/gocryptfs.longname.y4J-w3LBX165Mn_pGdDRY7Gb6EgHcTrdWjME3WGu-CQ= b/tests/example_filesystems/v0.9/gocryptfs.longname.y4J-w3LBX165Mn_pGdDRY7Gb6EgHcTrdWjME3WGu-CQ=Binary files differ index 78eb3ff..78eb3ff 100644 --- a/integration_tests/example_filesystems/v0.9/gocryptfs.longname.y4J-w3LBX165Mn_pGdDRY7Gb6EgHcTrdWjME3WGu-CQ= +++ b/tests/example_filesystems/v0.9/gocryptfs.longname.y4J-w3LBX165Mn_pGdDRY7Gb6EgHcTrdWjME3WGu-CQ= diff --git a/integration_tests/example_filesystems/v0.9/gocryptfs.longname.y4J-w3LBX165Mn_pGdDRY7Gb6EgHcTrdWjME3WGu-CQ=.name b/tests/example_filesystems/v0.9/gocryptfs.longname.y4J-w3LBX165Mn_pGdDRY7Gb6EgHcTrdWjME3WGu-CQ=.name index 535cee7..535cee7 100644 --- a/integration_tests/example_filesystems/v0.9/gocryptfs.longname.y4J-w3LBX165Mn_pGdDRY7Gb6EgHcTrdWjME3WGu-CQ=.name +++ b/tests/example_filesystems/v0.9/gocryptfs.longname.y4J-w3LBX165Mn_pGdDRY7Gb6EgHcTrdWjME3WGu-CQ=.name diff --git a/integration_tests/example_filesystems/v0.9/hwE1RKIXtF8hmQMvEXSTtg== b/tests/example_filesystems/v0.9/hwE1RKIXtF8hmQMvEXSTtg== index 4190a7e..4190a7e 120000 --- a/integration_tests/example_filesystems/v0.9/hwE1RKIXtF8hmQMvEXSTtg== +++ b/tests/example_filesystems/v0.9/hwE1RKIXtF8hmQMvEXSTtg== diff --git a/integration_tests/cli_test.go b/tests/integration_tests/cli_test.go index 062a90d..15bd063 100644 --- a/integration_tests/cli_test.go +++ b/tests/integration_tests/cli_test.go @@ -9,16 +9,18 @@ import (  	"github.com/rfjakob/gocryptfs/internal/configfile"  	"github.com/rfjakob/gocryptfs/internal/nametransform" + +	"github.com/rfjakob/gocryptfs/tests/test_helpers"  )  // Test -init flag  func TestInit(t *testing.T) { -	dir := tmpDir + "TestInit/" +	dir := test_helpers.TmpDir + "TestInit/"  	err := os.Mkdir(dir, 0777)  	if err != nil {  		t.Fatal(err)  	} -	cmd := exec.Command(gocryptfsBinary, "-init", "-extpass", "echo test", "-scryptn=10", dir) +	cmd := exec.Command(test_helpers.GocryptfsBinary, "-init", "-extpass", "echo test", "-scryptn=10", dir)  	if testing.Verbose() {  		cmd.Stdout = os.Stdout  		cmd.Stderr = os.Stderr @@ -33,7 +35,7 @@ func TestInit(t *testing.T) {  	}  	// Test -passwd -	cmd2 := exec.Command(gocryptfsBinary, "-passwd", "-extpass", "echo test", dir) +	cmd2 := exec.Command(test_helpers.GocryptfsBinary, "-passwd", "-extpass", "echo test", dir)  	if testing.Verbose() {  		cmd2.Stdout = os.Stdout  		cmd2.Stderr = os.Stderr @@ -46,13 +48,13 @@ func TestInit(t *testing.T) {  // Test -init & -config flag  func TestInitConfig(t *testing.T) { -	dir := tmpDir + "TestInitConfig/" -	config := tmpDir + "TestInitConfig.conf" +	dir := test_helpers.TmpDir + "TestInitConfig/" +	config := test_helpers.TmpDir + "TestInitConfig.conf"  	err := os.Mkdir(dir, 0777)  	if err != nil {  		t.Fatal(err)  	} -	cmd := exec.Command(gocryptfsBinary, "-init", "-extpass", "echo test", +	cmd := exec.Command(test_helpers.GocryptfsBinary, "-init", "-extpass", "echo test",  		"-config", config, "-scryptn=10", dir)  	if testing.Verbose() {  		cmd.Stdout = os.Stdout @@ -68,7 +70,7 @@ func TestInitConfig(t *testing.T) {  	}  	// Test -passwd & -config -	cmd2 := exec.Command(gocryptfsBinary, "-passwd", "-extpass", "echo test", +	cmd2 := exec.Command(test_helpers.GocryptfsBinary, "-passwd", "-extpass", "echo test",  		"-config", config, dir)  	if testing.Verbose() {  		cmd2.Stdout = os.Stdout @@ -82,12 +84,12 @@ func TestInitConfig(t *testing.T) {  // Test -init -plaintextnames  func TestInitPlaintextNames(t *testing.T) { -	dir := tmpDir + "TestInitPlaintextNames/" +	dir := test_helpers.TmpDir + "TestInitPlaintextNames/"  	err := os.Mkdir(dir, 0777)  	if err != nil {  		t.Fatal(err)  	} -	cmd := exec.Command(gocryptfsBinary, "-init", "-extpass", "echo test", +	cmd := exec.Command(test_helpers.GocryptfsBinary, "-init", "-extpass", "echo test",  		"-scryptn=10", "-plaintextnames", dir)  	if testing.Verbose() {  		cmd.Stdout = os.Stdout diff --git a/integration_tests/main_test.go b/tests/integration_tests/main_test.go index c7607ce..b6cb8ca 100644 --- a/integration_tests/main_test.go +++ b/tests/integration_tests/main_test.go @@ -14,6 +14,8 @@ import (  	"sync"  	"syscall"  	"testing" + +	"github.com/rfjakob/gocryptfs/tests/test_helpers"  )  var plaintextNames bool @@ -27,10 +29,10 @@ func TestMain(m *testing.M) {  	if testing.Verbose() {  		fmt.Println("***** Testing with OpenSSL")  	} -	resetTmpDir(false) // <- this also create gocryptfs.diriv -	mountOrExit(defaultCipherDir, defaultPlainDir, "--zerokey") +	test_helpers.ResetTmpDir(false) // <- this also create gocryptfs.diriv +	test_helpers.MountOrExit(test_helpers.DefaultCipherDir, test_helpers.DefaultPlainDir, "--zerokey")  	r := m.Run() -	unmount(defaultPlainDir) +	test_helpers.Unmount(test_helpers.DefaultPlainDir)  	if r != 0 {  		os.Exit(r) @@ -43,10 +45,10 @@ func TestMain(m *testing.M) {  	if testing.Verbose() {  		fmt.Println("***** Testing with native Go crypto")  	} -	resetTmpDir(false) -	mountOrExit(defaultCipherDir, defaultPlainDir, "--zerokey", "--openssl=false") +	test_helpers.ResetTmpDir(false) +	test_helpers.MountOrExit(test_helpers.DefaultCipherDir, test_helpers.DefaultPlainDir, "--zerokey", "--openssl=false")  	r = m.Run() -	unmount(defaultPlainDir) +	test_helpers.Unmount(test_helpers.DefaultPlainDir)  	if r != 0 {  		os.Exit(r) @@ -55,11 +57,11 @@ func TestMain(m *testing.M) {  	if testing.Verbose() {  		fmt.Println("***** Testing \"--plaintextnames\"")  	} -	resetTmpDir(true) // do not create gocryptfs.diriv -	mountOrExit(defaultCipherDir, defaultPlainDir, "--zerokey", "--plaintextnames") +	test_helpers.ResetTmpDir(true) // do not create gocryptfs.diriv +	test_helpers.MountOrExit(test_helpers.DefaultCipherDir, test_helpers.DefaultPlainDir, "--zerokey", "--plaintextnames")  	plaintextNames = true  	r = m.Run() -	unmount(defaultPlainDir) +	test_helpers.Unmount(test_helpers.DefaultPlainDir)  	if r != 0 {  		os.Exit(r) @@ -70,7 +72,7 @@ func TestMain(m *testing.M) {  // Write "n" zero bytes to filename "fn", read again, compare hash  func testWriteN(t *testing.T, fn string, n int) string { -	file, err := os.Create(defaultPlainDir + fn) +	file, err := os.Create(test_helpers.DefaultPlainDir + fn)  	if err != nil {  		t.Fatal(err)  	} @@ -85,12 +87,12 @@ func testWriteN(t *testing.T, fn string, n int) string {  		t.Error(err)  	} -	verifySize(t, defaultPlainDir+fn, n) +	test_helpers.VerifySize(t, test_helpers.DefaultPlainDir+fn, n)  	bin := md5.Sum(d)  	hashWant := hex.EncodeToString(bin[:]) -	hashActual := md5fn(defaultPlainDir + fn) +	hashActual := test_helpers.Md5fn(test_helpers.DefaultPlainDir + fn)  	if hashActual != hashWant {  		t.Errorf("Wrong content, hashWant=%s hashActual=%s", hashWant, hashActual) @@ -116,7 +118,7 @@ func TestWrite1Mx100(t *testing.T) {  	// Read and check 100 times to catch race conditions  	var i int  	for i = 0; i < 100; i++ { -		hashActual := md5fn(defaultPlainDir + "1M") +		hashActual := test_helpers.Md5fn(test_helpers.DefaultPlainDir + "1M")  		if hashActual != hashWant {  			fmt.Printf("Read corruption in loop # %d\n", i)  			t.FailNow() @@ -127,39 +129,39 @@ func TestWrite1Mx100(t *testing.T) {  }  func TestTruncate(t *testing.T) { -	fn := defaultPlainDir + "truncate" +	fn := test_helpers.DefaultPlainDir + "truncate"  	file, err := os.Create(fn)  	if err != nil {  		t.FailNow()  	}  	// Grow to two blocks  	file.Truncate(7000) -	verifySize(t, fn, 7000) -	if md5fn(fn) != "95d4ec7038e3e4fdbd5f15c34c3f0b34" { +	test_helpers.VerifySize(t, fn, 7000) +	if test_helpers.Md5fn(fn) != "95d4ec7038e3e4fdbd5f15c34c3f0b34" {  		t.Errorf("wrong content")  	}  	// Shrink - needs RMW  	file.Truncate(6999) -	verifySize(t, fn, 6999) -	if md5fn(fn) != "35fd15873ec6c35380064a41b9b9683b" { +	test_helpers.VerifySize(t, fn, 6999) +	if test_helpers.Md5fn(fn) != "35fd15873ec6c35380064a41b9b9683b" {  		t.Errorf("wrong content")  	}  	// Shrink to one partial block  	file.Truncate(465) -	verifySize(t, fn, 465) -	if md5fn(fn) != "a1534d6e98a6b21386456a8f66c55260" { +	test_helpers.VerifySize(t, fn, 465) +	if test_helpers.Md5fn(fn) != "a1534d6e98a6b21386456a8f66c55260" {  		t.Errorf("wrong content")  	}  	// Grow to exactly one block  	file.Truncate(4096) -	verifySize(t, fn, 4096) -	if md5fn(fn) != "620f0b67a91f7f74151bc5be745b7110" { +	test_helpers.VerifySize(t, fn, 4096) +	if test_helpers.Md5fn(fn) != "620f0b67a91f7f74151bc5be745b7110" {  		t.Errorf("wrong content")  	}  }  func TestAppend(t *testing.T) { -	fn := defaultPlainDir + "append" +	fn := test_helpers.DefaultPlainDir + "append"  	file, err := os.Create(fn)  	if err != nil {  		t.FailNow() @@ -172,7 +174,7 @@ func TestAppend(t *testing.T) {  		buf.Write(data)  		bin := md5.Sum(buf.Bytes())  		hashWant = hex.EncodeToString(bin[:]) -		hashActual := md5fn(fn) +		hashActual := test_helpers.Md5fn(fn)  		if hashWant != hashActual {  			t.FailNow()  		} @@ -183,7 +185,7 @@ func TestAppend(t *testing.T) {  	file.Seek(0, 0)  	for i := 0; i <= 500; i++ {  		file.Write(data) -		hashActual := md5fn(fn) +		hashActual := test_helpers.Md5fn(fn)  		if hashWant != hashActual {  			t.FailNow()  		} @@ -193,7 +195,7 @@ func TestAppend(t *testing.T) {  // Create a file with holes by writing to offset 0 (block #0) and  // offset 4096 (block #1).  func TestFileHoles(t *testing.T) { -	fn := defaultPlainDir + "fileholes" +	fn := test_helpers.DefaultPlainDir + "fileholes"  	file, err := os.Create(fn)  	if err != nil {  		t.Errorf("file create failed") @@ -221,7 +223,7 @@ func TestRmwRace(t *testing.T) {  	runtime.GOMAXPROCS(10) -	fn := defaultPlainDir + "rmwrace" +	fn := test_helpers.DefaultPlainDir + "rmwrace"  	f1, err := os.Create(fn)  	if err != nil {  		t.Fatalf("file create failed") @@ -274,7 +276,7 @@ func TestRmwRace(t *testing.T) {  		// [oooooossss]  		buf, _ := ioutil.ReadFile(fn) -		m := md5hex(buf) +		m := test_helpers.Md5hex(buf)  		goodMd5[m] = goodMd5[m] + 1  		/* @@ -292,7 +294,7 @@ func TestRmwRace(t *testing.T) {  // With "--plaintextnames", the name "/gocryptfs.conf" is reserved.  // Otherwise there should be no restrictions.  func TestFiltered(t *testing.T) { -	filteredFile := defaultPlainDir + "gocryptfs.conf" +	filteredFile := test_helpers.DefaultPlainDir + "gocryptfs.conf"  	file, err := os.Create(filteredFile)  	if plaintextNames == true && err == nil {  		t.Errorf("should have failed but didn't") @@ -310,13 +312,13 @@ func TestFiltered(t *testing.T) {  }  func TestFilenameEncryption(t *testing.T) { -	file, err := os.Create(defaultPlainDir + "TestFilenameEncryption.txt") +	file, err := os.Create(test_helpers.DefaultPlainDir + "TestFilenameEncryption.txt")  	file.Close()  	if err != nil {  		t.Fatal(err)  	} -	_, err = os.Stat(defaultCipherDir + "TestFilenameEncryption.txt") +	_, err = os.Stat(test_helpers.DefaultCipherDir + "TestFilenameEncryption.txt")  	if plaintextNames == true && err != nil {  		t.Errorf("plaintextnames not working: %v", err)  	} else if plaintextNames == false && err == nil { @@ -325,19 +327,19 @@ func TestFilenameEncryption(t *testing.T) {  }  // Test Mkdir and Rmdir -func TestMkdirRmdir(t *testing.T) { -	testMkdirRmdir(t, defaultPlainDir) +func testMkdirRmdir(t *testing.T) { +	test_helpers.TestMkdirRmdir(t, test_helpers.DefaultPlainDir)  }  // Test Rename -func TestRename(t *testing.T) { -	testRename(t, defaultPlainDir) +func testRename(t *testing.T) { +	test_helpers.TestRename(t, test_helpers.DefaultPlainDir)  }  // Overwrite an empty directory with another directory  func TestDirOverwrite(t *testing.T) { -	dir1 := defaultPlainDir + "DirOverwrite1" -	dir2 := defaultPlainDir + "DirOverwrite2" +	dir1 := test_helpers.DefaultPlainDir + "DirOverwrite1" +	dir2 := test_helpers.DefaultPlainDir + "DirOverwrite2"  	err := os.Mkdir(dir1, 0777)  	if err != nil {  		t.Fatal(err) @@ -353,12 +355,12 @@ func TestDirOverwrite(t *testing.T) {  }  func TestLongNames(t *testing.T) { -	fi, err := ioutil.ReadDir(defaultCipherDir) +	fi, err := ioutil.ReadDir(test_helpers.DefaultCipherDir)  	if err != nil {  		t.Fatal(err)  	}  	cnt1 := len(fi) -	wd := defaultPlainDir +	wd := test_helpers.DefaultPlainDir  	// Create file with long name  	n255x := string(bytes.Repeat([]byte("x"), 255))  	f, err := os.Create(wd + n255x) @@ -366,7 +368,7 @@ func TestLongNames(t *testing.T) {  		t.Fatalf("Could not create n255x: %v", err)  	}  	f.Close() -	if !verifyExistence(wd + n255x) { +	if !test_helpers.VerifyExistence(wd + n255x) {  		t.Errorf("n255x is not in directory listing")  	}  	// Rename long to long @@ -375,7 +377,7 @@ func TestLongNames(t *testing.T) {  	if err != nil {  		t.Fatalf("Could not rename n255x to n255y: %v", err)  	} -	if !verifyExistence(wd + n255y) { +	if !test_helpers.VerifyExistence(wd + n255y) {  		t.Errorf("n255y is not in directory listing")  	}  	// Rename long to short @@ -383,7 +385,7 @@ func TestLongNames(t *testing.T) {  	if err != nil {  		t.Fatalf("Could not rename n255y to short: %v", err)  	} -	if !verifyExistence(wd + "short") { +	if !test_helpers.VerifyExistence(wd + "short") {  		t.Errorf("short is not in directory listing")  	}  	// Rename short to long @@ -391,7 +393,7 @@ func TestLongNames(t *testing.T) {  	if err != nil {  		t.Fatalf("Could not rename short to n255x: %v", err)  	} -	if !verifyExistence(wd + n255x) { +	if !test_helpers.VerifyExistence(wd + n255x) {  		t.Errorf("255x is not in directory listing II")  	}  	// Unlink @@ -399,7 +401,7 @@ func TestLongNames(t *testing.T) {  	if err != nil {  		t.Fatalf("Could not unlink n255x: %v", err)  	} -	if verifyExistence(wd + n255x) { +	if test_helpers.VerifyExistence(wd + n255x) {  		t.Errorf("n255x still there after unlink")  	}  	// Long symlink @@ -408,7 +410,7 @@ func TestLongNames(t *testing.T) {  	if err != nil {  		t.Fatal(err)  	} -	if !verifyExistence(wd + n255s) { +	if !test_helpers.VerifyExistence(wd + n255s) {  		t.Errorf("n255s is not in directory listing")  	}  	err = syscall.Unlink(wd + n255s) @@ -426,7 +428,7 @@ func TestLongNames(t *testing.T) {  		t.Error(err)  	}  	// Check for orphaned files -	fi, err = ioutil.ReadDir(defaultCipherDir) +	fi, err = ioutil.ReadDir(test_helpers.DefaultCipherDir)  	if err != nil {  		t.Fatal(err)  	} diff --git a/integration_tests/performance_test.go b/tests/integration_tests/performance_test.go index 9a0399a..67f0b28 100644 --- a/integration_tests/performance_test.go +++ b/tests/integration_tests/performance_test.go @@ -8,13 +8,15 @@ import (  	"io/ioutil"  	"os"  	"testing" + +	"github.com/rfjakob/gocryptfs/tests/test_helpers"  )  func BenchmarkStreamWrite(t *testing.B) {  	buf := make([]byte, 1024*1024)  	t.SetBytes(int64(len(buf))) -	file, err := os.Create(defaultPlainDir + "BenchmarkWrite") +	file, err := os.Create(test_helpers.DefaultPlainDir + "BenchmarkWrite")  	if err != nil {  		t.FailNow()  	} @@ -35,7 +37,7 @@ func BenchmarkStreamRead(t *testing.B) {  	buf := make([]byte, 1024*1024)  	t.SetBytes(int64(len(buf))) -	fn := defaultPlainDir + "BenchmarkWrite" +	fn := test_helpers.DefaultPlainDir + "BenchmarkWrite"  	fi, err := os.Stat(fn)  	if err != nil {  		t.Fatal(err) @@ -82,7 +84,7 @@ func BenchmarkStreamRead(t *testing.B) {  // createFiles - create "count" files of size "size" bytes each  func createFiles(t *testing.B, count int, size int) { -	dir := fmt.Sprintf("%s/createFiles_%d_%d", defaultPlainDir, count, size) +	dir := fmt.Sprintf("%s/createFiles_%d_%d", test_helpers.DefaultPlainDir, count, size)  	err := os.Mkdir(dir, 0777)  	if err != nil {  		t.Fatal(err) diff --git a/stress_tests/extractloop.bash b/tests/stress_tests/extractloop.bash index c488707..c488707 100755 --- a/stress_tests/extractloop.bash +++ b/tests/stress_tests/extractloop.bash diff --git a/stress_tests/extractloop.md5sums b/tests/stress_tests/extractloop.md5sums index 2cf6349..2cf6349 100644 --- a/stress_tests/extractloop.md5sums +++ b/tests/stress_tests/extractloop.md5sums diff --git a/stress_tests/fsstress-gocryptfs.bash b/tests/stress_tests/fsstress-gocryptfs.bash index 44ba569..44ba569 120000 --- a/stress_tests/fsstress-gocryptfs.bash +++ b/tests/stress_tests/fsstress-gocryptfs.bash diff --git a/stress_tests/fsstress-loopback.bash b/tests/stress_tests/fsstress-loopback.bash index 51c68db..51c68db 100755 --- a/stress_tests/fsstress-loopback.bash +++ b/tests/stress_tests/fsstress-loopback.bash diff --git a/integration_tests/helpers.go b/tests/test_helpers/helpers.go index 4881a4b..2f3bf0c 100644 --- a/integration_tests/helpers.go +++ b/tests/test_helpers/helpers.go @@ -1,4 +1,4 @@ -package integration_tests +package test_helpers  import (  	"crypto/md5" @@ -15,43 +15,43 @@ import (  )  // Note: the code assumes that all have a trailing slash -const tmpDir = "/tmp/gocryptfs_main_test/" -const defaultPlainDir = tmpDir + "plain/" -const defaultCipherDir = tmpDir + "cipher/" +const TmpDir = "/tmp/gocryptfs_main_test/" +const DefaultPlainDir = TmpDir + "plain/" +const DefaultCipherDir = TmpDir + "cipher/" -const gocryptfsBinary = "../gocryptfs" +const GocryptfsBinary = "../../gocryptfs" -// resetTmpDir - delete old tmp dir, create new one, write gocryptfs.diriv -func resetTmpDir(plaintextNames bool) { +// ResetTmpDir - delete old tmp dir, create new one, write gocryptfs.diriv +func ResetTmpDir(plaintextNames bool) {  	// Try to unmount everything -	entries, err := ioutil.ReadDir(tmpDir) +	entries, err := ioutil.ReadDir(TmpDir)  	if err == nil {  		for _, e := range entries { -			fu := exec.Command("fusermount", "-z", "-u", filepath.Join(tmpDir, e.Name())) +			fu := exec.Command("fusermount", "-z", "-u", filepath.Join(TmpDir, e.Name()))  			fu.Run()  		}  	} -	err = os.RemoveAll(tmpDir) +	err = os.RemoveAll(TmpDir)  	if err != nil {  		fmt.Println("resetTmpDir: RemoveAll:" + err.Error())  		os.Exit(1)  	} -	err = os.MkdirAll(defaultPlainDir, 0777) +	err = os.MkdirAll(DefaultPlainDir, 0777)  	if err != nil {  		fmt.Println(err)  		os.Exit(1)  	} -	err = os.MkdirAll(defaultCipherDir, 0777) +	err = os.MkdirAll(DefaultCipherDir, 0777)  	if err != nil {  		fmt.Println(err)  		os.Exit(1)  	}  	if !plaintextNames { -		err = nametransform.WriteDirIV(defaultCipherDir) +		err = nametransform.WriteDirIV(DefaultCipherDir)  		if err != nil {  			fmt.Println(err)  			os.Exit(1) @@ -59,8 +59,8 @@ func resetTmpDir(plaintextNames bool) {  	}  } -// mount CIPHERDIR "c" on PLAINDIR "p" -func mount(c string, p string, extraArgs ...string) error { +// Mount CIPHERDIR "c" on PLAINDIR "p" +func Mount(c string, p string, extraArgs ...string) error {  	var args []string  	args = append(args, extraArgs...)  	args = append(args, "-nosyslog", "-q", "-wpanic") @@ -68,31 +68,33 @@ func mount(c string, p string, extraArgs ...string) error {  	//args = append(args, "-d")  	args = append(args, c)  	args = append(args, p) -	cmd := exec.Command(gocryptfsBinary, args...) +	cmd := exec.Command(GocryptfsBinary, args...)  	cmd.Stderr = os.Stderr -	cmd.Stdout = os.Stdout +	if testing.Verbose() { +		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...) +// MountOrExit calls mount() and exits on failure. +func MountOrExit(c string, p string, extraArgs ...string) { +	err := Mount(c, p, extraArgs...)  	if err != nil {  		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...) +// 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 { +// Unmount PLAINDIR "p" +func Unmount(p string) error {  	fu := exec.Command("fusermount", "-u", "-z", p)  	fu.Stdout = os.Stdout  	fu.Stderr = os.Stderr @@ -104,17 +106,17 @@ func unmount(p string) error {  }  // Return md5 string for file "filename" -func md5fn(filename string) string { +func Md5fn(filename string) string {  	buf, err := ioutil.ReadFile(filename)  	if err != nil {  		fmt.Printf("ReadFile: %v\n", err)  		return ""  	} -	return md5hex(buf) +	return Md5hex(buf)  }  // Return md5 string for "buf" -func md5hex(buf []byte) string { +func Md5hex(buf []byte) string {  	rawHash := md5.Sum(buf)  	hash := hex.EncodeToString(rawHash[:])  	return hash @@ -123,7 +125,7 @@ func md5hex(buf []byte) string {  // Verify that the file size equals "want". This checks:  // 1) Size reported by Stat()  // 2) Number of bytes returned when reading the whole file -func verifySize(t *testing.T, path string, want int) { +func VerifySize(t *testing.T, path string, want int) {  	buf, err := ioutil.ReadFile(path)  	if err != nil {  		t.Errorf("ReadFile failed: %v", err) @@ -140,7 +142,7 @@ func verifySize(t *testing.T, path string, want int) {  }  // Create and delete a directory -func testMkdirRmdir(t *testing.T, plainDir string) { +func TestMkdirRmdir(t *testing.T, plainDir string) {  	dir := plainDir + "dir1"  	err := os.Mkdir(dir, 0777)  	if err != nil { @@ -187,7 +189,7 @@ func testMkdirRmdir(t *testing.T, plainDir string) {  }  // Create and rename a file -func testRename(t *testing.T, plainDir string) { +func TestRename(t *testing.T, plainDir string) {  	file1 := plainDir + "rename1"  	file2 := plainDir + "rename2"  	err := ioutil.WriteFile(file1, []byte("content"), 0777) @@ -203,7 +205,7 @@ func testRename(t *testing.T, plainDir string) {  // verifyExistence - check in 3 ways that "path" exists:  // stat, open, readdir -func verifyExistence(path string) bool { +func VerifyExistence(path string) bool {  	// Check that file can be stated  	_, err := os.Stat(path) | 
