mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2024-12-25 15:20:25 +00:00
Update references to test helpers
Replace: * tests/src -> framework/tests/src * tests/include -> framework/tests/include Except for occurrences of: * tests/src/test_helpers (since this only contains ssl_helpers.c) * tests/src/test_certs.h * tests/include/alt_dummy Signed-off-by: David Horstmann <david.horstmann@arm.com>
This commit is contained in:
parent
531adafb0a
commit
5b93d97b95
@ -398,7 +398,7 @@ add_subdirectory(library)
|
||||
add_subdirectory(pkgconfig)
|
||||
|
||||
#
|
||||
# The C files in tests/src directory contain test code shared among test suites
|
||||
# The C files in framework/tests/src directory contain test code shared among test suites
|
||||
# and programs. This shared test code is compiled and linked to test suites and
|
||||
# programs objects as a set of compiled objects. The compiled objects are NOT
|
||||
# built into a library that the test suite and program objects would link
|
||||
@ -417,7 +417,7 @@ if(ENABLE_TESTING OR ENABLE_PROGRAMS)
|
||||
add_library(mbedtls_test_helpers OBJECT ${MBEDTLS_TEST_HELPER_FILES})
|
||||
set_base_compile_options(mbedtls_test_helpers)
|
||||
target_include_directories(mbedtls_test_helpers
|
||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tests/include
|
||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/framework/tests/include
|
||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tf-psa-crypto/include
|
||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tf-psa-crypto/drivers/builtin/include
|
||||
|
@ -2416,9 +2416,9 @@ Changes
|
||||
fit into the record buffer. Previously, such extensions were silently
|
||||
dropped. As a consequence, the TLS handshake now fails when the output
|
||||
buffer is not large enough to hold the ClientHello.
|
||||
* The unit tests now rely on header files in tests/include/test and source
|
||||
files in tests/src. When building with make or cmake, the files in
|
||||
tests/src are compiled and the resulting object linked into each test
|
||||
* The unit tests now rely on header files in framework/tests/include/test and source
|
||||
files in framework/tests/src. When building with make or cmake, the files in
|
||||
framework/tests/src are compiled and the resulting object linked into each test
|
||||
executable.
|
||||
* The ECP module, enabled by `MBEDTLS_ECP_C`, now depends on
|
||||
`MBEDTLS_CTR_DRBG_C` or `MBEDTLS_HMAC_DRBG_C` for some side-channel
|
||||
|
6
Makefile
6
Makefile
@ -222,8 +222,8 @@ C_SOURCE_FILES = $(wildcard \
|
||||
tf-psa-crypto/drivers/*/*/*/*.c \
|
||||
tf-psa-crypto/drivers/*/*/*/*/*.c \
|
||||
programs/*/*.[hc] \
|
||||
tests/include/*/*.h tests/include/*/*/*.h \
|
||||
tests/src/*.c tests/src/*/*.c \
|
||||
framework/tests/include/*/*.h framework/tests/include/*/*/*.h \
|
||||
framework/tests/src/*.c framework/tests/src/*/*.c \
|
||||
tests/suites/*.function \
|
||||
tf-psa-crypto/tests/suites/*.function \
|
||||
)
|
||||
@ -241,5 +241,5 @@ cscope.in.out cscope.po.out cscope.out: $(C_SOURCE_FILES)
|
||||
cscope -bq -u -Iinclude -Ilibrary -Itf-psa-crypto/core \
|
||||
-Itf-psa-crypto/include \
|
||||
-Itf-psa-crypto/drivers/builtin/src \
|
||||
$(patsubst %,-I%,$(wildcard tf-psa-crypto/drivers/*/include)) -Itests/include $(C_SOURCE_FILES)
|
||||
$(patsubst %,-I%,$(wildcard tf-psa-crypto/drivers/*/include)) -Iframework/tests/include $(C_SOURCE_FILES)
|
||||
.PHONY: cscope global
|
||||
|
@ -78,7 +78,7 @@ Summary of files to modify when adding a new algorithm or key type:
|
||||
|
||||
* [ ] PSA Crypto API draft, if not already done — [PSA standardization](#psa-standardization)
|
||||
* [ ] `include/psa/crypto_values.h` or `include/psa/crypto_extra.h` — [New functions and macros](#new-functions-and-macros)
|
||||
* [ ] `include/psa/crypto_config.h`, `tests/include/test/drivers/crypto_config_test_driver_extension.h` — [Preprocessor symbols](#preprocessor-symbols)
|
||||
* [ ] `include/psa/crypto_config.h`, `framework/tests/include/test/drivers/crypto_config_test_driver_extension.h` — [Preprocessor symbols](#preprocessor-symbols)
|
||||
* Occasionally `library/check_crypto_config.h` — [Preprocessor symbols](#preprocessor-symbols)
|
||||
* [ ] `include/mbedtls/config_psa.h` — [Preprocessor symbols](#preprocessor-symbols)
|
||||
* [ ] `library/psa_crypto.c`, `library/psa_crypto_*.[hc]` — [Implementation of the mechanisms](#implementation-of-the-mechanisms)
|
||||
@ -128,7 +128,7 @@ Each cryptographic mechanism is optional and can be selected by the application
|
||||
* If `MBEDTLS_PSA_CRYPTO_CONFIG` is disabled: based on the available mechanisms in Mbed TLS, deduced from `mbedtls/mbedtls_config.h` by code in `include/mbedtls/config_psa.h`.
|
||||
* if `MBEDTLS_PSA_CRYPTO_CONFIG` is enabled: in the application configuration file `include/psa/crypto_config.h` (or `MBEDTLS_PSA_CRYPTO_CONFIG_FILE`, plus `MBEDTLS_PSA_CRYPTO_USER_CONFIG_FILE`), with code in `include/mbedtls/config_psa.h` deducing the necessary underlying `MBEDTLS_xxx` symbols.
|
||||
* For transparent keys (keys that are not in a secure element), the feature is implemented by Mbed TLS if `MBEDTLS_PSA_BUILTIN_ttt_xxx` is defined, and by an accelerator driver if `MBEDTLS_PSA_ACCEL_ttt_xxx` is defined. `MBEDTLS_PSA_BUILTIN_ttt_xxx` constants are set in `include/mbedtls/config_psa.h` based on the application requests `PSA_WANT_ttt_xxx` and the accelerator driver declarations `MBEDTLS_PSA_ACCEL_ttt_xxx`.
|
||||
* For the testing of the driver dispatch code, `tests/include/test/drivers/crypto_config_test_driver_extension.h` sets additional `MBEDTLS_PSA_ACCEL_xxx` symbols.
|
||||
* For the testing of the driver dispatch code, `framework/tests/include/test/drivers/crypto_config_test_driver_extension.h` sets additional `MBEDTLS_PSA_ACCEL_xxx` symbols.
|
||||
|
||||
For more details, see *[Conditional inclusion of cryptographic mechanism through the PSA API in Mbed TLS](../proposed/psa-conditional-inclusion-c.html)*.
|
||||
|
||||
|
@ -661,7 +661,7 @@ psa_status_t mem_poison_psa_aead_update(psa_aead_operation_t *operation,
|
||||
#define psa_aead_update(...) mem_poison_psa_aead_update(__VA_ARGS__)
|
||||
```
|
||||
|
||||
There now exists a more generic mechanism for making exactly this kind of transformation - the PSA test wrappers, which exist in the files `tests/include/test/psa_test_wrappers.h` and `tests/src/psa_test_wrappers.c`. These are wrappers around all PSA functions that allow testing code to be inserted at the start and end of a PSA function call.
|
||||
There now exists a more generic mechanism for making exactly this kind of transformation - the PSA test wrappers, which exist in the files `framework/tests/include/test/psa_test_wrappers.h` and `framework/tests/src/psa_test_wrappers.c`. These are wrappers around all PSA functions that allow testing code to be inserted at the start and end of a PSA function call.
|
||||
|
||||
The test wrappers are generated by a script, although they are not automatically generated as part of the build process. Instead, they are checked into source control and must be manually updated when functions change by running `framework/scripts/generate_psa_wrappers.py`.
|
||||
|
||||
|
@ -132,8 +132,8 @@ The driver interface includes a fallback mechanism so that a driver can reject a
|
||||
|
||||
We have test drivers that are enabled by `PSA_CRYPTO_DRIVER_TEST` (not present
|
||||
in the usual config files, must be defined on the command line or in a custom
|
||||
config file). Those test drivers are implemented in `tests/src/drivers/*.c`
|
||||
and their API is declared in `tests/include/test/drivers/*.h`.
|
||||
config file). Those test drivers are implemented in `framework/tests/src/drivers/*.c`
|
||||
and their API is declared in `framework/tests/include/test/drivers/*.h`.
|
||||
|
||||
We have two test driver registered: `mbedtls_test_opaque_driver` and
|
||||
`mbedtls_test_transparent_driver`. These are described in
|
||||
@ -212,7 +212,7 @@ desired.)
|
||||
The renaming process for `libtestdriver1` is implemented as a few Perl regexes
|
||||
applied to a copy of the library code, see the `libtestdriver1.a` target in
|
||||
`tests/Makefile`. Another modification that's done to this copy is appending
|
||||
`tests/include/test/drivers/crypto_config_test_driver_extension.h` to
|
||||
`framework/tests/include/test/drivers/crypto_config_test_driver_extension.h` to
|
||||
`psa/crypto_config.h`. This file reverses the `ACCEL`/`BUILTIN` macros so that
|
||||
`libtestdriver1` includes as built-in what the main `libmbedcrypto.a` will
|
||||
have accelerated; see that file's initial comment for details. See also
|
||||
|
@ -43,7 +43,7 @@ There are three deliverables for creating such a driver. These are:
|
||||
- C header files defining the types required by the driver description. The names of these header files are declared in the driver description file.
|
||||
- An object file compiled for the target platform defining the functions required by the driver description. Implementations may allow drivers to be provided as source files and compiled with the core instead of being pre-compiled.
|
||||
|
||||
The Mbed TLS driver tests for the aforementioned entry points provide examples of how these deliverables can be implemented. For sample driver description JSON files, see [`mbedtls_test_transparent_driver.json`](https://github.com/Mbed-TLS/mbedtls/blob/development/scripts/data_files/driver_jsons/mbedtls_test_transparent_driver.json) or [`mbedtls_test_opaque_driver.json`](https://github.com/Mbed-TLS/mbedtls/blob/development/scripts/data_files/driver_jsons/mbedtls_test_transparent_driver.json). The header file required by the driver description is [`test_driver.h`](https://github.com/Mbed-TLS/mbedtls/blob/development/tests/include/test/drivers/test_driver.h). As Mbed TLS tests are built from source, there is no object file for the test driver. However, the source for the test driver can be found under `tests/src/drivers`.
|
||||
The Mbed TLS driver tests for the aforementioned entry points provide examples of how these deliverables can be implemented. For sample driver description JSON files, see [`mbedtls_test_transparent_driver.json`](https://github.com/Mbed-TLS/mbedtls/blob/development/scripts/data_files/driver_jsons/mbedtls_test_transparent_driver.json) or [`mbedtls_test_opaque_driver.json`](https://github.com/Mbed-TLS/mbedtls/blob/development/scripts/data_files/driver_jsons/mbedtls_test_transparent_driver.json). The header file required by the driver description is [`test_driver.h`](https://github.com/Mbed-TLS/mbedtls/blob/development/framework/tests/include/test/drivers/test_driver.h). As Mbed TLS tests are built from source, there is no object file for the test driver. However, the source for the test driver can be found under `framework/tests/src/drivers`.
|
||||
|
||||
### Process for Entry Points where auto-generation is not implemented
|
||||
|
||||
|
@ -7,7 +7,7 @@ foreach(exe IN LISTS executables)
|
||||
add_executable(${exe} ${exe}.c $<TARGET_OBJECTS:tf_psa_crypto_test>)
|
||||
set_base_compile_options(${exe})
|
||||
target_link_libraries(${exe} ${tfpsacrypto_target} ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include)
|
||||
target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../framework/tests/include)
|
||||
endforeach()
|
||||
|
||||
install(TARGETS ${executables}
|
||||
|
@ -7,7 +7,7 @@ foreach(exe IN LISTS executables)
|
||||
add_executable(${exe} ${exe}.c $<TARGET_OBJECTS:tf_psa_crypto_test>)
|
||||
set_base_compile_options(${exe})
|
||||
target_link_libraries(${exe} ${tfpsacrypto_target} ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include)
|
||||
target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../framework/tests/include)
|
||||
endforeach()
|
||||
|
||||
install(TARGETS ${executables}
|
||||
|
@ -41,7 +41,7 @@ foreach(exe IN LISTS executables_no_common_c executables_with_common_c)
|
||||
|
||||
add_executable(${exe} ${exe_sources})
|
||||
set_base_compile_options(${exe})
|
||||
target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include)
|
||||
target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../framework/tests/include)
|
||||
|
||||
if (NOT FUZZINGENGINE_LIB)
|
||||
target_link_libraries(${exe} ${libs})
|
||||
|
@ -9,7 +9,7 @@ foreach(exe IN LISTS executables)
|
||||
add_executable(${exe} ${exe}.c $<TARGET_OBJECTS:tf_psa_crypto_test>)
|
||||
set_base_compile_options(${exe})
|
||||
target_link_libraries(${exe} ${tfpsacrypto_target} ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include)
|
||||
target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../framework/tests/include)
|
||||
endforeach()
|
||||
|
||||
install(TARGETS ${executables}
|
||||
|
@ -8,7 +8,7 @@ foreach(exe IN LISTS executables_mbedtls)
|
||||
add_executable(${exe} ${exe}.c $<TARGET_OBJECTS:tf_psa_crypto_test>)
|
||||
set_base_compile_options(${exe})
|
||||
target_link_libraries(${exe} ${mbedtls_target} ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include)
|
||||
target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../framework/tests/include)
|
||||
endforeach()
|
||||
|
||||
set(executables_mbedcrypto
|
||||
@ -37,7 +37,7 @@ foreach(exe IN LISTS executables_mbedcrypto)
|
||||
add_executable(${exe} ${exe}.c $<TARGET_OBJECTS:tf_psa_crypto_test>)
|
||||
set_base_compile_options(${exe})
|
||||
target_link_libraries(${exe} ${tfpsacrypto_target} ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include)
|
||||
target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../framework/tests/include)
|
||||
endforeach()
|
||||
|
||||
install(TARGETS ${executables_mbedtls} ${executables_mbedcrypto}
|
||||
|
@ -31,7 +31,7 @@ foreach(exe IN LISTS executables)
|
||||
add_executable(${exe} ${exe}.c $<TARGET_OBJECTS:tf_psa_crypto_test>)
|
||||
set_base_compile_options(${exe})
|
||||
target_link_libraries(${exe} ${tfpsacrypto_target} ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include)
|
||||
target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../framework/tests/include)
|
||||
endforeach()
|
||||
|
||||
target_include_directories(psa_constant_names PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
@ -8,7 +8,7 @@ foreach(exe IN LISTS executables)
|
||||
add_executable(${exe} ${exe}.c $<TARGET_OBJECTS:tf_psa_crypto_test>)
|
||||
set_base_compile_options(${exe})
|
||||
target_link_libraries(${exe} ${tfpsacrypto_target} ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include)
|
||||
target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../framework/tests/include)
|
||||
endforeach()
|
||||
|
||||
install(TARGETS ${executables}
|
||||
|
@ -42,7 +42,7 @@ foreach(exe IN LISTS executables)
|
||||
${extra_sources})
|
||||
set_base_compile_options(${exe})
|
||||
target_link_libraries(${exe} ${libs} ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include)
|
||||
target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../framework/tests/include)
|
||||
if(exe STREQUAL "ssl_client2" OR exe STREQUAL "ssl_server2")
|
||||
if(GEN_FILES)
|
||||
add_dependencies(${exe} generate_query_config_c)
|
||||
@ -55,7 +55,7 @@ endforeach()
|
||||
if(THREADS_FOUND)
|
||||
add_executable(ssl_pthread_server ssl_pthread_server.c $<TARGET_OBJECTS:tf_psa_crypto_test>)
|
||||
set_base_compile_options(ssl_pthread_server)
|
||||
target_include_directories(ssl_pthread_server PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include)
|
||||
target_include_directories(ssl_pthread_server PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../framework/tests/include)
|
||||
target_link_libraries(ssl_pthread_server ${libs} ${CMAKE_THREAD_LIBS_INIT})
|
||||
list(APPEND executables ssl_pthread_server)
|
||||
endif(THREADS_FOUND)
|
||||
|
@ -86,7 +86,7 @@ foreach(exe IN LISTS executables_libs executables_mbedcrypto)
|
||||
${extra_sources})
|
||||
set_base_compile_options(${exe})
|
||||
target_include_directories(${exe}
|
||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include)
|
||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../framework/tests/include)
|
||||
target_include_directories(${exe}
|
||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../library
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../tf-psa-crypto/core)
|
||||
|
@ -261,7 +261,7 @@ static void mutex_lock_not_initialized(const char *name)
|
||||
mbedtls_threading_mutex_t mutex;
|
||||
memset(&mutex, 0, sizeof(mutex));
|
||||
/* This mutex usage error is detected by our test framework's mutex usage
|
||||
* verification framework. See tests/src/threading_helpers.c. Other
|
||||
* verification framework. See framework/tests/src/threading_helpers.c. Other
|
||||
* threading implementations (e.g. pthread without our instrumentation)
|
||||
* might consider this normal usage. */
|
||||
TEST_ASSERT(mbedtls_mutex_lock(&mutex) == 0);
|
||||
@ -277,7 +277,7 @@ static void mutex_unlock_not_initialized(const char *name)
|
||||
mbedtls_threading_mutex_t mutex;
|
||||
memset(&mutex, 0, sizeof(mutex));
|
||||
/* This mutex usage error is detected by our test framework's mutex usage
|
||||
* verification framework. See tests/src/threading_helpers.c. Other
|
||||
* verification framework. See framework/tests/src/threading_helpers.c. Other
|
||||
* threading implementations (e.g. pthread without our instrumentation)
|
||||
* might consider this normal usage. */
|
||||
TEST_ASSERT(mbedtls_mutex_unlock(&mutex) == 0);
|
||||
@ -293,7 +293,7 @@ static void mutex_free_not_initialized(const char *name)
|
||||
mbedtls_threading_mutex_t mutex;
|
||||
memset(&mutex, 0, sizeof(mutex));
|
||||
/* This mutex usage error is detected by our test framework's mutex usage
|
||||
* verification framework. See tests/src/threading_helpers.c. Other
|
||||
* verification framework. See framework/tests/src/threading_helpers.c. Other
|
||||
* threading implementations (e.g. pthread without our instrumentation)
|
||||
* might consider this normal usage. */
|
||||
mbedtls_mutex_free(&mutex);
|
||||
@ -307,7 +307,7 @@ static void mutex_double_init(const char *name)
|
||||
mbedtls_threading_mutex_t mutex;
|
||||
mbedtls_mutex_init(&mutex);
|
||||
/* This mutex usage error is detected by our test framework's mutex usage
|
||||
* verification framework. See tests/src/threading_helpers.c. Other
|
||||
* verification framework. See framework/tests/src/threading_helpers.c. Other
|
||||
* threading implementations (e.g. pthread without our instrumentation)
|
||||
* might consider this normal usage. */
|
||||
mbedtls_mutex_init(&mutex);
|
||||
@ -323,7 +323,7 @@ static void mutex_double_free(const char *name)
|
||||
mbedtls_mutex_init(&mutex);
|
||||
mbedtls_mutex_free(&mutex);
|
||||
/* This mutex usage error is detected by our test framework's mutex usage
|
||||
* verification framework. See tests/src/threading_helpers.c. Other
|
||||
* verification framework. See framework/tests/src/threading_helpers.c. Other
|
||||
* threading implementations (e.g. pthread without our instrumentation)
|
||||
* might consider this normal usage. */
|
||||
mbedtls_mutex_free(&mutex);
|
||||
@ -338,7 +338,7 @@ static void mutex_leak(const char *name)
|
||||
mbedtls_mutex_init(&mutex);
|
||||
#endif
|
||||
/* This mutex usage error is detected by our test framework's mutex usage
|
||||
* verification framework. See tests/src/threading_helpers.c. Other
|
||||
* verification framework. See framework/tests/src/threading_helpers.c. Other
|
||||
* threading implementations (e.g. pthread without our instrumentation)
|
||||
* might consider this normal usage. */
|
||||
}
|
||||
@ -361,7 +361,7 @@ typedef struct {
|
||||
* - "msan": triggers MSan (Memory Sanitizer).
|
||||
* - "pthread": requires MBEDTLS_THREADING_PTHREAD and MBEDTLS_TEST_HOOKS,
|
||||
* which enables MBEDTLS_TEST_MUTEX_USAGE internally in the test
|
||||
* framework (see tests/src/threading_helpers.c).
|
||||
* framework (see framework/tests/src/threading_helpers.c).
|
||||
*/
|
||||
const char *platform;
|
||||
|
||||
|
@ -13,7 +13,7 @@ foreach(exe IN LISTS executables)
|
||||
add_executable(${exe} ${exe}.c $<TARGET_OBJECTS:tf_psa_crypto_test>)
|
||||
set_base_compile_options(${exe})
|
||||
target_link_libraries(${exe} ${libs} ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include)
|
||||
target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../framework/tests/include)
|
||||
endforeach()
|
||||
|
||||
install(TARGETS ${executables}
|
||||
|
@ -16,7 +16,7 @@ foreach(exe IN LISTS executables)
|
||||
add_executable(${exe} ${exe}.c $<TARGET_OBJECTS:tf_psa_crypto_test>)
|
||||
set_base_compile_options(${exe})
|
||||
target_link_libraries(${exe} ${libs} ${CMAKE_THREAD_LIBS_INIT})
|
||||
target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include)
|
||||
target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../framework/tests/include)
|
||||
endforeach()
|
||||
|
||||
target_link_libraries(cert_app ${mbedtls_target})
|
||||
|
@ -28,10 +28,10 @@ my $psa_header_dir = 'tf-psa-crypto/include/psa';
|
||||
my $tls_source_dir = 'library';
|
||||
my $crypto_core_source_dir = 'tf-psa-crypto/core';
|
||||
my $crypto_source_dir = 'tf-psa-crypto/drivers/builtin/src';
|
||||
my $test_source_dir = 'tests/src';
|
||||
my $test_header_dir = 'tests/include/test';
|
||||
my $test_drivers_header_dir = 'tests/include/test/drivers';
|
||||
my $test_drivers_source_dir = 'tests/src/drivers';
|
||||
my $test_source_dir = 'framework/tests/src';
|
||||
my $test_header_dir = 'framework/tests/include/test';
|
||||
my $test_drivers_header_dir = 'framework/tests/include/test/drivers';
|
||||
my $test_drivers_source_dir = 'framework/tests/src/drivers';
|
||||
|
||||
my @thirdparty_header_dirs = qw(
|
||||
tf-psa-crypto/drivers/everest/include/everest
|
||||
@ -53,7 +53,7 @@ my @include_directories = qw(
|
||||
tf-psa-crypto/drivers/everest/include/everest
|
||||
tf-psa-crypto/drivers/everest/include/everest/vs2013
|
||||
tf-psa-crypto/drivers/everest/include/everest/kremlib
|
||||
tests/include
|
||||
framework/tests/include
|
||||
);
|
||||
my $include_directories = join(';', map {"../../$_"} @include_directories);
|
||||
|
||||
|
@ -245,10 +245,10 @@ $(BINARIES): %$(EXEXT): %.c $(MBEDLIBS) $(TEST_OBJS_DEPS) $(MBEDTLS_TEST_OBJS)
|
||||
echo " CC $<"
|
||||
$(CC) $(LOCAL_CFLAGS) $(CFLAGS) $< $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@
|
||||
|
||||
LOCAL_CRYPTO_CFLAGS = $(patsubst -I./include, -I../../tests/include, $(patsubst -I../%,-I../../%, $(LOCAL_CFLAGS)))
|
||||
LOCAL_CRYPTO_CFLAGS = $(patsubst -I./include, -I../../framework/tests/include, $(patsubst -I../%,-I../../%, $(LOCAL_CFLAGS)))
|
||||
LOCAL_CRYPTO_LDFLAGS = $(patsubst -L../library, -L../../library, \
|
||||
$(patsubst -L../tests/%, -L../../tests/%, \
|
||||
$(patsubst ./src/%,../../tests/src/%, $(LOCAL_LDFLAGS))))
|
||||
$(patsubst ./src/%,../../framework/tests/src/%, $(LOCAL_LDFLAGS))))
|
||||
$(CRYPTO_BINARIES): %$(EXEXT): %.c $(MBEDLIBS) $(TEST_OBJS_DEPS) $(MBEDTLS_TEST_OBJS)
|
||||
echo " CC $<"
|
||||
cd ../tf-psa-crypto/tests && $(CC) $(LOCAL_CRYPTO_CFLAGS) $(CFLAGS) $(subst $(EXEXT),,$(@F)).c $(LOCAL_CRYPTO_LDFLAGS) $(LDFLAGS) -o $(@F)
|
||||
|
@ -164,7 +164,7 @@ else
|
||||
fi
|
||||
|
||||
check scripts/generate_psa_constants.py programs/psa/psa_constant_names_generated.c
|
||||
check framework/scripts/generate_test_keys.py tests/src/test_keys.h
|
||||
check framework/scripts/generate_test_keys.py framework/tests/src/test_keys.h
|
||||
check scripts/generate_driver_wrappers.py ${crypto_core_dir}/psa_crypto_driver_wrappers.h \
|
||||
${crypto_core_dir}/psa_crypto_driver_wrappers_no_static.c
|
||||
|
||||
@ -185,4 +185,4 @@ fi
|
||||
# Generated files that are present in the repository even in the development
|
||||
# branch. (This is intended to be temporary, until the generator scripts are
|
||||
# fully reviewed and the build scripts support a generated header file.)
|
||||
check framework/scripts/generate_psa_wrappers.py tests/include/test/psa_test_wrappers.h tests/src/psa_test_wrappers.c
|
||||
check framework/scripts/generate_psa_wrappers.py framework/tests/include/test/psa_test_wrappers.h framework/tests/src/psa_test_wrappers.c
|
||||
|
@ -247,7 +247,7 @@ class CodeParser():
|
||||
"library/*.h",
|
||||
"tf-psa-crypto/core/*.h",
|
||||
"tf-psa-crypto/drivers/builtin/src/*.h",
|
||||
"tests/include/test/drivers/*.h",
|
||||
"framework/tests/include/test/drivers/*.h",
|
||||
])
|
||||
all_macros["private"] = self.parse_macros([
|
||||
"library/*.c",
|
||||
|
@ -18,7 +18,7 @@ component_build_tfm_armcc () {
|
||||
cp configs/config-tfm.h "$CONFIG_H"
|
||||
|
||||
msg "build: TF-M config, armclang armv7-m thumb2"
|
||||
helper_armc6_build_test "--target=arm-arm-none-eabi -march=armv7-m -mthumb -Os -std=c99 -Werror -Wall -Wextra -Wwrite-strings -Wpointer-arith -Wimplicit-fallthrough -Wshadow -Wvla -Wformat=2 -Wno-format-nonliteral -Wshadow -Wasm-operand-widths -Wunused -I../tests/include/spe"
|
||||
helper_armc6_build_test "--target=arm-arm-none-eabi -march=armv7-m -mthumb -Os -std=c99 -Werror -Wall -Wextra -Wwrite-strings -Wpointer-arith -Wimplicit-fallthrough -Wshadow -Wvla -Wformat=2 -Wno-format-nonliteral -Wshadow -Wasm-operand-widths -Wunused -I../framework/tests/include/spe"
|
||||
}
|
||||
|
||||
test_build_opt () {
|
||||
|
@ -67,12 +67,12 @@ component_build_psa_crypto_spm () {
|
||||
# We can only compile, not link, since our test and sample programs
|
||||
# aren't equipped for the modified names used when MBEDTLS_PSA_CRYPTO_SPM
|
||||
# is active.
|
||||
make CC=gcc CFLAGS='-Werror -Wall -Wextra -I../tests/include/spe' lib
|
||||
make CC=gcc CFLAGS='-Werror -Wall -Wextra -I../framework/tests/include/spe' lib
|
||||
|
||||
# Check that if a symbol is renamed by crypto_spe.h, the non-renamed
|
||||
# version is not present.
|
||||
echo "Checking for renamed symbols in the library"
|
||||
check_renamed_symbols tests/include/spe/crypto_spe.h library/libmbedcrypto.a
|
||||
check_renamed_symbols framework/tests/include/spe/crypto_spe.h library/libmbedcrypto.a
|
||||
}
|
||||
|
||||
# The goal of this component is to build a configuration where:
|
||||
@ -537,7 +537,7 @@ component_test_crypto_for_psa_service () {
|
||||
component_build_crypto_baremetal () {
|
||||
msg "build: make, crypto only, baremetal config"
|
||||
scripts/config.py crypto_baremetal
|
||||
make CFLAGS="-O1 -Werror -I$PWD/tests/include/baremetal-override/"
|
||||
make CFLAGS="-O1 -Werror -I$PWD/framework/tests/include/baremetal-override/"
|
||||
are_empty_libraries library/libmbedx509.* library/libmbedtls.*
|
||||
}
|
||||
|
||||
@ -1437,7 +1437,7 @@ component_test_tfm_config_p256m_driver_accel_ec () {
|
||||
common_tfm_config
|
||||
|
||||
# Build crypto library
|
||||
make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -I../tests/include/spe" LDFLAGS="$ASAN_CFLAGS"
|
||||
make CC=$ASAN_CC CFLAGS="$ASAN_CFLAGS -I../framework/tests/include/spe" LDFLAGS="$ASAN_CFLAGS"
|
||||
|
||||
# Make sure any built-in EC alg was not re-enabled by accident (additive config)
|
||||
not grep mbedtls_ecdsa_ ${BUILTIN_SRC_PATH}/ecdsa.o
|
||||
@ -1471,7 +1471,7 @@ component_test_tfm_config_no_p256m () {
|
||||
echo "#undef MBEDTLS_PSA_P256M_DRIVER_ENABLED" >> "$CONFIG_H"
|
||||
|
||||
msg "build: TF-M config without p256m"
|
||||
make CFLAGS='-Werror -Wall -Wextra -I../tests/include/spe' tests
|
||||
make CFLAGS='-Werror -Wall -Wextra -I../framework/tests/include/spe' tests
|
||||
|
||||
# Check that p256m was not built
|
||||
not grep p256_ecdsa_ library/libmbedcrypto.a
|
||||
@ -2649,7 +2649,7 @@ component_test_psa_crypto_drivers () {
|
||||
msg "build: full + test drivers dispatching to builtins"
|
||||
scripts/config.py full
|
||||
loc_cflags="$ASAN_CFLAGS -DPSA_CRYPTO_DRIVER_TEST -DMBEDTLS_CONFIG_ADJUST_TEST_ACCELERATORS"
|
||||
loc_cflags="${loc_cflags} -I../tests/include"
|
||||
loc_cflags="${loc_cflags} -I../framework/tests/include"
|
||||
|
||||
make CC=$ASAN_CC CFLAGS="${loc_cflags}" LDFLAGS="$ASAN_CFLAGS"
|
||||
|
||||
@ -2690,8 +2690,8 @@ component_build_psa_alt_headers () {
|
||||
# Build the library and some programs.
|
||||
# Don't build the fuzzers to avoid having to go through hoops to set
|
||||
# a correct include path for programs/fuzz/Makefile.
|
||||
make CFLAGS="-I ../tests/include/alt-extra -DMBEDTLS_PSA_CRYPTO_PLATFORM_FILE='\"psa/crypto_platform_alt.h\"' -DMBEDTLS_PSA_CRYPTO_STRUCT_FILE='\"psa/crypto_struct_alt.h\"'" lib
|
||||
make -C programs -o fuzz CFLAGS="-I ../tests/include/alt-extra -DMBEDTLS_PSA_CRYPTO_PLATFORM_FILE='\"psa/crypto_platform_alt.h\"' -DMBEDTLS_PSA_CRYPTO_STRUCT_FILE='\"psa/crypto_struct_alt.h\"'"
|
||||
make CFLAGS="-I ../framework/tests/include/alt-extra -DMBEDTLS_PSA_CRYPTO_PLATFORM_FILE='\"psa/crypto_platform_alt.h\"' -DMBEDTLS_PSA_CRYPTO_STRUCT_FILE='\"psa/crypto_struct_alt.h\"'" lib
|
||||
make -C programs -o fuzz CFLAGS="-I ../framework/tests/include/alt-extra -DMBEDTLS_PSA_CRYPTO_PLATFORM_FILE='\"psa/crypto_platform_alt.h\"' -DMBEDTLS_PSA_CRYPTO_STRUCT_FILE='\"psa/crypto_struct_alt.h\"'"
|
||||
|
||||
# Check that we're getting the alternative include guards and not the
|
||||
# original include guards.
|
||||
|
@ -219,7 +219,7 @@ component_test_full_deprecated_warning () {
|
||||
component_build_baremetal () {
|
||||
msg "build: make, baremetal config"
|
||||
scripts/config.py baremetal
|
||||
make CFLAGS="-O1 -Werror -I$PWD/tests/include/baremetal-override/"
|
||||
make CFLAGS="-O1 -Werror -I$PWD/framework/tests/include/baremetal-override/"
|
||||
}
|
||||
|
||||
support_build_baremetal () {
|
||||
@ -238,11 +238,11 @@ component_build_tfm () {
|
||||
cp configs/config-tfm.h "$CONFIG_H"
|
||||
|
||||
msg "build: TF-M config, clang, armv7-m thumb2"
|
||||
make lib CC="clang" CFLAGS="--target=arm-linux-gnueabihf -march=armv7-m -mthumb -Os -std=c99 -Werror -Wall -Wextra -Wwrite-strings -Wpointer-arith -Wimplicit-fallthrough -Wshadow -Wvla -Wformat=2 -Wno-format-nonliteral -Wshadow -Wasm-operand-widths -Wunused -I../tests/include/spe"
|
||||
make lib CC="clang" CFLAGS="--target=arm-linux-gnueabihf -march=armv7-m -mthumb -Os -std=c99 -Werror -Wall -Wextra -Wwrite-strings -Wpointer-arith -Wimplicit-fallthrough -Wshadow -Wvla -Wformat=2 -Wno-format-nonliteral -Wshadow -Wasm-operand-widths -Wunused -I../framework/tests/include/spe"
|
||||
|
||||
msg "build: TF-M config, gcc native build"
|
||||
make clean
|
||||
make lib CC="gcc" CFLAGS="-Os -std=c99 -Werror -Wall -Wextra -Wwrite-strings -Wpointer-arith -Wshadow -Wvla -Wformat=2 -Wno-format-nonliteral -Wshadow -Wformat-signedness -Wlogical-op -I../tests/include/spe"
|
||||
make lib CC="gcc" CFLAGS="-Os -std=c99 -Werror -Wall -Wextra -Wwrite-strings -Wpointer-arith -Wshadow -Wvla -Wformat=2 -Wno-format-nonliteral -Wshadow -Wformat-signedness -Wlogical-op -I../framework/tests/include/spe"
|
||||
}
|
||||
|
||||
component_test_malloc_0_null () {
|
||||
|
@ -12,7 +12,7 @@
|
||||
skip_suites_without_constant_flow () {
|
||||
# Skip the test suites that don't have any constant-flow annotations.
|
||||
# This will need to be adjusted if we ever start declaring things as
|
||||
# secret from macros or functions inside tests/include or tests/src.
|
||||
# secret from macros or functions inside framework/tests/include or framework/tests/src.
|
||||
SKIP_TEST_SUITES=$(
|
||||
git -C tests/suites grep -L TEST_CF_ 'test_suite_*.function' |
|
||||
sed 's/test_suite_//; s/\.function$//' |
|
||||
|
@ -30,7 +30,7 @@ typedef struct mbedtls_threading_mutex_t {
|
||||
pthread_mutex_t MBEDTLS_PRIVATE(mutex);
|
||||
|
||||
/* WARNING - state should only be accessed when holding the mutex lock in
|
||||
* tests/src/threading_helpers.c, otherwise corruption can occur.
|
||||
* framework/tests/src/threading_helpers.c, otherwise corruption can occur.
|
||||
* state will be 0 after a failed init or a free, and nonzero after a
|
||||
* successful init. This field is for testing only and thus not considered
|
||||
* part of the public API of Mbed TLS and may change without notice.*/
|
||||
|
@ -61,7 +61,7 @@ static void threading_mutex_init_pthread(mbedtls_threading_mutex_t *mutex)
|
||||
* this here in a thread safe manner without a significant performance
|
||||
* hit, so state transitions are checked in tests only via the state
|
||||
* variable. Please make sure any new mutex that gets added is exercised in
|
||||
* tests; see tests/src/threading_helpers.c for more details. */
|
||||
* tests; see framework/tests/src/threading_helpers.c for more details. */
|
||||
(void) pthread_mutex_init(&mutex->mutex, NULL);
|
||||
}
|
||||
|
||||
|
@ -303,7 +303,7 @@ function(add_test_suite suite_name)
|
||||
# files are automatically included because the library targets declare
|
||||
# them as PUBLIC.
|
||||
target_include_directories(test_suite_${data_name}
|
||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include
|
||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../framework/tests/include
|
||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../library
|
||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../core
|
||||
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../drivers/builtin/src)
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Functional testing of functions in the constant_time module.
|
||||
*
|
||||
* The tests are instrumented with #TEST_CF_SECRET and #TEST_CF_PUBLIC
|
||||
* (see tests/include/test/constant_flow.h) so that running the tests
|
||||
* (see framework/tests/include/test/constant_flow.h) so that running the tests
|
||||
* under MSan or Valgrind will detect a non-constant-time implementation.
|
||||
*/
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user