From 7f9e81431f399dfc117d5680b6fd04fc745384d0 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Tue, 13 Jan 2015 09:04:30 +0100 Subject: [PATCH] Reduce time spent in tests Make testing crypto functions with large buffers optional, use the flag '-test.largecrypto'. --- key_test.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/key_test.go b/key_test.go index 6fdcca836..77919f046 100644 --- a/key_test.go +++ b/key_test.go @@ -14,6 +14,7 @@ import ( var testPassword = "foobar" var testCleanup = flag.Bool("test.cleanup", true, "clean up after running tests (remove local backend directory with all content)") +var testLargeCrypto = flag.Bool("test.largecrypto", false, "also test crypto functions with large payloads") func setupBackend(t testing.TB) restic.Server { tempdir, err := ioutil.TempDir("", "restic-test-") @@ -53,7 +54,12 @@ func TestEncryptDecrypt(t *testing.T) { defer teardownBackend(t, s) k := setupKey(t, s, testPassword) - for _, size := range []int{5, 23, 1 << 20, 7<<20 + 123} { + tests := []int{5, 23, 2<<18 + 23, 1 << 20} + if *testLargeCrypto { + tests = append(tests, 7<<20+123) + } + + for _, size := range tests { data := make([]byte, size) f, err := os.Open("/dev/urandom") ok(t, err) @@ -75,11 +81,15 @@ func TestEncryptDecrypt(t *testing.T) { } func TestLargeEncrypt(t *testing.T) { + if !*testLargeCrypto { + t.SkipNow() + } + s := setupBackend(t) defer teardownBackend(t, s) k := setupKey(t, s, testPassword) - for _, size := range []int{chunker.MaxSize, chunker.MaxSize + 1} { + for _, size := range []int{chunker.MaxSize, chunker.MaxSize + 1, chunker.MaxSize + 1<<20} { data := make([]byte, size) f, err := os.Open("/dev/urandom") ok(t, err)