From 9ca8e9a633501c3ec3c95d2576b795eee8d9b1cc Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Sun, 14 Feb 2021 14:50:44 -0500 Subject: make 'make test' able to run unit test harnesses This adds a couple of make targets to do unit tests that are linked to libc: test-FOO : builds and runs test-FOO for any test-FOO.c test : builds and runs all test-FOO tests Note that building and running this test does not quite work yet /on this branch/. In order to do that, we need some cleanups and reorganizing that I don't want to push just yet, which can be found on https://github.com/rhboot/shim/tree/test-reorg Signed-off-by: Peter Jones --- shim.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'shim.h') diff --git a/shim.h b/shim.h index 55b0aa28..0a6c8cfa 100644 --- a/shim.h +++ b/shim.h @@ -26,15 +26,21 @@ #endif #endif +#ifndef SHIM_UNIT_TEST #include #include #undef uefi_call_wrapper #include #include +#endif #include #include +#ifdef SHIM_UNIT_TEST +#include "include/test.h" +#endif + #ifdef __x86_64__ #ifndef DEFAULT_LOADER #define DEFAULT_LOADER L"\\grubx64.efi" @@ -222,6 +228,7 @@ verify_buffer (char *data, int datasize, PE_COFF_LOADER_IMAGE_CONTEXT *context, UINT8 *sha256hash, UINT8 *sha1hash); +#ifndef SHIM_UNIT_TEST #define perror_(file, line, func, fmt, ...) ({ \ UINTN __perror_ret = 0; \ if (!in_protocol) \ @@ -233,5 +240,9 @@ verify_buffer (char *data, int datasize, perror_(__FILE__, __LINE__ - 1, __func__, fmt, ##__VA_ARGS__) #define LogError(fmt, ...) \ LogError_(__FILE__, __LINE__ - 1, __func__, fmt, ##__VA_ARGS__) +#else +#define perror(fmt, ...) +#define LogError(fmt, ...) +#endif #endif /* SHIM_H_ */ -- cgit v1.2.3