tests: matrix: convert to table-based style
And add AES-SIV
This commit is contained in:
parent
04cdc695f0
commit
084cd597ab
@ -12,6 +12,7 @@ package matrix
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@ -31,24 +32,45 @@ 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 {
|
|
||||||
for _, plaintextnames = range []bool{true, false} {
|
|
||||||
if testing.Verbose() {
|
if testing.Verbose() {
|
||||||
fmt.Printf("matrix: testing openssl=%v plaintextnames=%v\n", openssl, plaintextnames)
|
j, _ := json.Marshal(testcase)
|
||||||
|
fmt.Printf("matrix: testcase = %s\n", string(j))
|
||||||
}
|
}
|
||||||
|
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))
|
||||||
|
opts = append(opts, fmt.Sprintf("-aessiv=%v", testcase.Aessiv))
|
||||||
test_helpers.MountOrExit(test_helpers.DefaultCipherDir, test_helpers.DefaultPlainDir, opts...)
|
test_helpers.MountOrExit(test_helpers.DefaultCipherDir, test_helpers.DefaultPlainDir, opts...)
|
||||||
r := m.Run()
|
r := m.Run()
|
||||||
test_helpers.UnmountPanic(test_helpers.DefaultPlainDir)
|
test_helpers.UnmountPanic(test_helpers.DefaultPlainDir)
|
||||||
@ -56,7 +78,6 @@ func TestMain(m *testing.M) {
|
|||||||
os.Exit(r)
|
os.Exit(r)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user