From 554879da008e254c6e3961617abfc632de4443de Mon Sep 17 00:00:00 2001 From: Daniel Pouzzner Date: Fri, 21 Aug 2020 01:28:03 -0500 Subject: [PATCH] lkm: self-test working now (certain options, which ones TBD, crash kernel). --- linuxkm/lkm_testcrypto.c | 14 +++++++++++--- linuxkm/module_hooks.c | 8 +++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/linuxkm/lkm_testcrypto.c b/linuxkm/lkm_testcrypto.c index 5d9685e79..e08360769 100644 --- a/linuxkm/lkm_testcrypto.c +++ b/linuxkm/lkm_testcrypto.c @@ -113,6 +113,11 @@ _Pragma("GCC diagnostic ignored \"-Wunused-function\""); #include #endif + #ifdef WOLFSSL_LINUXKM + #undef printf + #define printf(...) ({}) + #endif + /* enable way for customer to override test/bench printf */ #ifdef XPRINTF #undef printf @@ -444,6 +449,9 @@ static THREAD_RETURN err_sys(const char* msg, int es) static int err_sys(const char* msg, int es) #endif { + (void)msg; + (void)es; + printf("%s error = %d\n", msg, es); EXIT_TEST(-1); @@ -28839,7 +28847,7 @@ static void *my_Realloc_cb(void *ptr, size_t size) static int memcb_test(void) { int ret = 0; -#ifndef WOLFSSL_NO_MALLOC +#if !defined(WOLFSSL_NO_MALLOC) && !defined(WOLFSSL_LINUXKM) byte* b = NULL; #endif wolfSSL_Malloc_cb mc; @@ -28850,7 +28858,7 @@ static int memcb_test(void) if (wolfSSL_GetAllocators(&mc, &fc, &rc) != 0) return -12800; -#ifndef WOLFSSL_NO_MALLOC +#if !defined(WOLFSSL_NO_MALLOC) && !defined(WOLFSSL_LINUXKM) /* test realloc */ b = (byte*)XREALLOC(b, 1024, NULL, DYNAMIC_TYPE_TMP_BUFFER); if (b == NULL) { @@ -28878,7 +28886,7 @@ static int memcb_test(void) ret = -12803; #endif /* !WOLFSSL_NO_MALLOC */ -#ifndef WOLFSSL_NO_MALLOC +#if !defined(WOLFSSL_NO_MALLOC) && !defined(WOLFSSL_LINUXKM) exit_memcb: #endif diff --git a/linuxkm/module_hooks.c b/linuxkm/module_hooks.c index fb92bfd11..520bbb619 100644 --- a/linuxkm/module_hooks.c +++ b/linuxkm/module_hooks.c @@ -27,13 +27,15 @@ static int wolfssl_init(void) #ifndef NO_CRYPT_TEST ret = wolfcrypt_test(NULL); - if (ret != WOLFSSL_SUCCESS) { - pr_err("wolfcrypt_test() failed: %s", wc_GetErrorString(ret)); + if (ret < 0) { + pr_err("wolfcrypt_test() failed with code %d", ret); return -ENOTRECOVERABLE; } + pr_info("wolfSSL " LIBWOLFSSL_VERSION_STRING " self-test passed. See https://www.wolfssl.com/ for information.\n"); +#else + pr_info("wolfSSL " LIBWOLFSSL_VERSION_STRING " loaded. See https://www.wolfssl.com/ for information.\n"); #endif - pr_info("wolfSSL " LIBWOLFSSL_VERSION_STRING " loaded. See https://www.wolfssl.com/ for information.\n"); pr_info("Copyright (C) 2006-2020 wolfSSL Inc. All Rights Reserved.\n"); return 0;