From 2fb1d52746eac18f1251e1e303b312fe148d29a8 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Mon, 23 Aug 2021 16:00:21 +0200 Subject: [PATCH] tests/matrix: add -xchacha test --- tests/matrix/fallocate_test.go | 8 +++++++- tests/matrix/matrix_test.go | 13 ++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/tests/matrix/fallocate_test.go b/tests/matrix/fallocate_test.go index c94c070..84eae7e 100644 --- a/tests/matrix/fallocate_test.go +++ b/tests/matrix/fallocate_test.go @@ -156,7 +156,13 @@ func TestFallocate(t *testing.T) { if err != nil { t.Fatal(err) } - err = syscallcompat.Fallocate(fd, FALLOC_DEFAULT, 0, 8110) + var plain int64 = 8110 + if testcase.isSet("-xchacha") { + // xchacha has 24 byte ivs instead of 16. 8kiB are two blocks, so + // 2x8=16 bytes more. + plain = plain - 16 + } + err = syscallcompat.Fallocate(fd, FALLOC_DEFAULT, 0, plain) if err != nil { t.Fatal(err) } diff --git a/tests/matrix/matrix_test.go b/tests/matrix/matrix_test.go index 0ee5688..f34b5f2 100644 --- a/tests/matrix/matrix_test.go +++ b/tests/matrix/matrix_test.go @@ -39,6 +39,16 @@ type testcaseMatrix struct { extraArgs []string } +// isSet finds out if `extraArg` is set in `tc.extraArgs` +func (tc *testcaseMatrix) isSet(extraArg string) bool { + for _, v := range tc.extraArgs { + if v == extraArg { + return true + } + } + return false +} + var matrix = []testcaseMatrix{ // Normal {false, "auto", false, false, nil}, @@ -56,6 +66,7 @@ var matrix = []testcaseMatrix{ {false, "auto", false, false, []string{"-serialize_reads"}}, {false, "auto", false, false, []string{"-sharedstorage"}}, {false, "auto", false, false, []string{"-deterministic-names"}}, + {false, "auto", false, true, []string{"-xchacha"}}, } // This is the entry point for the tests @@ -73,7 +84,7 @@ func TestMain(m *testing.M) { createDirIV := true if testcase.plaintextnames { createDirIV = false - } else if len(testcase.extraArgs) == 1 && testcase.extraArgs[0] == "-deterministic-names" { + } else if testcase.isSet("-deterministic-names") { createDirIV = false } test_helpers.ResetTmpDir(createDirIV)