1# 2#Component Makefile 3# 4 5LS_TESTDIR := ../libsodium/test/default 6LS_TEST_OBJDIR := libsodium/test/default 7 8TESTS_ALL ?= 0 9 10ifeq ($(TESTS_ALL),1) 11$(info not linking libsodium tests, use 'TEST_COMPONENTS=libsodium' to test it) 12else 13COMPONENT_ADD_LDFLAGS = -Wl,--whole-archive -l$(COMPONENT_NAME) -Wl,--no-whole-archive 14endif # TESTS_ALL 15 16COMPONENT_SRCDIRS := . $(LS_TESTDIR) 17 18COMPONENT_PRIV_INCLUDEDIRS := $(LS_TESTDIR)/../quirks 19 20COMPONENT_OBJS := test_sodium.o 21 22# The libsodium test suite is designed to be run each test case as an executable on a desktop computer and uses 23# filesytem to write & then compare contents of each file. 24# 25# For now, use their "BROWSER_TEST" mode with these hacks so that 26# multiple test cases can be combined into one ELF file. 27# 28# Run each test case from test_sodium.c as CASENAME_xmain(). 29 30define sodium_testcase 31# This would generate 'warning "main" redefined' warnings at runtime, which are 32# silenced here. Only other solution involves patching libsodium's cmptest.h. 33$(LS_TEST_OBJDIR)/$(1).o: CFLAGS+=-Dxmain=$(1)_xmain -Dmain=$(1)_main 34$(LS_TEST_OBJDIR)/$(1).o: CPPFLAGS+=-Wp,-w 35COMPONENT_OBJS += $(LS_TEST_OBJDIR)/$(1).o 36endef 37 38TEST_CASES := chacha20 aead_chacha20poly1305 box box2 ed25519_convert sign hash 39 40$(foreach case,$(TEST_CASES),$(eval $(call sodium_testcase,$(case)))) 41 42# this seems odd, but it prevents the libsodium test harness from 43# trying to write to a file! 44CFLAGS += -DBROWSER_TESTS 45