linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC v1 0/2] crypto: tcrypt: small changes to run under KUnit
@ 2021-07-15 21:31 Daniel Latypov
  2021-07-15 21:31 ` [RFC v1 1/2] crypto: tcrypt: minimal conversion " Daniel Latypov
  2021-07-15 21:31 ` [RFC v1 2/2] crypto: tcrypt: call KUNIT_FAIL() instead of pr_err() Daniel Latypov
  0 siblings, 2 replies; 7+ messages in thread
From: Daniel Latypov @ 2021-07-15 21:31 UTC (permalink / raw)
  To: herbert
  Cc: davem, linux-crypto, brendanhiggins, davidgow, linux-kernel,
	kunit-dev, Daniel Latypov

tcrypt.c calls itself a "[q]uick & dirty crypto testing module."
One that "will only exist until we have a better testing mechanism."

This RFC seeks to start a discussion if KUnit can fill the role of that
"better testing mechanism."

As-is, these example changes don't make the test code much cleaner.
But they do provide a new way of running the test that's hopefully more
accessible, namely
$ ./tools/testing/kunit/kunit.py run --kunitconfig=crypto
...
[16:53:16] Starting KUnit Kernel ...
[16:53:19] ============================================================
[16:53:19] ======== [PASSED] tcrypt ========
[16:53:19] [PASSED] tcrypt
[16:53:19] ============================================================
[16:53:19] Testing complete. 1 tests run. 0 failed. 0 crashed. 0 skipped.
[16:53:19] Elapsed time: 8.806s total, 0.001s configuring, 5.764s building, 0.000s running

This series contains
* an initial patch with the boilerplate needed to run
under KUnit and track pass/fail status in the `test` context object
instead of passing around an int.
* another change to plumb the `test` context object to other test cases
that could previously fail w/o affecting the overall pass/fail status.

I haven't reformatted the code for now just to make the changes a bit
easier to read and skim over. checkpatch.pl isn't happy about the
spacing in the second patch.

== Other pros ==

If we want, we can go down the path of trying to structure the tests in
more idiomatic KUnit fashion to get some benefits like 
* automatically freeing memory at the end of tests when allocated using
  kunit_kmalloc() and friends instead of having to maintain labels
  * can be made to call arbitrary cleanup functions as well
  * this hopefully makes the tests more readable, at the expense of a
  bit more runtime overhead dynamically tracking these allocations
  * doing this just for the kmalloc's and __get_free_page() directly in
  * tcrypt.c saves 100+ lines of code.

* flagging test cases with KASAN issues (and eventually UBSAN)

* a bit easier way to dynamically run subsets of tests via glob
  * e.g. kunit.py run 'crypto.*sha512*'
  * KUnit currently only supports filtering by the suite ("crypto")
  right now, but we should have test-level filtering support soonish.

== Cons ==

The main cons are we'd be slightly changing how these tests are built
and run with these example patches

These changes are mainly
* building the test now requires CONFIG_KUNIT
* Running `insmod` on the module will always return 0, even if tests
  failed
  * the test instead prints out (K)TAP output to denote pass/fail
  * this is the format kselftest uses, but it's not fully standardized

And if we eventually try to restructure the test as mentioned above:
* more disruptive changes to how the tests are run
  * we'd have to move away from using the "mode" parameter
* a decent amount of code churn

Daniel Latypov (2):
  crypto: tcrypt: minimal conversion to run under KUnit
  crypto: tcrypt: call KUNIT_FAIL() instead of pr_err()

 crypto/Kconfig  |    5 +-
 crypto/tcrypt.c | 1063 +++++++++++++++++++++++------------------------
 2 files changed, 524 insertions(+), 544 deletions(-)


base-commit: e9338abf0e186336022293d2e454c106761f262b
-- 
2.32.0.402.g57bb445576-goog


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [RFC v1 1/2] crypto: tcrypt: minimal conversion to run under KUnit
  2021-07-15 21:31 [RFC v1 0/2] crypto: tcrypt: small changes to run under KUnit Daniel Latypov
@ 2021-07-15 21:31 ` Daniel Latypov
  2021-07-23  6:43   ` Herbert Xu
  2021-07-15 21:31 ` [RFC v1 2/2] crypto: tcrypt: call KUNIT_FAIL() instead of pr_err() Daniel Latypov
  1 sibling, 1 reply; 7+ messages in thread
From: Daniel Latypov @ 2021-07-15 21:31 UTC (permalink / raw)
  To: herbert
  Cc: davem, linux-crypto, brendanhiggins, davidgow, linux-kernel,
	kunit-dev, Daniel Latypov

tcrypt.c calls itself a "[q]uick & dirty crypto testing module."
One that "will only exist until we have a better testing mechanism."

This is a fairly minimal change to get the test running under KUnit,
which is hopefully a "better testing mechanism" than a plain test
module.

THe main benefit is that it provides a more standardized way to run the
test, and one that is hopefully faster and easier, see below.

The test can still be run as a test module, but
* now it prints KTAP output (like kselftest) as a structured means of
reporting pass/fail
* has a dependency on CONFIG_KUNIT
* sadly does not allow controlling the return code from mod_init, it'll
always be 0

If we continue down this path and start splitting up the test cases,
there's a few benefits KUnit can provide:
* When running with CONFIG_KASAN=y, it can mark the current test case as
FAILED with a diagnostic error message
  * UBSAN support is just waiting to be picked up, might get more

* We can try and refactor tests to use KUnit utilities for managed
allocations/deallocations
  * some local hacking suggests this can cut down 100s of lines
  * avoids having to set up chains of labels w/ gotos

* KUnit supports running subsets of tests by suite name
  * this could be extended to filtering by test name
  * would no longer need a large switch statement to do this

== Running the test ==
We can run it like so (uses ARCH=um)
$ ./tools/testing/kunit/kunit.py run --kunitconfig /dev/stdin <<EOF
  CONFIG_KUNIT=y
  CONFIG_CRYPTO=y
  CONFIG_CRYPTO_MANAGER=y
  CONFIG_CRYPTO_TEST=y
EOF

Or instead, thanks to the crypto/.kunitconfig file this patch adds:
$ ./tools/testing/kunit/kunit.py run --kunitconfig=crypto

From a fresh tree, this builds in runs in ~1 minute, and after an
incremental rebuild, it takes only seconds.

We can add on `--arch=x86_64` to instead run it in a QEMU VM, which only
takes a bit longer.

== Questions ==
* does this seem like it would make running the test easier?
* does `tvmem` actually need page-aligned buffers?
* I have no clue how FIPS intersects with all of this.
  * would it be fine to leave the test code built-in for FIPS instead of
  returning -EAGAIN?

Signed-off-by: Daniel Latypov <dlatypov@google.com>
---
 crypto/Kconfig  |   5 +-
 crypto/tcrypt.c | 301 +++++++++++++++++++++++-------------------------
 2 files changed, 143 insertions(+), 163 deletions(-)

diff --git a/crypto/Kconfig b/crypto/Kconfig
index ca3b02dcbbfa..73bb14f3c0b6 100644
--- a/crypto/Kconfig
+++ b/crypto/Kconfig
@@ -200,9 +200,8 @@ config CRYPTO_AUTHENC
 	  This is required for IPSec.
 
 config CRYPTO_TEST
-	tristate "Testing module"
-	depends on m || EXPERT
-	select CRYPTO_MANAGER
+	tristate "Testing module" if !KUNIT_ALL_TESTS
+	depends on CRYPTO_MANAGER && KUNIT
 	help
 	  Quick & dirty crypto test module.
 
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index f8d06da78e4f..319fe71a69b5 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -22,6 +22,7 @@
 #include <crypto/aead.h>
 #include <crypto/hash.h>
 #include <crypto/skcipher.h>
+#include <kunit/test.h>
 #include <linux/err.h>
 #include <linux/fips.h>
 #include <linux/init.h>
@@ -1652,7 +1653,7 @@ static void test_available(void)
 	}
 }
 
-static inline int tcrypt_test(const char *alg)
+static inline void tcrypt_test(struct kunit *test, const char *alg)
 {
 	int ret;
 
@@ -1662,376 +1663,376 @@ static inline int tcrypt_test(const char *alg)
 	/* non-fips algs return -EINVAL in fips mode */
 	if (fips_enabled && ret == -EINVAL)
 		ret = 0;
-	return ret;
+	KUNIT_EXPECT_EQ_MSG(test, ret, 0, "alg_test(%s) failed", alg);
 }
 
-static int do_test(const char *alg, u32 type, u32 mask, int m, u32 num_mb)
+static void do_test(struct kunit *test, const char *alg, u32 type, u32 mask,
+		    int m, u32 num_mb)
 {
 	int i;
-	int ret = 0;
 
 	switch (m) {
 	case 0:
 		if (alg) {
 			if (!crypto_has_alg(alg, type,
 					    mask ?: CRYPTO_ALG_TYPE_MASK))
-				ret = -ENOENT;
+				KUNIT_FAIL(test, "don't have alg '%s'", alg);
 			break;
 		}
 
 		for (i = 1; i < 200; i++)
-			ret += do_test(NULL, 0, 0, i, num_mb);
+			do_test(test, NULL, 0, 0, i, num_mb);
 		break;
 
 	case 1:
-		ret += tcrypt_test("md5");
+		tcrypt_test(test, "md5");
 		break;
 
 	case 2:
-		ret += tcrypt_test("sha1");
+		tcrypt_test(test, "sha1");
 		break;
 
 	case 3:
-		ret += tcrypt_test("ecb(des)");
-		ret += tcrypt_test("cbc(des)");
-		ret += tcrypt_test("ctr(des)");
+		tcrypt_test(test, "ecb(des)");
+		tcrypt_test(test, "cbc(des)");
+		tcrypt_test(test, "ctr(des)");
 		break;
 
 	case 4:
-		ret += tcrypt_test("ecb(des3_ede)");
-		ret += tcrypt_test("cbc(des3_ede)");
-		ret += tcrypt_test("ctr(des3_ede)");
+		tcrypt_test(test, "ecb(des3_ede)");
+		tcrypt_test(test, "cbc(des3_ede)");
+		tcrypt_test(test, "ctr(des3_ede)");
 		break;
 
 	case 5:
-		ret += tcrypt_test("md4");
+		tcrypt_test(test, "md4");
 		break;
 
 	case 6:
-		ret += tcrypt_test("sha256");
+		tcrypt_test(test, "sha256");
 		break;
 
 	case 7:
-		ret += tcrypt_test("ecb(blowfish)");
-		ret += tcrypt_test("cbc(blowfish)");
-		ret += tcrypt_test("ctr(blowfish)");
+		tcrypt_test(test, "ecb(blowfish)");
+		tcrypt_test(test, "cbc(blowfish)");
+		tcrypt_test(test, "ctr(blowfish)");
 		break;
 
 	case 8:
-		ret += tcrypt_test("ecb(twofish)");
-		ret += tcrypt_test("cbc(twofish)");
-		ret += tcrypt_test("ctr(twofish)");
-		ret += tcrypt_test("lrw(twofish)");
-		ret += tcrypt_test("xts(twofish)");
+		tcrypt_test(test, "ecb(twofish)");
+		tcrypt_test(test, "cbc(twofish)");
+		tcrypt_test(test, "ctr(twofish)");
+		tcrypt_test(test, "lrw(twofish)");
+		tcrypt_test(test, "xts(twofish)");
 		break;
 
 	case 9:
-		ret += tcrypt_test("ecb(serpent)");
-		ret += tcrypt_test("cbc(serpent)");
-		ret += tcrypt_test("ctr(serpent)");
-		ret += tcrypt_test("lrw(serpent)");
-		ret += tcrypt_test("xts(serpent)");
+		tcrypt_test(test, "ecb(serpent)");
+		tcrypt_test(test, "cbc(serpent)");
+		tcrypt_test(test, "ctr(serpent)");
+		tcrypt_test(test, "lrw(serpent)");
+		tcrypt_test(test, "xts(serpent)");
 		break;
 
 	case 10:
-		ret += tcrypt_test("ecb(aes)");
-		ret += tcrypt_test("cbc(aes)");
-		ret += tcrypt_test("lrw(aes)");
-		ret += tcrypt_test("xts(aes)");
-		ret += tcrypt_test("ctr(aes)");
-		ret += tcrypt_test("rfc3686(ctr(aes))");
-		ret += tcrypt_test("ofb(aes)");
-		ret += tcrypt_test("cfb(aes)");
+		tcrypt_test(test, "ecb(aes)");
+		tcrypt_test(test, "cbc(aes)");
+		tcrypt_test(test, "lrw(aes)");
+		tcrypt_test(test, "xts(aes)");
+		tcrypt_test(test, "ctr(aes)");
+		tcrypt_test(test, "rfc3686(ctr(aes))");
+		tcrypt_test(test, "ofb(aes)");
+		tcrypt_test(test, "cfb(aes)");
 		break;
 
 	case 11:
-		ret += tcrypt_test("sha384");
+		tcrypt_test(test, "sha384");
 		break;
 
 	case 12:
-		ret += tcrypt_test("sha512");
+		tcrypt_test(test, "sha512");
 		break;
 
 	case 13:
-		ret += tcrypt_test("deflate");
+		tcrypt_test(test, "deflate");
 		break;
 
 	case 14:
-		ret += tcrypt_test("ecb(cast5)");
-		ret += tcrypt_test("cbc(cast5)");
-		ret += tcrypt_test("ctr(cast5)");
+		tcrypt_test(test, "ecb(cast5)");
+		tcrypt_test(test, "cbc(cast5)");
+		tcrypt_test(test, "ctr(cast5)");
 		break;
 
 	case 15:
-		ret += tcrypt_test("ecb(cast6)");
-		ret += tcrypt_test("cbc(cast6)");
-		ret += tcrypt_test("ctr(cast6)");
-		ret += tcrypt_test("lrw(cast6)");
-		ret += tcrypt_test("xts(cast6)");
+		tcrypt_test(test, "ecb(cast6)");
+		tcrypt_test(test, "cbc(cast6)");
+		tcrypt_test(test, "ctr(cast6)");
+		tcrypt_test(test, "lrw(cast6)");
+		tcrypt_test(test, "xts(cast6)");
 		break;
 
 	case 16:
-		ret += tcrypt_test("ecb(arc4)");
+		tcrypt_test(test, "ecb(arc4)");
 		break;
 
 	case 17:
-		ret += tcrypt_test("michael_mic");
+		tcrypt_test(test, "michael_mic");
 		break;
 
 	case 18:
-		ret += tcrypt_test("crc32c");
+		tcrypt_test(test, "crc32c");
 		break;
 
 	case 19:
-		ret += tcrypt_test("ecb(tea)");
+		tcrypt_test(test, "ecb(tea)");
 		break;
 
 	case 20:
-		ret += tcrypt_test("ecb(xtea)");
+		tcrypt_test(test, "ecb(xtea)");
 		break;
 
 	case 21:
-		ret += tcrypt_test("ecb(khazad)");
+		tcrypt_test(test, "ecb(khazad)");
 		break;
 
 	case 22:
-		ret += tcrypt_test("wp512");
+		tcrypt_test(test, "wp512");
 		break;
 
 	case 23:
-		ret += tcrypt_test("wp384");
+		tcrypt_test(test, "wp384");
 		break;
 
 	case 24:
-		ret += tcrypt_test("wp256");
+		tcrypt_test(test, "wp256");
 		break;
 
 	case 26:
-		ret += tcrypt_test("ecb(anubis)");
-		ret += tcrypt_test("cbc(anubis)");
+		tcrypt_test(test, "ecb(anubis)");
+		tcrypt_test(test, "cbc(anubis)");
 		break;
 
 	case 30:
-		ret += tcrypt_test("ecb(xeta)");
+		tcrypt_test(test, "ecb(xeta)");
 		break;
 
 	case 31:
-		ret += tcrypt_test("pcbc(fcrypt)");
+		tcrypt_test(test, "pcbc(fcrypt)");
 		break;
 
 	case 32:
-		ret += tcrypt_test("ecb(camellia)");
-		ret += tcrypt_test("cbc(camellia)");
-		ret += tcrypt_test("ctr(camellia)");
-		ret += tcrypt_test("lrw(camellia)");
-		ret += tcrypt_test("xts(camellia)");
+		tcrypt_test(test, "ecb(camellia)");
+		tcrypt_test(test, "cbc(camellia)");
+		tcrypt_test(test, "ctr(camellia)");
+		tcrypt_test(test, "lrw(camellia)");
+		tcrypt_test(test, "xts(camellia)");
 		break;
 
 	case 33:
-		ret += tcrypt_test("sha224");
+		tcrypt_test(test, "sha224");
 		break;
 
 	case 35:
-		ret += tcrypt_test("gcm(aes)");
+		tcrypt_test(test, "gcm(aes)");
 		break;
 
 	case 36:
-		ret += tcrypt_test("lzo");
+		tcrypt_test(test, "lzo");
 		break;
 
 	case 37:
-		ret += tcrypt_test("ccm(aes)");
+		tcrypt_test(test, "ccm(aes)");
 		break;
 
 	case 38:
-		ret += tcrypt_test("cts(cbc(aes))");
+		tcrypt_test(test, "cts(cbc(aes))");
 		break;
 
         case 39:
-		ret += tcrypt_test("xxhash64");
+		tcrypt_test(test, "xxhash64");
 		break;
 
         case 40:
-		ret += tcrypt_test("rmd160");
+		tcrypt_test(test, "rmd160");
 		break;
 
 	case 41:
-		ret += tcrypt_test("blake2s-256");
+		tcrypt_test(test, "blake2s-256");
 		break;
 
 	case 42:
-		ret += tcrypt_test("blake2b-512");
+		tcrypt_test(test, "blake2b-512");
 		break;
 
 	case 43:
-		ret += tcrypt_test("ecb(seed)");
+		tcrypt_test(test, "ecb(seed)");
 		break;
 
 	case 45:
-		ret += tcrypt_test("rfc4309(ccm(aes))");
+		tcrypt_test(test, "rfc4309(ccm(aes))");
 		break;
 
 	case 46:
-		ret += tcrypt_test("ghash");
+		tcrypt_test(test, "ghash");
 		break;
 
 	case 47:
-		ret += tcrypt_test("crct10dif");
+		tcrypt_test(test, "crct10dif");
 		break;
 
 	case 48:
-		ret += tcrypt_test("sha3-224");
+		tcrypt_test(test, "sha3-224");
 		break;
 
 	case 49:
-		ret += tcrypt_test("sha3-256");
+		tcrypt_test(test, "sha3-256");
 		break;
 
 	case 50:
-		ret += tcrypt_test("sha3-384");
+		tcrypt_test(test, "sha3-384");
 		break;
 
 	case 51:
-		ret += tcrypt_test("sha3-512");
+		tcrypt_test(test, "sha3-512");
 		break;
 
 	case 52:
-		ret += tcrypt_test("sm3");
+		tcrypt_test(test, "sm3");
 		break;
 
 	case 53:
-		ret += tcrypt_test("streebog256");
+		tcrypt_test(test, "streebog256");
 		break;
 
 	case 54:
-		ret += tcrypt_test("streebog512");
+		tcrypt_test(test, "streebog512");
 		break;
 
 	case 100:
-		ret += tcrypt_test("hmac(md5)");
+		tcrypt_test(test, "hmac(md5)");
 		break;
 
 	case 101:
-		ret += tcrypt_test("hmac(sha1)");
+		tcrypt_test(test, "hmac(sha1)");
 		break;
 
 	case 102:
-		ret += tcrypt_test("hmac(sha256)");
+		tcrypt_test(test, "hmac(sha256)");
 		break;
 
 	case 103:
-		ret += tcrypt_test("hmac(sha384)");
+		tcrypt_test(test, "hmac(sha384)");
 		break;
 
 	case 104:
-		ret += tcrypt_test("hmac(sha512)");
+		tcrypt_test(test, "hmac(sha512)");
 		break;
 
 	case 105:
-		ret += tcrypt_test("hmac(sha224)");
+		tcrypt_test(test, "hmac(sha224)");
 		break;
 
 	case 106:
-		ret += tcrypt_test("xcbc(aes)");
+		tcrypt_test(test, "xcbc(aes)");
 		break;
 
 	case 108:
-		ret += tcrypt_test("hmac(rmd160)");
+		tcrypt_test(test, "hmac(rmd160)");
 		break;
 
 	case 109:
-		ret += tcrypt_test("vmac64(aes)");
+		tcrypt_test(test, "vmac64(aes)");
 		break;
 
 	case 111:
-		ret += tcrypt_test("hmac(sha3-224)");
+		tcrypt_test(test, "hmac(sha3-224)");
 		break;
 
 	case 112:
-		ret += tcrypt_test("hmac(sha3-256)");
+		tcrypt_test(test, "hmac(sha3-256)");
 		break;
 
 	case 113:
-		ret += tcrypt_test("hmac(sha3-384)");
+		tcrypt_test(test, "hmac(sha3-384)");
 		break;
 
 	case 114:
-		ret += tcrypt_test("hmac(sha3-512)");
+		tcrypt_test(test, "hmac(sha3-512)");
 		break;
 
 	case 115:
-		ret += tcrypt_test("hmac(streebog256)");
+		tcrypt_test(test, "hmac(streebog256)");
 		break;
 
 	case 116:
-		ret += tcrypt_test("hmac(streebog512)");
+		tcrypt_test(test, "hmac(streebog512)");
 		break;
 
 	case 150:
-		ret += tcrypt_test("ansi_cprng");
+		tcrypt_test(test, "ansi_cprng");
 		break;
 
 	case 151:
-		ret += tcrypt_test("rfc4106(gcm(aes))");
+		tcrypt_test(test, "rfc4106(gcm(aes))");
 		break;
 
 	case 152:
-		ret += tcrypt_test("rfc4543(gcm(aes))");
+		tcrypt_test(test, "rfc4543(gcm(aes))");
 		break;
 
 	case 153:
-		ret += tcrypt_test("cmac(aes)");
+		tcrypt_test(test, "cmac(aes)");
 		break;
 
 	case 154:
-		ret += tcrypt_test("cmac(des3_ede)");
+		tcrypt_test(test, "cmac(des3_ede)");
 		break;
 
 	case 155:
-		ret += tcrypt_test("authenc(hmac(sha1),cbc(aes))");
+		tcrypt_test(test, "authenc(hmac(sha1),cbc(aes))");
 		break;
 
 	case 156:
-		ret += tcrypt_test("authenc(hmac(md5),ecb(cipher_null))");
+		tcrypt_test(test, "authenc(hmac(md5),ecb(cipher_null))");
 		break;
 
 	case 157:
-		ret += tcrypt_test("authenc(hmac(sha1),ecb(cipher_null))");
+		tcrypt_test(test, "authenc(hmac(sha1),ecb(cipher_null))");
 		break;
 	case 181:
-		ret += tcrypt_test("authenc(hmac(sha1),cbc(des))");
+		tcrypt_test(test, "authenc(hmac(sha1),cbc(des))");
 		break;
 	case 182:
-		ret += tcrypt_test("authenc(hmac(sha1),cbc(des3_ede))");
+		tcrypt_test(test, "authenc(hmac(sha1),cbc(des3_ede))");
 		break;
 	case 183:
-		ret += tcrypt_test("authenc(hmac(sha224),cbc(des))");
+		tcrypt_test(test, "authenc(hmac(sha224),cbc(des))");
 		break;
 	case 184:
-		ret += tcrypt_test("authenc(hmac(sha224),cbc(des3_ede))");
+		tcrypt_test(test, "authenc(hmac(sha224),cbc(des3_ede))");
 		break;
 	case 185:
-		ret += tcrypt_test("authenc(hmac(sha256),cbc(des))");
+		tcrypt_test(test, "authenc(hmac(sha256),cbc(des))");
 		break;
 	case 186:
-		ret += tcrypt_test("authenc(hmac(sha256),cbc(des3_ede))");
+		tcrypt_test(test, "authenc(hmac(sha256),cbc(des3_ede))");
 		break;
 	case 187:
-		ret += tcrypt_test("authenc(hmac(sha384),cbc(des))");
+		tcrypt_test(test, "authenc(hmac(sha384),cbc(des))");
 		break;
 	case 188:
-		ret += tcrypt_test("authenc(hmac(sha384),cbc(des3_ede))");
+		tcrypt_test(test, "authenc(hmac(sha384),cbc(des3_ede))");
 		break;
 	case 189:
-		ret += tcrypt_test("authenc(hmac(sha512),cbc(des))");
+		tcrypt_test(test, "authenc(hmac(sha512),cbc(des))");
 		break;
 	case 190:
-		ret += tcrypt_test("authenc(hmac(sha512),cbc(des3_ede))");
+		tcrypt_test(test, "authenc(hmac(sha512),cbc(des3_ede))");
 		break;
 	case 191:
-		ret += tcrypt_test("ecb(sm4)");
-		ret += tcrypt_test("cbc(sm4)");
-		ret += tcrypt_test("ctr(sm4)");
+		tcrypt_test(test, "ecb(sm4)");
+		tcrypt_test(test, "cbc(sm4)");
+		tcrypt_test(test, "ctr(sm4)");
 		break;
 	case 200:
 		test_cipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0,
@@ -2973,55 +2974,35 @@ static int do_test(const char *alg, u32 type, u32 mask, int m, u32 num_mb)
 		test_available();
 		break;
 	}
-
-	return ret;
 }
 
-static int __init tcrypt_mod_init(void)
+static void tcrypt(struct kunit *test)
 {
-	int err = -ENOMEM;
 	int i;
 
 	for (i = 0; i < TVMEMSIZE; i++) {
-		tvmem[i] = (void *)__get_free_page(GFP_KERNEL);
-		if (!tvmem[i])
-			goto err_free_tv;
-	}
-
-	err = do_test(alg, type, mask, mode, num_mb);
-
-	if (err) {
-		printk(KERN_ERR "tcrypt: one or more tests failed!\n");
-		goto err_free_tv;
-	} else {
-		pr_debug("all tests passed\n");
+		// TODO: is this properly equivalent to __get_free_page?
+		// Or do they really really need these to be individual pages???
+		tvmem[i] = kunit_kmalloc(test, PAGE_SIZE, GFP_KERNEL);
+		KUNIT_ASSERT_NOT_ERR_OR_NULL(test, tvmem[i]);
 	}
 
-	/* We intentionaly return -EAGAIN to prevent keeping the module,
-	 * unless we're running in fips mode. It does all its work from
-	 * init() and doesn't offer any runtime functionality, but in
-	 * the fips case, checking for a successful load is helpful.
-	 * => we don't need it in the memory, do we?
-	 *                                        -- mludvig
-	 */
-	if (!fips_enabled)
-		err = -EAGAIN;
-
-err_free_tv:
-	for (i = 0; i < TVMEMSIZE && tvmem[i]; i++)
-		free_page((unsigned long)tvmem[i]);
-
-	return err;
+	do_test(test, alg, type, mask, mode, num_mb);
+	// TODO: I don't think we need to return -EAGAIN if !fips_enabled, do
+	// we?
 }
 
-/*
- * If an init function is provided, an exit function must also be provided
- * to allow module unload.
- */
-static void __exit tcrypt_mod_fini(void) { }
+static struct kunit_case crypto_test_cases[] = {
+	KUNIT_CASE(tcrypt),
+	{}
+};
+
+static struct kunit_suite crypto_test_suite = {
+	.name = "tcrypt",
+	.test_cases = crypto_test_cases,
+};
 
-late_initcall(tcrypt_mod_init);
-module_exit(tcrypt_mod_fini);
+kunit_test_suites(&crypto_test_suite);
 
 module_param(alg, charp, 0);
 module_param(type, uint, 0);
-- 
2.32.0.402.g57bb445576-goog


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [RFC v1 2/2] crypto: tcrypt: call KUNIT_FAIL() instead of pr_err()
  2021-07-15 21:31 [RFC v1 0/2] crypto: tcrypt: small changes to run under KUnit Daniel Latypov
  2021-07-15 21:31 ` [RFC v1 1/2] crypto: tcrypt: minimal conversion " Daniel Latypov
@ 2021-07-15 21:31 ` Daniel Latypov
  1 sibling, 0 replies; 7+ messages in thread
From: Daniel Latypov @ 2021-07-15 21:31 UTC (permalink / raw)
  To: herbert
  Cc: davem, linux-crypto, brendanhiggins, davidgow, linux-kernel,
	kunit-dev, Daniel Latypov

When running the test module, tests outside of the default set can run
and print errors, but not signal failure via a non-zero exit code from
mod_init().
So it's up to a human to make sure they don't overlook any error logs.

KUnit doesn't use the exit code, but rather structured TAP output, like
kselftest. With this change, errors are still logged, but also mark the
overall KUnit test suite as failed to make the failure more obvious.

Example failure message from the kunit.py view:
[15:45:45] ======== [FAILED] tcrypt ========
[15:45:45] [FAILED] tcrypt
[15:45:45]     # tcrypt: EXPECTATION FAILED at crypto/tcrypt.c:1520
[15:45:45] failed to load transform for ecb(aes): -2

Raw kernel output:
    # Subtest: tcrypt
    1..1
    # tcrypt: EXPECTATION FAILED at crypto/tcrypt.c:1520
failed to load transform for ecb(aes): -2
    ...
    not ok 1 - tcrypt

Signed-off-by: Daniel Latypov <dlatypov@google.com>
---
 crypto/tcrypt.c | 762 ++++++++++++++++++++++++------------------------
 1 file changed, 381 insertions(+), 381 deletions(-)

diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index 319fe71a69b5..ea62d217bd38 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -249,7 +249,7 @@ static int test_mb_aead_cycles(struct test_mb_aead_data *data, int enc,
 	return ret;
 }
 
-static void test_mb_aead_speed(const char *algo, int enc, int secs,
+static void test_mb_aead_speed(struct kunit *test, const char *algo, int enc, int secs,
 			       struct aead_speed_template *template,
 			       unsigned int tcount, u8 authsize,
 			       unsigned int aad_size, u8 *keysize, u32 num_mb)
@@ -266,7 +266,7 @@ static void test_mb_aead_speed(const char *algo, int enc, int secs,
 
 
 	if (aad_size >= PAGE_SIZE) {
-		pr_err("associate data length (%u) too big\n", aad_size);
+		KUNIT_FAIL(test, "associate data length (%u) too big\n", aad_size);
 		return;
 	}
 
@@ -285,7 +285,7 @@ static void test_mb_aead_speed(const char *algo, int enc, int secs,
 
 	tfm = crypto_alloc_aead(algo, 0, 0);
 	if (IS_ERR(tfm)) {
-		pr_err("failed to load transform for %s: %ld\n",
+		KUNIT_FAIL(test, "failed to load transform for %s: %ld\n",
 			algo, PTR_ERR(tfm));
 		goto out_free_data;
 	}
@@ -316,7 +316,7 @@ static void test_mb_aead_speed(const char *algo, int enc, int secs,
 	for (i = 0; i < num_mb; ++i) {
 		data[i].req = aead_request_alloc(tfm, GFP_KERNEL);
 		if (!data[i].req) {
-			pr_err("alg: skcipher: Failed to allocate request for %s\n",
+			KUNIT_FAIL(test, "alg: skcipher: Failed to allocate request for %s\n",
 			       algo);
 			while (i--)
 				aead_request_free(data[i].req);
@@ -341,7 +341,7 @@ static void test_mb_aead_speed(const char *algo, int enc, int secs,
 			int bs = round_up(*b_size, crypto_aead_blocksize(tfm));
 
 			if (bs + authsize > XBUFSIZE * PAGE_SIZE) {
-				pr_err("template (%u) too big for buffer (%lu)\n",
+				KUNIT_FAIL(test, "template (%u) too big for buffer (%lu)\n",
 				       authsize + bs,
 				       XBUFSIZE * PAGE_SIZE);
 				goto out;
@@ -365,7 +365,7 @@ static void test_mb_aead_speed(const char *algo, int enc, int secs,
 
 			ret = crypto_aead_setkey(tfm, key, *keysize);
 			if (ret) {
-				pr_err("setkey() failed flags=%x\n",
+				KUNIT_FAIL(test, "setkey() failed flags=%x\n",
 				       crypto_aead_get_flags(tfm));
 				goto out;
 			}
@@ -402,7 +402,7 @@ static void test_mb_aead_speed(const char *algo, int enc, int secs,
 					ret = do_one_aead_op(cur->req, ret);
 
 					if (ret) {
-						pr_err("calculating auth failed (%d)\n",
+						KUNIT_FAIL(test, "calculating auth failed (%d)\n",
 						       ret);
 						break;
 					}
@@ -425,7 +425,7 @@ static void test_mb_aead_speed(const char *algo, int enc, int secs,
 			}
 
 			if (ret) {
-				pr_err("%s() failed return code=%d\n", e, ret);
+				KUNIT_FAIL(test, "%s() failed return code=%d\n", e, ret);
 				break;
 			}
 			b_size++;
@@ -519,7 +519,7 @@ static int test_aead_cycles(struct aead_request *req, int enc, int blen)
 	return ret;
 }
 
-static void test_aead_speed(const char *algo, int enc, unsigned int secs,
+static void test_aead_speed(struct kunit *test, const char *algo, int enc, unsigned int secs,
 			    struct aead_speed_template *template,
 			    unsigned int tcount, u8 authsize,
 			    unsigned int aad_size, u8 *keysize)
@@ -546,7 +546,7 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs,
 		return;
 
 	if (aad_size >= PAGE_SIZE) {
-		pr_err("associate data length (%u) too big\n", aad_size);
+		KUNIT_FAIL(test, "associate data length (%u) too big\n", aad_size);
 		goto out_noxbuf;
 	}
 
@@ -570,7 +570,7 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs,
 	tfm = crypto_alloc_aead(algo, 0, 0);
 
 	if (IS_ERR(tfm)) {
-		pr_err("alg: aead: Failed to load transform for %s: %ld\n", algo,
+		KUNIT_FAIL(test, "alg: aead: Failed to load transform for %s: %ld\n", algo,
 		       PTR_ERR(tfm));
 		goto out_notfm;
 	}
@@ -581,7 +581,7 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs,
 
 	req = aead_request_alloc(tfm, GFP_KERNEL);
 	if (!req) {
-		pr_err("alg: aead: Failed to allocate request for %s\n",
+		KUNIT_FAIL(test, "alg: aead: Failed to allocate request for %s\n",
 		       algo);
 		goto out_noreq;
 	}
@@ -599,7 +599,7 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs,
 			memset(assoc, 0xff, aad_size);
 
 			if ((*keysize + bs) > TVMEMSIZE * PAGE_SIZE) {
-				pr_err("template (%u) too big for tvmem (%lu)\n",
+				KUNIT_FAIL(test, "template (%u) too big for tvmem (%lu)\n",
 				       *keysize + bs,
 					TVMEMSIZE * PAGE_SIZE);
 				goto out;
@@ -627,7 +627,7 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs,
 			memset(tvmem[0], 0xff, PAGE_SIZE);
 
 			if (ret) {
-				pr_err("setkey() failed flags=%x\n",
+				KUNIT_FAIL(test, "setkey() failed flags=%x\n",
 						crypto_aead_get_flags(tfm));
 				goto out;
 			}
@@ -654,7 +654,7 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs,
 						     crypto_aead_encrypt(req));
 
 				if (ret) {
-					pr_err("calculating auth failed (%d)\n",
+					KUNIT_FAIL(test, "calculating auth failed (%d)\n",
 					       ret);
 					break;
 				}
@@ -673,7 +673,7 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs,
 			}
 
 			if (ret) {
-				pr_err("%s() failed return code=%d\n", e, ret);
+				KUNIT_FAIL(test, "%s() failed return code=%d\n", e, ret);
 				break;
 			}
 			b_size++;
@@ -814,7 +814,7 @@ static int test_mb_ahash_cycles(struct test_mb_ahash_data *data, int blen,
 	return ret;
 }
 
-static void test_mb_ahash_speed(const char *algo, unsigned int secs,
+static void test_mb_ahash_speed(struct kunit *test, const char *algo, unsigned int secs,
 				struct hash_speed *speed, u32 num_mb)
 {
 	struct test_mb_ahash_data *data;
@@ -828,7 +828,7 @@ static void test_mb_ahash_speed(const char *algo, unsigned int secs,
 
 	tfm = crypto_alloc_ahash(algo, 0, 0);
 	if (IS_ERR(tfm)) {
-		pr_err("failed to load transform for %s: %ld\n",
+		KUNIT_FAIL(test, "failed to load transform for %s: %ld\n",
 			algo, PTR_ERR(tfm));
 		goto free_data;
 	}
@@ -841,7 +841,7 @@ static void test_mb_ahash_speed(const char *algo, unsigned int secs,
 
 		data[i].req = ahash_request_alloc(tfm, GFP_KERNEL);
 		if (!data[i].req) {
-			pr_err("alg: hash: Failed to allocate request for %s\n",
+			KUNIT_FAIL(test, "alg: hash: Failed to allocate request for %s\n",
 			       algo);
 			goto out;
 		}
@@ -865,7 +865,7 @@ static void test_mb_ahash_speed(const char *algo, unsigned int secs,
 			continue;
 
 		if (speed[i].blen > XBUFSIZE * PAGE_SIZE) {
-			pr_err("template (%u) too big for tvmem (%lu)\n",
+			KUNIT_FAIL(test, "template (%u) too big for tvmem (%lu)\n",
 			       speed[i].blen, XBUFSIZE * PAGE_SIZE);
 			goto out;
 		}
@@ -892,7 +892,7 @@ static void test_mb_ahash_speed(const char *algo, unsigned int secs,
 
 
 		if (ret) {
-			pr_err("At least one hashing failed ret=%d\n", ret);
+			KUNIT_FAIL(test, "At least one hashing failed ret=%d\n", ret);
 			break;
 		}
 	}
@@ -1057,7 +1057,7 @@ static int test_ahash_cycles(struct ahash_request *req, int blen,
 	return 0;
 }
 
-static void test_ahash_speed_common(const char *algo, unsigned int secs,
+static void test_ahash_speed_common(struct kunit *test, const char *algo, unsigned int secs,
 				    struct hash_speed *speed, unsigned mask)
 {
 	struct scatterlist sg[TVMEMSIZE];
@@ -1069,7 +1069,7 @@ static void test_ahash_speed_common(const char *algo, unsigned int secs,
 
 	tfm = crypto_alloc_ahash(algo, 0, mask);
 	if (IS_ERR(tfm)) {
-		pr_err("failed to load transform for %s: %ld\n",
+		KUNIT_FAIL(test, "failed to load transform for %s: %ld\n",
 		       algo, PTR_ERR(tfm));
 		return;
 	}
@@ -1078,7 +1078,7 @@ static void test_ahash_speed_common(const char *algo, unsigned int secs,
 			get_driver_name(crypto_ahash, tfm));
 
 	if (crypto_ahash_digestsize(tfm) > MAX_DIGEST_SIZE) {
-		pr_err("digestsize(%u) > %d\n", crypto_ahash_digestsize(tfm),
+		KUNIT_FAIL(test, "digestsize(%u) > %d\n", crypto_ahash_digestsize(tfm),
 		       MAX_DIGEST_SIZE);
 		goto out;
 	}
@@ -1086,7 +1086,7 @@ static void test_ahash_speed_common(const char *algo, unsigned int secs,
 	test_hash_sg_init(sg);
 	req = ahash_request_alloc(tfm, GFP_KERNEL);
 	if (!req) {
-		pr_err("ahash request allocation failure\n");
+		KUNIT_FAIL(test, "ahash request allocation failure\n");
 		goto out;
 	}
 
@@ -1100,7 +1100,7 @@ static void test_ahash_speed_common(const char *algo, unsigned int secs,
 
 	for (i = 0; speed[i].blen != 0; i++) {
 		if (speed[i].blen > TVMEMSIZE * PAGE_SIZE) {
-			pr_err("template (%u) too big for tvmem (%lu)\n",
+			KUNIT_FAIL(test, "template (%u) too big for tvmem (%lu)\n",
 			       speed[i].blen, TVMEMSIZE * PAGE_SIZE);
 			break;
 		}
@@ -1124,7 +1124,7 @@ static void test_ahash_speed_common(const char *algo, unsigned int secs,
 		}
 
 		if (ret) {
-			pr_err("hashing failed ret=%d\n", ret);
+			KUNIT_FAIL(test, "hashing failed ret=%d\n", ret);
 			break;
 		}
 	}
@@ -1138,16 +1138,16 @@ static void test_ahash_speed_common(const char *algo, unsigned int secs,
 	crypto_free_ahash(tfm);
 }
 
-static void test_ahash_speed(const char *algo, unsigned int secs,
+static void test_ahash_speed(struct kunit *test, const char *algo, unsigned int secs,
 			     struct hash_speed *speed)
 {
-	return test_ahash_speed_common(algo, secs, speed, 0);
+	return test_ahash_speed_common(test, algo, secs, speed, 0);
 }
 
-static void test_hash_speed(const char *algo, unsigned int secs,
+static void test_hash_speed(struct kunit *test, const char *algo, unsigned int secs,
 			    struct hash_speed *speed)
 {
-	return test_ahash_speed_common(algo, secs, speed, CRYPTO_ALG_ASYNC);
+	return test_ahash_speed_common(test, algo, secs, speed, CRYPTO_ALG_ASYNC);
 }
 
 struct test_mb_skcipher_data {
@@ -1251,7 +1251,7 @@ static int test_mb_acipher_cycles(struct test_mb_skcipher_data *data, int enc,
 	return ret;
 }
 
-static void test_mb_skcipher_speed(const char *algo, int enc, int secs,
+static void test_mb_skcipher_speed(struct kunit *test, const char *algo, int enc, int secs,
 				   struct cipher_speed_template *template,
 				   unsigned int tcount, u8 *keysize, u32 num_mb)
 {
@@ -1275,7 +1275,7 @@ static void test_mb_skcipher_speed(const char *algo, int enc, int secs,
 
 	tfm = crypto_alloc_skcipher(algo, 0, 0);
 	if (IS_ERR(tfm)) {
-		pr_err("failed to load transform for %s: %ld\n",
+		KUNIT_FAIL(test, "failed to load transform for %s: %ld\n",
 			algo, PTR_ERR(tfm));
 		goto out_free_data;
 	}
@@ -1299,7 +1299,7 @@ static void test_mb_skcipher_speed(const char *algo, int enc, int secs,
 	for (i = 0; i < num_mb; ++i) {
 		data[i].req = skcipher_request_alloc(tfm, GFP_KERNEL);
 		if (!data[i].req) {
-			pr_err("alg: skcipher: Failed to allocate request for %s\n",
+			KUNIT_FAIL(test, "alg: skcipher: Failed to allocate request for %s\n",
 			       algo);
 			while (i--)
 				skcipher_request_free(data[i].req);
@@ -1324,7 +1324,7 @@ static void test_mb_skcipher_speed(const char *algo, int enc, int secs,
 			u32 bs = round_up(*b_size, crypto_skcipher_blocksize(tfm));
 
 			if (bs > XBUFSIZE * PAGE_SIZE) {
-				pr_err("template (%u) too big for buffer (%lu)\n",
+				KUNIT_FAIL(test, "template (%u) too big for buffer (%lu)\n",
 				       *b_size, XBUFSIZE * PAGE_SIZE);
 				goto out;
 			}
@@ -1347,7 +1347,7 @@ static void test_mb_skcipher_speed(const char *algo, int enc, int secs,
 
 			ret = crypto_skcipher_setkey(tfm, key, *keysize);
 			if (ret) {
-				pr_err("setkey() failed flags=%x\n",
+				KUNIT_FAIL(test, "setkey() failed flags=%x\n",
 				       crypto_skcipher_get_flags(tfm));
 				goto out;
 			}
@@ -1393,7 +1393,7 @@ static void test_mb_skcipher_speed(const char *algo, int enc, int secs,
 			}
 
 			if (ret) {
-				pr_err("%s() failed flags=%x\n", e,
+				KUNIT_FAIL(test, "%s() failed flags=%x\n", e,
 				       crypto_skcipher_get_flags(tfm));
 				break;
 			}
@@ -1494,7 +1494,7 @@ static int test_acipher_cycles(struct skcipher_request *req, int enc,
 	return ret;
 }
 
-static void test_skcipher_speed(const char *algo, int enc, unsigned int secs,
+static void test_skcipher_speed(struct kunit *test, const char *algo, int enc, unsigned int secs,
 				struct cipher_speed_template *template,
 				unsigned int tcount, u8 *keysize, bool async)
 {
@@ -1517,7 +1517,7 @@ static void test_skcipher_speed(const char *algo, int enc, unsigned int secs,
 	tfm = crypto_alloc_skcipher(algo, 0, async ? 0 : CRYPTO_ALG_ASYNC);
 
 	if (IS_ERR(tfm)) {
-		pr_err("failed to load transform for %s: %ld\n", algo,
+		KUNIT_FAIL(test, "failed to load transform for %s: %ld\n", algo,
 		       PTR_ERR(tfm));
 		return;
 	}
@@ -1527,7 +1527,7 @@ static void test_skcipher_speed(const char *algo, int enc, unsigned int secs,
 
 	req = skcipher_request_alloc(tfm, GFP_KERNEL);
 	if (!req) {
-		pr_err("tcrypt: skcipher: Failed to allocate request for %s\n",
+		KUNIT_FAIL(test, "tcrypt: skcipher: Failed to allocate request for %s\n",
 		       algo);
 		goto out;
 	}
@@ -1544,7 +1544,7 @@ static void test_skcipher_speed(const char *algo, int enc, unsigned int secs,
 			struct scatterlist sg[TVMEMSIZE];
 
 			if ((*keysize + bs) > TVMEMSIZE * PAGE_SIZE) {
-				pr_err("template (%u) too big for "
+				KUNIT_FAIL(test, "template (%u) too big for "
 				       "tvmem (%lu)\n", *keysize + bs,
 				       TVMEMSIZE * PAGE_SIZE);
 				goto out_free_req;
@@ -1568,7 +1568,7 @@ static void test_skcipher_speed(const char *algo, int enc, unsigned int secs,
 
 			ret = crypto_skcipher_setkey(tfm, key, *keysize);
 			if (ret) {
-				pr_err("setkey() failed flags=%x\n",
+				KUNIT_FAIL(test, "setkey() failed flags=%x\n",
 					crypto_skcipher_get_flags(tfm));
 				goto out_free_req;
 			}
@@ -1609,7 +1609,7 @@ static void test_skcipher_speed(const char *algo, int enc, unsigned int secs,
 			}
 
 			if (ret) {
-				pr_err("%s() failed flags=%x\n", e,
+				KUNIT_FAIL(test, "%s() failed flags=%x\n", e,
 				       crypto_skcipher_get_flags(tfm));
 				break;
 			}
@@ -1625,19 +1625,19 @@ static void test_skcipher_speed(const char *algo, int enc, unsigned int secs,
 	crypto_free_skcipher(tfm);
 }
 
-static void test_acipher_speed(const char *algo, int enc, unsigned int secs,
+static void test_acipher_speed(struct kunit *test, const char *algo, int enc, unsigned int secs,
 			       struct cipher_speed_template *template,
 			       unsigned int tcount, u8 *keysize)
 {
-	return test_skcipher_speed(algo, enc, secs, template, tcount, keysize,
+	return test_skcipher_speed(test, algo, enc, secs, template, tcount, keysize,
 				   true);
 }
 
-static void test_cipher_speed(const char *algo, int enc, unsigned int secs,
+static void test_cipher_speed(struct kunit *test, const char *algo, int enc, unsigned int secs,
 			      struct cipher_speed_template *template,
 			      unsigned int tcount, u8 *keysize)
 {
-	return test_skcipher_speed(algo, enc, secs, template, tcount, keysize,
+	return test_skcipher_speed(test, algo, enc, secs, template, tcount, keysize,
 				   false);
 }
 
@@ -1657,7 +1657,7 @@ static inline void tcrypt_test(struct kunit *test, const char *alg)
 {
 	int ret;
 
-	pr_debug("testing %s\n", alg);
+	kunit_info(test, "testing %s\n", alg);
 
 	ret = alg_test(alg, alg, 0, 0);
 	/* non-fips algs return -EINVAL in fips mode */
@@ -2035,400 +2035,400 @@ static void do_test(struct kunit *test, const char *alg, u32 type, u32 mask,
 		tcrypt_test(test, "ctr(sm4)");
 		break;
 	case 200:
-		test_cipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "ecb(aes)", ENCRYPT, sec, NULL, 0,
 				speed_template_16_24_32);
-		test_cipher_speed("ecb(aes)", DECRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "ecb(aes)", DECRYPT, sec, NULL, 0,
 				speed_template_16_24_32);
-		test_cipher_speed("cbc(aes)", ENCRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "cbc(aes)", ENCRYPT, sec, NULL, 0,
 				speed_template_16_24_32);
-		test_cipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "cbc(aes)", DECRYPT, sec, NULL, 0,
 				speed_template_16_24_32);
-		test_cipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "lrw(aes)", ENCRYPT, sec, NULL, 0,
 				speed_template_32_40_48);
-		test_cipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "lrw(aes)", DECRYPT, sec, NULL, 0,
 				speed_template_32_40_48);
-		test_cipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "xts(aes)", ENCRYPT, sec, NULL, 0,
 				speed_template_32_64);
-		test_cipher_speed("xts(aes)", DECRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "xts(aes)", DECRYPT, sec, NULL, 0,
 				speed_template_32_64);
-		test_cipher_speed("cts(cbc(aes))", ENCRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "cts(cbc(aes))", ENCRYPT, sec, NULL, 0,
 				speed_template_16_24_32);
-		test_cipher_speed("cts(cbc(aes))", DECRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "cts(cbc(aes))", DECRYPT, sec, NULL, 0,
 				speed_template_16_24_32);
-		test_cipher_speed("ctr(aes)", ENCRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "ctr(aes)", ENCRYPT, sec, NULL, 0,
 				speed_template_16_24_32);
-		test_cipher_speed("ctr(aes)", DECRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "ctr(aes)", DECRYPT, sec, NULL, 0,
 				speed_template_16_24_32);
-		test_cipher_speed("cfb(aes)", ENCRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "cfb(aes)", ENCRYPT, sec, NULL, 0,
 				speed_template_16_24_32);
-		test_cipher_speed("cfb(aes)", DECRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "cfb(aes)", DECRYPT, sec, NULL, 0,
 				speed_template_16_24_32);
 		break;
 
 	case 201:
-		test_cipher_speed("ecb(des3_ede)", ENCRYPT, sec,
+		test_cipher_speed(test, "ecb(des3_ede)", ENCRYPT, sec,
 				des3_speed_template, DES3_SPEED_VECTORS,
 				speed_template_24);
-		test_cipher_speed("ecb(des3_ede)", DECRYPT, sec,
+		test_cipher_speed(test, "ecb(des3_ede)", DECRYPT, sec,
 				des3_speed_template, DES3_SPEED_VECTORS,
 				speed_template_24);
-		test_cipher_speed("cbc(des3_ede)", ENCRYPT, sec,
+		test_cipher_speed(test, "cbc(des3_ede)", ENCRYPT, sec,
 				des3_speed_template, DES3_SPEED_VECTORS,
 				speed_template_24);
-		test_cipher_speed("cbc(des3_ede)", DECRYPT, sec,
+		test_cipher_speed(test, "cbc(des3_ede)", DECRYPT, sec,
 				des3_speed_template, DES3_SPEED_VECTORS,
 				speed_template_24);
-		test_cipher_speed("ctr(des3_ede)", ENCRYPT, sec,
+		test_cipher_speed(test, "ctr(des3_ede)", ENCRYPT, sec,
 				des3_speed_template, DES3_SPEED_VECTORS,
 				speed_template_24);
-		test_cipher_speed("ctr(des3_ede)", DECRYPT, sec,
+		test_cipher_speed(test, "ctr(des3_ede)", DECRYPT, sec,
 				des3_speed_template, DES3_SPEED_VECTORS,
 				speed_template_24);
 		break;
 
 	case 202:
-		test_cipher_speed("ecb(twofish)", ENCRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "ecb(twofish)", ENCRYPT, sec, NULL, 0,
 				speed_template_16_24_32);
-		test_cipher_speed("ecb(twofish)", DECRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "ecb(twofish)", DECRYPT, sec, NULL, 0,
 				speed_template_16_24_32);
-		test_cipher_speed("cbc(twofish)", ENCRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "cbc(twofish)", ENCRYPT, sec, NULL, 0,
 				speed_template_16_24_32);
-		test_cipher_speed("cbc(twofish)", DECRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "cbc(twofish)", DECRYPT, sec, NULL, 0,
 				speed_template_16_24_32);
-		test_cipher_speed("ctr(twofish)", ENCRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "ctr(twofish)", ENCRYPT, sec, NULL, 0,
 				speed_template_16_24_32);
-		test_cipher_speed("ctr(twofish)", DECRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "ctr(twofish)", DECRYPT, sec, NULL, 0,
 				speed_template_16_24_32);
-		test_cipher_speed("lrw(twofish)", ENCRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "lrw(twofish)", ENCRYPT, sec, NULL, 0,
 				speed_template_32_40_48);
-		test_cipher_speed("lrw(twofish)", DECRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "lrw(twofish)", DECRYPT, sec, NULL, 0,
 				speed_template_32_40_48);
-		test_cipher_speed("xts(twofish)", ENCRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "xts(twofish)", ENCRYPT, sec, NULL, 0,
 				speed_template_32_48_64);
-		test_cipher_speed("xts(twofish)", DECRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "xts(twofish)", DECRYPT, sec, NULL, 0,
 				speed_template_32_48_64);
 		break;
 
 	case 203:
-		test_cipher_speed("ecb(blowfish)", ENCRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "ecb(blowfish)", ENCRYPT, sec, NULL, 0,
 				  speed_template_8_32);
-		test_cipher_speed("ecb(blowfish)", DECRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "ecb(blowfish)", DECRYPT, sec, NULL, 0,
 				  speed_template_8_32);
-		test_cipher_speed("cbc(blowfish)", ENCRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "cbc(blowfish)", ENCRYPT, sec, NULL, 0,
 				  speed_template_8_32);
-		test_cipher_speed("cbc(blowfish)", DECRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "cbc(blowfish)", DECRYPT, sec, NULL, 0,
 				  speed_template_8_32);
-		test_cipher_speed("ctr(blowfish)", ENCRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "ctr(blowfish)", ENCRYPT, sec, NULL, 0,
 				  speed_template_8_32);
-		test_cipher_speed("ctr(blowfish)", DECRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "ctr(blowfish)", DECRYPT, sec, NULL, 0,
 				  speed_template_8_32);
 		break;
 
 	case 204:
-		test_cipher_speed("ecb(des)", ENCRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "ecb(des)", ENCRYPT, sec, NULL, 0,
 				  speed_template_8);
-		test_cipher_speed("ecb(des)", DECRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "ecb(des)", DECRYPT, sec, NULL, 0,
 				  speed_template_8);
-		test_cipher_speed("cbc(des)", ENCRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "cbc(des)", ENCRYPT, sec, NULL, 0,
 				  speed_template_8);
-		test_cipher_speed("cbc(des)", DECRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "cbc(des)", DECRYPT, sec, NULL, 0,
 				  speed_template_8);
 		break;
 
 	case 205:
-		test_cipher_speed("ecb(camellia)", ENCRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "ecb(camellia)", ENCRYPT, sec, NULL, 0,
 				speed_template_16_24_32);
-		test_cipher_speed("ecb(camellia)", DECRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "ecb(camellia)", DECRYPT, sec, NULL, 0,
 				speed_template_16_24_32);
-		test_cipher_speed("cbc(camellia)", ENCRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "cbc(camellia)", ENCRYPT, sec, NULL, 0,
 				speed_template_16_24_32);
-		test_cipher_speed("cbc(camellia)", DECRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "cbc(camellia)", DECRYPT, sec, NULL, 0,
 				speed_template_16_24_32);
-		test_cipher_speed("ctr(camellia)", ENCRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "ctr(camellia)", ENCRYPT, sec, NULL, 0,
 				speed_template_16_24_32);
-		test_cipher_speed("ctr(camellia)", DECRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "ctr(camellia)", DECRYPT, sec, NULL, 0,
 				speed_template_16_24_32);
-		test_cipher_speed("lrw(camellia)", ENCRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "lrw(camellia)", ENCRYPT, sec, NULL, 0,
 				speed_template_32_40_48);
-		test_cipher_speed("lrw(camellia)", DECRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "lrw(camellia)", DECRYPT, sec, NULL, 0,
 				speed_template_32_40_48);
-		test_cipher_speed("xts(camellia)", ENCRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "xts(camellia)", ENCRYPT, sec, NULL, 0,
 				speed_template_32_48_64);
-		test_cipher_speed("xts(camellia)", DECRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "xts(camellia)", DECRYPT, sec, NULL, 0,
 				speed_template_32_48_64);
 		break;
 
 	case 207:
-		test_cipher_speed("ecb(serpent)", ENCRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "ecb(serpent)", ENCRYPT, sec, NULL, 0,
 				  speed_template_16_32);
-		test_cipher_speed("ecb(serpent)", DECRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "ecb(serpent)", DECRYPT, sec, NULL, 0,
 				  speed_template_16_32);
-		test_cipher_speed("cbc(serpent)", ENCRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "cbc(serpent)", ENCRYPT, sec, NULL, 0,
 				  speed_template_16_32);
-		test_cipher_speed("cbc(serpent)", DECRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "cbc(serpent)", DECRYPT, sec, NULL, 0,
 				  speed_template_16_32);
-		test_cipher_speed("ctr(serpent)", ENCRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "ctr(serpent)", ENCRYPT, sec, NULL, 0,
 				  speed_template_16_32);
-		test_cipher_speed("ctr(serpent)", DECRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "ctr(serpent)", DECRYPT, sec, NULL, 0,
 				  speed_template_16_32);
-		test_cipher_speed("lrw(serpent)", ENCRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "lrw(serpent)", ENCRYPT, sec, NULL, 0,
 				  speed_template_32_48);
-		test_cipher_speed("lrw(serpent)", DECRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "lrw(serpent)", DECRYPT, sec, NULL, 0,
 				  speed_template_32_48);
-		test_cipher_speed("xts(serpent)", ENCRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "xts(serpent)", ENCRYPT, sec, NULL, 0,
 				  speed_template_32_64);
-		test_cipher_speed("xts(serpent)", DECRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "xts(serpent)", DECRYPT, sec, NULL, 0,
 				  speed_template_32_64);
 		break;
 
 	case 208:
-		test_cipher_speed("ecb(arc4)", ENCRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "ecb(arc4)", ENCRYPT, sec, NULL, 0,
 				  speed_template_8);
 		break;
 
 	case 209:
-		test_cipher_speed("ecb(cast5)", ENCRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "ecb(cast5)", ENCRYPT, sec, NULL, 0,
 				  speed_template_8_16);
-		test_cipher_speed("ecb(cast5)", DECRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "ecb(cast5)", DECRYPT, sec, NULL, 0,
 				  speed_template_8_16);
-		test_cipher_speed("cbc(cast5)", ENCRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "cbc(cast5)", ENCRYPT, sec, NULL, 0,
 				  speed_template_8_16);
-		test_cipher_speed("cbc(cast5)", DECRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "cbc(cast5)", DECRYPT, sec, NULL, 0,
 				  speed_template_8_16);
-		test_cipher_speed("ctr(cast5)", ENCRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "ctr(cast5)", ENCRYPT, sec, NULL, 0,
 				  speed_template_8_16);
-		test_cipher_speed("ctr(cast5)", DECRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "ctr(cast5)", DECRYPT, sec, NULL, 0,
 				  speed_template_8_16);
 		break;
 
 	case 210:
-		test_cipher_speed("ecb(cast6)", ENCRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "ecb(cast6)", ENCRYPT, sec, NULL, 0,
 				  speed_template_16_32);
-		test_cipher_speed("ecb(cast6)", DECRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "ecb(cast6)", DECRYPT, sec, NULL, 0,
 				  speed_template_16_32);
-		test_cipher_speed("cbc(cast6)", ENCRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "cbc(cast6)", ENCRYPT, sec, NULL, 0,
 				  speed_template_16_32);
-		test_cipher_speed("cbc(cast6)", DECRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "cbc(cast6)", DECRYPT, sec, NULL, 0,
 				  speed_template_16_32);
-		test_cipher_speed("ctr(cast6)", ENCRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "ctr(cast6)", ENCRYPT, sec, NULL, 0,
 				  speed_template_16_32);
-		test_cipher_speed("ctr(cast6)", DECRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "ctr(cast6)", DECRYPT, sec, NULL, 0,
 				  speed_template_16_32);
-		test_cipher_speed("lrw(cast6)", ENCRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "lrw(cast6)", ENCRYPT, sec, NULL, 0,
 				  speed_template_32_48);
-		test_cipher_speed("lrw(cast6)", DECRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "lrw(cast6)", DECRYPT, sec, NULL, 0,
 				  speed_template_32_48);
-		test_cipher_speed("xts(cast6)", ENCRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "xts(cast6)", ENCRYPT, sec, NULL, 0,
 				  speed_template_32_64);
-		test_cipher_speed("xts(cast6)", DECRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "xts(cast6)", DECRYPT, sec, NULL, 0,
 				  speed_template_32_64);
 		break;
 
 	case 211:
-		test_aead_speed("rfc4106(gcm(aes))", ENCRYPT, sec,
+		test_aead_speed(test, "rfc4106(gcm(aes))", ENCRYPT, sec,
 				NULL, 0, 16, 16, aead_speed_template_20);
-		test_aead_speed("gcm(aes)", ENCRYPT, sec,
+		test_aead_speed(test, "gcm(aes)", ENCRYPT, sec,
 				NULL, 0, 16, 8, speed_template_16_24_32);
-		test_aead_speed("rfc4106(gcm(aes))", DECRYPT, sec,
+		test_aead_speed(test, "rfc4106(gcm(aes))", DECRYPT, sec,
 				NULL, 0, 16, 16, aead_speed_template_20);
-		test_aead_speed("gcm(aes)", DECRYPT, sec,
+		test_aead_speed(test, "gcm(aes)", DECRYPT, sec,
 				NULL, 0, 16, 8, speed_template_16_24_32);
 		break;
 
 	case 212:
-		test_aead_speed("rfc4309(ccm(aes))", ENCRYPT, sec,
+		test_aead_speed(test, "rfc4309(ccm(aes))", ENCRYPT, sec,
 				NULL, 0, 16, 16, aead_speed_template_19);
-		test_aead_speed("rfc4309(ccm(aes))", DECRYPT, sec,
+		test_aead_speed(test, "rfc4309(ccm(aes))", DECRYPT, sec,
 				NULL, 0, 16, 16, aead_speed_template_19);
 		break;
 
 	case 213:
-		test_aead_speed("rfc7539esp(chacha20,poly1305)", ENCRYPT, sec,
+		test_aead_speed(test, "rfc7539esp(chacha20,poly1305)", ENCRYPT, sec,
 				NULL, 0, 16, 8, aead_speed_template_36);
-		test_aead_speed("rfc7539esp(chacha20,poly1305)", DECRYPT, sec,
+		test_aead_speed(test, "rfc7539esp(chacha20,poly1305)", DECRYPT, sec,
 				NULL, 0, 16, 8, aead_speed_template_36);
 		break;
 
 	case 214:
-		test_cipher_speed("chacha20", ENCRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "chacha20", ENCRYPT, sec, NULL, 0,
 				  speed_template_32);
 		break;
 
 	case 215:
-		test_mb_aead_speed("rfc4106(gcm(aes))", ENCRYPT, sec, NULL,
+		test_mb_aead_speed(test, "rfc4106(gcm(aes))", ENCRYPT, sec, NULL,
 				   0, 16, 16, aead_speed_template_20, num_mb);
-		test_mb_aead_speed("gcm(aes)", ENCRYPT, sec, NULL, 0, 16, 8,
+		test_mb_aead_speed(test, "gcm(aes)", ENCRYPT, sec, NULL, 0, 16, 8,
 				   speed_template_16_24_32, num_mb);
-		test_mb_aead_speed("rfc4106(gcm(aes))", DECRYPT, sec, NULL,
+		test_mb_aead_speed(test, "rfc4106(gcm(aes))", DECRYPT, sec, NULL,
 				   0, 16, 16, aead_speed_template_20, num_mb);
-		test_mb_aead_speed("gcm(aes)", DECRYPT, sec, NULL, 0, 16, 8,
+		test_mb_aead_speed(test, "gcm(aes)", DECRYPT, sec, NULL, 0, 16, 8,
 				   speed_template_16_24_32, num_mb);
 		break;
 
 	case 216:
-		test_mb_aead_speed("rfc4309(ccm(aes))", ENCRYPT, sec, NULL, 0,
+		test_mb_aead_speed(test, "rfc4309(ccm(aes))", ENCRYPT, sec, NULL, 0,
 				   16, 16, aead_speed_template_19, num_mb);
-		test_mb_aead_speed("rfc4309(ccm(aes))", DECRYPT, sec, NULL, 0,
+		test_mb_aead_speed(test, "rfc4309(ccm(aes))", DECRYPT, sec, NULL, 0,
 				   16, 16, aead_speed_template_19, num_mb);
 		break;
 
 	case 217:
-		test_mb_aead_speed("rfc7539esp(chacha20,poly1305)", ENCRYPT,
+		test_mb_aead_speed(test, "rfc7539esp(chacha20,poly1305)", ENCRYPT,
 				   sec, NULL, 0, 16, 8, aead_speed_template_36,
 				   num_mb);
-		test_mb_aead_speed("rfc7539esp(chacha20,poly1305)", DECRYPT,
+		test_mb_aead_speed(test, "rfc7539esp(chacha20,poly1305)", DECRYPT,
 				   sec, NULL, 0, 16, 8, aead_speed_template_36,
 				   num_mb);
 		break;
 
 	case 218:
-		test_cipher_speed("ecb(sm4)", ENCRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "ecb(sm4)", ENCRYPT, sec, NULL, 0,
 				speed_template_16);
-		test_cipher_speed("ecb(sm4)", DECRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "ecb(sm4)", DECRYPT, sec, NULL, 0,
 				speed_template_16);
-		test_cipher_speed("cbc(sm4)", ENCRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "cbc(sm4)", ENCRYPT, sec, NULL, 0,
 				speed_template_16);
-		test_cipher_speed("cbc(sm4)", DECRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "cbc(sm4)", DECRYPT, sec, NULL, 0,
 				speed_template_16);
-		test_cipher_speed("ctr(sm4)", ENCRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "ctr(sm4)", ENCRYPT, sec, NULL, 0,
 				speed_template_16);
-		test_cipher_speed("ctr(sm4)", DECRYPT, sec, NULL, 0,
+		test_cipher_speed(test, "ctr(sm4)", DECRYPT, sec, NULL, 0,
 				speed_template_16);
 		break;
 
 	case 219:
-		test_cipher_speed("adiantum(xchacha12,aes)", ENCRYPT, sec, NULL,
+		test_cipher_speed(test, "adiantum(xchacha12,aes)", ENCRYPT, sec, NULL,
 				  0, speed_template_32);
-		test_cipher_speed("adiantum(xchacha12,aes)", DECRYPT, sec, NULL,
+		test_cipher_speed(test, "adiantum(xchacha12,aes)", DECRYPT, sec, NULL,
 				  0, speed_template_32);
-		test_cipher_speed("adiantum(xchacha20,aes)", ENCRYPT, sec, NULL,
+		test_cipher_speed(test, "adiantum(xchacha20,aes)", ENCRYPT, sec, NULL,
 				  0, speed_template_32);
-		test_cipher_speed("adiantum(xchacha20,aes)", DECRYPT, sec, NULL,
+		test_cipher_speed(test, "adiantum(xchacha20,aes)", DECRYPT, sec, NULL,
 				  0, speed_template_32);
 		break;
 
 	case 220:
-		test_acipher_speed("essiv(cbc(aes),sha256)",
+		test_acipher_speed(test, "essiv(cbc(aes),sha256)",
 				  ENCRYPT, sec, NULL, 0,
 				  speed_template_16_24_32);
-		test_acipher_speed("essiv(cbc(aes),sha256)",
+		test_acipher_speed(test, "essiv(cbc(aes),sha256)",
 				  DECRYPT, sec, NULL, 0,
 				  speed_template_16_24_32);
 		break;
 
 	case 221:
-		test_aead_speed("aegis128", ENCRYPT, sec,
+		test_aead_speed(test, "aegis128", ENCRYPT, sec,
 				NULL, 0, 16, 8, speed_template_16);
-		test_aead_speed("aegis128", DECRYPT, sec,
+		test_aead_speed(test, "aegis128", DECRYPT, sec,
 				NULL, 0, 16, 8, speed_template_16);
 		break;
 
 	case 300:
 		if (alg) {
-			test_hash_speed(alg, sec, generic_hash_speed_template);
+			test_hash_speed(test, alg, sec, generic_hash_speed_template);
 			break;
 		}
 		fallthrough;
 	case 301:
-		test_hash_speed("md4", sec, generic_hash_speed_template);
+		test_hash_speed(test, "md4", sec, generic_hash_speed_template);
 		if (mode > 300 && mode < 400) break;
 		fallthrough;
 	case 302:
-		test_hash_speed("md5", sec, generic_hash_speed_template);
+		test_hash_speed(test, "md5", sec, generic_hash_speed_template);
 		if (mode > 300 && mode < 400) break;
 		fallthrough;
 	case 303:
-		test_hash_speed("sha1", sec, generic_hash_speed_template);
+		test_hash_speed(test, "sha1", sec, generic_hash_speed_template);
 		if (mode > 300 && mode < 400) break;
 		fallthrough;
 	case 304:
-		test_hash_speed("sha256", sec, generic_hash_speed_template);
+		test_hash_speed(test, "sha256", sec, generic_hash_speed_template);
 		if (mode > 300 && mode < 400) break;
 		fallthrough;
 	case 305:
-		test_hash_speed("sha384", sec, generic_hash_speed_template);
+		test_hash_speed(test, "sha384", sec, generic_hash_speed_template);
 		if (mode > 300 && mode < 400) break;
 		fallthrough;
 	case 306:
-		test_hash_speed("sha512", sec, generic_hash_speed_template);
+		test_hash_speed(test, "sha512", sec, generic_hash_speed_template);
 		if (mode > 300 && mode < 400) break;
 		fallthrough;
 	case 307:
-		test_hash_speed("wp256", sec, generic_hash_speed_template);
+		test_hash_speed(test, "wp256", sec, generic_hash_speed_template);
 		if (mode > 300 && mode < 400) break;
 		fallthrough;
 	case 308:
-		test_hash_speed("wp384", sec, generic_hash_speed_template);
+		test_hash_speed(test, "wp384", sec, generic_hash_speed_template);
 		if (mode > 300 && mode < 400) break;
 		fallthrough;
 	case 309:
-		test_hash_speed("wp512", sec, generic_hash_speed_template);
+		test_hash_speed(test, "wp512", sec, generic_hash_speed_template);
 		if (mode > 300 && mode < 400) break;
 		fallthrough;
 	case 313:
-		test_hash_speed("sha224", sec, generic_hash_speed_template);
+		test_hash_speed(test, "sha224", sec, generic_hash_speed_template);
 		if (mode > 300 && mode < 400) break;
 		fallthrough;
 	case 314:
-		test_hash_speed("xxhash64", sec, generic_hash_speed_template);
+		test_hash_speed(test, "xxhash64", sec, generic_hash_speed_template);
 		if (mode > 300 && mode < 400) break;
 		fallthrough;
 	case 315:
-		test_hash_speed("rmd160", sec, generic_hash_speed_template);
+		test_hash_speed(test, "rmd160", sec, generic_hash_speed_template);
 		if (mode > 300 && mode < 400) break;
 		fallthrough;
 	case 316:
-		test_hash_speed("blake2s-256", sec, generic_hash_speed_template);
+		test_hash_speed(test, "blake2s-256", sec, generic_hash_speed_template);
 		if (mode > 300 && mode < 400) break;
 		fallthrough;
 	case 317:
-		test_hash_speed("blake2b-512", sec, generic_hash_speed_template);
+		test_hash_speed(test, "blake2b-512", sec, generic_hash_speed_template);
 		if (mode > 300 && mode < 400) break;
 		fallthrough;
 	case 318:
 		klen = 16;
-		test_hash_speed("ghash", sec, generic_hash_speed_template);
+		test_hash_speed(test, "ghash", sec, generic_hash_speed_template);
 		if (mode > 300 && mode < 400) break;
 		fallthrough;
 	case 319:
-		test_hash_speed("crc32c", sec, generic_hash_speed_template);
+		test_hash_speed(test, "crc32c", sec, generic_hash_speed_template);
 		if (mode > 300 && mode < 400) break;
 		fallthrough;
 	case 320:
-		test_hash_speed("crct10dif", sec, generic_hash_speed_template);
+		test_hash_speed(test, "crct10dif", sec, generic_hash_speed_template);
 		if (mode > 300 && mode < 400) break;
 		fallthrough;
 	case 321:
-		test_hash_speed("poly1305", sec, poly1305_speed_template);
+		test_hash_speed(test, "poly1305", sec, poly1305_speed_template);
 		if (mode > 300 && mode < 400) break;
 		fallthrough;
 	case 322:
-		test_hash_speed("sha3-224", sec, generic_hash_speed_template);
+		test_hash_speed(test, "sha3-224", sec, generic_hash_speed_template);
 		if (mode > 300 && mode < 400) break;
 		fallthrough;
 	case 323:
-		test_hash_speed("sha3-256", sec, generic_hash_speed_template);
+		test_hash_speed(test, "sha3-256", sec, generic_hash_speed_template);
 		if (mode > 300 && mode < 400) break;
 		fallthrough;
 	case 324:
-		test_hash_speed("sha3-384", sec, generic_hash_speed_template);
+		test_hash_speed(test, "sha3-384", sec, generic_hash_speed_template);
 		if (mode > 300 && mode < 400) break;
 		fallthrough;
 	case 325:
-		test_hash_speed("sha3-512", sec, generic_hash_speed_template);
+		test_hash_speed(test, "sha3-512", sec, generic_hash_speed_template);
 		if (mode > 300 && mode < 400) break;
 		fallthrough;
 	case 326:
-		test_hash_speed("sm3", sec, generic_hash_speed_template);
+		test_hash_speed(test, "sm3", sec, generic_hash_speed_template);
 		if (mode > 300 && mode < 400) break;
 		fallthrough;
 	case 327:
-		test_hash_speed("streebog256", sec,
+		test_hash_speed(test, "streebog256", sec,
 				generic_hash_speed_template);
 		if (mode > 300 && mode < 400) break;
 		fallthrough;
 	case 328:
-		test_hash_speed("streebog512", sec,
+		test_hash_speed(test, "streebog512", sec,
 				generic_hash_speed_template);
 		if (mode > 300 && mode < 400) break;
 		fallthrough;
@@ -2437,109 +2437,109 @@ static void do_test(struct kunit *test, const char *alg, u32 type, u32 mask,
 
 	case 400:
 		if (alg) {
-			test_ahash_speed(alg, sec, generic_hash_speed_template);
+			test_ahash_speed(test, alg, sec, generic_hash_speed_template);
 			break;
 		}
 		fallthrough;
 	case 401:
-		test_ahash_speed("md4", sec, generic_hash_speed_template);
+		test_ahash_speed(test, "md4", sec, generic_hash_speed_template);
 		if (mode > 400 && mode < 500) break;
 		fallthrough;
 	case 402:
-		test_ahash_speed("md5", sec, generic_hash_speed_template);
+		test_ahash_speed(test, "md5", sec, generic_hash_speed_template);
 		if (mode > 400 && mode < 500) break;
 		fallthrough;
 	case 403:
-		test_ahash_speed("sha1", sec, generic_hash_speed_template);
+		test_ahash_speed(test, "sha1", sec, generic_hash_speed_template);
 		if (mode > 400 && mode < 500) break;
 		fallthrough;
 	case 404:
-		test_ahash_speed("sha256", sec, generic_hash_speed_template);
+		test_ahash_speed(test, "sha256", sec, generic_hash_speed_template);
 		if (mode > 400 && mode < 500) break;
 		fallthrough;
 	case 405:
-		test_ahash_speed("sha384", sec, generic_hash_speed_template);
+		test_ahash_speed(test, "sha384", sec, generic_hash_speed_template);
 		if (mode > 400 && mode < 500) break;
 		fallthrough;
 	case 406:
-		test_ahash_speed("sha512", sec, generic_hash_speed_template);
+		test_ahash_speed(test, "sha512", sec, generic_hash_speed_template);
 		if (mode > 400 && mode < 500) break;
 		fallthrough;
 	case 407:
-		test_ahash_speed("wp256", sec, generic_hash_speed_template);
+		test_ahash_speed(test, "wp256", sec, generic_hash_speed_template);
 		if (mode > 400 && mode < 500) break;
 		fallthrough;
 	case 408:
-		test_ahash_speed("wp384", sec, generic_hash_speed_template);
+		test_ahash_speed(test, "wp384", sec, generic_hash_speed_template);
 		if (mode > 400 && mode < 500) break;
 		fallthrough;
 	case 409:
-		test_ahash_speed("wp512", sec, generic_hash_speed_template);
+		test_ahash_speed(test, "wp512", sec, generic_hash_speed_template);
 		if (mode > 400 && mode < 500) break;
 		fallthrough;
 	case 413:
-		test_ahash_speed("sha224", sec, generic_hash_speed_template);
+		test_ahash_speed(test, "sha224", sec, generic_hash_speed_template);
 		if (mode > 400 && mode < 500) break;
 		fallthrough;
 	case 414:
-		test_ahash_speed("xxhash64", sec, generic_hash_speed_template);
+		test_ahash_speed(test, "xxhash64", sec, generic_hash_speed_template);
 		if (mode > 400 && mode < 500) break;
 		fallthrough;
 	case 415:
-		test_ahash_speed("rmd160", sec, generic_hash_speed_template);
+		test_ahash_speed(test, "rmd160", sec, generic_hash_speed_template);
 		if (mode > 400 && mode < 500) break;
 		fallthrough;
 	case 416:
-		test_ahash_speed("blake2s-256", sec, generic_hash_speed_template);
+		test_ahash_speed(test, "blake2s-256", sec, generic_hash_speed_template);
 		if (mode > 400 && mode < 500) break;
 		fallthrough;
 	case 417:
-		test_ahash_speed("blake2b-512", sec, generic_hash_speed_template);
+		test_ahash_speed(test, "blake2b-512", sec, generic_hash_speed_template);
 		if (mode > 400 && mode < 500) break;
 		fallthrough;
 	case 418:
-		test_ahash_speed("sha3-224", sec, generic_hash_speed_template);
+		test_ahash_speed(test, "sha3-224", sec, generic_hash_speed_template);
 		if (mode > 400 && mode < 500) break;
 		fallthrough;
 	case 419:
-		test_ahash_speed("sha3-256", sec, generic_hash_speed_template);
+		test_ahash_speed(test, "sha3-256", sec, generic_hash_speed_template);
 		if (mode > 400 && mode < 500) break;
 		fallthrough;
 	case 420:
-		test_ahash_speed("sha3-384", sec, generic_hash_speed_template);
+		test_ahash_speed(test, "sha3-384", sec, generic_hash_speed_template);
 		if (mode > 400 && mode < 500) break;
 		fallthrough;
 	case 421:
-		test_ahash_speed("sha3-512", sec, generic_hash_speed_template);
+		test_ahash_speed(test, "sha3-512", sec, generic_hash_speed_template);
 		if (mode > 400 && mode < 500) break;
 		fallthrough;
 	case 422:
-		test_mb_ahash_speed("sha1", sec, generic_hash_speed_template,
+		test_mb_ahash_speed(test, "sha1", sec, generic_hash_speed_template,
 				    num_mb);
 		if (mode > 400 && mode < 500) break;
 		fallthrough;
 	case 423:
-		test_mb_ahash_speed("sha256", sec, generic_hash_speed_template,
+		test_mb_ahash_speed(test, "sha256", sec, generic_hash_speed_template,
 				    num_mb);
 		if (mode > 400 && mode < 500) break;
 		fallthrough;
 	case 424:
-		test_mb_ahash_speed("sha512", sec, generic_hash_speed_template,
+		test_mb_ahash_speed(test, "sha512", sec, generic_hash_speed_template,
 				    num_mb);
 		if (mode > 400 && mode < 500) break;
 		fallthrough;
 	case 425:
-		test_mb_ahash_speed("sm3", sec, generic_hash_speed_template,
+		test_mb_ahash_speed(test, "sm3", sec, generic_hash_speed_template,
 				    num_mb);
 		if (mode > 400 && mode < 500) break;
 		fallthrough;
 	case 426:
-		test_mb_ahash_speed("streebog256", sec,
+		test_mb_ahash_speed(test, "streebog256", sec,
 				    generic_hash_speed_template, num_mb);
 		if (mode > 400 && mode < 500) break;
 		fallthrough;
 	case 427:
-		test_mb_ahash_speed("streebog512", sec,
+		test_mb_ahash_speed(test, "streebog512", sec,
 				    generic_hash_speed_template, num_mb);
 		if (mode > 400 && mode < 500) break;
 		fallthrough;
@@ -2547,426 +2547,426 @@ static void do_test(struct kunit *test, const char *alg, u32 type, u32 mask,
 		break;
 
 	case 500:
-		test_acipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "ecb(aes)", ENCRYPT, sec, NULL, 0,
 				   speed_template_16_24_32);
-		test_acipher_speed("ecb(aes)", DECRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "ecb(aes)", DECRYPT, sec, NULL, 0,
 				   speed_template_16_24_32);
-		test_acipher_speed("cbc(aes)", ENCRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "cbc(aes)", ENCRYPT, sec, NULL, 0,
 				   speed_template_16_24_32);
-		test_acipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "cbc(aes)", DECRYPT, sec, NULL, 0,
 				   speed_template_16_24_32);
-		test_acipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "lrw(aes)", ENCRYPT, sec, NULL, 0,
 				   speed_template_32_40_48);
-		test_acipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "lrw(aes)", DECRYPT, sec, NULL, 0,
 				   speed_template_32_40_48);
-		test_acipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "xts(aes)", ENCRYPT, sec, NULL, 0,
 				   speed_template_32_64);
-		test_acipher_speed("xts(aes)", DECRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "xts(aes)", DECRYPT, sec, NULL, 0,
 				   speed_template_32_64);
-		test_acipher_speed("cts(cbc(aes))", ENCRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "cts(cbc(aes))", ENCRYPT, sec, NULL, 0,
 				   speed_template_16_24_32);
-		test_acipher_speed("cts(cbc(aes))", DECRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "cts(cbc(aes))", DECRYPT, sec, NULL, 0,
 				   speed_template_16_24_32);
-		test_acipher_speed("ctr(aes)", ENCRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "ctr(aes)", ENCRYPT, sec, NULL, 0,
 				   speed_template_16_24_32);
-		test_acipher_speed("ctr(aes)", DECRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "ctr(aes)", DECRYPT, sec, NULL, 0,
 				   speed_template_16_24_32);
-		test_acipher_speed("cfb(aes)", ENCRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "cfb(aes)", ENCRYPT, sec, NULL, 0,
 				   speed_template_16_24_32);
-		test_acipher_speed("cfb(aes)", DECRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "cfb(aes)", DECRYPT, sec, NULL, 0,
 				   speed_template_16_24_32);
-		test_acipher_speed("ofb(aes)", ENCRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "ofb(aes)", ENCRYPT, sec, NULL, 0,
 				   speed_template_16_24_32);
-		test_acipher_speed("ofb(aes)", DECRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "ofb(aes)", DECRYPT, sec, NULL, 0,
 				   speed_template_16_24_32);
-		test_acipher_speed("rfc3686(ctr(aes))", ENCRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "rfc3686(ctr(aes))", ENCRYPT, sec, NULL, 0,
 				   speed_template_20_28_36);
-		test_acipher_speed("rfc3686(ctr(aes))", DECRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "rfc3686(ctr(aes))", DECRYPT, sec, NULL, 0,
 				   speed_template_20_28_36);
 		break;
 
 	case 501:
-		test_acipher_speed("ecb(des3_ede)", ENCRYPT, sec,
+		test_acipher_speed(test, "ecb(des3_ede)", ENCRYPT, sec,
 				   des3_speed_template, DES3_SPEED_VECTORS,
 				   speed_template_24);
-		test_acipher_speed("ecb(des3_ede)", DECRYPT, sec,
+		test_acipher_speed(test, "ecb(des3_ede)", DECRYPT, sec,
 				   des3_speed_template, DES3_SPEED_VECTORS,
 				   speed_template_24);
-		test_acipher_speed("cbc(des3_ede)", ENCRYPT, sec,
+		test_acipher_speed(test, "cbc(des3_ede)", ENCRYPT, sec,
 				   des3_speed_template, DES3_SPEED_VECTORS,
 				   speed_template_24);
-		test_acipher_speed("cbc(des3_ede)", DECRYPT, sec,
+		test_acipher_speed(test, "cbc(des3_ede)", DECRYPT, sec,
 				   des3_speed_template, DES3_SPEED_VECTORS,
 				   speed_template_24);
-		test_acipher_speed("cfb(des3_ede)", ENCRYPT, sec,
+		test_acipher_speed(test, "cfb(des3_ede)", ENCRYPT, sec,
 				   des3_speed_template, DES3_SPEED_VECTORS,
 				   speed_template_24);
-		test_acipher_speed("cfb(des3_ede)", DECRYPT, sec,
+		test_acipher_speed(test, "cfb(des3_ede)", DECRYPT, sec,
 				   des3_speed_template, DES3_SPEED_VECTORS,
 				   speed_template_24);
-		test_acipher_speed("ofb(des3_ede)", ENCRYPT, sec,
+		test_acipher_speed(test, "ofb(des3_ede)", ENCRYPT, sec,
 				   des3_speed_template, DES3_SPEED_VECTORS,
 				   speed_template_24);
-		test_acipher_speed("ofb(des3_ede)", DECRYPT, sec,
+		test_acipher_speed(test, "ofb(des3_ede)", DECRYPT, sec,
 				   des3_speed_template, DES3_SPEED_VECTORS,
 				   speed_template_24);
 		break;
 
 	case 502:
-		test_acipher_speed("ecb(des)", ENCRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "ecb(des)", ENCRYPT, sec, NULL, 0,
 				   speed_template_8);
-		test_acipher_speed("ecb(des)", DECRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "ecb(des)", DECRYPT, sec, NULL, 0,
 				   speed_template_8);
-		test_acipher_speed("cbc(des)", ENCRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "cbc(des)", ENCRYPT, sec, NULL, 0,
 				   speed_template_8);
-		test_acipher_speed("cbc(des)", DECRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "cbc(des)", DECRYPT, sec, NULL, 0,
 				   speed_template_8);
-		test_acipher_speed("cfb(des)", ENCRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "cfb(des)", ENCRYPT, sec, NULL, 0,
 				   speed_template_8);
-		test_acipher_speed("cfb(des)", DECRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "cfb(des)", DECRYPT, sec, NULL, 0,
 				   speed_template_8);
-		test_acipher_speed("ofb(des)", ENCRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "ofb(des)", ENCRYPT, sec, NULL, 0,
 				   speed_template_8);
-		test_acipher_speed("ofb(des)", DECRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "ofb(des)", DECRYPT, sec, NULL, 0,
 				   speed_template_8);
 		break;
 
 	case 503:
-		test_acipher_speed("ecb(serpent)", ENCRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "ecb(serpent)", ENCRYPT, sec, NULL, 0,
 				   speed_template_16_32);
-		test_acipher_speed("ecb(serpent)", DECRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "ecb(serpent)", DECRYPT, sec, NULL, 0,
 				   speed_template_16_32);
-		test_acipher_speed("cbc(serpent)", ENCRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "cbc(serpent)", ENCRYPT, sec, NULL, 0,
 				   speed_template_16_32);
-		test_acipher_speed("cbc(serpent)", DECRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "cbc(serpent)", DECRYPT, sec, NULL, 0,
 				   speed_template_16_32);
-		test_acipher_speed("ctr(serpent)", ENCRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "ctr(serpent)", ENCRYPT, sec, NULL, 0,
 				   speed_template_16_32);
-		test_acipher_speed("ctr(serpent)", DECRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "ctr(serpent)", DECRYPT, sec, NULL, 0,
 				   speed_template_16_32);
-		test_acipher_speed("lrw(serpent)", ENCRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "lrw(serpent)", ENCRYPT, sec, NULL, 0,
 				   speed_template_32_48);
-		test_acipher_speed("lrw(serpent)", DECRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "lrw(serpent)", DECRYPT, sec, NULL, 0,
 				   speed_template_32_48);
-		test_acipher_speed("xts(serpent)", ENCRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "xts(serpent)", ENCRYPT, sec, NULL, 0,
 				   speed_template_32_64);
-		test_acipher_speed("xts(serpent)", DECRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "xts(serpent)", DECRYPT, sec, NULL, 0,
 				   speed_template_32_64);
 		break;
 
 	case 504:
-		test_acipher_speed("ecb(twofish)", ENCRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "ecb(twofish)", ENCRYPT, sec, NULL, 0,
 				   speed_template_16_24_32);
-		test_acipher_speed("ecb(twofish)", DECRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "ecb(twofish)", DECRYPT, sec, NULL, 0,
 				   speed_template_16_24_32);
-		test_acipher_speed("cbc(twofish)", ENCRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "cbc(twofish)", ENCRYPT, sec, NULL, 0,
 				   speed_template_16_24_32);
-		test_acipher_speed("cbc(twofish)", DECRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "cbc(twofish)", DECRYPT, sec, NULL, 0,
 				   speed_template_16_24_32);
-		test_acipher_speed("ctr(twofish)", ENCRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "ctr(twofish)", ENCRYPT, sec, NULL, 0,
 				   speed_template_16_24_32);
-		test_acipher_speed("ctr(twofish)", DECRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "ctr(twofish)", DECRYPT, sec, NULL, 0,
 				   speed_template_16_24_32);
-		test_acipher_speed("lrw(twofish)", ENCRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "lrw(twofish)", ENCRYPT, sec, NULL, 0,
 				   speed_template_32_40_48);
-		test_acipher_speed("lrw(twofish)", DECRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "lrw(twofish)", DECRYPT, sec, NULL, 0,
 				   speed_template_32_40_48);
-		test_acipher_speed("xts(twofish)", ENCRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "xts(twofish)", ENCRYPT, sec, NULL, 0,
 				   speed_template_32_48_64);
-		test_acipher_speed("xts(twofish)", DECRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "xts(twofish)", DECRYPT, sec, NULL, 0,
 				   speed_template_32_48_64);
 		break;
 
 	case 505:
-		test_acipher_speed("ecb(arc4)", ENCRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "ecb(arc4)", ENCRYPT, sec, NULL, 0,
 				   speed_template_8);
 		break;
 
 	case 506:
-		test_acipher_speed("ecb(cast5)", ENCRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "ecb(cast5)", ENCRYPT, sec, NULL, 0,
 				   speed_template_8_16);
-		test_acipher_speed("ecb(cast5)", DECRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "ecb(cast5)", DECRYPT, sec, NULL, 0,
 				   speed_template_8_16);
-		test_acipher_speed("cbc(cast5)", ENCRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "cbc(cast5)", ENCRYPT, sec, NULL, 0,
 				   speed_template_8_16);
-		test_acipher_speed("cbc(cast5)", DECRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "cbc(cast5)", DECRYPT, sec, NULL, 0,
 				   speed_template_8_16);
-		test_acipher_speed("ctr(cast5)", ENCRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "ctr(cast5)", ENCRYPT, sec, NULL, 0,
 				   speed_template_8_16);
-		test_acipher_speed("ctr(cast5)", DECRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "ctr(cast5)", DECRYPT, sec, NULL, 0,
 				   speed_template_8_16);
 		break;
 
 	case 507:
-		test_acipher_speed("ecb(cast6)", ENCRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "ecb(cast6)", ENCRYPT, sec, NULL, 0,
 				   speed_template_16_32);
-		test_acipher_speed("ecb(cast6)", DECRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "ecb(cast6)", DECRYPT, sec, NULL, 0,
 				   speed_template_16_32);
-		test_acipher_speed("cbc(cast6)", ENCRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "cbc(cast6)", ENCRYPT, sec, NULL, 0,
 				   speed_template_16_32);
-		test_acipher_speed("cbc(cast6)", DECRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "cbc(cast6)", DECRYPT, sec, NULL, 0,
 				   speed_template_16_32);
-		test_acipher_speed("ctr(cast6)", ENCRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "ctr(cast6)", ENCRYPT, sec, NULL, 0,
 				   speed_template_16_32);
-		test_acipher_speed("ctr(cast6)", DECRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "ctr(cast6)", DECRYPT, sec, NULL, 0,
 				   speed_template_16_32);
-		test_acipher_speed("lrw(cast6)", ENCRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "lrw(cast6)", ENCRYPT, sec, NULL, 0,
 				   speed_template_32_48);
-		test_acipher_speed("lrw(cast6)", DECRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "lrw(cast6)", DECRYPT, sec, NULL, 0,
 				   speed_template_32_48);
-		test_acipher_speed("xts(cast6)", ENCRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "xts(cast6)", ENCRYPT, sec, NULL, 0,
 				   speed_template_32_64);
-		test_acipher_speed("xts(cast6)", DECRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "xts(cast6)", DECRYPT, sec, NULL, 0,
 				   speed_template_32_64);
 		break;
 
 	case 508:
-		test_acipher_speed("ecb(camellia)", ENCRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "ecb(camellia)", ENCRYPT, sec, NULL, 0,
 				   speed_template_16_32);
-		test_acipher_speed("ecb(camellia)", DECRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "ecb(camellia)", DECRYPT, sec, NULL, 0,
 				   speed_template_16_32);
-		test_acipher_speed("cbc(camellia)", ENCRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "cbc(camellia)", ENCRYPT, sec, NULL, 0,
 				   speed_template_16_32);
-		test_acipher_speed("cbc(camellia)", DECRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "cbc(camellia)", DECRYPT, sec, NULL, 0,
 				   speed_template_16_32);
-		test_acipher_speed("ctr(camellia)", ENCRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "ctr(camellia)", ENCRYPT, sec, NULL, 0,
 				   speed_template_16_32);
-		test_acipher_speed("ctr(camellia)", DECRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "ctr(camellia)", DECRYPT, sec, NULL, 0,
 				   speed_template_16_32);
-		test_acipher_speed("lrw(camellia)", ENCRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "lrw(camellia)", ENCRYPT, sec, NULL, 0,
 				   speed_template_32_48);
-		test_acipher_speed("lrw(camellia)", DECRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "lrw(camellia)", DECRYPT, sec, NULL, 0,
 				   speed_template_32_48);
-		test_acipher_speed("xts(camellia)", ENCRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "xts(camellia)", ENCRYPT, sec, NULL, 0,
 				   speed_template_32_64);
-		test_acipher_speed("xts(camellia)", DECRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "xts(camellia)", DECRYPT, sec, NULL, 0,
 				   speed_template_32_64);
 		break;
 
 	case 509:
-		test_acipher_speed("ecb(blowfish)", ENCRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "ecb(blowfish)", ENCRYPT, sec, NULL, 0,
 				   speed_template_8_32);
-		test_acipher_speed("ecb(blowfish)", DECRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "ecb(blowfish)", DECRYPT, sec, NULL, 0,
 				   speed_template_8_32);
-		test_acipher_speed("cbc(blowfish)", ENCRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "cbc(blowfish)", ENCRYPT, sec, NULL, 0,
 				   speed_template_8_32);
-		test_acipher_speed("cbc(blowfish)", DECRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "cbc(blowfish)", DECRYPT, sec, NULL, 0,
 				   speed_template_8_32);
-		test_acipher_speed("ctr(blowfish)", ENCRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "ctr(blowfish)", ENCRYPT, sec, NULL, 0,
 				   speed_template_8_32);
-		test_acipher_speed("ctr(blowfish)", DECRYPT, sec, NULL, 0,
+		test_acipher_speed(test, "ctr(blowfish)", DECRYPT, sec, NULL, 0,
 				   speed_template_8_32);
 		break;
 
 	case 600:
-		test_mb_skcipher_speed("ecb(aes)", ENCRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "ecb(aes)", ENCRYPT, sec, NULL, 0,
 				       speed_template_16_24_32, num_mb);
-		test_mb_skcipher_speed("ecb(aes)", DECRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "ecb(aes)", DECRYPT, sec, NULL, 0,
 				       speed_template_16_24_32, num_mb);
-		test_mb_skcipher_speed("cbc(aes)", ENCRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "cbc(aes)", ENCRYPT, sec, NULL, 0,
 				       speed_template_16_24_32, num_mb);
-		test_mb_skcipher_speed("cbc(aes)", DECRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "cbc(aes)", DECRYPT, sec, NULL, 0,
 				       speed_template_16_24_32, num_mb);
-		test_mb_skcipher_speed("lrw(aes)", ENCRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "lrw(aes)", ENCRYPT, sec, NULL, 0,
 				       speed_template_32_40_48, num_mb);
-		test_mb_skcipher_speed("lrw(aes)", DECRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "lrw(aes)", DECRYPT, sec, NULL, 0,
 				       speed_template_32_40_48, num_mb);
-		test_mb_skcipher_speed("xts(aes)", ENCRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "xts(aes)", ENCRYPT, sec, NULL, 0,
 				       speed_template_32_64, num_mb);
-		test_mb_skcipher_speed("xts(aes)", DECRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "xts(aes)", DECRYPT, sec, NULL, 0,
 				       speed_template_32_64, num_mb);
-		test_mb_skcipher_speed("cts(cbc(aes))", ENCRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "cts(cbc(aes))", ENCRYPT, sec, NULL, 0,
 				       speed_template_16_24_32, num_mb);
-		test_mb_skcipher_speed("cts(cbc(aes))", DECRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "cts(cbc(aes))", DECRYPT, sec, NULL, 0,
 				       speed_template_16_24_32, num_mb);
-		test_mb_skcipher_speed("ctr(aes)", ENCRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "ctr(aes)", ENCRYPT, sec, NULL, 0,
 				       speed_template_16_24_32, num_mb);
-		test_mb_skcipher_speed("ctr(aes)", DECRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "ctr(aes)", DECRYPT, sec, NULL, 0,
 				       speed_template_16_24_32, num_mb);
-		test_mb_skcipher_speed("cfb(aes)", ENCRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "cfb(aes)", ENCRYPT, sec, NULL, 0,
 				       speed_template_16_24_32, num_mb);
-		test_mb_skcipher_speed("cfb(aes)", DECRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "cfb(aes)", DECRYPT, sec, NULL, 0,
 				       speed_template_16_24_32, num_mb);
-		test_mb_skcipher_speed("ofb(aes)", ENCRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "ofb(aes)", ENCRYPT, sec, NULL, 0,
 				       speed_template_16_24_32, num_mb);
-		test_mb_skcipher_speed("ofb(aes)", DECRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "ofb(aes)", DECRYPT, sec, NULL, 0,
 				       speed_template_16_24_32, num_mb);
-		test_mb_skcipher_speed("rfc3686(ctr(aes))", ENCRYPT, sec, NULL,
+		test_mb_skcipher_speed(test, "rfc3686(ctr(aes))", ENCRYPT, sec, NULL,
 				       0, speed_template_20_28_36, num_mb);
-		test_mb_skcipher_speed("rfc3686(ctr(aes))", DECRYPT, sec, NULL,
+		test_mb_skcipher_speed(test, "rfc3686(ctr(aes))", DECRYPT, sec, NULL,
 				       0, speed_template_20_28_36, num_mb);
 		break;
 
 	case 601:
-		test_mb_skcipher_speed("ecb(des3_ede)", ENCRYPT, sec,
+		test_mb_skcipher_speed(test, "ecb(des3_ede)", ENCRYPT, sec,
 				       des3_speed_template, DES3_SPEED_VECTORS,
 				       speed_template_24, num_mb);
-		test_mb_skcipher_speed("ecb(des3_ede)", DECRYPT, sec,
+		test_mb_skcipher_speed(test, "ecb(des3_ede)", DECRYPT, sec,
 				       des3_speed_template, DES3_SPEED_VECTORS,
 				       speed_template_24, num_mb);
-		test_mb_skcipher_speed("cbc(des3_ede)", ENCRYPT, sec,
+		test_mb_skcipher_speed(test, "cbc(des3_ede)", ENCRYPT, sec,
 				       des3_speed_template, DES3_SPEED_VECTORS,
 				       speed_template_24, num_mb);
-		test_mb_skcipher_speed("cbc(des3_ede)", DECRYPT, sec,
+		test_mb_skcipher_speed(test, "cbc(des3_ede)", DECRYPT, sec,
 				       des3_speed_template, DES3_SPEED_VECTORS,
 				       speed_template_24, num_mb);
-		test_mb_skcipher_speed("cfb(des3_ede)", ENCRYPT, sec,
+		test_mb_skcipher_speed(test, "cfb(des3_ede)", ENCRYPT, sec,
 				       des3_speed_template, DES3_SPEED_VECTORS,
 				       speed_template_24, num_mb);
-		test_mb_skcipher_speed("cfb(des3_ede)", DECRYPT, sec,
+		test_mb_skcipher_speed(test, "cfb(des3_ede)", DECRYPT, sec,
 				       des3_speed_template, DES3_SPEED_VECTORS,
 				       speed_template_24, num_mb);
-		test_mb_skcipher_speed("ofb(des3_ede)", ENCRYPT, sec,
+		test_mb_skcipher_speed(test, "ofb(des3_ede)", ENCRYPT, sec,
 				       des3_speed_template, DES3_SPEED_VECTORS,
 				       speed_template_24, num_mb);
-		test_mb_skcipher_speed("ofb(des3_ede)", DECRYPT, sec,
+		test_mb_skcipher_speed(test, "ofb(des3_ede)", DECRYPT, sec,
 				       des3_speed_template, DES3_SPEED_VECTORS,
 				       speed_template_24, num_mb);
 		break;
 
 	case 602:
-		test_mb_skcipher_speed("ecb(des)", ENCRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "ecb(des)", ENCRYPT, sec, NULL, 0,
 				       speed_template_8, num_mb);
-		test_mb_skcipher_speed("ecb(des)", DECRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "ecb(des)", DECRYPT, sec, NULL, 0,
 				       speed_template_8, num_mb);
-		test_mb_skcipher_speed("cbc(des)", ENCRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "cbc(des)", ENCRYPT, sec, NULL, 0,
 				       speed_template_8, num_mb);
-		test_mb_skcipher_speed("cbc(des)", DECRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "cbc(des)", DECRYPT, sec, NULL, 0,
 				       speed_template_8, num_mb);
-		test_mb_skcipher_speed("cfb(des)", ENCRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "cfb(des)", ENCRYPT, sec, NULL, 0,
 				       speed_template_8, num_mb);
-		test_mb_skcipher_speed("cfb(des)", DECRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "cfb(des)", DECRYPT, sec, NULL, 0,
 				       speed_template_8, num_mb);
-		test_mb_skcipher_speed("ofb(des)", ENCRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "ofb(des)", ENCRYPT, sec, NULL, 0,
 				       speed_template_8, num_mb);
-		test_mb_skcipher_speed("ofb(des)", DECRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "ofb(des)", DECRYPT, sec, NULL, 0,
 				       speed_template_8, num_mb);
 		break;
 
 	case 603:
-		test_mb_skcipher_speed("ecb(serpent)", ENCRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "ecb(serpent)", ENCRYPT, sec, NULL, 0,
 				       speed_template_16_32, num_mb);
-		test_mb_skcipher_speed("ecb(serpent)", DECRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "ecb(serpent)", DECRYPT, sec, NULL, 0,
 				       speed_template_16_32, num_mb);
-		test_mb_skcipher_speed("cbc(serpent)", ENCRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "cbc(serpent)", ENCRYPT, sec, NULL, 0,
 				       speed_template_16_32, num_mb);
-		test_mb_skcipher_speed("cbc(serpent)", DECRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "cbc(serpent)", DECRYPT, sec, NULL, 0,
 				       speed_template_16_32, num_mb);
-		test_mb_skcipher_speed("ctr(serpent)", ENCRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "ctr(serpent)", ENCRYPT, sec, NULL, 0,
 				       speed_template_16_32, num_mb);
-		test_mb_skcipher_speed("ctr(serpent)", DECRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "ctr(serpent)", DECRYPT, sec, NULL, 0,
 				       speed_template_16_32, num_mb);
-		test_mb_skcipher_speed("lrw(serpent)", ENCRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "lrw(serpent)", ENCRYPT, sec, NULL, 0,
 				       speed_template_32_48, num_mb);
-		test_mb_skcipher_speed("lrw(serpent)", DECRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "lrw(serpent)", DECRYPT, sec, NULL, 0,
 				       speed_template_32_48, num_mb);
-		test_mb_skcipher_speed("xts(serpent)", ENCRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "xts(serpent)", ENCRYPT, sec, NULL, 0,
 				       speed_template_32_64, num_mb);
-		test_mb_skcipher_speed("xts(serpent)", DECRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "xts(serpent)", DECRYPT, sec, NULL, 0,
 				       speed_template_32_64, num_mb);
 		break;
 
 	case 604:
-		test_mb_skcipher_speed("ecb(twofish)", ENCRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "ecb(twofish)", ENCRYPT, sec, NULL, 0,
 				       speed_template_16_24_32, num_mb);
-		test_mb_skcipher_speed("ecb(twofish)", DECRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "ecb(twofish)", DECRYPT, sec, NULL, 0,
 				       speed_template_16_24_32, num_mb);
-		test_mb_skcipher_speed("cbc(twofish)", ENCRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "cbc(twofish)", ENCRYPT, sec, NULL, 0,
 				       speed_template_16_24_32, num_mb);
-		test_mb_skcipher_speed("cbc(twofish)", DECRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "cbc(twofish)", DECRYPT, sec, NULL, 0,
 				       speed_template_16_24_32, num_mb);
-		test_mb_skcipher_speed("ctr(twofish)", ENCRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "ctr(twofish)", ENCRYPT, sec, NULL, 0,
 				       speed_template_16_24_32, num_mb);
-		test_mb_skcipher_speed("ctr(twofish)", DECRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "ctr(twofish)", DECRYPT, sec, NULL, 0,
 				       speed_template_16_24_32, num_mb);
-		test_mb_skcipher_speed("lrw(twofish)", ENCRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "lrw(twofish)", ENCRYPT, sec, NULL, 0,
 				       speed_template_32_40_48, num_mb);
-		test_mb_skcipher_speed("lrw(twofish)", DECRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "lrw(twofish)", DECRYPT, sec, NULL, 0,
 				       speed_template_32_40_48, num_mb);
-		test_mb_skcipher_speed("xts(twofish)", ENCRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "xts(twofish)", ENCRYPT, sec, NULL, 0,
 				       speed_template_32_48_64, num_mb);
-		test_mb_skcipher_speed("xts(twofish)", DECRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "xts(twofish)", DECRYPT, sec, NULL, 0,
 				       speed_template_32_48_64, num_mb);
 		break;
 
 	case 605:
-		test_mb_skcipher_speed("ecb(arc4)", ENCRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "ecb(arc4)", ENCRYPT, sec, NULL, 0,
 				       speed_template_8, num_mb);
 		break;
 
 	case 606:
-		test_mb_skcipher_speed("ecb(cast5)", ENCRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "ecb(cast5)", ENCRYPT, sec, NULL, 0,
 				       speed_template_8_16, num_mb);
-		test_mb_skcipher_speed("ecb(cast5)", DECRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "ecb(cast5)", DECRYPT, sec, NULL, 0,
 				       speed_template_8_16, num_mb);
-		test_mb_skcipher_speed("cbc(cast5)", ENCRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "cbc(cast5)", ENCRYPT, sec, NULL, 0,
 				       speed_template_8_16, num_mb);
-		test_mb_skcipher_speed("cbc(cast5)", DECRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "cbc(cast5)", DECRYPT, sec, NULL, 0,
 				       speed_template_8_16, num_mb);
-		test_mb_skcipher_speed("ctr(cast5)", ENCRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "ctr(cast5)", ENCRYPT, sec, NULL, 0,
 				       speed_template_8_16, num_mb);
-		test_mb_skcipher_speed("ctr(cast5)", DECRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "ctr(cast5)", DECRYPT, sec, NULL, 0,
 				       speed_template_8_16, num_mb);
 		break;
 
 	case 607:
-		test_mb_skcipher_speed("ecb(cast6)", ENCRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "ecb(cast6)", ENCRYPT, sec, NULL, 0,
 				       speed_template_16_32, num_mb);
-		test_mb_skcipher_speed("ecb(cast6)", DECRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "ecb(cast6)", DECRYPT, sec, NULL, 0,
 				       speed_template_16_32, num_mb);
-		test_mb_skcipher_speed("cbc(cast6)", ENCRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "cbc(cast6)", ENCRYPT, sec, NULL, 0,
 				       speed_template_16_32, num_mb);
-		test_mb_skcipher_speed("cbc(cast6)", DECRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "cbc(cast6)", DECRYPT, sec, NULL, 0,
 				       speed_template_16_32, num_mb);
-		test_mb_skcipher_speed("ctr(cast6)", ENCRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "ctr(cast6)", ENCRYPT, sec, NULL, 0,
 				       speed_template_16_32, num_mb);
-		test_mb_skcipher_speed("ctr(cast6)", DECRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "ctr(cast6)", DECRYPT, sec, NULL, 0,
 				       speed_template_16_32, num_mb);
-		test_mb_skcipher_speed("lrw(cast6)", ENCRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "lrw(cast6)", ENCRYPT, sec, NULL, 0,
 				       speed_template_32_48, num_mb);
-		test_mb_skcipher_speed("lrw(cast6)", DECRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "lrw(cast6)", DECRYPT, sec, NULL, 0,
 				       speed_template_32_48, num_mb);
-		test_mb_skcipher_speed("xts(cast6)", ENCRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "xts(cast6)", ENCRYPT, sec, NULL, 0,
 				       speed_template_32_64, num_mb);
-		test_mb_skcipher_speed("xts(cast6)", DECRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "xts(cast6)", DECRYPT, sec, NULL, 0,
 				       speed_template_32_64, num_mb);
 		break;
 
 	case 608:
-		test_mb_skcipher_speed("ecb(camellia)", ENCRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "ecb(camellia)", ENCRYPT, sec, NULL, 0,
 				       speed_template_16_32, num_mb);
-		test_mb_skcipher_speed("ecb(camellia)", DECRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "ecb(camellia)", DECRYPT, sec, NULL, 0,
 				       speed_template_16_32, num_mb);
-		test_mb_skcipher_speed("cbc(camellia)", ENCRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "cbc(camellia)", ENCRYPT, sec, NULL, 0,
 				       speed_template_16_32, num_mb);
-		test_mb_skcipher_speed("cbc(camellia)", DECRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "cbc(camellia)", DECRYPT, sec, NULL, 0,
 				       speed_template_16_32, num_mb);
-		test_mb_skcipher_speed("ctr(camellia)", ENCRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "ctr(camellia)", ENCRYPT, sec, NULL, 0,
 				       speed_template_16_32, num_mb);
-		test_mb_skcipher_speed("ctr(camellia)", DECRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "ctr(camellia)", DECRYPT, sec, NULL, 0,
 				       speed_template_16_32, num_mb);
-		test_mb_skcipher_speed("lrw(camellia)", ENCRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "lrw(camellia)", ENCRYPT, sec, NULL, 0,
 				       speed_template_32_48, num_mb);
-		test_mb_skcipher_speed("lrw(camellia)", DECRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "lrw(camellia)", DECRYPT, sec, NULL, 0,
 				       speed_template_32_48, num_mb);
-		test_mb_skcipher_speed("xts(camellia)", ENCRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "xts(camellia)", ENCRYPT, sec, NULL, 0,
 				       speed_template_32_64, num_mb);
-		test_mb_skcipher_speed("xts(camellia)", DECRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "xts(camellia)", DECRYPT, sec, NULL, 0,
 				       speed_template_32_64, num_mb);
 		break;
 
 	case 609:
-		test_mb_skcipher_speed("ecb(blowfish)", ENCRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "ecb(blowfish)", ENCRYPT, sec, NULL, 0,
 				       speed_template_8_32, num_mb);
-		test_mb_skcipher_speed("ecb(blowfish)", DECRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "ecb(blowfish)", DECRYPT, sec, NULL, 0,
 				       speed_template_8_32, num_mb);
-		test_mb_skcipher_speed("cbc(blowfish)", ENCRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "cbc(blowfish)", ENCRYPT, sec, NULL, 0,
 				       speed_template_8_32, num_mb);
-		test_mb_skcipher_speed("cbc(blowfish)", DECRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "cbc(blowfish)", DECRYPT, sec, NULL, 0,
 				       speed_template_8_32, num_mb);
-		test_mb_skcipher_speed("ctr(blowfish)", ENCRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "ctr(blowfish)", ENCRYPT, sec, NULL, 0,
 				       speed_template_8_32, num_mb);
-		test_mb_skcipher_speed("ctr(blowfish)", DECRYPT, sec, NULL, 0,
+		test_mb_skcipher_speed(test, "ctr(blowfish)", DECRYPT, sec, NULL, 0,
 				       speed_template_8_32, num_mb);
 		break;
 
-- 
2.32.0.402.g57bb445576-goog


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [RFC v1 1/2] crypto: tcrypt: minimal conversion to run under KUnit
  2021-07-15 21:31 ` [RFC v1 1/2] crypto: tcrypt: minimal conversion " Daniel Latypov
@ 2021-07-23  6:43   ` Herbert Xu
  2021-07-23 19:31     ` Daniel Latypov
  0 siblings, 1 reply; 7+ messages in thread
From: Herbert Xu @ 2021-07-23  6:43 UTC (permalink / raw)
  To: Daniel Latypov
  Cc: davem, linux-crypto, brendanhiggins, davidgow, linux-kernel, kunit-dev

On Thu, Jul 15, 2021 at 02:31:37PM -0700, Daniel Latypov wrote:
>> == Questions ==
> * does this seem like it would make running the test easier?

I don't mind.  tcrypt these days isn't used so much for correctness
testing.  It's mostly being used for speed testing.  A secondary
use is to instantiate templates.

> * does `tvmem` actually need page-aligned buffers?

I think it may be needed for those split-SG test cases where
we deliberately create a buffer that straddles a page boundary.

> * I have no clue how FIPS intersects with all of this.

It doesn't really matter because in FIPS mode when a correctness
test fails the kernel panics.

>   * would it be fine to leave the test code built-in for FIPS instead of
>   returning -EAGAIN?

The returning -EAGAIN is irrelevant in FIPS mode.  It's more of
an aid in normal mode when you use tcrypt for speed testing.

Thanks,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC v1 1/2] crypto: tcrypt: minimal conversion to run under KUnit
  2021-07-23  6:43   ` Herbert Xu
@ 2021-07-23 19:31     ` Daniel Latypov
  2021-07-30  2:55       ` Herbert Xu
  0 siblings, 1 reply; 7+ messages in thread
From: Daniel Latypov @ 2021-07-23 19:31 UTC (permalink / raw)
  To: Herbert Xu
  Cc: davem, linux-crypto, brendanhiggins, davidgow, linux-kernel, kunit-dev

On Thu, Jul 22, 2021 at 11:43 PM Herbert Xu <herbert@gondor.apana.org.au> wrote:
>
> On Thu, Jul 15, 2021 at 02:31:37PM -0700, Daniel Latypov wrote:
> >> == Questions ==
> > * does this seem like it would make running the test easier?
>
> I don't mind.  tcrypt these days isn't used so much for correctness
> testing.  It's mostly being used for speed testing.  A secondary
> use is to instantiate templates.

Thanks, that makes a lot of sense.
In that case, how useful would `kunit.py run` be? I.e. Do people
mostly want to see numbers on bare metal?

The default mode of `kunit.py run` is to use ARCH=um.
I assume (for at least most of the library-type crypto code) it should
have the same performance characteristics, but that might not be the
case. I can try and get some numbers on that.

There's an option to make `kunit.py run` use ARCH=86_64, but it'll be
in a QEMU VM, so again there's some performance overhead.

If either option seems useful, then perhaps a minimal patch like this
would be beneficial.
I can make it even smaller and less intrusive by restoring the "ret +=
..." code and having a single `KUNIT_EXPECT_EQ_MSG(test, ret, 0, "at
least one test case failed")` at the very end.

It does not sound like patch #2 or any future attempts to try and make
use of KUnit features is necessarily worth it, if correctness testing
isn't really the goal of tcrypt.c anymore.

>
> > * does `tvmem` actually need page-aligned buffers?
>
> I think it may be needed for those split-SG test cases where
> we deliberately create a buffer that straddles a page boundary.
>
> > * I have no clue how FIPS intersects with all of this.
>
> It doesn't really matter because in FIPS mode when a correctness
> test fails the kernel panics.
>
> >   * would it be fine to leave the test code built-in for FIPS instead of
> >   returning -EAGAIN?
>
> The returning -EAGAIN is irrelevant in FIPS mode.  It's more of
> an aid in normal mode when you use tcrypt for speed testing.
>
> Thanks,
> --
> Email: Herbert Xu <herbert@gondor.apana.org.au>
> Home Page: http://gondor.apana.org.au/~herbert/
> PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC v1 1/2] crypto: tcrypt: minimal conversion to run under KUnit
  2021-07-23 19:31     ` Daniel Latypov
@ 2021-07-30  2:55       ` Herbert Xu
  2021-07-30  5:33         ` David Gow
  0 siblings, 1 reply; 7+ messages in thread
From: Herbert Xu @ 2021-07-30  2:55 UTC (permalink / raw)
  To: Daniel Latypov
  Cc: davem, linux-crypto, brendanhiggins, davidgow, linux-kernel, kunit-dev

On Fri, Jul 23, 2021 at 12:31:28PM -0700, Daniel Latypov wrote:
>
> Thanks, that makes a lot of sense.
> In that case, how useful would `kunit.py run` be? I.e. Do people
> mostly want to see numbers on bare metal?

I think it's a mix of both.  As in performance on bare metal and
under virtualisation may be of interest.  I don't think you're going
to be going through kunit for the speed tests though, because you
need to supply module parameters for tcrypt to do that.

Cheers,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC v1 1/2] crypto: tcrypt: minimal conversion to run under KUnit
  2021-07-30  2:55       ` Herbert Xu
@ 2021-07-30  5:33         ` David Gow
  0 siblings, 0 replies; 7+ messages in thread
From: David Gow @ 2021-07-30  5:33 UTC (permalink / raw)
  To: Herbert Xu
  Cc: Daniel Latypov, davem, linux-crypto, Brendan Higgins,
	Linux Kernel Mailing List, KUnit Development

On Fri, Jul 30, 2021 at 10:55 AM Herbert Xu <herbert@gondor.apana.org.au> wrote:
>
> On Fri, Jul 23, 2021 at 12:31:28PM -0700, Daniel Latypov wrote:
> >
> > Thanks, that makes a lot of sense.
> > In that case, how useful would `kunit.py run` be? I.e. Do people
> > mostly want to see numbers on bare metal?
>
> I think it's a mix of both.  As in performance on bare metal and
> under virtualisation may be of interest.  I don't think you're going
> to be going through kunit for the speed tests though, because you
> need to supply module parameters for tcrypt to do that.

FYI, there is a patch for kunit_tool which will allow kernel
parameters to be passed through:
https://patchwork.kernel.org/project/linux-kselftest/patch/20210715160819.1107685-1-dlatypov@google.com/

That being said, no-one's ever used any of the KUnit tooling for
performance testing before, as far as I know, so whether or not it
turns out to be useful or not remains to be seen. With this patch,
it'd at least be an option if you wanted to try it.

-- David

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-07-30  5:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-15 21:31 [RFC v1 0/2] crypto: tcrypt: small changes to run under KUnit Daniel Latypov
2021-07-15 21:31 ` [RFC v1 1/2] crypto: tcrypt: minimal conversion " Daniel Latypov
2021-07-23  6:43   ` Herbert Xu
2021-07-23 19:31     ` Daniel Latypov
2021-07-30  2:55       ` Herbert Xu
2021-07-30  5:33         ` David Gow
2021-07-15 21:31 ` [RFC v1 2/2] crypto: tcrypt: call KUNIT_FAIL() instead of pr_err() Daniel Latypov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).