summaryrefslogtreecommitdiff
path: root/shim.h
diff options
context:
space:
mode:
authorPeter Jones <pjones@redhat.com>2021-02-14 14:50:44 -0500
committerPeter Jones <pjones@redhat.com>2021-02-25 10:15:14 -0500
commit9ca8e9a633501c3ec3c95d2576b795eee8d9b1cc (patch)
tree00bb38ceba093b70cb1f54a85dac69c4e3de7532 /shim.h
parent73322ba087d10d06b0656816bf4b7ba80b02c751 (diff)
downloadefi-boot-shim-9ca8e9a633501c3ec3c95d2576b795eee8d9b1cc.tar.gz
efi-boot-shim-9ca8e9a633501c3ec3c95d2576b795eee8d9b1cc.zip
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 <pjones@redhat.com>
Diffstat (limited to 'shim.h')
-rw-r--r--shim.h11
1 files changed, 11 insertions, 0 deletions
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 <efi.h>
#include <efilib.h>
#undef uefi_call_wrapper
#include <efierr.h>
#include <efiip.h>
+#endif
#include <stddef.h>
#include <stdint.h>
+#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_ */