summaryrefslogtreecommitdiff
path: root/include/test.mk
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 /include/test.mk
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 'include/test.mk')
-rw-r--r--include/test.mk45
1 files changed, 45 insertions, 0 deletions
diff --git a/include/test.mk b/include/test.mk
new file mode 100644
index 00000000..f70fdaa9
--- /dev/null
+++ b/include/test.mk
@@ -0,0 +1,45 @@
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+# test.mk - makefile to make local test programs
+#
+
+.SUFFIXES:
+
+CC = gcc
+VALGRIND ?=
+DEBUG_PRINTS ?= 0
+CFLAGS = -O2 -ggdb -std=gnu11 \
+ -isystem $(TOPDIR)/include/system \
+ $(EFI_INCLUDES) \
+ -Iinclude -iquote . \
+ -fshort-wchar -flto -fno-builtin \
+ -Wall \
+ -Wextra \
+ -Wsign-compare \
+ -Wno-deprecated-declarations \
+ -Wno-pointer-sign \
+ -Wno-unused \
+ -Werror \
+ -Werror=nonnull \
+ -Werror=nonnull-compare \
+ $(ARCH_DEFINES) \
+ -DEFI_FUNCTION_WRAPPER \
+ -DGNU_EFI_USE_MS_ABI -DPAGE_SIZE=4096 \
+ -DSHIM_UNIT_TEST \
+ "-DDEFAULT_DEBUG_PRINT_STATE=$(DEBUG_PRINTS)"
+
+tests := $(patsubst %.c,%,$(wildcard test-*.c))
+
+$(tests) :: test-% : test.c test-%.c $(test-%_FILES)
+ $(CC) $(CFLAGS) -o $@ $^ $(wildcard $*.c) $(test-$*_FILES)
+ $(VALGRIND) ./$@
+
+test : $(tests)
+
+all : test
+
+clean :
+
+.PHONY: $(tests) all test clean
+
+# vim:ft=make