diff --git a/tests/.gitignore b/tests/.gitignore index fbbd0dfe2e..805287eb25 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -8,4 +8,4 @@ data_files/hmac_drbg_seed data_files/ctr_drbg_seed data_files/entropy_seed -/instrument_record_status.h +include/test/instrument_record_status.h diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index bd5ed8328f..cc5a9c67d7 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -46,7 +46,7 @@ function(add_test_suite suite_name) DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/generate_test_code.py mbedtls ${CMAKE_CURRENT_SOURCE_DIR}/suites/helpers.function ${CMAKE_CURRENT_SOURCE_DIR}/suites/main_test.function ${CMAKE_CURRENT_SOURCE_DIR}/suites/host_test.function ${CMAKE_CURRENT_SOURCE_DIR}/suites/test_suite_${suite_name}.function ${CMAKE_CURRENT_SOURCE_DIR}/suites/test_suite_${data_name}.data ) - include_directories(${CMAKE_CURRENT_SOURCE_DIR}) + include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) add_executable(test_suite_${data_name} test_suite_${data_name}.c) target_link_libraries(test_suite_${data_name} ${libs}) if(${data_name} MATCHES ${SKIP_TEST_SUITES_REGEX}) diff --git a/tests/Makefile b/tests/Makefile index e74bf95489..e027e127cc 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -6,7 +6,7 @@ CFLAGS ?= -O2 WARNING_CFLAGS ?= -Wall -Wextra LDFLAGS ?= -LOCAL_CFLAGS = $(WARNING_CFLAGS) -I../include -I../library -D_FILE_OFFSET_BITS=64 +LOCAL_CFLAGS = $(WARNING_CFLAGS) -I./include -I../include -I../library -D_FILE_OFFSET_BITS=64 LOCAL_LDFLAGS = -L../library \ -lmbedtls$(SHARED_SUFFIX) \ -lmbedx509$(SHARED_SUFFIX) \ @@ -110,9 +110,9 @@ $(BINARIES): %$(EXEXT): %.c $(DEP) $(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ # Some test suites require additional header files. -$(filter test_suite_psa_crypto%, $(BINARIES)): psa_crypto_helpers.h +$(filter test_suite_psa_crypto%, $(BINARIES)): include/test/psa_crypto_helpers.h $(addprefix embedded_,$(filter test_suite_psa_crypto%, $(APPS))): embedded_%: TESTS/mbedtls/%/psa_crypto_helpers.h -$(filter test_suite_psa_%, $(BINARIES)): psa_helpers.h +$(filter test_suite_psa_%, $(BINARIES)): include/test/psa_helpers.h $(addprefix embedded_,$(filter test_suite_psa_%, $(APPS))): embedded_%: TESTS/mbedtls/%/psa_helpers.h clean: @@ -152,7 +152,7 @@ $(EMBEDDED_TESTS): embedded_%: suites/$$(firstword $$(subst ., ,$$*)).function s generate-target-tests: $(EMBEDDED_TESTS) define copy_header_to_target -TESTS/mbedtls/$(1)/$(2): $(2) +TESTS/mbedtls/$(1)/$(2): include/test/$(2) echo " Copy ./$$@" ifndef WINDOWS mkdir -p $$(@D) @@ -163,11 +163,11 @@ else endif endef -$(foreach app, $(APPS), $(foreach file, $(wildcard *.h), \ +$(foreach app, $(APPS), $(foreach file, $(notdir $(wildcard include/test/*.h)), \ $(eval $(call copy_header_to_target,$(app),$(file))))) ifdef RECORD_PSA_STATUS_COVERAGE_LOG -$(BINARIES): instrument_record_status.h -instrument_record_status.h: ../include/psa/crypto.h Makefile +$(BINARIES): include/test/instrument_record_status.h +include/test/instrument_record_status.h: ../include/psa/crypto.h Makefile sed <../include/psa/crypto.h >$@ -n 's/^psa_status_t \([A-Za-z0-9_]*\)(.*/#define \1(...) RECORD_STATUS("\1", \1(__VA_ARGS__))/p' endif diff --git a/tests/psa_crypto_helpers.h b/tests/include/test/psa_crypto_helpers.h similarity index 99% rename from tests/psa_crypto_helpers.h rename to tests/include/test/psa_crypto_helpers.h index 19303de570..1dd6084337 100644 --- a/tests/psa_crypto_helpers.h +++ b/tests/include/test/psa_crypto_helpers.h @@ -22,7 +22,7 @@ #ifndef PSA_CRYPTO_HELPERS_H #define PSA_CRYPTO_HELPERS_H -#include "psa_helpers.h" +#include "test/psa_helpers.h" #include diff --git a/tests/psa_helpers.h b/tests/include/test/psa_helpers.h similarity index 100% rename from tests/psa_helpers.h rename to tests/include/test/psa_helpers.h diff --git a/tests/suites/test_suite_cipher.function b/tests/suites/test_suite_cipher.function index 8405f69c7a..7834073142 100644 --- a/tests/suites/test_suite_cipher.function +++ b/tests/suites/test_suite_cipher.function @@ -10,7 +10,7 @@ #endif #if defined(MBEDTLS_USE_PSA_CRYPTO) -#include "psa_crypto_helpers.h" +#include "test/psa_crypto_helpers.h" #endif /* END_HEADER */ diff --git a/tests/suites/test_suite_pk.function b/tests/suites/test_suite_pk.function index d88ca5454f..a67cb45645 100644 --- a/tests/suites/test_suite_pk.function +++ b/tests/suites/test_suite_pk.function @@ -17,7 +17,7 @@ #if defined(MBEDTLS_USE_PSA_CRYPTO) #include "mbedtls/psa_util.h" -#include "psa_crypto_helpers.h" +#include "test/psa_crypto_helpers.h" #define PSA_INIT( ) PSA_ASSERT( psa_crypto_init( ) ) #else /* Define empty macros so that we can use them in the preamble and teardown diff --git a/tests/suites/test_suite_psa_crypto.function b/tests/suites/test_suite_psa_crypto.function index bc95f6fb0a..ae4045c74f 100644 --- a/tests/suites/test_suite_psa_crypto.function +++ b/tests/suites/test_suite_psa_crypto.function @@ -9,7 +9,7 @@ * uses mbedtls_ctr_drbg internally. */ #include "mbedtls/ctr_drbg.h" -#include "psa_crypto_helpers.h" +#include "test/psa_crypto_helpers.h" /* Tests that require more than 128kB of RAM plus change have this symbol * as a dependency. Currently we always define this symbol, so the tests diff --git a/tests/suites/test_suite_psa_crypto_entropy.function b/tests/suites/test_suite_psa_crypto_entropy.function index 8538d6d8df..66c241e5e4 100644 --- a/tests/suites/test_suite_psa_crypto_entropy.function +++ b/tests/suites/test_suite_psa_crypto_entropy.function @@ -4,7 +4,7 @@ #include "mbedtls/entropy.h" #include "mbedtls/entropy_poll.h" -#include "psa_crypto_helpers.h" +#include "test/psa_crypto_helpers.h" #if defined(MBEDTLS_PSA_ITS_FILE_C) #include #else diff --git a/tests/suites/test_suite_psa_crypto_hash.function b/tests/suites/test_suite_psa_crypto_hash.function index d50ff5ad27..6c577c06af 100644 --- a/tests/suites/test_suite_psa_crypto_hash.function +++ b/tests/suites/test_suite_psa_crypto_hash.function @@ -2,7 +2,7 @@ #include -#include "psa_crypto_helpers.h" +#include "test/psa_crypto_helpers.h" /* END_HEADER */ diff --git a/tests/suites/test_suite_psa_crypto_init.function b/tests/suites/test_suite_psa_crypto_init.function index 3283ac9f6d..fd4ff21fc5 100644 --- a/tests/suites/test_suite_psa_crypto_init.function +++ b/tests/suites/test_suite_psa_crypto_init.function @@ -1,7 +1,7 @@ /* BEGIN_HEADER */ #include -#include "psa_crypto_helpers.h" +#include "test/psa_crypto_helpers.h" /* Some tests in this module configure entropy sources. */ #include "psa_crypto_invasive.h" diff --git a/tests/suites/test_suite_psa_crypto_persistent_key.function b/tests/suites/test_suite_psa_crypto_persistent_key.function index e2d87efd88..49ce964fb9 100644 --- a/tests/suites/test_suite_psa_crypto_persistent_key.function +++ b/tests/suites/test_suite_psa_crypto_persistent_key.function @@ -9,7 +9,7 @@ #include -#include "psa_crypto_helpers.h" +#include "test/psa_crypto_helpers.h" #include "psa_crypto_storage.h" #include "mbedtls/md.h" diff --git a/tests/suites/test_suite_psa_crypto_se_driver_hal.function b/tests/suites/test_suite_psa_crypto_se_driver_hal.function index f95f7e5265..9f44b884b6 100644 --- a/tests/suites/test_suite_psa_crypto_se_driver_hal.function +++ b/tests/suites/test_suite_psa_crypto_se_driver_hal.function @@ -1,5 +1,5 @@ /* BEGIN_HEADER */ -#include "psa_crypto_helpers.h" +#include "test/psa_crypto_helpers.h" #include "psa/crypto_se_driver.h" #include "psa_crypto_se.h" diff --git a/tests/suites/test_suite_psa_crypto_se_driver_hal_mocks.function b/tests/suites/test_suite_psa_crypto_se_driver_hal_mocks.function index f6acb07271..ef50a68140 100644 --- a/tests/suites/test_suite_psa_crypto_se_driver_hal_mocks.function +++ b/tests/suites/test_suite_psa_crypto_se_driver_hal_mocks.function @@ -1,5 +1,5 @@ /* BEGIN_HEADER */ -#include "psa_crypto_helpers.h" +#include "test/psa_crypto_helpers.h" #include "psa/crypto_se_driver.h" #include "psa_crypto_se.h" diff --git a/tests/suites/test_suite_psa_crypto_slot_management.function b/tests/suites/test_suite_psa_crypto_slot_management.function index 4c824f7de6..a9c7f04592 100644 --- a/tests/suites/test_suite_psa_crypto_slot_management.function +++ b/tests/suites/test_suite_psa_crypto_slot_management.function @@ -1,7 +1,7 @@ /* BEGIN_HEADER */ #include -#include "psa_crypto_helpers.h" +#include "test/psa_crypto_helpers.h" #include "psa_crypto_storage.h" typedef enum diff --git a/tests/suites/test_suite_psa_its.function b/tests/suites/test_suite_psa_its.function index 04a735a29c..b6cc488a6f 100644 --- a/tests/suites/test_suite_psa_its.function +++ b/tests/suites/test_suite_psa_its.function @@ -7,7 +7,7 @@ #include "../library/psa_crypto_its.h" -#include "psa_helpers.h" +#include "test/psa_helpers.h" /* Internal definitions of the implementation, copied for the sake of * some of the tests and of the cleanup code. */