tests: Create an include folder
Create an include folder dedicated to include files for tests. With the upcoming work on tests for PSA crypto drivers the number of includes specific to tests is going to increase significantly thus create a dedicated folder. Don't put the include files in the include folder but in include/test folder. This way test headers can be included using a test/* path pattern as mbedtls and psa headers are included using an mbedtls/* and psa/* path pattern. This makes explicit the scope of the test headers. Move the existing includes for tests into include/test and update the code and build systems (make and cmake) accordingly. Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
parent
87a51aa08e
commit
02c78b7825
2
tests/.gitignore
vendored
2
tests/.gitignore
vendored
@ -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
|
||||
|
@ -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})
|
||||
|
@ -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
|
||||
|
@ -22,7 +22,7 @@
|
||||
#ifndef PSA_CRYPTO_HELPERS_H
|
||||
#define PSA_CRYPTO_HELPERS_H
|
||||
|
||||
#include "psa_helpers.h"
|
||||
#include "test/psa_helpers.h"
|
||||
|
||||
#include <psa/crypto.h>
|
||||
|
@ -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 */
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 <stdio.h>
|
||||
#else
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "psa_crypto_helpers.h"
|
||||
#include "test/psa_crypto_helpers.h"
|
||||
|
||||
/* END_HEADER */
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* BEGIN_HEADER */
|
||||
#include <stdint.h>
|
||||
|
||||
#include "psa_crypto_helpers.h"
|
||||
#include "test/psa_crypto_helpers.h"
|
||||
/* Some tests in this module configure entropy sources. */
|
||||
#include "psa_crypto_invasive.h"
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "psa_crypto_helpers.h"
|
||||
#include "test/psa_crypto_helpers.h"
|
||||
#include "psa_crypto_storage.h"
|
||||
|
||||
#include "mbedtls/md.h"
|
||||
|
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* BEGIN_HEADER */
|
||||
#include <stdint.h>
|
||||
|
||||
#include "psa_crypto_helpers.h"
|
||||
#include "test/psa_crypto_helpers.h"
|
||||
#include "psa_crypto_storage.h"
|
||||
|
||||
typedef enum
|
||||
|
@ -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. */
|
||||
|
Loading…
Reference in New Issue
Block a user