component.mk 1.4 KB

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