diff --git a/tests/Makefile.inc b/tests/Makefile.inc index fa5faab973..5027dd894b 100644 --- a/tests/Makefile.inc +++ b/tests/Makefile.inc @@ -55,6 +55,10 @@ TEST_CFLAGS += -D__TEST__ TEST_CFLAGS += -I$(cmockasrc)/include +ifneq ($(filter-out 0,$(TEST_PRINT)),) +TEST_CFLAGS += -DTEST_PRINT=1 +endif + # Link against Cmocka TEST_LDFLAGS := -L$(cmockaobj)/src -lcmocka -Wl,-rpath=$(cmockaobj)/src TEST_LDFLAGS += -Wl,--gc-sections diff --git a/tests/stubs/console.c b/tests/stubs/console.c index bd40209716..14b3e71056 100644 --- a/tests/stubs/console.c +++ b/tests/stubs/console.c @@ -3,14 +3,28 @@ #include #include #include +#include + +#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; }