crypto: testmgr: allow building a copy as loadable module for testing.
Subsystems (2)
PATCH 1/1 crypto: testmgr: allow building a copy as loadable module for testing.
There is no way to just run the tests built into testmgr. Also it is rarely possible to build testmgr modular due to KConfig dependencies.
Add a module that does not provide infrastructure, just runs testmgr tests.
--- crypto/Kconfig | 8 ++ crypto/Makefile | 3 + crypto/alg_test_desc.h | 219 ++++++++++++++++++++++++++++++++++++++ crypto/algboss.c | 2 + crypto/algboss_runtests.c | 38 +++++++ crypto/testmgr.c | 71 +----------- crypto/testmgr.h | 146 +------------------------ crypto/testmgr_runtests.c | 1 + 8 files changed, 277 insertions(+), 211 deletions(-) create mode 100644 crypto/alg_test_desc.h create mode 100644 crypto/algboss_runtests.c create mode 120000 crypto/testmgr_runtests.c
crypto/Kconfig +8 -0
@@ -119,6 +119,14 @@ config CRYPTO_MANAGER Create default cryptographic template instantiations such as cbc(aes). +config CRYPTO_MANAGER_RUNTESTS + tristate "Cryptographic algorithm manager: test module" + depends on CRYPTO_MANAGER2 && !CRYPTO_MANAGER_DISABLE_TESTS + default m + help + Build a module that runs the tests from cryptographic algorithm + manager when loaded. + config CRYPTO_MANAGER2 def_tristate CRYPTO_MANAGER || (CRYPTO_MANAGER!=n && CRYPTO_ALGAPI=y) select CRYPTO_AEAD2
crypto/Makefile +3 -0
@@ -47,6 +47,9 @@ crypto_acompress-y += scompress.o obj-$(CONFIG_CRYPTO_ACOMP2) += crypto_acompress.o cryptomgr-y := algboss.o testmgr.o +cryptomgr_runtests-y := testmgr_runtests.o algboss_runtests.o + +obj-$(CONFIG_CRYPTO_MANAGER_RUNTESTS) += cryptomgr_runtests.o obj-$(CONFIG_CRYPTO_MANAGER2) += cryptomgr.o obj-$(CONFIG_CRYPTO_USER) += crypto_user.o
crypto/alg_test_desc.h new file +219 -0
219 lines not on this page · raw message
crypto/algboss.c +2 -0
@@ -300,5 +300,7 @@ static void __exit cryptomgr_exit(void)arch_initcall (cryptomgr_init);module_exit (cryptomgr_exit); +EXPORT_SYMBOL_GPL (alg_test); +MODULE_LICENSE ("GPL" );MODULE_DESCRIPTION ("Crypto Algorithm Manager" );
crypto/algboss_runtests.c new file +38 -0
@@ -0,0 +1,38 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +#include <linux/module.h> +#include "alg_test_desc.h" + +static int __init testmgr_runtests_init (void ) +{ +int i; +int ret =0 ; + +for (i =0 ; i < nr_alg_test_descs; i++) { +const char *alg = alg_test_descs[i].alg; +int rc; + +pr_info ("Testing %s ..." , alg); + rc = alg_test_descs[i].test (alg_test_descs + i, alg,0 ,0 ); +switch (rc) { +case 0 : +pr_info ("PASSED\n" ); +break ; +case -2 : +pr_info ("SKIPPED\n" ); +break ; + +default : + ret = rc; +pr_err ("%s FAILED(%i)\n" , alg, rc); + } + } +return ret; +} + +static void __exit testmgr_runtests_exit(void) {} + +module_init (testmgr_runtests_init); +module_exit (testmgr_runtests_exit); + +MODULE_LICENSE ("GPL" ); +MODULE_DESCRIPTION ("Crypto Algorithm Manager Test Module" );
crypto/testmgr.c +5 -66
98 lines not on this page · raw message
crypto/testmgr.h +1 -145
155 lines not on this page · raw message
crypto/testmgr_runtests.c new file +1 -0
@@ -0,0 +1 @@ +testmgr.c
Signature · 1 line
2.23.0
Quoted 7 lines · Michal Suchanek
There is no way to just run the tests built into testmgr. Also it is rarely possible to build testmgr modular due to KConfig dependencies.
Add a module that does not provide infrastructure, just runs testmgr tests.
Signed-off-by Michal Suchanek <[email protected]>
Why does this need to be a kernel module? Since the self-tests are already run at algorithm registration time, it's already possible to use AF_ALG or crypto_user to allocate all algorithms which have self-tests.
- Eric