tests: matrix: convert to table-based style

And add AES-SIV
This commit is contained in:
Jakob Unterwurzacher 2016-10-08 19:15:28 +02:00
parent 04cdc695f0
commit 084cd597ab
1 changed files with 41 additions and 20 deletions

View File

@ -12,6 +12,7 @@ package matrix
import ( import (
"bytes" "bytes"
"encoding/json"
"flag" "flag"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
@ -31,30 +32,50 @@ import (
// a global variable // a global variable
var plaintextnames bool var plaintextnames bool
type testcaseMatrix struct {
// Exported so we can dump the struct using json.Marshal
Plaintextnames bool
Openssl string
Aessiv bool
}
var matrix []testcaseMatrix = []testcaseMatrix{
// Normal
{false, "auto", false},
{false, "true", false},
{false, "false", false},
// Plaintextnames
{true, "true", false},
{true, "false", false},
// AES-SIV (does not use openssl, no need to test permutations)
{false, "auto", true},
{true, "auto", true},
}
// This is the entry point for the tests // This is the entry point for the tests
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
// Make "testing.Verbose()" return the correct value // Make "testing.Verbose()" return the correct value
flag.Parse() flag.Parse()
opensslVariants := []bool{true, false} for _, testcase := range matrix {
if !cryptocore.HaveModernGoGCM { if !cryptocore.HaveModernGoGCM && testcase.Openssl != "true" {
fmt.Printf("Skipping Go GCM variant, Go installation is too old") fmt.Printf("Skipping Go GCM variant, Go installation is too old")
opensslVariants = opensslVariants[:1] continue
} }
for _, openssl := range opensslVariants { if testing.Verbose() {
for _, plaintextnames = range []bool{true, false} { j, _ := json.Marshal(testcase)
if testing.Verbose() { fmt.Printf("matrix: testcase = %s\n", string(j))
fmt.Printf("matrix: testing openssl=%v plaintextnames=%v\n", openssl, plaintextnames) }
} plaintextnames = testcase.Plaintextnames
test_helpers.ResetTmpDir(plaintextnames) test_helpers.ResetTmpDir(plaintextnames)
opts := []string{"--zerokey"} opts := []string{"-zerokey"}
opts = append(opts, fmt.Sprintf("-openssl=%v", openssl)) opts = append(opts, fmt.Sprintf("-openssl=%v", testcase.Openssl))
opts = append(opts, fmt.Sprintf("-plaintextnames=%v", plaintextnames)) opts = append(opts, fmt.Sprintf("-plaintextnames=%v", testcase.Plaintextnames))
test_helpers.MountOrExit(test_helpers.DefaultCipherDir, test_helpers.DefaultPlainDir, opts...) opts = append(opts, fmt.Sprintf("-aessiv=%v", testcase.Aessiv))
r := m.Run() test_helpers.MountOrExit(test_helpers.DefaultCipherDir, test_helpers.DefaultPlainDir, opts...)
test_helpers.UnmountPanic(test_helpers.DefaultPlainDir) r := m.Run()
if r != 0 { test_helpers.UnmountPanic(test_helpers.DefaultPlainDir)
os.Exit(r) if r != 0 {
} os.Exit(r)
} }
} }
os.Exit(0) os.Exit(0)