summaryrefslogtreecommitdiffstats
path: root/tests/stubs/console.c
diff options
context:
space:
mode:
authorJakub Czapiga <jacz@semihalf.com>2021-09-09 12:11:39 +0200
committerFelix Held <felix-coreboot@felixheld.de>2021-09-13 14:00:57 +0000
commit29faa8a5a25a843bd3495ca8c6b9aad79e143033 (patch)
treec8a2846ddac7574c1620a3cfe11a0606ef90506a /tests/stubs/console.c
parentc54e22c589b4974b6e94e11f363f99e726661026 (diff)
downloadcoreboot-29faa8a5a25a843bd3495ca8c6b9aad79e143033.tar.gz
coreboot-29faa8a5a25a843bd3495ca8c6b9aad79e143033.tar.bz2
coreboot-29faa8a5a25a843bd3495ca8c6b9aad79e143033.zip
tests/stubs/console: Allow enabling printk to print to stdout
By adding TEST_PRINT=1 to <test-name>-config field or by passing it as a parameter to make one can enable printing in printk() and vprintk(). This can be helpful when developing unit tests. Note, that to effectively enable or disable printk() printing to stdout, test(s) have to be recompiled. Signed-off-by: Jakub Czapiga <jacz@semihalf.com> Change-Id: Ibdec8bb128f42ba4d9cb8bbb4a8c5159a2b52ac5 Reviewed-on: https://review.coreboot.org/c/coreboot/+/57526 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Yu-Ping Wu <yupingso@google.com> Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
Diffstat (limited to 'tests/stubs/console.c')
-rw-r--r--tests/stubs/console.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/stubs/console.c b/tests/stubs/console.c
index bd4020971638..14b3e7105648 100644
--- a/tests/stubs/console.c
+++ b/tests/stubs/console.c
@@ -3,14 +3,28 @@
#include <console/console.h>
#include <stdarg.h>
#include <stdio.h>
+#include <tests/test.h>
+
+#ifndef TEST_PRINT
+#define TEST_PRINT 0
+#endif
int printk(int msg_level, const char *fmt, ...)
{
+#if TEST_PRINT
+ va_list v;
+ va_start(v, fmt);
+ vprint_message(fmt, v);
+ va_end(v);
+#endif
return 0;
}
int vprintk(int msg_level, const char *fmt, va_list args)
{
+#if TEST_PRINT
+ vprint_message(fmt, args);
+#endif
return 0;
}