lkm: tweaks to self-test dynamics/messages.

This commit is contained in:
Daniel Pouzzner
2020-08-21 12:10:17 -05:00
parent 554879da00
commit 217ec4ebd3
3 changed files with 10 additions and 3 deletions

View File

@@ -113,7 +113,7 @@ _Pragma("GCC diagnostic ignored \"-Wunused-function\"");
#include <stdio.h> #include <stdio.h>
#endif #endif
#ifdef WOLFSSL_LINUXKM #if defined(WOLFSSL_LINUXKM) && !defined(DEBUG_WOLFSSL_VERBOSE)
#undef printf #undef printf
#define printf(...) ({}) #define printf(...) ({})
#endif #endif
@@ -452,7 +452,11 @@ static int err_sys(const char* msg, int es)
(void)msg; (void)msg;
(void)es; (void)es;
#ifdef WOLFSSL_LINUXKM
lkm_printf("%s error = %d\n", msg, es);
#else
printf("%s error = %d\n", msg, es); printf("%s error = %d\n", msg, es);
#endif
EXIT_TEST(-1); EXIT_TEST(-1);
} }

View File

@@ -11,6 +11,7 @@
#include <wolfssl/ssl.h> #include <wolfssl/ssl.h>
#ifndef NO_CRYPT_TEST #ifndef NO_CRYPT_TEST
#include <wolfcrypt/test/test.h> #include <wolfcrypt/test/test.h>
#include <linux/delay.h>
#endif #endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0) #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)
@@ -28,7 +29,8 @@ static int wolfssl_init(void)
#ifndef NO_CRYPT_TEST #ifndef NO_CRYPT_TEST
ret = wolfcrypt_test(NULL); ret = wolfcrypt_test(NULL);
if (ret < 0) { if (ret < 0) {
pr_err("wolfcrypt_test() failed with code %d", ret); pr_err("wolfcrypt self-test failed.");
msleep(10);
return -ENOTRECOVERABLE; return -ENOTRECOVERABLE;
} }
pr_info("wolfSSL " LIBWOLFSSL_VERSION_STRING " self-test passed. See https://www.wolfssl.com/ for information.\n"); pr_info("wolfSSL " LIBWOLFSSL_VERSION_STRING " self-test passed. See https://www.wolfssl.com/ for information.\n");

View File

@@ -111,7 +111,8 @@
/* work around namespace conflict between wolfssl/internal.h (enum HandShakeType) and linux/key.h (extern int()). */ /* work around namespace conflict between wolfssl/internal.h (enum HandShakeType) and linux/key.h (extern int()). */
#define key_update wc_key_update #define key_update wc_key_update
#define printf(format, args...) printk(KERN_INFO "wolfssl: %s(): " format, __func__, ## args) #define lkm_printf(format, args...) printk(KERN_INFO "wolfssl: %s(): " format, __func__, ## args)
#define printf(...) lkm_printf(__VA_ARGS__)
#define XSNPRINTF snprintf /* needed to suppress inclusion of stdio.h in wolfssl/wolfcrypt/types.h */ #define XSNPRINTF snprintf /* needed to suppress inclusion of stdio.h in wolfssl/wolfcrypt/types.h */
/* the rigmarole around kstrtol() here is to accommodate its warn-unused-result attribute. */ /* the rigmarole around kstrtol() here is to accommodate its warn-unused-result attribute. */
#define XATOI(s) ({ long _xatoi_res = 0; int _xatoi_ret = kstrtol(s, 10, &_xatoi_res); if (_xatoi_ret != 0) { _xatoi_res = 0; } (int)_xatoi_res; }) #define XATOI(s) ({ long _xatoi_res = 0; int _xatoi_ret = kstrtol(s, 10, &_xatoi_res); if (_xatoi_ret != 0) { _xatoi_res = 0; } (int)_xatoi_res; })