summaryrefslogtreecommitdiff
path: root/include/test.mk
diff options
context:
space:
mode:
authorSteve McIntyre <steve@einval.com>2021-03-23 23:49:46 +0000
committerSteve McIntyre <steve@einval.com>2021-03-23 23:49:46 +0000
commit031e5cce385d3f96b1caa1d53495332a7eb03749 (patch)
treeb4988dfbd191b2242b9294e24075b39a608b1155 /include/test.mk
parent7bf7a6d0852382bb645119b18df3ff461aaba247 (diff)
downloadefi-boot-shim-upstream/15.3.tar.gz
efi-boot-shim-upstream/15.3.zip
New upstream version 15.3upstream/15.3
Diffstat (limited to 'include/test.mk')
-rw-r--r--include/test.mk58
1 files changed, 58 insertions, 0 deletions
diff --git a/include/test.mk b/include/test.mk
new file mode 100644
index 00000000..62cf983a
--- /dev/null
+++ b/include/test.mk
@@ -0,0 +1,58 @@
+# 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 \
+ $(shell $(CC) -Werror=nonnull-compare -E -x c /dev/null >/dev/null 2>&1 && echo -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)"
+
+$(wildcard test-*.c) :: %.c : test-random.h
+$(patsubst %.c,%,$(wildcard test-*.c)) :: | test-random.h
+$(patsubst %.c,%.o,$(wildcard test-*.c)) : | test-random.h
+
+test-random.h:
+ dd if=/dev/urandom bs=512 count=17 of=random.bin
+ xxd -i random.bin test-random.h
+
+test-sbat_FILES = csv.c
+test-str_FILES = lib/string.c
+
+tests := $(patsubst %.c,%,$(wildcard test-*.c))
+
+$(tests) :: test-% : test.c test-%.c $(test-%_FILES)
+ $(CC) $(CFLAGS) -o $@ $^ $(wildcard $*.c) $(test-$*_FILES)
+ $(VALGRIND) ./$@
+
+test : $(tests)
+
+clean :
+ @rm -vf test-random.h random.bin
+
+all : clean test
+
+.PHONY: $(tests) all test clean
+.SECONDARY: random.bin
+
+# vim:ft=make