From 5271fc50c7a7a1776c017fe60e346714f9bc87df Mon Sep 17 00:00:00 2001 From: Geoffrey Challen Date: Thu, 31 Dec 2015 12:03:41 -0500 Subject: [PATCH] Moving the secret inside the tests, not in a library function. --- kern/include/kern/secret.h | 12 +++++------- kern/include/lib.h | 1 - kern/lib/kprintf.c | 22 +--------------------- kern/test/synchtest.c | 4 ++-- 4 files changed, 8 insertions(+), 31 deletions(-) diff --git a/kern/include/kern/secret.h b/kern/include/kern/secret.h index 49931b5..aa2c972 100644 --- a/kern/include/kern/secret.h +++ b/kern/include/kern/secret.h @@ -38,14 +38,12 @@ #define _SECRET_H_ /* - * During automated testing this is set to a random 32-bit value, to ensure - * that the kernel is actually running the compiled binaries. A non-zero value - * can also be used as a flag to change test output. During normal testing - * this can be set to zero to disable printing the kernel secret and enable - * normal test output. + * During automated testing all instances of KERNEL_SECRET in trusted tests + * are rewritten to a random value to ensure that the kernel is actually + * running the appropriate tests. So this value is never actually used, but + * allows normally compilation and operation. */ -// #define KERNEL_SECRET ((unsigned long long)1) // Cast for consistent printf -#define KERNEL_SECRET ((unsigned long long)0) // Cast for consistent printf +#define KERNEL_SECRET "" #endif /* _SECRET_H_ */ diff --git a/kern/include/lib.h b/kern/include/lib.h index a25c079..b114e58 100644 --- a/kern/include/lib.h +++ b/kern/include/lib.h @@ -204,6 +204,5 @@ void random_spinner(uint32_t); */ int tkprintf(const char *format, ...) __PF(1,2); -int skprintf(const char *format, ...) __PF(1,2); #endif /* _LIB_H_ */ diff --git a/kern/lib/kprintf.c b/kern/lib/kprintf.c index 397355e..c8a3baa 100644 --- a/kern/lib/kprintf.c +++ b/kern/lib/kprintf.c @@ -149,7 +149,7 @@ tkprintf(const char *fmt, ...) int chars; va_list ap; - if (KERNEL_SECRET != 0) { + if (strcmp(KERNEL_SECRET, "") != 0) { return 0; } @@ -160,26 +160,6 @@ tkprintf(const char *fmt, ...) return chars; } -/* - * kprintf variant that prints the automated secret - */ -int -skprintf(const char *fmt, ...) -{ - int chars; - va_list ap; - - if (KERNEL_SECRET != 0) { - kprintf("SECRET=%llu ", KERNEL_SECRET); - } - - va_start(ap, fmt); - chars = vkprintf(fmt, ap); - va_end(ap); - - return chars; -} - /* * panic() is for fatal errors. It prints the printf arguments it's * passed and then halts the system. diff --git a/kern/test/synchtest.c b/kern/test/synchtest.c index cc401c3..b08eca7 100644 --- a/kern/test/synchtest.c +++ b/kern/test/synchtest.c @@ -98,9 +98,9 @@ static void success(bool status, const char *msg) { if (status == SUCCESS) { - skprintf("%s: SUCCESS\n", msg); + kprintf("%s%s: SUCCESS\n", KERNEL_SECRET, msg); } else { - skprintf("%s: FAIL\n", msg); + kprintf("%s%s: FAIL\n", KERNEL_SECRET, msg); } }