Test: Secure side tests for the split build
TF-M builds as an external project feeded by TFM_TEST_REPO_PATH.
Having TFM_TEST_REPO_PATH in the build options, main TF-M repo adds
add_subdirectory(${TFM_TEST_REPO_PATH}/tests)
to include testing compoannent on secure side.
Signed-off-by: Anton Komlev <anton.komlev@arm.com>
Change-Id: Id9c4db3031aa266ff408ac932bd62bbd3d8dd079
diff --git a/app_ns_test/CMakeLists.txt b/app_ns_test/CMakeLists.txt
deleted file mode 100644
index d66ece8..0000000
--- a/app_ns_test/CMakeLists.txt
+++ /dev/null
@@ -1,56 +0,0 @@
-#-------------------------------------------------------------------------------
-# Copyright (c) 2023, Arm Limited. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
-#
-#-------------------------------------------------------------------------------
-cmake_minimum_required(VERSION 3.15)
-
-if (NOT DEFINED CONFIG_SPE_PATH OR NOT EXISTS ${CONFIG_SPE_PATH})
- message(FATAL_ERROR "CONFIG_SPE_PATH = ${CONFIG_SPE_PATH} is not defined or incorrect. Please provide full path to TF-M build artifacts using -DCONFIG_SPE_PATH=")
-endif()
-
-if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)
- set(CROSS_COMPILE arm-none-eabi)
- set(CMAKE_TOOLCHAIN_FILE ${CONFIG_SPE_PATH}/cmake/toolchain_ns_GNUARM.cmake)
-endif()
-
-if (NOT DEFINED TFM_TEST_PATH)
- set(TFM_TEST_PATH ${CMAKE_SOURCE_DIR}/../test)
-endif()
-
-set(TFM_NS_REG_TEST ON)
-set(NS ON)
-set(TEST_NS ON)
-#------------------------------------------------------------------------------
-
-list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/../cmake)
-list(APPEND CMAKE_MODULE_PATH ${CONFIG_SPE_PATH}/cmake)
-
-project(tfm_ns LANGUAGES C)
-
-add_executable(tfm_ns)
-
-add_subdirectory(../ns_interface ${CMAKE_BINARY_DIR}/ns_interface)
-add_subdirectory(../test ${CMAKE_BINARY_DIR}/tests)
-
-include(../test/config/set_config.cmake)
-
-############################# TFM NS main app ##################################
-
-target_sources(tfm_ns
- PRIVATE
- test_app.c
-)
-
-target_link_libraries(tfm_ns
- PRIVATE
- tfm_test_broker
- tfm_ns_tests
- tfm_test_framework_common
-)
-
-set_target_properties(tfm_ns PROPERTIES
- SUFFIX ".axf"
- RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
-)
diff --git a/app_test_ns/CMakeLists.txt b/app_test_ns/CMakeLists.txt
new file mode 100644
index 0000000..7845d39
--- /dev/null
+++ b/app_test_ns/CMakeLists.txt
@@ -0,0 +1,67 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2023, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+cmake_minimum_required(VERSION 3.15)
+
+if (NOT DEFINED CONFIG_SPE_PATH OR NOT EXISTS ${CONFIG_SPE_PATH})
+ message(FATAL_ERROR "CONFIG_SPE_PATH = ${CONFIG_SPE_PATH} is not defined or incorrect. Please provide full path to TF-M build artifacts using -DCONFIG_SPE_PATH=")
+endif()
+
+if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)
+ set(CROSS_COMPILE arm-none-eabi)
+ set(CMAKE_TOOLCHAIN_FILE ${CONFIG_SPE_PATH}/cmake/toolchain_ns_GNUARM.cmake)
+endif()
+
+#--- Test configuration --------------------------------------------------------
+# include(../test/config/default_ns_test_config.cmake)
+# Temporary hardcoded. Need better mechnism of NS tests selectoin
+
+set(TFM_NS_REG_TEST ON)
+set(NS ON)
+set(TEST_NS ON)
+
+set(TEST_NS_ATTESTATION OFF CACHE BOOL "Whether to build NS regression Attestation tests")
+set(TEST_NS_T_COSE OFF CACHE BOOL "Whether to build NS regression t_cose tests")
+set(TEST_NS_CRYPTO ON CACHE BOOL "Whether to build NS regression Crypto tests")
+set(TEST_NS_ITS ON CACHE BOOL "Whether to build NS regression ITS tests")
+set(TEST_NS_PS ON CACHE BOOL "Whether to build NS regression PS tests")
+set(TEST_NS_PLATFORM ON CACHE BOOL "Whether to build NS regression Platform tests")
+set(TEST_NS_FWU OFF CACHE BOOL "Whether to build NS regression FWU tests")
+set(TEST_NS_MULTI_CORE OFF CACHE BOOL "Whether to build NS regression multi-core tests")
+set(TEST_NS_MANAGE_NSID OFF CACHE BOOL "Whether to build NS regression NSID management tests")
+#------------------------------------------------------------------------------
+
+# Include default test configurations (this not about which test suites to enable or disable)
+include(${CMAKE_CURRENT_LIST_DIR}/test/config/default_test_config.cmake)
+
+list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/../cmake)
+list(APPEND CMAKE_MODULE_PATH ${CONFIG_SPE_PATH}/cmake)
+
+project(tfm_ns LANGUAGES C)
+
+add_executable(tfm_ns)
+
+add_subdirectory(../ns_interface ${CMAKE_BINARY_DIR}/ns_interface)
+add_subdirectory(../test ${CMAKE_BINARY_DIR}/tests)
+
+############################# TFM NS main app ##################################
+
+target_sources(tfm_ns
+ PRIVATE
+ test_app.c
+)
+
+target_link_libraries(tfm_ns
+ PRIVATE
+ tfm_test_broker
+ tfm_ns_tests
+ tfm_test_framework_common
+)
+
+set_target_properties(tfm_ns PROPERTIES
+ SUFFIX ".axf"
+ RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
+)
diff --git a/app_ns_test/test_app.c b/app_test_ns/test_app.c
similarity index 100%
rename from app_ns_test/test_app.c
rename to app_test_ns/test_app.c
diff --git a/app_test_s/CMakeLists.txt b/app_test_s/CMakeLists.txt
new file mode 100644
index 0000000..5a5a397
--- /dev/null
+++ b/app_test_s/CMakeLists.txt
@@ -0,0 +1,47 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2023, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+cmake_minimum_required(VERSION 3.15)
+
+# Force cross compilation and avoid compiler search and test
+set(CMAKE_SYSTEM_NAME Generic)
+set(CMAKE_C_COMPILER_FORCED TRUE)
+set(CMAKE_CXX_COMPILER_FORCED TRUE)
+
+project("TF-M SPE for tests" LANGUAGES C)
+
+if (NOT DEFINED CONFIG_TFM_SOURCE_PATH OR NOT EXISTS ${CONFIG_TFM_SOURCE_PATH})
+#TODO: Fetch TF-M repositry if not exists
+ message(FATAL_ERROR "CONFIG_TFM_SOURCE_PATH = ${CONFIG_TFM_SOURCE_PATH} is not defined or incorrect. Please provide full path to TF-M sources.")
+endif()
+
+if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)
+ set(CROSS_COMPILE arm-none-eabi CACHE STRING "Cross-compiler prefix")
+ set(CMAKE_TOOLCHAIN_FILE ${CONFIG_TFM_SOURCE_PATH}/toolchain_GNUARM.cmake)
+endif()
+
+if (NOT DEFINED CONFIG_TFM_REG_TESTS OR NOT EXISTS ${CONFIG_TFM_REG_TESTS})
+ message(WARNING "The default refgression test set is used. Use CONFIG_TFM_REG_TESTS argument to specify alternative configuration")
+ set(CONFIG_TFM_REG_TESTS ${CMAKE_SOURCE_DIR}/config_test.cmake)
+ endif()
+
+#------------------------------------------------------------------------------
+
+# tfm_s_test is IMPORTED to inform CMake that it has no source files.
+add_executable(tfm_s_test IMPORTED)
+
+include(ExternalProject)
+ExternalProject_Add(TF-M
+ SOURCE_DIR ${CONFIG_TFM_SOURCE_PATH}
+ BINARY_DIR build-spe
+ INSTALL_DIR api_ns
+ CMAKE_ARGS -DTFM_PLATFORM=${TFM_PLATFORM} -DTFM_TEST_REPO_PATH=${CMAKE_SOURCE_DIR}/.. -DTFM_EXTRA_CONFIG_PATH=${CONFIG_TFM_REG_TESTS} -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
+ PREFIX "temp"
+)
+
+add_dependencies(tfm_s_test TF-M)
+
+install(DIRECTORY ${CMAKE_BINARY_DIR}/build-spe/bin DESTINATION ${CMAKE_BINARY_DIR})
diff --git a/app_test_s/config_test.cmake b/app_test_s/config_test.cmake
new file mode 100644
index 0000000..b1b3512
--- /dev/null
+++ b/app_test_s/config_test.cmake
@@ -0,0 +1,34 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2023, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+# This is default configuration file for building TF-M SPE image for S+NS tests.
+# This file to be included in to TF-M build via TFM_EXTRA_CONFIG_PATH command option.
+# An alternative file can be pased for S test via CONFIG_TFM_REG_TESTS argument.
+#-------------------------------------------------------------------------------
+
+set(TEST_S ON CACHE BOOL "Whether to build S regression tests")
+set(TFM_S_REG_TEST ON CACHE BOOL "Enable S regression test")
+set(NS OFF CACHE BOOL "Enalbe NS side build")
+
+set(TEST_S_ATTESTATION ON CACHE BOOL "Whether to build S regression Attestation tests")
+set(TEST_S_CRYPTO ON CACHE BOOL "Whether to build S regression Crypto tests")
+set(TEST_S_ITS ON CACHE BOOL "Whether to build S regression ITS tests")
+set(TEST_S_PS ON CACHE BOOL "Whether to build S regression PS tests")
+set(TEST_S_PLATFORM ON CACHE BOOL "Whether to build S regression Platform tests")
+set(TEST_S_SFN_BACKEND ON CACHE BOOL "Whether to build S regression SFN tests")
+
+set(TEST_S_FWU OFF CACHE BOOL "Whether to build S regression FWU tests")
+set(TEST_S_IPC OFF CACHE BOOL "Whether to build S regression IPC tests")
+set(TEST_S_FPU OFF CACHE BOOL "Whether to build S regression FPU tests")
+
+#-------------------------------------------------------------------------------
+# Use local repositories and avoid fetching them on evey clean build.
+# A tempoarl settings to be remove later.
+#-------------------------------------------------------------------------------
+if(EXISTS ${CMAKE_SOURCE_DIR}/localrepos.cmake)
+ include(${CMAKE_SOURCE_DIR}/localrepos.cmake)
+endif()
diff --git a/log/CMakeLists.txt b/log/CMakeLists.txt
index 2ac6ceb..101c94d 100644
--- a/log/CMakeLists.txt
+++ b/log/CMakeLists.txt
@@ -7,21 +7,19 @@
############################# Ns Log ###########################################
add_library(tfm_log STATIC)
-add_library(tfm_log_interface INTERFACE)
target_sources(tfm_log
PRIVATE
tfm_log_raw.c
)
-target_include_directories(tfm_log_interface
- INTERFACE
- .
+target_include_directories(tfm_log
+ PUBLIC
+ ${CMAKE_CURRENT_SOURCE_DIR}
)
target_link_libraries(tfm_log
INTERFACE
- tfm_log_interface
platform_common_interface
PUBLIC
platform_ns
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 15053d7..d89cb53 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -21,14 +21,8 @@
framework
)
-target_link_libraries(tfm_test_framework_common
- PUBLIC
- tfm_log_interface
-)
-if(TFM_S_REG_TEST OR TFM_NS_REG_TEST)
- add_subdirectory(secure_fw)
-endif()
+add_subdirectory(secure_fw)
if(TEST_BL2)
add_subdirectory(bl2)
@@ -37,3 +31,5 @@
if(TEST_BL1_1 OR TEST_BL1_2)
add_subdirectory(bl1)
endif()
+
+include(config/check_config.cmake)
diff --git a/test/config/check_config.cmake b/test/config/check_config.cmake
index 919740c..3a26751 100644
--- a/test/config/check_config.cmake
+++ b/test/config/check_config.cmake
@@ -5,6 +5,20 @@
#
#-------------------------------------------------------------------------------
+function(tfm_invalid_config)
+ if (${ARGV})
+ string (REPLACE ";" " " ARGV_STRING "${ARGV}")
+ string (REPLACE "STREQUAL" "=" ARGV_STRING "${ARGV_STRING}")
+ string (REPLACE "GREATER" ">" ARGV_STRING "${ARGV_STRING}")
+ string (REPLACE "LESS" "<" ARGV_STRING "${ARGV_STRING}")
+ string (REPLACE "VERSION_LESS" "<" ARGV_STRING "${ARGV_STRING}")
+ string (REPLACE "EQUAL" "=" ARGV_STRING "${ARGV_STRING}")
+ string (REPLACE "IN_LIST" "in" ARGV_STRING "${ARGV_STRING}")
+
+ message(FATAL_ERROR "INVALID CONFIG: ${ARGV_STRING}")
+ endif()
+endfunction()
+
########################## Check Flags Input ###################################
tfm_invalid_config((NOT TFM_PARTITION_PROTECTED_STORAGE) AND (TEST_NS_PS OR TEST_S_PS))
diff --git a/test/config/default_test_config.cmake b/test/config/default_test_config.cmake
index 452cca6..827d2ff 100644
--- a/test/config/default_test_config.cmake
+++ b/test/config/default_test_config.cmake
@@ -5,35 +5,6 @@
#
#-------------------------------------------------------------------------------
-########################## NS test suites ######################################
-
-set(TEST_NS_ATTESTATION OFF CACHE BOOL "Whether to build NS regression Attestation tests")
-set(TEST_NS_T_COSE OFF CACHE BOOL "Whether to build NS regression t_cose tests")
-set(TEST_NS_QCBOR OFF CACHE BOOL "Whether to build NS regression QCBOR tests")
-set(TEST_NS_CRYPTO OFF CACHE BOOL "Whether to build NS regression Crypto tests")
-set(TEST_NS_ITS OFF CACHE BOOL "Whether to build NS regression ITS tests")
-set(TEST_NS_PS OFF CACHE BOOL "Whether to build NS regression PS tests")
-set(TEST_NS_PLATFORM OFF CACHE BOOL "Whether to build NS regression Platform tests")
-set(TEST_NS_FWU OFF CACHE BOOL "Whether to build NS regression FWU tests")
-set(TEST_NS_IPC OFF CACHE BOOL "Whether to build NS regression IPC tests")
-set(TEST_NS_SLIH_IRQ OFF CACHE BOOL "Whether to build NS regression Second-Level Interrupt Handling tests")
-set(TEST_NS_FLIH_IRQ OFF CACHE BOOL "Whether to build NS regression First-Level Interrupt Handling tests")
-set(TEST_NS_MULTI_CORE OFF CACHE BOOL "Whether to build NS regression multi-core tests")
-set(TEST_NS_MANAGE_NSID OFF CACHE BOOL "Whether to build NS regression NSID management tests")
-set(TEST_NS_SFN_BACKEND OFF CACHE BOOL "Whether to build NS regression SFN backend tests")
-set(TEST_NS_FPU OFF CACHE BOOL "Whether to build NS regression FPU tests")
-
-########################## S test suites #######################################
-
-set(TEST_S_ATTESTATION OFF CACHE BOOL "Whether to build S regression Attestation tests")
-set(TEST_S_CRYPTO OFF CACHE BOOL "Whether to build S regression Crypto tests")
-set(TEST_S_ITS OFF CACHE BOOL "Whether to build S regression ITS tests")
-set(TEST_S_PS OFF CACHE BOOL "Whether to build S regression PS tests")
-set(TEST_S_PLATFORM OFF CACHE BOOL "Whether to build S regression Platform tests")
-set(TEST_S_FWU OFF CACHE BOOL "Whether to build S regression FWU tests")
-set(TEST_S_IPC OFF CACHE BOOL "Whether to build S regression IPC tests")
-set(TEST_S_SFN_BACKEND OFF CACHE BOOL "Whether to build S regression SFN tests")
-
################################## PS Tests ####################################
set(PS_TEST_NV_COUNTERS ON CACHE BOOL "Use the test NV counters to test Protected Storage rollback scenarios")
@@ -69,10 +40,6 @@
set(TFM_FWU_TEST_WRITE_WITH_NULL OFF CACHE BOOL "Test psa_fwu_write with data block NULL")
set(TFM_FWU_TEST_QUERY_WITH_NULL OFF CACHE BOOL "Test psa_fwu_query with info NULL")
-############################################ FPU Tests #########################
-
-set(TEST_S_FPU OFF CACHE BOOL "Whether to build S regression FPU tests")
-
################################## Extra test suites ###########################
set(EXTRA_NS_TEST_SUITE_PATH "" CACHE PATH "List of extra non-secure test suites directories. An extra test suite folder contains source code, CMakeLists.txt and cmake configuration file")
diff --git a/test/config/set_config.cmake b/test/config/set_config.cmake
index 0407a2d..97ac8a9 100644
--- a/test/config/set_config.cmake
+++ b/test/config/set_config.cmake
@@ -59,12 +59,6 @@
set(TEST_NS_FPU OFF CACHE BOOL "Whether to build NS regression FPU tests")
endif()
-########################## Test profile ########################################
-
-if (TFM_PROFILE)
- include(${TFM_TEST_PATH}/config/profile/${TFM_PROFILE}_test.cmake)
-endif()
-
########################## SLIH/FLIH IRQ Test ##################################
# Make FLIH IRQ test as the default IRQ test
@@ -100,10 +94,10 @@
########################## Load default config #################################
if (TEST_S)
- include(${TFM_TEST_PATH}/config/default_s_test_config.cmake)
+ include(${TFM_TEST_REPO_PATH}/test/config/default_s_test_config.cmake)
endif()
if (TEST_NS)
- include(${TFM_TEST_PATH}/config/default_ns_test_config.cmake)
+include(${TFM_TEST_REPO_PATH}/test/config/default_ns_test_config.cmake)
endif()
###################### Test Partition configurations ###########################
@@ -125,5 +119,3 @@
else()
set(TEST_PARTITION_FPU_TEST OFF)
endif()
-
-include(${TFM_TEST_PATH}/config/default_test_config.cmake)
diff --git a/test/secure_fw/CMakeLists.txt b/test/secure_fw/CMakeLists.txt
index 8a9a4f4..1a55c2a 100644
--- a/test/secure_fw/CMakeLists.txt
+++ b/test/secure_fw/CMakeLists.txt
@@ -41,7 +41,47 @@
"
)
-include(secure_tests.cmake)
+if (TFM_S_REG_TEST)
+
+ # secure test services are required if any secure test is opened
+ add_subdirectory(common_test_services/tfm_secure_client_service)
+ add_subdirectory(common_test_services/tfm_secure_client_2)
+
+ add_library(tfm_test_framework_s INTERFACE)
+
+ target_link_libraries(tfm_test_framework_s
+ INTERFACE
+ psa_interface
+ tfm_test_framework_common
+ tfm_sprt
+ tfm_config
+ )
+
+ target_compile_definitions(tfm_test_framework_s
+ INTERFACE
+ USE_SP_LOG
+ $<$<BOOL:${PS_TEST_NV_COUNTERS}>:PS_TEST_NV_COUNTERS>
+ )
+
+ target_link_libraries(tfm_test_framework_common
+ PUBLIC
+ tfm_test_framework_s
+ )
+
+ add_library(tfm_s_tests STATIC)
+
+ target_sources(tfm_s_tests
+ PRIVATE
+ ${CMAKE_CURRENT_SOURCE_DIR}/secure_suites.c
+ )
+
+ target_link_libraries(tfm_s_tests
+ PUBLIC
+ tfm_test_framework_s
+ tfm_spm
+ )
+
+endif()
# Include test suites at last after other targets are setup.
add_subdirectory(suites)
diff --git a/test/secure_fw/secure_tests.cmake b/test/secure_fw/secure_tests.cmake
deleted file mode 100644
index 74fadfb..0000000
--- a/test/secure_fw/secure_tests.cmake
+++ /dev/null
@@ -1,102 +0,0 @@
-#-------------------------------------------------------------------------------
-# Copyright (c) 2021-2022, Arm Limited. All rights reserved.
-# Copyright (c) 2022 Cypress Semiconductor Corporation (an Infineon company)
-# or an affiliate of Cypress Semiconductor Corporation. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
-#
-#-------------------------------------------------------------------------------
-
-# Since the main test directory is a NS dir, this subdir is specifically made a
-# secure directory as it build the secure side tests and services
-if (EXISTS ${TARGET_PLATFORM_PATH}/preload_ns.cmake)
- include(${TARGET_PLATFORM_PATH}/preload.cmake)
- tfm_toolchain_reload_compiler()
-endif()
-
-# Install directory for non-secure interface API of test services
-# NS can pick up those interface files to build non-secure test cases
-set(TEST_SERVICE_SRC_INSTALL_DIR ${TFM_INSTALL_PATH}/interface/src/test_service)
-set(TEST_SERVICE_INC_INSTALL_DIR ${TFM_INSTALL_PATH}/interface/include/test_service)
-
-# Test services are also required by some NS regression tests.
-# Include test services at first no matter whether secure tests are enabled.
-add_subdirectory(suites/spm/ipc/service ${CMAKE_BINARY_DIR}/tf-m-tests/ipc_srv)
-add_subdirectory(suites/spm/sfn/service ${CMAKE_BINARY_DIR}/tf-m-tests/sfn_srv)
-add_subdirectory(suites/spm/irq/service ${CMAKE_BINARY_DIR}/tf-m-tests/irq_srv)
-add_subdirectory(suites/ps/service ${CMAKE_BINARY_DIR}/tf-m-tests/ps_srv)
-add_subdirectory(suites/fpu/service ${CMAKE_BINARY_DIR}/tf-m-tests/fpu_srv)
-
-if (NOT TFM_S_REG_TEST)
- return()
-endif()
-
-# secure test services are required if any secure test is opened
-add_subdirectory(common_test_services/tfm_secure_client_service ${CMAKE_BINARY_DIR}/tf-m-tests/secure_client_srv)
-add_subdirectory(common_test_services/tfm_secure_client_2 ${CMAKE_BINARY_DIR}/tf-m-tests/secure_client_2_srv)
-
-add_library(tfm_test_framework_s INTERFACE)
-add_library(tfm_s_tests INTERFACE)
-
-target_link_libraries(tfm_test_framework_s
- INTERFACE
- psa_interface
- tfm_test_framework_common
- tfm_sprt
-)
-
-target_compile_definitions(tfm_test_framework_s
- INTERFACE
- USE_SP_LOG
-)
-
-target_sources(tfm_s_tests
- INTERFACE
- ${CMAKE_CURRENT_SOURCE_DIR}/secure_suites.c
-)
-
-target_link_libraries(tfm_s_tests
- INTERFACE
- tfm_test_framework_s
- tfm_config
- tfm_spm
-)
-
-target_compile_definitions(tfm_s_tests
- INTERFACE
- $<$<BOOL:${PS_TEST_NV_COUNTERS}>:PS_TEST_NV_COUNTERS>
-)
-
-############################# Secure tests #####################################
-
-# Add secure test library targets here to inherit secure side configurations
-if (TEST_S_CRYPTO)
- add_library(tfm_test_suite_crypto_s STATIC EXCLUDE_FROM_ALL)
-endif()
-if (TEST_S_ATTESTATION)
- add_library(tfm_test_suite_attestation_s STATIC EXCLUDE_FROM_ALL)
-endif()
-if (TEST_S_ITS)
- add_library(tfm_test_suite_its_s STATIC EXCLUDE_FROM_ALL)
-endif()
-if (TEST_S_PS)
- add_library(tfm_test_suite_ps_s STATIC EXCLUDE_FROM_ALL)
-endif()
-if (TEST_S_PLATFORM)
- add_library(tfm_test_suite_platform_s STATIC EXCLUDE_FROM_ALL)
-endif()
-if (TEST_S_IPC)
- add_library(tfm_test_suite_ipc_s STATIC EXCLUDE_FROM_ALL)
-endif()
-if (TEST_S_SFN_BACKEND)
- add_library(tfm_test_suite_sfn_s STATIC EXCLUDE_FROM_ALL)
-endif()
-if (TEST_S_FWU)
- add_library(tfm_test_suite_fwu_s STATIC EXCLUDE_FROM_ALL)
-endif()
-if (TEST_S_FPU)
- add_library(tfm_test_suite_fpu_s STATIC EXCLUDE_FROM_ALL)
-endif()
-if (EXTRA_S_TEST_SUITE_PATH)
- add_library(tfm_test_suite_extra_s STATIC EXCLUDE_FROM_ALL)
-endif()
diff --git a/test/secure_fw/suites/CMakeLists.txt b/test/secure_fw/suites/CMakeLists.txt
index cda6e6d..0bf6be7 100644
--- a/test/secure_fw/suites/CMakeLists.txt
+++ b/test/secure_fw/suites/CMakeLists.txt
@@ -9,16 +9,19 @@
cmake_minimum_required(VERSION 3.13)
-# For multi-core projects, the NS app can be run on a different CPU to the
-# Secure code. To facilitate this, we once again reload the compiler to load the
-# setting for the NS CPU. Cmake settings are directory scoped so this affects
-# anything loaded from or declared in this dir.
-if (EXISTS ${TARGET_PLATFORM_PATH}/preload_ns.cmake)
- include(${TARGET_PLATFORM_PATH}/preload_ns.cmake)
- tfm_toolchain_reload_compiler()
-endif()
+add_subdirectory(spm/ipc/service)
+add_subdirectory(spm/sfn/service)
+add_subdirectory(spm/irq/service)
+add_subdirectory(ps/service)
+add_subdirectory(fpu/service)
if(TFM_NS_REG_TEST AND NS)
+
+ target_link_libraries(tfm_test_framework_common
+ PUBLIC
+ tfm_log
+ )
+
add_library(tfm_ns_tests INTERFACE)
add_library(tfm_test_framework_ns INTERFACE)
@@ -50,18 +53,6 @@
$<$<BOOL:${SYMMETRIC_INITIAL_ATTESTATION}>:SYMMETRIC_INITIAL_ATTESTATION>
$<$<BOOL:${TFM_FUZZER_TOOL_TESTS}>:TFM_FUZZER_TOOL_TESTS>
)
-else()
- # Skip building NS regresstion test suites if NS is OFF.
- # NS test flags are kept to select corresponding test services. They are
- # unset here to skip building NS regression test suites.
- get_cmake_property(CACHE_VARS CACHE_VARIABLES)
-
- foreach(CACHE_VAR ${CACHE_VARS})
- string(REGEX MATCH "^TEST_NS_.*" _NS_TEST_FOUND "${CACHE_VAR}")
- if (_NS_TEST_FOUND AND "${${CACHE_VAR}}")
- unset(${CACHE_VAR} CACHE)
- endif()
- endforeach()
endif()
# Add test suites.
@@ -70,8 +61,9 @@
add_subdirectory(crypto)
add_subdirectory(extra)
add_subdirectory(its)
-# add_subdirectory(qcbor)
add_subdirectory(ps)
+# Do we need to test these external components?
+# add_subdirectory(qcbor)
# add_subdirectory(t_cose)
add_subdirectory(platform)
add_subdirectory(fwu)
@@ -79,13 +71,3 @@
add_subdirectory(nsid)
add_subdirectory(fpu)
add_subdirectory(spm)
-
-if(TFM_FUZZER_TOOL_TESTS AND TFM_NS_REG_TEST AND NS)
- if (NOT DEFINED TFM_FUZZER_TOOL_TESTS_CMAKE_INC_PATH)
- # The location of the file needs to be defined either from command line
- # or from config cmake file.
- message(FATAL_ERROR "Incomplete build configuration: TFM_FUZZER_TOOL_TESTS_CMAKE_INC_PATH is undefined.")
- else()
- add_subdirectory(${TFM_FUZZER_TOOL_TESTS_CMAKE_INC_PATH} ${CMAKE_BINARY_DIR}/suites/tfm_fuzz)
- endif()
-endif()
diff --git a/test/secure_fw/suites/attestation/CMakeLists.txt b/test/secure_fw/suites/attestation/CMakeLists.txt
index c95a05b..657937b 100644
--- a/test/secure_fw/suites/attestation/CMakeLists.txt
+++ b/test/secure_fw/suites/attestation/CMakeLists.txt
@@ -7,10 +7,6 @@
cmake_policy(SET CMP0079 NEW)
-if (NOT TEST_NS_ATTESTATION AND NOT TEST_S_ATTESTATION)
- return()
-endif()
-
####################### Non Secure #############################################
if (TEST_NS_ATTESTATION)
@@ -64,15 +60,15 @@
####################### Secure #################################################
if (TEST_S_ATTESTATION)
- target_sources(tfm_test_suite_attestation_s
- PRIVATE
- ${CMAKE_CURRENT_SOURCE_DIR}/attest_token_test.c
- ${CMAKE_CURRENT_SOURCE_DIR}/attest_token_decode_common.c
- ${CMAKE_CURRENT_SOURCE_DIR}/ext/qcbor_util/qcbor_util.c
- $<$<BOOL:${SYMMETRIC_INITIAL_ATTESTATION}>:${CMAKE_CURRENT_SOURCE_DIR}/attest_token_decode_symmetric.c>
- $<$<BOOL:${SYMMETRIC_INITIAL_ATTESTATION}>:${CMAKE_CURRENT_SOURCE_DIR}/secure/attest_symmetric_s_interface_testsuite.c>
- $<$<NOT:$<BOOL:${SYMMETRIC_INITIAL_ATTESTATION}>>:${CMAKE_CURRENT_SOURCE_DIR}/attest_token_decode_asymmetric.c>
- $<$<NOT:$<BOOL:${SYMMETRIC_INITIAL_ATTESTATION}>>:${CMAKE_CURRENT_SOURCE_DIR}/secure/attest_asymmetric_s_interface_testsuite.c>
+
+ add_library(tfm_test_suite_attestation_s STATIC
+ ${CMAKE_CURRENT_SOURCE_DIR}/attest_token_test.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/attest_token_decode_common.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/ext/qcbor_util/qcbor_util.c
+ $<$<BOOL:${SYMMETRIC_INITIAL_ATTESTATION}>:${CMAKE_CURRENT_SOURCE_DIR}/attest_token_decode_symmetric.c>
+ $<$<BOOL:${SYMMETRIC_INITIAL_ATTESTATION}>:${CMAKE_CURRENT_SOURCE_DIR}/secure/attest_symmetric_s_interface_testsuite.c>
+ $<$<NOT:$<BOOL:${SYMMETRIC_INITIAL_ATTESTATION}>>:${CMAKE_CURRENT_SOURCE_DIR}/attest_token_decode_asymmetric.c>
+ $<$<NOT:$<BOOL:${SYMMETRIC_INITIAL_ATTESTATION}>>:${CMAKE_CURRENT_SOURCE_DIR}/secure/attest_asymmetric_s_interface_testsuite.c>
)
target_include_directories(tfm_test_suite_attestation_s
@@ -108,7 +104,7 @@
)
target_link_libraries(tfm_s_tests
- INTERFACE
+ PRIVATE
tfm_test_suite_attestation_s
)
endif()
diff --git a/test/secure_fw/suites/crypto/CMakeLists.txt b/test/secure_fw/suites/crypto/CMakeLists.txt
index 02217ff..811b2cb 100644
--- a/test/secure_fw/suites/crypto/CMakeLists.txt
+++ b/test/secure_fw/suites/crypto/CMakeLists.txt
@@ -7,10 +7,6 @@
cmake_policy(SET CMP0079 NEW)
-if (NOT TEST_NS_CRYPTO AND NOT TEST_S_CRYPTO)
- return()
-endif()
-
####################### Non Secure #############################################
if (TEST_NS_CRYPTO)
@@ -67,10 +63,10 @@
####################### Secure #################################################
if (TEST_S_CRYPTO)
- target_sources(tfm_test_suite_crypto_s
- PRIVATE
- ${CMAKE_CURRENT_SOURCE_DIR}/crypto_tests_common.c
- ${CMAKE_CURRENT_SOURCE_DIR}/secure/crypto_sec_interface_testsuite.c
+
+ add_library(tfm_test_suite_crypto_s STATIC
+ ${CMAKE_CURRENT_SOURCE_DIR}/crypto_tests_common.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/secure/crypto_sec_interface_testsuite.c
)
target_include_directories(tfm_test_suite_crypto_s
@@ -87,7 +83,7 @@
)
target_link_libraries(tfm_s_tests
- INTERFACE
+ PRIVATE
tfm_test_suite_crypto_s
)
diff --git a/test/secure_fw/suites/extra/CMakeLists.txt b/test/secure_fw/suites/extra/CMakeLists.txt
index 48a81a2..e9e9204 100644
--- a/test/secure_fw/suites/extra/CMakeLists.txt
+++ b/test/secure_fw/suites/extra/CMakeLists.txt
@@ -9,10 +9,6 @@
cmake_policy(SET CMP0079 NEW)
-if (NOT EXTRA_NS_TEST_SUITE_PATH AND NOT EXTRA_S_TEST_SUITE_PATH)
- return()
-endif()
-
####################### Non-Secure extra test library ##########################
if (EXTRA_NS_TEST_SUITE_PATH)
@@ -42,6 +38,8 @@
####################### Secure extra test library ##############################
if (EXTRA_S_TEST_SUITE_PATH)
+ add_library(tfm_test_suite_extra_s STATIC)
+
target_include_directories(tfm_test_suite_extra_s
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/secure
@@ -59,7 +57,7 @@
)
target_link_libraries(tfm_s_tests
- INTERFACE
+ PUBLIC
tfm_test_suite_extra_s
)
endif()
diff --git a/test/secure_fw/suites/fpu/CMakeLists.txt b/test/secure_fw/suites/fpu/CMakeLists.txt
index 1baad2c..e1c2f33 100644
--- a/test/secure_fw/suites/fpu/CMakeLists.txt
+++ b/test/secure_fw/suites/fpu/CMakeLists.txt
@@ -45,10 +45,9 @@
####################### Secure #################################################
if (TEST_S_FPU)
- target_sources(tfm_test_suite_fpu_s
- PRIVATE
- ${CMAKE_CURRENT_SOURCE_DIR}/fpu_tests_common.c
- ${CMAKE_CURRENT_SOURCE_DIR}/secure/fpu_s_interface_testsuite.c
+ add_library(tfm_test_suite_fpu_s STATIC
+ ${CMAKE_CURRENT_SOURCE_DIR}/fpu_tests_common.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/secure/fpu_s_interface_testsuite.c
)
target_include_directories(tfm_test_suite_fpu_s
@@ -68,7 +67,7 @@
)
target_link_libraries(tfm_s_tests
- INTERFACE
+ PRIVATE
tfm_test_suite_fpu_s
)
endif()
diff --git a/test/secure_fw/suites/fpu/service/CMakeLists.txt b/test/secure_fw/suites/fpu/service/CMakeLists.txt
index bca3f25..b566c6c 100644
--- a/test/secure_fw/suites/fpu/service/CMakeLists.txt
+++ b/test/secure_fw/suites/fpu/service/CMakeLists.txt
@@ -36,7 +36,7 @@
.
PRIVATE
${CMAKE_BINARY_DIR}/generated/secure_fw/test_services/tfm_fpu_service
- ${TFM_TEST_PATH}/secure_fw/suites/fpu
+ ${TFM_TEST_REPO_PATH}/test/secure_fw/suites/fpu
)
target_include_directories(tfm_partitions
diff --git a/test/secure_fw/suites/fwu/mcuboot/CMakeLists.txt b/test/secure_fw/suites/fwu/mcuboot/CMakeLists.txt
index 4d6d513..954c57c 100644
--- a/test/secure_fw/suites/fwu/mcuboot/CMakeLists.txt
+++ b/test/secure_fw/suites/fwu/mcuboot/CMakeLists.txt
@@ -51,6 +51,8 @@
####################### Secure #################################################
if (TEST_S_FWU)
+ add_library(tfm_test_suite_fwu_s STATIC)
+
target_sources(tfm_test_suite_fwu_s
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/fwu_tests_common.c
diff --git a/test/secure_fw/suites/its/CMakeLists.txt b/test/secure_fw/suites/its/CMakeLists.txt
index 8b10a90..c87f9f9 100644
--- a/test/secure_fw/suites/its/CMakeLists.txt
+++ b/test/secure_fw/suites/its/CMakeLists.txt
@@ -7,10 +7,6 @@
cmake_policy(SET CMP0079 NEW)
-if (NOT TEST_NS_ITS AND NOT TEST_S_ITS)
- return()
-endif()
-
####################### Non Secure #############################################
if (TEST_NS_ITS)
@@ -49,11 +45,10 @@
####################### Secure #################################################
if (TEST_S_ITS)
- target_sources(tfm_test_suite_its_s
- PRIVATE
- ${CMAKE_CURRENT_SOURCE_DIR}/its_tests_common.c
- ${CMAKE_CURRENT_SOURCE_DIR}/secure/psa_its_s_interface_testsuite.c
- ${CMAKE_CURRENT_SOURCE_DIR}/secure/psa_its_s_reliability_testsuite.c
+ add_library(tfm_test_suite_its_s STATIC
+ ${CMAKE_CURRENT_SOURCE_DIR}/its_tests_common.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/secure/psa_its_s_interface_testsuite.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/secure/psa_its_s_reliability_testsuite.c
)
target_include_directories(tfm_test_suite_its_s
@@ -76,7 +71,7 @@
)
target_link_libraries(tfm_s_tests
- INTERFACE
+ PRIVATE
tfm_test_suite_its_s
)
endif()
diff --git a/test/secure_fw/suites/platform/CMakeLists.txt b/test/secure_fw/suites/platform/CMakeLists.txt
index 90c628f..543c3c5 100644
--- a/test/secure_fw/suites/platform/CMakeLists.txt
+++ b/test/secure_fw/suites/platform/CMakeLists.txt
@@ -7,10 +7,6 @@
cmake_policy(SET CMP0079 NEW)
-if (NOT TEST_NS_PLATFORM AND NOT TEST_S_PLATFORM)
- return()
-endif()
-
####################### Non Secure #############################################
if (TEST_NS_PLATFORM)
@@ -48,10 +44,9 @@
####################### Secure #################################################
if (TEST_S_PLATFORM)
- target_sources(tfm_test_suite_platform_s
- PRIVATE
- ${CMAKE_CURRENT_SOURCE_DIR}/platform_tests_common.c
- ${CMAKE_CURRENT_SOURCE_DIR}/secure/platform_s_interface_testsuite.c
+ add_library(tfm_test_suite_platform_s STATIC
+ ${CMAKE_CURRENT_SOURCE_DIR}/platform_tests_common.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/secure/platform_s_interface_testsuite.c
)
target_include_directories(tfm_test_suite_platform_s
@@ -73,7 +68,7 @@
)
target_link_libraries(tfm_s_tests
- INTERFACE
+ PRIVATE
tfm_test_suite_platform_s
)
endif()
diff --git a/test/secure_fw/suites/ps/CMakeLists.txt b/test/secure_fw/suites/ps/CMakeLists.txt
index d59d5a4..53eb697 100644
--- a/test/secure_fw/suites/ps/CMakeLists.txt
+++ b/test/secure_fw/suites/ps/CMakeLists.txt
@@ -7,10 +7,6 @@
cmake_policy(SET CMP0079 NEW)
-if (NOT TEST_NS_PS AND NOT TEST_S_PS)
- return()
-endif()
-
####################### Non Secure #############################################
if (TEST_NS_PS)
@@ -52,11 +48,10 @@
####################### Secure #################################################
if (TEST_S_PS)
- target_sources(tfm_test_suite_ps_s
- PRIVATE
- ${CMAKE_CURRENT_SOURCE_DIR}/secure/psa_ps_s_interface_testsuite.c
- ${CMAKE_CURRENT_SOURCE_DIR}/secure/psa_ps_s_reliability_testsuite.c
- $<$<BOOL:${PS_TEST_NV_COUNTERS}>:${CMAKE_CURRENT_SOURCE_DIR}/secure/ps_rollback_protection_testsuite.c>
+ add_library(tfm_test_suite_ps_s STATIC
+ ${CMAKE_CURRENT_SOURCE_DIR}/secure/psa_ps_s_interface_testsuite.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/secure/psa_ps_s_reliability_testsuite.c
+ $<$<BOOL:${PS_TEST_NV_COUNTERS}>:${CMAKE_CURRENT_SOURCE_DIR}/secure/ps_rollback_protection_testsuite.c>
)
target_sources(tfm_app_rot_partition_ps
@@ -87,7 +82,7 @@
)
target_link_libraries(tfm_s_tests
- INTERFACE
+ PRIVATE
tfm_test_suite_ps_s
)
endif()
diff --git a/test/secure_fw/suites/spm/ipc/CMakeLists.txt b/test/secure_fw/suites/spm/ipc/CMakeLists.txt
index f3b85d1..957f65e 100644
--- a/test/secure_fw/suites/spm/ipc/CMakeLists.txt
+++ b/test/secure_fw/suites/spm/ipc/CMakeLists.txt
@@ -7,10 +7,6 @@
cmake_policy(SET CMP0079 NEW)
-if (NOT TEST_NS_IPC AND NOT TEST_S_IPC)
- return()
-endif()
-
####################### Non Secure #############################################
if (TEST_NS_IPC)
@@ -51,10 +47,9 @@
####################### Secure #################################################
if (TEST_S_IPC)
- target_sources(tfm_test_suite_ipc_s
- PRIVATE
- ${CMAKE_CURRENT_SOURCE_DIR}/secure/ipc_s_interface_testsuite.c
- ${CMAKE_CURRENT_SOURCE_DIR}/../common/suites/client_api_tests.c
+ add_library(tfm_test_suite_ipc_s STATIC
+ ${CMAKE_CURRENT_SOURCE_DIR}/secure/ipc_s_interface_testsuite.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/../common/suites/client_api_tests.c
)
target_include_directories(tfm_test_suite_ipc_s
@@ -77,7 +72,7 @@
)
target_link_libraries(tfm_s_tests
- INTERFACE
+ PRIVATE
tfm_test_suite_ipc_s
)
endif()
diff --git a/test/secure_fw/suites/spm/ipc/service/tfm_ipc_client/CMakeLists.txt b/test/secure_fw/suites/spm/ipc/service/tfm_ipc_client/CMakeLists.txt
index fc8573c..f8b9b08 100644
--- a/test/secure_fw/suites/spm/ipc/service/tfm_ipc_client/CMakeLists.txt
+++ b/test/secure_fw/suites/spm/ipc/service/tfm_ipc_client/CMakeLists.txt
@@ -33,7 +33,7 @@
.
PRIVATE
${CMAKE_BINARY_DIR}/generated/secure_fw/test_services/tfm_ipc_client
- ${TFM_TEST_PATH}/secure_fw/common_test_services/tfm_secure_client_2
+ ${TFM_TEST_REPO_PATH}/test/secure_fw/common_test_services/tfm_secure_client_2
)
target_include_directories(tfm_partitions
diff --git a/test/secure_fw/suites/spm/sfn/CMakeLists.txt b/test/secure_fw/suites/spm/sfn/CMakeLists.txt
index 78de25c..186f038 100644
--- a/test/secure_fw/suites/spm/sfn/CMakeLists.txt
+++ b/test/secure_fw/suites/spm/sfn/CMakeLists.txt
@@ -48,6 +48,8 @@
########################### Secure #############################################
if (TEST_S_SFN_BACKEND)
+ add_library(tfm_test_suite_sfn_s STATIC EXCLUDE_FROM_ALL)
+
target_sources(tfm_test_suite_sfn_s
PRIVATE
secure/sfn_backend_s_testsuite.c