tests: split "normal" tests into "cli" and "defaults"

Also fixes the failure to run the benchmarks do to the missing
gocryptfs.diriv.
This commit is contained in:
Jakob Unterwurzacher 2016-10-16 13:39:25 +02:00
parent dc78e634aa
commit 57e8df990c
4 changed files with 26 additions and 10 deletions

View File

@ -1,4 +1,4 @@
package normal
package cli
// Test CLI operations like "-init", "-password" etc
@ -15,9 +15,7 @@ import (
func TestMain(m *testing.M) {
test_helpers.ResetTmpDir(false)
test_helpers.MountOrExit(test_helpers.DefaultCipherDir, test_helpers.DefaultPlainDir, "--zerokey")
r := m.Run()
test_helpers.UnmountPanic(test_helpers.DefaultPlainDir)
os.Exit(r)
}

View File

@ -0,0 +1,17 @@
// Tests and benchmarks performed with default settings only.
package defaults
import (
"os"
"testing"
"github.com/rfjakob/gocryptfs/tests/test_helpers"
)
func TestMain(m *testing.M) {
test_helpers.ResetTmpDir(true)
test_helpers.MountOrExit(test_helpers.DefaultCipherDir, test_helpers.DefaultPlainDir, "-zerokey")
r := m.Run()
test_helpers.UnmountPanic(test_helpers.DefaultPlainDir)
os.Exit(r)
}

View File

@ -1,6 +1,5 @@
package normal
// Benchmarks
// Tests and benchmarks performed with default settings only.
package defaults
import (
"fmt"
@ -12,13 +11,14 @@ import (
"github.com/rfjakob/gocryptfs/tests/test_helpers"
)
// Benchmarks
func BenchmarkStreamWrite(t *testing.B) {
buf := make([]byte, 1024*1024)
t.SetBytes(int64(len(buf)))
file, err := os.Create(test_helpers.DefaultPlainDir + "BenchmarkWrite")
file, err := os.Create(test_helpers.DefaultPlainDir + "/BenchmarkWrite")
if err != nil {
t.FailNow()
t.Fatal(err)
}
t.ResetTimer()
@ -27,7 +27,7 @@ func BenchmarkStreamWrite(t *testing.B) {
written, err := file.Write(buf)
if err != nil {
fmt.Printf("err=\"%s\", written=%d\n", err.Error(), written)
t.FailNow()
t.Fatal(err)
}
}
file.Close()
@ -37,7 +37,7 @@ func BenchmarkStreamRead(t *testing.B) {
buf := make([]byte, 1024*1024)
t.SetBytes(int64(len(buf)))
fn := test_helpers.DefaultPlainDir + "BenchmarkWrite"
fn := test_helpers.DefaultPlainDir + "/BenchmarkWrite"
fi, err := os.Stat(fn)
if err != nil {
t.Fatal(err)

View File

@ -1,3 +1,4 @@
// Tests run for (almost all) combinations of openssl, aessiv, plaintextnames.
package matrix
// File reading, writing, modification, truncate