tests: skip tests with -openssl=false on Go 1.4 and lower

Go versions 1.4 and lower lack NewGCMWithNonceSize(), which causes
a panic in the test.
This commit is contained in:
Jakob Unterwurzacher 2016-10-04 22:29:14 +02:00
parent b80d01056f
commit db5782028a
4 changed files with 22 additions and 2 deletions

View File

@ -10,6 +10,10 @@ import (
"github.com/rfjakob/gocryptfs/internal/tlog" "github.com/rfjakob/gocryptfs/internal/tlog"
) )
const (
HaveModernGoGCM = false
)
// goGCMWrapper - This wrapper makes sure gocryptfs can be compiled on Go // goGCMWrapper - This wrapper makes sure gocryptfs can be compiled on Go
// versions 1.4 and lower that lack NewGCMWithNonceSize(). // versions 1.4 and lower that lack NewGCMWithNonceSize().
// 128 bit GCM IVs will not work when using built-in Go crypto, obviously, when // 128 bit GCM IVs will not work when using built-in Go crypto, obviously, when

View File

@ -7,6 +7,10 @@ import (
"crypto/cipher" "crypto/cipher"
) )
const (
HaveModernGoGCM = true
)
// goGCMWrapper - This wrapper makes sure gocryptfs can be compiled on Go // goGCMWrapper - This wrapper makes sure gocryptfs can be compiled on Go
// versions 1.4 and lower that lack NewGCMWithNonceSize(). // versions 1.4 and lower that lack NewGCMWithNonceSize().
// 128 bit GCM IVs will not work when using built-in Go crypto, obviously, when // 128 bit GCM IVs will not work when using built-in Go crypto, obviously, when

View File

@ -12,6 +12,7 @@ import (
"os" "os"
"testing" "testing"
"github.com/rfjakob/gocryptfs/internal/cryptocore"
"github.com/rfjakob/gocryptfs/tests/test_helpers" "github.com/rfjakob/gocryptfs/tests/test_helpers"
) )
@ -22,7 +23,12 @@ var opensslOpt string
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()
for _, opensslOpt = range []string{"-openssl=false", "-openssl=true"} { variants := []string{"-openssl=true", "-openssl=false"}
if !cryptocore.HaveModernGoGCM {
fmt.Printf("Skipping Go GCM variant, Go installation is too old")
variants = variants[:1]
}
for _, opensslOpt = range variants {
if testing.Verbose() { if testing.Verbose() {
fmt.Printf("example_filesystems: testing with %q\n", opensslOpt) fmt.Printf("example_filesystems: testing with %q\n", opensslOpt)
} }

View File

@ -22,6 +22,7 @@ import (
"syscall" "syscall"
"testing" "testing"
"github.com/rfjakob/gocryptfs/internal/cryptocore"
"github.com/rfjakob/gocryptfs/internal/syscallcompat" "github.com/rfjakob/gocryptfs/internal/syscallcompat"
"github.com/rfjakob/gocryptfs/tests/test_helpers" "github.com/rfjakob/gocryptfs/tests/test_helpers"
) )
@ -34,7 +35,12 @@ var plaintextnames bool
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()
for _, openssl := range []bool{true, false} { opensslVariants := []bool{true, false}
if !cryptocore.HaveModernGoGCM {
fmt.Printf("Skipping Go GCM variant, Go installation is too old")
opensslVariants = opensslVariants[:1]
}
for _, openssl := range opensslVariants {
for _, plaintextnames = range []bool{true, false} { for _, plaintextnames = range []bool{true, false} {
if testing.Verbose() { if testing.Verbose() {
fmt.Printf("matrix: testing openssl=%v plaintextnames=%v\n", openssl, plaintextnames) fmt.Printf("matrix: testing openssl=%v plaintextnames=%v\n", openssl, plaintextnames)