[Skiboot] [PATCH] secvar/test: use vendored mbedtls instead of host
Eric Richter
erichte at linux.ibm.com
Fri Oct 2 02:37:42 AEST 2020
Linking against the host mbedtls introduces problems if the host does not
have the library, or if the host has a different version installed.
This patch changes the tests to instead build mbedtls from the version
included in skiboot using the host compiler, removing the dependency on
external mbedtls.
Signed-off-by: Eric Richter <erichte at linux.ibm.com>
---
NOTE: This patch should be applied on top of the PATCH v6/v6a series[1] for
the secvar driver implementation.
[1] https://lists.ozlabs.org/pipermail/skiboot/2020-September/017278.html
libstb/secvar/test/Makefile.check | 15 ++++++++++-----
libstb/secvar/test/secvar-test-secboot-tpm.c | 2 --
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/libstb/secvar/test/Makefile.check b/libstb/secvar/test/Makefile.check
index 3a99f8d8..b2cafcf6 100644
--- a/libstb/secvar/test/Makefile.check
+++ b/libstb/secvar/test/Makefile.check
@@ -32,15 +32,20 @@ $(SECVAR_TEST:%=%-check) : %-check: %
$(call QTEST, RUN-TEST ,$(VALGRIND) $<, $<)
@$(RM) -f secboot.img
-HOSTMBEDFLAGS += -lmbedcrypto -lmbedx509
+HOST_MBEDTLS_OBJS=$(MBEDTLS_OBJS:%.o=$(CRYPTO_DIR)/%.host.o)
+HOST_MBEDTLS_CFLAGS=-I$(SRC)/$(LIBSTB_DIR)/crypto -DMBEDTLS_CONFIG_FILE='<mbedtls-config.h>'
+HOST_MBEDTLS_CFLAGS+= -Wno-unused-function -Wno-suggest-attribute=const
+%.host.o: %.c
+ $(call Q, HOSTCC , $(HOSTCC) $(HOSTCFLAGS) $(HOST_MBEDTLS_CFLAGS) -O0 -g -c -o $@ $<, $<)
+
$(SECVAR_TEST) : core/test/stubs.o
-$(SECVAR_TEST) : % : %.c
- $(call Q, HOSTCC ,$(HOSTCC) $(HOSTCFLAGS) $(HOSTMBEDFLAGS) -O0 -g -I include -I . -I libfdt -o $@ $< core/test/stubs.o, $<)
+$(SECVAR_TEST) : % : %.c $(HOST_MBEDTLS_OBJS)
+ $(call Q, HOSTCC ,$(HOSTCC) $(HOSTCFLAGS) -O0 -g -I include -I . -I libfdt -o $@ $< $(HOST_MBEDTLS_OBJS) core/test/stubs.o, $<)
-$(SECVAR_TEST:%=%-gcov): %-gcov : %.c %
- $(call Q, HOSTCC ,$(HOSTCC) $(HOSTCFLAGS) $(HOSTGCOVCFLAGS) $(HOSTMBEDFLAGS) -I include -I . -I libfdt -lgcov -o $@ $< core/test/stubs.o, $<)
+$(SECVAR_TEST:%=%-gcov): %-gcov : %.c % $(HOST_MBEDTLS_OBJS)
+ $(call Q, HOSTCC ,$(HOSTCC) $(HOSTCFLAGS) $(HOSTGCOVCFLAGS) -I include -I . -I libfdt -lgcov -o $@ $< $(HOST_MBEDTLS_OBJS) core/test/stubs.o, $<)
-include $(wildcard libstb/secvar/test/*.d)
diff --git a/libstb/secvar/test/secvar-test-secboot-tpm.c b/libstb/secvar/test/secvar-test-secboot-tpm.c
index e883b884..798ca281 100644
--- a/libstb/secvar/test/secvar-test-secboot-tpm.c
+++ b/libstb/secvar/test/secvar-test-secboot-tpm.c
@@ -4,8 +4,6 @@
#include "secvar_common_test.c"
#include "../storage/secboot_tpm.c"
#include "../storage/fakenv_ops.c"
-#include "../../crypto/mbedtls/library/sha256.c"
-#include "../../crypto/mbedtls/library/platform_util.c"
#include "../secvar_util.c"
char *secboot_buffer;
--
2.28.0
More information about the Skiboot
mailing list