Build: Split NS and Secure regression tests build
Seperate NS and Secure regressin test builds.
- TF-M secure build integrates secure regression tests and test
services via test/secure_regression.
- Non-secure regression tests are built via test/ns_regression.
- Pass tf-m-tests test config to TF-M secure build via argument
CONFIG_TFM_TEST_CONFIG_FILE.
- Fix issues when no regression test is enabled.
Signed-off-by: David Hu <david.hu@arm.com>
Change-Id: I1e550bf6d6a36a220275743c3312a61f7ae2c78e
diff --git a/app_broker/CMakeLists.txt b/app_broker/CMakeLists.txt
index 2933833..08ffb89 100644
--- a/app_broker/CMakeLists.txt
+++ b/app_broker/CMakeLists.txt
@@ -30,9 +30,6 @@
# lib parth
set(APP_LIB_DIR ${CMAKE_CURRENT_LIST_DIR}/../lib)
-# TF-M logging
-add_subdirectory(${APP_LIB_DIR}/log ${CMAKE_CURRENT_BINARY_DIR}/lib/log)
-
# OS wrapper library consists of the wrapper layer of RTOSes, such as RTX
add_library(os_wrapper STATIC)
@@ -113,6 +110,24 @@
)
endif()
+# TF-M ns logging
+add_library(tfm_ns_log STATIC EXCLUDE_FROM_ALL)
+
+target_sources(tfm_ns_log
+ PRIVATE
+ ${APP_LIB_DIR}/log/tfm_log_raw.c
+)
+
+target_include_directories(tfm_ns_log
+ PUBLIC
+ ${APP_LIB_DIR}/log/
+)
+
+target_link_libraries(tfm_ns_log
+ PRIVATE
+ platform_ns
+)
+
################## Update plaform_ns with NS settings #################
target_include_directories(platform_ns
@@ -166,6 +181,11 @@
PUBLIC
RTX_OS
tfm_api_ns
- tfm_log
+ tfm_ns_log
$<$<BOOL:${TFM_PARTITION_NS_AGENT_MAILBOX}>:ns_multi_core>
)
+
+target_compile_definitions(tfm_test_broker
+ PUBLIC
+ $<$<BOOL:${TFM_NS_REG_TEST}>:TFM_NS_REG_TEST>
+)
diff --git a/cmake/utils.cmake b/cmake/utils.cmake
index 2717293..2fd6dbb 100644
--- a/cmake/utils.cmake
+++ b/cmake/utils.cmake
@@ -54,3 +54,34 @@
message(STATUS "${footer}")
endfunction()
+# Collect arguments via command line.
+# cmd_line: the output argument to collect the arguments via command line
+#
+# Those command line arguments will be passed to ExternalProject_Add().
+# Those arguments shall not be populated by the settings parsed inside each ExternalProject_Add()
+function(collect_build_cmd_args cmd_line)
+
+ get_cmake_property(CACHE_ARGS CACHE_VARIABLES)
+ foreach(CACHE_ARG ${CACHE_ARGS})
+ get_property(ARG_HELPSTRING CACHE "${CACHE_ARG}" PROPERTY HELPSTRING)
+ if("${ARG_HELPSTRING}" MATCHES "variable specified on the command line")
+ get_property(CACHE_ARG_TYPE CACHE ${CACHE_ARG} PROPERTY TYPE)
+ set(ARG_VAL ${${CACHE_ARG}})
+
+ # CMake automatically converts relative paths passed via command line into absolute
+ # ones. Since external projects have different base directories compared to root
+ # directory, relative paths will be incorrectly converted inside external projects.
+ # Enforce all the relative paths into abosulte paths before collecting them in the
+ # build command argument list.
+ if(NOT ${ARG_VAL} STREQUAL "")
+ if(IS_DIRECTORY ${ARG_VAL} AND NOT IS_ABSOLUTE ${ARG_VAL})
+ get_filename_component(ABS_PATH ${ARG_VAL} ABSOLUTE)
+ set(ARG_VAL ${ABS_PATH})
+ endif()
+ endif()
+ list(APPEND TEMP_CMD_LINE "-D${CACHE_ARG}:${CACHE_ARG_TYPE}=${ARG_VAL}")
+ endif()
+ endforeach()
+
+ set(${cmd_line} ${TEMP_CMD_LINE} PARENT_SCOPE)
+endfunction()
diff --git a/erpc/server/app/CMakeLists.txt b/erpc/server/app/CMakeLists.txt
index 83fdb22..0d58275 100644
--- a/erpc/server/app/CMakeLists.txt
+++ b/erpc/server/app/CMakeLists.txt
@@ -30,5 +30,5 @@
target_link_libraries(erpc_app
PRIVATE
erpc_server
- tfm_log
+ tfm_ns_log
)
diff --git a/lib/log/CMakeLists.txt b/lib/log/CMakeLists.txt
deleted file mode 100644
index a843b41..0000000
--- a/lib/log/CMakeLists.txt
+++ /dev/null
@@ -1,25 +0,0 @@
-#-------------------------------------------------------------------------------
-# Copyright (c) 2020-2022, Arm Limited. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
-#
-#-------------------------------------------------------------------------------
-
-############################# Ns Log ###########################################
-
-add_library(tfm_log INTERFACE)
-
-target_sources(tfm_log
- INTERFACE
- tfm_log_raw.c
-)
-
-target_include_directories(tfm_log
- INTERFACE
- .
-)
-
-target_link_libraries(tfm_log
- INTERFACE
- platform_ns
-)
diff --git a/tests_reg/CMakeLists.txt b/tests_reg/CMakeLists.txt
index a60f744..cf33c84 100644
--- a/tests_reg/CMakeLists.txt
+++ b/tests_reg/CMakeLists.txt
@@ -21,6 +21,7 @@
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/../cmake)
list(APPEND CMAKE_MODULE_PATH ${CONFIG_SPE_PATH}/cmake)
+list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/utils)
include(remote_library)
include(toolchain_selection)
@@ -29,24 +30,28 @@
# Platform abilities for example IRQ test support status
include(${CONFIG_SPE_PATH}/platform/config.cmake OPTIONAL)
-set(TFM_NS_REG_TEST ON)
-set(NS ON)
+include(${TFM_TOOLCHAIN_FILE})
+project(tfm_ns LANGUAGES C ASM)
+tfm_toolchain_reload_compiler()
+
+# Include configs exported from TF-M
+include(${CONFIG_SPE_PATH}/cmake/spe_config.cmake)
# Test suite configurations - set up by SPE build
include(${CONFIG_SPE_PATH}/config_ns_test.cmake)
-# Test configurations
+# Default test configurations
include(${CMAKE_CURRENT_LIST_DIR}/test/config/default_test_config.cmake)
-
-include(${TFM_TOOLCHAIN_FILE})
-project(tfm_ns LANGUAGES C ASM)
-tfm_toolchain_reload_compiler()
+# Config check in case additional test configs passed in via command line.
+include(${CMAKE_CURRENT_LIST_DIR}/test/config/check_config.cmake)
add_executable(tfm_ns)
add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../lib/ext ${CMAKE_BINARY_DIR}/lib/ext)
add_subdirectory(../app_broker ${CMAKE_BINARY_DIR}/app_broker)
-add_subdirectory(test)
+if(TFM_NS_REG_TEST)
+ add_subdirectory(test/ns_regression)
+endif()
############################# TFM NS main app ##################################
@@ -58,8 +63,12 @@
target_link_libraries(tfm_ns
PRIVATE
tfm_test_broker
- tfm_ns_tests
- tfm_test_framework_common
+ $<$<BOOL:${TFM_NS_REG_TEST}>:tfm_ns_tests>
+)
+
+target_compile_definitions(tfm_ns
+ PUBLIC
+ $<$<BOOL:${TFM_NS_REG_TEST}>:TFM_NS_REG_TEST>
)
set_target_properties(tfm_ns PROPERTIES
diff --git a/tests_reg/spe/CMakeLists.txt b/tests_reg/spe/CMakeLists.txt
index 21534a6..c312810 100644
--- a/tests_reg/spe/CMakeLists.txt
+++ b/tests_reg/spe/CMakeLists.txt
@@ -7,25 +7,21 @@
cmake_minimum_required(VERSION 3.15)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/../../cmake)
+list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/../utils)
include(utils)
+include(regression_flag_parse)
-# 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)
+collect_build_cmd_args(TFM_CMDLINE_CONFIGS)
-project("TF-M SPE for tests" LANGUAGES C)
+project("TF-M SPE for tests" NONE)
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 TFM_TOOLCHAIN_FILE)
- set(TFM_TOOLCHAIN_FILE ${CONFIG_TFM_SOURCE_PATH}/toolchain_GNUARM.cmake)
-endif()
-
-include(${CMAKE_CURRENT_LIST_DIR}/config/set_config.cmake)
+# Parse regression test flags, include both NS and S ones
+parse_regression_flag(TFM_CMDLINE_CONFIGS)
# tfm_s_test is IMPORTED to inform CMake that it has no source files.
add_executable(tfm_s_test IMPORTED)
@@ -35,12 +31,10 @@
SOURCE_DIR ${CONFIG_TFM_SOURCE_PATH}
BINARY_DIR build-spe
INSTALL_DIR api_ns
- CMAKE_ARGS -DTFM_PLATFORM=${TFM_PLATFORM}
- CMAKE_ARGS -DCONFIG_TFM_TEST_DIR=${CMAKE_CURRENT_LIST_DIR}/../test
- CMAKE_ARGS -DTFM_EXTRA_CONFIG_PATH=${CMAKE_CURRENT_BINARY_DIR}/config_spe.cmake
+ CMAKE_ARGS -DCONFIG_TFM_TEST_DIR=${CMAKE_CURRENT_LIST_DIR}/../test/secure_regression
+ CMAKE_ARGS -DCONFIG_TFM_TEST_CONFIG_FILE=${CMAKE_CURRENT_LIST_DIR}/../test/config/config.cmake
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
- CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
- CMAKE_ARGS -DTFM_TOOLCHAIN_FILE=${TFM_TOOLCHAIN_FILE}
+ CMAKE_CACHE_DEFAULT_ARGS ${TFM_CMDLINE_CONFIGS}
PREFIX "temp"
)
diff --git a/tests_reg/spe/config/config_spe.cmake.in b/tests_reg/spe/config/config_spe.cmake.in
deleted file mode 100644
index 22f024d..0000000
--- a/tests_reg/spe/config/config_spe.cmake.in
+++ /dev/null
@@ -1,40 +0,0 @@
-#-------------------------------------------------------------------------------
-# Copyright (c) 2023, Arm Limited. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
-#
-#-------------------------------------------------------------------------------
-
-# This is 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.
-#-------------------------------------------------------------------------------
-
-# Command-line options
-@COMMAND_LINE_OPTIONS@
-
-set(TEST_S @TEST_S@ CACHE BOOL "Enable Secure Tests")
-set(TEST_NS @TEST_NS@ CACHE BOOL "Enable NS Tests")
-set(TFM_S_REG_TEST ON CACHE BOOL "Enable S regression test")
-
-# The following NS test configs are required for SPE build to include test codes
-set(TEST_NS_ATTESTATION @TEST_NS_ATTESTATION@ CACHE BOOL "Enable NS Attestation Tests")
-
-# Secure Partitions
-@SP_CONFIG_OPTIONS@
-# Secure test suites
-@S_TEST_CONFIG_OPTIONS@
-# Test configurations
-include(@PROFILE_TEST_CONFIG_FILE@)
-include(${CONFIG_TFM_TEST_DIR}/config/default_test_config.cmake)
-
-# Test Secure Partition building using out-of-tree build
-list(APPEND TFM_EXTRA_MANIFEST_LIST_FILES ${CONFIG_TFM_TEST_DIR}/secure_fw/tfm_test_manifest_list.yaml)
-list(APPEND TFM_EXTRA_PARTITION_PATHS
- ${CONFIG_TFM_TEST_DIR}/secure_fw/common_test_services/tfm_secure_client_service
- ${CONFIG_TFM_TEST_DIR}/secure_fw/common_test_services/tfm_secure_client_2
- ${CONFIG_TFM_TEST_DIR}/secure_fw/suites/spm/ipc/service
- ${CONFIG_TFM_TEST_DIR}/secure_fw/suites/spm/sfn/service
- ${CONFIG_TFM_TEST_DIR}/secure_fw/suites/spm/irq/service
- ${CONFIG_TFM_TEST_DIR}/secure_fw/suites/ps/service
- ${CONFIG_TFM_TEST_DIR}/secure_fw/suites/fpu/service
-)
diff --git a/tests_reg/spe/config/default_config.cmake b/tests_reg/spe/config/default_config.cmake
deleted file mode 100644
index c5f998c..0000000
--- a/tests_reg/spe/config/default_config.cmake
+++ /dev/null
@@ -1,74 +0,0 @@
-#-------------------------------------------------------------------------------
-# Copyright (c) 2023, Arm Limited. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
-#
-#-------------------------------------------------------------------------------
-
-if(NOT DEFINED TEST_S AND NOT DEFINED TEST_NS)
- # Only when there is no user input, both test are enabled.
- set(TEST_S ON CACHE BOOL "Enable Secure Tests")
- set(TEST_NS ON CACHE BOOL "Enable NS Tests")
-endif()
-
-# Explicitly set values
-set(TEST_S OFF CACHE BOOL "Enable Secure Tests")
-set(TEST_NS OFF CACHE BOOL "Enable NS Tests")
-
-################## Set configs that follow TEST_S/TEST_NS #########################################
-# "conditional" configs
-if(CONFIG_TFM_SPM_BACKEND_IPC)
- set(TEST_S_IPC ${TEST_S} CACHE BOOL "Whether to build NS regression SFN backend tests")
- set(TEST_NS_IPC ${TEST_NS} CACHE BOOL "Whether to build NS regression SFN backend tests")
-else()
- set(TEST_S_SFN_BACKEND ${TEST_S} CACHE BOOL "Whether to build S regression SFN backend tests")
- set(TEST_NS_SFN_BACKEND ${TEST_NS} CACHE BOOL "Whether to build S regression SFN backend tests")
-endif()
-
-# Make FLIH IRQ test as the default IRQ test
-if (PLATFORM_FLIH_IRQ_TEST_SUPPORT AND NOT TEST_NS_SLIH_IRQ)
- set(TEST_NS_FLIH_IRQ ${TEST_NS} CACHE BOOL "Whether to build NS regression First-Level Interrupt Handling tests")
-endif()
-
-if (PLATFORM_SLIH_IRQ_TEST_SUPPORT AND NOT TEST_NS_FLIH_IRQ)
- set(TEST_NS_SLIH_IRQ ${TEST_NS} CACHE BOOL "Whether to build NS regression Second-Level Interrupt Handling tests")
-endif()
-
-if(PLATFORM_HAS_FIRMWARE_UPDATE_SUPPORT)
- set(TEST_S_FWU ${TEST_S} CACHE BOOL "Whether to build NS regression FWU tests")
- set(TEST_NS_FWU ${TEST_NS} CACHE BOOL "Whether to build NS regression FWU tests")
-endif()
-
-# Test suites that enabled by default as long as TEST_S is ON
-set(TEST_S_ATTESTATION ${TEST_S} CACHE BOOL "Whether to build S regression Attestation tests")
-set(TEST_S_CRYPTO ${TEST_S} CACHE BOOL "Whether to build S regression Crypto tests")
-set(TEST_S_ITS ${TEST_S} CACHE BOOL "Whether to build S regression ITS tests")
-set(TEST_S_PS ${TEST_S} CACHE BOOL "Whether to build S regression PS tests")
-set(TEST_S_PLATFORM ${TEST_S} CACHE BOOL "Whether to build S regression Platform tests")
-
-# Test suites that enabled by default as long as TEST_NS is ON
-set(TEST_NS_ATTESTATION ${TEST_NS} CACHE BOOL "Whether to build NS regression Attestation tests")
-set(TEST_NS_CRYPTO ${TEST_NS} CACHE BOOL "Whether to build NS regression Crypto tests")
-set(TEST_NS_ITS ${TEST_NS} CACHE BOOL "Whether to build NS regression ITS tests")
-set(TEST_NS_PS ${TEST_NS} CACHE BOOL "Whether to build NS regression PS tests")
-set(TEST_NS_PLATFORM ${TEST_NS} CACHE BOOL "Whether to build NS regression Platform tests")
-
-###################### Ensure "conditional" config has default values ##############################
-set(TEST_S_IPC OFF CACHE BOOL "Whether to build NS regression SFN backend tests")
-set(TEST_NS_IPC OFF CACHE BOOL "Whether to build NS regression SFN backend tests")
-set(TEST_S_SFN_BACKEND OFF CACHE BOOL "Whether to build S regression SFN backend tests")
-set(TEST_NS_SFN_BACKEND OFF CACHE BOOL "Whether to build S regression SFN backend tests")
-set(TEST_S_FWU OFF CACHE BOOL "Whether to build S regression FWU tests")
-set(TEST_NS_FWU OFF CACHE BOOL "Whether to build NS regression FWU 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")
-
-######################### Disabled test suites by default ##########################################
-set(TEST_S_FPU OFF CACHE BOOL "Whether to build S regression FPU tests")
-set(TEST_NS_FPU OFF CACHE BOOL "Whether to build NS regression FPU 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_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")
diff --git a/tests_reg/spe/config/profile_default_config.cmake b/tests_reg/spe/config/profile_default_config.cmake
deleted file mode 100644
index 0c1dae5..0000000
--- a/tests_reg/spe/config/profile_default_config.cmake
+++ /dev/null
@@ -1,72 +0,0 @@
-#-------------------------------------------------------------------------------
-# Copyright (c) 2023, Arm Limited. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
-#
-#-------------------------------------------------------------------------------
-
-if(NOT DEFINED TEST_S AND NOT DEFINED TEST_NS)
- # Only when there is no user input, both test are enabled.
- set(TEST_S ON CACHE BOOL "Enable Secure Tests")
- set(TEST_NS ON CACHE BOOL "Enable NS Tests")
-endif()
-
-# Explicitly set values
-set(TEST_S OFF CACHE BOOL "Enable Secure Tests")
-set(TEST_NS OFF CACHE BOOL "Enable NS Tests")
-
-################## Set configs that follow TEST_S/TEST_NS #########################################
-# "conditional" configs
-if(CONFIG_TFM_SPM_BACKEND_IPC)
- set(TEST_S_IPC ${TEST_S} CACHE BOOL "Whether to build NS regression SFN backend tests")
- set(TEST_NS_IPC ${TEST_NS} CACHE BOOL "Whether to build NS regression SFN backend tests")
-else()
- set(TEST_S_SFN_BACKEND ${TEST_S} CACHE BOOL "Whether to build S regression SFN backend tests")
- set(TEST_NS_SFN_BACKEND ${TEST_NS} CACHE BOOL "Whether to build S regression SFN backend tests")
-endif()
-
-# Make FLIH IRQ test as the default IRQ test
-if (PLATFORM_FLIH_IRQ_TEST_SUPPORT AND NOT TEST_NS_SLIH_IRQ)
- set(TEST_NS_FLIH_IRQ ${TEST_NS} CACHE BOOL "Whether to build NS regression First-Level Interrupt Handling tests")
-endif()
-
-if (PLATFORM_SLIH_IRQ_TEST_SUPPORT AND NOT TEST_NS_FLIH_IRQ)
- set(TEST_NS_SLIH_IRQ ${TEST_NS} CACHE BOOL "Whether to build NS regression Second-Level Interrupt Handling tests")
-endif()
-
-# Test suites that follow the corresponding Secure Partitions
-set(TEST_S_FWU ${TFM_PARTITION_FIRMWARE_UPDATE} CACHE BOOL "Whether to build NS regression FWU tests")
-set(TEST_NS_FWU ${TFM_PARTITION_FIRMWARE_UPDATE} CACHE BOOL "Whether to build NS regression FWU tests")
-
-set(TEST_S_ATTESTATION ${TFM_PARTITION_INITIAL_ATTESTATION} CACHE BOOL "Whether to build S regression Attestation tests")
-set(TEST_S_CRYPTO ${TFM_PARTITION_CRYPTO} CACHE BOOL "Whether to build S regression Crypto tests")
-set(TEST_S_ITS ${TFM_PARTITION_INTERNAL_TRUSTED_STORAGE} CACHE BOOL "Whether to build S regression ITS tests")
-set(TEST_S_PS ${TFM_PARTITION_PROTECTED_STORAGE} CACHE BOOL "Whether to build S regression PS tests")
-set(TEST_S_PLATFORM ${TFM_PARTITION_PLATFORM} CACHE BOOL "Whether to build S regression Platform tests")
-
-# Test suites that enabled by default as long as TEST_NS is ON
-set(TEST_NS_ATTESTATION ${TFM_PARTITION_INITIAL_ATTESTATION} CACHE BOOL "Whether to build NS regression Attestation tests")
-set(TEST_NS_CRYPTO ${TFM_PARTITION_CRYPTO} CACHE BOOL "Whether to build NS regression Crypto tests")
-set(TEST_NS_ITS ${TFM_PARTITION_INTERNAL_TRUSTED_STORAGE} CACHE BOOL "Whether to build NS regression ITS tests")
-set(TEST_NS_PS ${TFM_PARTITION_PROTECTED_STORAGE} CACHE BOOL "Whether to build NS regression PS tests")
-set(TEST_NS_PLATFORM ${TFM_PARTITION_PLATFORM} CACHE BOOL "Whether to build NS regression Platform tests")
-
-###################### Ensure "conditional" config has default values ##############################
-set(TEST_S_IPC OFF CACHE BOOL "Whether to build NS regression SFN backend tests")
-set(TEST_NS_IPC OFF CACHE BOOL "Whether to build NS regression SFN backend tests")
-set(TEST_S_SFN_BACKEND OFF CACHE BOOL "Whether to build S regression SFN backend tests")
-set(TEST_NS_SFN_BACKEND OFF CACHE BOOL "Whether to build S regression SFN backend tests")
-set(TEST_S_FWU OFF CACHE BOOL "Whether to build S regression FWU tests")
-set(TEST_NS_FWU OFF CACHE BOOL "Whether to build NS regression FWU 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")
-
-######################### Disabled test suites by default ##########################################
-set(TEST_S_FPU OFF CACHE BOOL "Whether to build S regression FPU tests")
-set(TEST_NS_FPU OFF CACHE BOOL "Whether to build NS regression FPU 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_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")
diff --git a/tests_reg/spe/config/set_config.cmake b/tests_reg/spe/config/set_config.cmake
deleted file mode 100644
index 4cea154..0000000
--- a/tests_reg/spe/config/set_config.cmake
+++ /dev/null
@@ -1,141 +0,0 @@
-#-------------------------------------------------------------------------------
-# Copyright (c) 2023, Arm Limited. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
-#
-#-------------------------------------------------------------------------------
-
-# Profile
-if(TFM_PROFILE)
- include(${CONFIG_TFM_SOURCE_PATH}/config/profile/${TFM_PROFILE}.cmake)
- set(PROFILE_TEST_CONFIG_FILE ${CMAKE_CURRENT_LIST_DIR}/../../test/config/profile/${TFM_PROFILE}_test.cmake)
-else()
- set(PROFILE_TEST_CONFIG_FILE ${CMAKE_CURRENT_LIST_DIR}/../../test/config/default_test_config.cmake)
-endif()
-
-# Backend config is required to enable or disable corresponding test suites
-# Set up backend config
-if((DEFINED TFM_ISOLATION_LEVEL AND TFM_ISOLATION_LEVEL GREATER 1) OR
- CONFIG_TFM_SPM_BACKEND STREQUAL "IPC" OR TFM_MULTI_CORE_TOPOLOGY)
- set(CONFIG_TFM_SPM_BACKEND_IPC ON)
- set(CONFIG_TFM_SPM_BACKEND_SFN OFF)
-else()
- #The default backend is SFN
- set(CONFIG_TFM_SPM_BACKEND_IPC OFF)
- set(CONFIG_TFM_SPM_BACKEND_SFN ON)
-endif()
-
-# Get platform configurations, for example, PLATFORM_HAS_FIRMWARE_UPDATE_SUPPORT
-include(${CONFIG_TFM_SOURCE_PATH}/config/tfm_platform.cmake)
-include(${TARGET_PLATFORM_PATH}/config.cmake OPTIONAL)
-
-# Set up test suites configurations according to command-line options.
-# By default (no test suites configs at all), configs are set according to default_config.cmake.
-# Users can:
-# 1. Disable all the S/NS tests by setting corresponding TEST_S/TEST_NS to OFF
-# 2. Disable individual test suites by setting the corresponding TEST_(N)S_* to OFF.
-# Other test suites are set according to default_config.cmake
-# 3. Enable individual test suites by setting the corresponding TEST_(N)S_* to ON.
-# Other test suites are disabled by default. To enable other test suites, set the corresponding
-# config option to ON. This applies to TEST_S and TEST_NS as well which can be used to enable
-# test suites that are disabled by default even then TEST_NS/S is enabled.
-
-# Check if user enabled individual test suites.
-# If not, the default config is applied
-set(LOAD_DEFAULT_CONFIG ON)
-get_cmake_property(CACHE_VARS CACHE_VARIABLES)
-foreach(CACHE_VAR ${CACHE_VARS})
- string(REGEX MATCH "^TEST_S.+" _S_TEST_FOUND "${CACHE_VAR}")
- if (_S_TEST_FOUND AND "${${CACHE_VAR}}")
- # User enabled individual S test suite, by default all other S test suites are off,
- # Unless TEST_S is explicity set to ON
- set(TEST_S OFF CACHE BOOL "Enable Secure Tests")
- set(LOAD_DEFAULT_CONFIG OFF)
- break()
- endif()
- string(REGEX MATCH "^TEST_NS.+" _NS_TEST_FOUND "${CACHE_VAR}")
- if (_NS_TEST_FOUND AND "${${CACHE_VAR}}")
- # User enabled individual NS test suite, by default all other NS test suites are OFF,
- # Unless TEST_NS is explicity set to ON
- set(TEST_NS OFF CACHE BOOL "Enable NS Tests")
- set(LOAD_DEFAULT_CONFIG OFF)
- break()
- endif()
-endforeach()
-
-# If the user also enable TEST_S/TEST_NS, the default configs should also be loaded.
-if((TEST_S OR TEST_NS) AND NOT LOAD_DEFAULT_CONFIG)
- set(LOAD_DEFAULT_CONFIG ON)
-endif()
-
-if(LOAD_DEFAULT_CONFIG)
- # If profile is set, then test suites are enabled according to Secure Partitions.
- # On the contrary, by default, Secure Partitions are enabled according to test suites.
- if(TFM_PROFILE)
- include(${CMAKE_CURRENT_LIST_DIR}/profile_default_config.cmake)
- else()
- include(${CMAKE_CURRENT_LIST_DIR}/default_config.cmake)
- endif()
-endif()
-
-# Set up dependency Secure Partition configs
-include(${CMAKE_CURRENT_LIST_DIR}/enable_dep_config.cmake)
-
-# Set up variables for config_*.cmake.in
-get_cmake_property(CACHE_VARS CACHE_VARIABLES)
-foreach(CACHE_VAR ${CACHE_VARS})
- get_property(HELP_STRING CACHE ${CACHE_VAR} PROPERTY HELPSTRING)
- get_property(CACHE_TYPE CACHE ${CACHE_VAR} PROPERTY TYPE)
-
- # Command-line options passing to Secure build
- if("${HELP_STRING}" MATCHES "variable specified on the command line")
- string(REGEX MATCH "^TEST_NS.*" _NS_TEST_FOUND "${CACHE_VAR}")
- if(NOT _NS_TEST_FOUND)
- # Skip NS test suite config options
- string(APPEND COMMAND_LINE_OPTIONS
- "set(${CACHE_VAR}\r\n ${${CACHE_VAR}}\r\n CACHE ${CACHE_TYPE} \"${HELP_STRING}\")\r\n")
- endif()
- endif()
-
- # Secure test suites
- string(REGEX MATCH "^TEST_S.+" _S_TEST_FOUND "${CACHE_VAR}")
- if (_S_TEST_FOUND)
- format_string(FORMATTED_CACHE_VAR ${CACHE_VAR} 25 " ")
- format_string(FORMATTED_CACHE_VAL ${${CACHE_VAR}} 5 " ")
- string(APPEND S_TEST_CONFIG_OPTIONS
- "set(${FORMATTED_CACHE_VAR} ${FORMATTED_CACHE_VAL} CACHE ${CACHE_TYPE} \"${HELP_STRING}\")\r\n"
- )
- endif()
-
- # NS test suits
- string(REGEX MATCH "^TEST_NS.+" _NS_TEST_FOUND "${CACHE_VAR}")
- if (_NS_TEST_FOUND)
- format_string(FORMATTED_CACHE_VAR ${CACHE_VAR} 25 " ")
- format_string(FORMATTED_CACHE_VAL ${${CACHE_VAR}} 5 " ")
- string(APPEND NS_TEST_CONFIG_OPTIONS
- "set(${FORMATTED_CACHE_VAR} ${FORMATTED_CACHE_VAL} CACHE ${CACHE_TYPE} \"${HELP_STRING}\")\r\n"
- )
- endif()
-
- # Secure Partitions
- string(REGEX MATCH "^TFM_PARTITION_.+" _PARTITION_FOUND "${CACHE_VAR}")
- if (_PARTITION_FOUND)
- format_string(FORMATTED_CACHE_VAR ${CACHE_VAR} 40 " ")
- format_string(FORMATTED_CACHE_VAL ${${CACHE_VAR}} 5 " ")
- string(APPEND SP_CONFIG_OPTIONS
- "set(${FORMATTED_CACHE_VAR} ${FORMATTED_CACHE_VAL} CACHE ${CACHE_TYPE} \"${HELP_STRING}\")\r\n"
- )
- endif()
-endforeach()
-
-# This file is for Secure build
-configure_file(${CMAKE_CURRENT_LIST_DIR}/config_spe.cmake.in
- ${CMAKE_BINARY_DIR}/config_spe.cmake
- @ONLY)
-
-# This file is for NS build
-configure_file(${CMAKE_CURRENT_LIST_DIR}/config_ns_test.cmake.in
- ${CMAKE_BINARY_DIR}/api_ns/config_ns_test.cmake
- @ONLY)
-
-include(${CMAKE_CURRENT_LIST_DIR}/check_config.cmake)
diff --git a/tests_reg/test/CMakeLists.txt b/tests_reg/test/CMakeLists.txt
deleted file mode 100644
index aa2025f..0000000
--- a/tests_reg/test/CMakeLists.txt
+++ /dev/null
@@ -1,32 +0,0 @@
-#-------------------------------------------------------------------------------
-# Copyright (c) 2020-2022, Arm Limited. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
-#
-#-------------------------------------------------------------------------------
-
-cmake_minimum_required(VERSION 3.13)
-
-add_library(tfm_test_framework_common INTERFACE)
-
-target_sources(tfm_test_framework_common
- INTERFACE
- ${CMAKE_CURRENT_SOURCE_DIR}/framework/test_framework.c
- ${CMAKE_CURRENT_SOURCE_DIR}/framework/test_framework_helpers.c
- ${CMAKE_CURRENT_SOURCE_DIR}/framework/test_framework_integ_test_helper.c
-)
-
-target_include_directories(tfm_test_framework_common
- INTERFACE
- framework
-)
-
-add_subdirectory(secure_fw)
-
-if(TEST_BL2)
- add_subdirectory(bl2)
-endif()
-
-if(TEST_BL1_1 OR TEST_BL1_2)
- add_subdirectory(bl1)
-endif()
diff --git a/tests_reg/test/bl1/CMakeLists.txt b/tests_reg/test/bl1/CMakeLists.txt
index 83c6dc0..529e4eb 100644
--- a/tests_reg/test/bl1/CMakeLists.txt
+++ b/tests_reg/test/bl1/CMakeLists.txt
@@ -11,11 +11,5 @@
return()
endif()
-# Reload the compiler options for the secure core, if the NS core differs
-if (EXISTS ${TARGET_PLATFORM_PATH}/preload_ns.cmake)
- include(${TARGET_PLATFORM_PATH}/preload.cmake)
- tfm_toolchain_reload_compiler()
-endif()
-
add_subdirectory(bl1_1)
add_subdirectory(bl1_2)
diff --git a/tests_reg/test/bl1/bl1_1/CMakeLists.txt b/tests_reg/test/bl1/bl1_1/CMakeLists.txt
index 520a3ec..4a2095e 100644
--- a/tests_reg/test/bl1/bl1_1/CMakeLists.txt
+++ b/tests_reg/test/bl1/bl1_1/CMakeLists.txt
@@ -9,6 +9,30 @@
return()
endif()
+set(LOG_SOURCE_ROOT ${TFM_TESTS_ROOT_DIR}/lib/log)
+
+add_library(bl1_1_log INTERFACE)
+
+target_sources(bl1_1_log
+ INTERFACE
+ ${LOG_SOURCE_ROOT}/tfm_log_raw.c
+)
+
+target_include_directories(bl1_1_log
+ INTERFACE
+ ${LOG_SOURCE_ROOT}
+)
+
+target_link_libraries(bl1_1_log
+ INTERFACE
+ platform_bl1_1
+)
+
+target_link_libraries(tfm_test_framework_common
+ INTERFACE
+ bl1_1_log
+)
+
add_subdirectory(suites/crypto)
add_subdirectory(suites/trng)
add_subdirectory(suites/integration)
@@ -30,7 +54,6 @@
tfm_test_framework_common
platform_bl1_1
bl1_1_shared_lib
- tfm_log
bl1_1_test_suite_crypto
bl1_1_test_suite_trng
bl1_1_test_suite_integration
diff --git a/tests_reg/test/bl2/CMakeLists.txt b/tests_reg/test/bl2/CMakeLists.txt
index e559800..b2a436c 100644
--- a/tests_reg/test/bl2/CMakeLists.txt
+++ b/tests_reg/test/bl2/CMakeLists.txt
@@ -13,10 +13,4 @@
return()
endif()
-# Reload the compiler options for the secure core, if the NS core differs
-if (EXISTS ${TARGET_PLATFORM_PATH}/preload_ns.cmake)
- include(${TARGET_PLATFORM_PATH}/preload.cmake)
- tfm_toolchain_reload_compiler()
-endif()
-
add_subdirectory(mcuboot)
diff --git a/tests_reg/test/bl2/mcuboot/CMakeLists.txt b/tests_reg/test/bl2/mcuboot/CMakeLists.txt
index 4dd1028..abb1665 100644
--- a/tests_reg/test/bl2/mcuboot/CMakeLists.txt
+++ b/tests_reg/test/bl2/mcuboot/CMakeLists.txt
@@ -11,25 +11,28 @@
# So a dedicated library is duplicated here, and it links the platform_s instead of platform_ns.
# TO-DO: find a better approach to reference the directory
-set(LOG_SOURCE_ROOT ${CMAKE_CURRENT_LIST_DIR}/../../../../lib/log)
+set(LOG_SOURCE_ROOT ${TFM_TESTS_ROOT_DIR}/lib/log)
add_library(mcuboot_test_log INTERFACE)
-add_library(mcuboot_test_log_interface INTERFACE)
target_sources(mcuboot_test_log
INTERFACE
${LOG_SOURCE_ROOT}/tfm_log_raw.c
)
-target_include_directories(mcuboot_test_log_interface
+target_include_directories(mcuboot_test_log
INTERFACE
${LOG_SOURCE_ROOT}
)
target_link_libraries(mcuboot_test_log
INTERFACE
- mcuboot_test_log_interface
- platform_common_interface
+ platform_bl2
+)
+
+target_link_libraries(tfm_test_framework_common
+ INTERFACE
+ mcuboot_test_log
)
add_subdirectory(suites/integration)
@@ -52,5 +55,4 @@
PRIVATE
platform_bl2
mcuboot_test_suite_integration
- mcuboot_test_log
)
diff --git a/tests_reg/spe/config/check_config.cmake b/tests_reg/test/config/check_config.cmake
similarity index 100%
rename from tests_reg/spe/config/check_config.cmake
rename to tests_reg/test/config/check_config.cmake
diff --git a/tests_reg/test/config/config.cmake b/tests_reg/test/config/config.cmake
new file mode 100644
index 0000000..56d6bff
--- /dev/null
+++ b/tests_reg/test/config/config.cmake
@@ -0,0 +1,172 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2023, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+include(${CMAKE_CURRENT_LIST_DIR}/enable_dep_config.cmake)
+
+########################## TEST SYNC ###########################################
+
+if ((NOT TFM_PARTITION_PROTECTED_STORAGE))
+ set(TEST_NS_PS OFF CACHE BOOL "Whether to build NS regression PS tests")
+ set(TEST_S_PS OFF CACHE BOOL "Whether to build S regression PS tests")
+endif()
+
+if (NOT TFM_PARTITION_INTERNAL_TRUSTED_STORAGE)
+ set(TEST_NS_ITS OFF CACHE BOOL "Whether to build NS regression ITS tests")
+ set(TEST_S_ITS OFF CACHE BOOL "Whether to build S regression ITS tests")
+
+ # TEST_NS_PS relies on TEST_NS_ITS
+ set(TEST_NS_PS OFF CACHE BOOL "Whether to build NS regression PS tests")
+endif()
+
+if (NOT TFM_PARTITION_CRYPTO)
+ set(TEST_NS_CRYPTO OFF CACHE BOOL "Whether to build NS regression Crypto tests")
+ set(TEST_S_CRYPTO OFF CACHE BOOL "Whether to build S regression Crypto tests")
+endif()
+
+if (NOT TFM_PARTITION_INITIAL_ATTESTATION)
+ set(TEST_NS_ATTESTATION OFF CACHE BOOL "Whether to build NS regression Attestation tests")
+ set(TEST_S_ATTESTATION OFF CACHE BOOL "Whether to build S regression Attestation tests")
+ set(TEST_NS_QCBOR OFF CACHE BOOL "Whether to build NS regression QCBOR tests")
+ set(TEST_NS_T_COSE OFF CACHE BOOL "Whether to build NS regression t_cose tests")
+endif()
+
+if (SYMMETRIC_INITIAL_ATTESTATION)
+ set(TEST_NS_T_COSE OFF CACHE BOOL "Whether to build NS regression t_cose tests")
+endif()
+
+if (NOT TFM_PARTITION_PLATFORM)
+ set(TEST_NS_PLATFORM OFF CACHE BOOL "Whether to build NS regression Platform tests")
+ set(TEST_S_PLATFORM OFF CACHE BOOL "Whether to build S regression Platform tests")
+endif()
+
+if (NOT TFM_PARTITION_FIRMWARE_UPDATE)
+ set(TEST_NS_FWU OFF CACHE BOOL "Whether to build NS regression FWU tests")
+ set(TEST_S_FWU OFF CACHE BOOL "Whether to build S regression FWU tests")
+endif()
+
+if (NOT TFM_MULTI_CORE_TOPOLOGY)
+ set(TEST_NS_MULTI_CORE OFF CACHE BOOL "Whether to build NS regression multi-core tests")
+endif()
+
+if (NOT TFM_NS_MANAGE_NSID)
+ set(TEST_NS_MANAGE_NSID OFF CACHE BOOL "Whether to build NS regression NSID management tests")
+endif()
+
+if (CONFIG_TFM_FLOAT_ABI STREQUAL "soft")
+ set(TEST_S_FPU OFF CACHE BOOL "Whether to build S regression FPU tests")
+ set(TEST_NS_FPU OFF CACHE BOOL "Whether to build NS regression FPU tests")
+endif()
+
+########################## Test profile ########################################
+
+if (TFM_PROFILE)
+ include(${CMAKE_CURRENT_LIST_DIR}/profile/${TFM_PROFILE}_test.cmake)
+endif()
+
+########################## SLIH/FLIH IRQ Test ##################################
+
+# Make FLIH IRQ test as the default IRQ test
+if (PLATFORM_FLIH_IRQ_TEST_SUPPORT
+ AND TEST_NS AND NOT TEST_NS_SLIH_IRQ)
+ set(TEST_NS_FLIH_IRQ ON CACHE BOOL "Whether to build NS regression First-Level Interrupt Handling tests")
+endif()
+
+if (PLATFORM_SLIH_IRQ_TEST_SUPPORT
+ AND TEST_NS AND NOT TEST_NS_FLIH_IRQ)
+ set(TEST_NS_SLIH_IRQ ON CACHE BOOL "Whether to build NS regression Second-Level Interrupt Handling tests")
+endif()
+
+############################ IPC backend test ##################################
+if (CONFIG_TFM_SPM_BACKEND_IPC AND TEST_NS)
+ set(TEST_NS_IPC ON CACHE BOOL "Whether to build NS regression SFN backend tests")
+endif()
+
+if (CONFIG_TFM_SPM_BACKEND_IPC AND TEST_S)
+ set(TEST_S_IPC ON CACHE BOOL "Whether to build NS regression SFN backend tests")
+endif()
+
+############################ SFN backend test ##################################
+
+if (CONFIG_TFM_SPM_BACKEND_SFN AND TEST_NS)
+ set(TEST_NS_SFN_BACKEND ON CACHE BOOL "Whether to build NS regression SFN backend tests")
+endif()
+
+if (CONFIG_TFM_SPM_BACKEND_SFN AND TEST_S)
+ set(TEST_S_SFN_BACKEND ON CACHE BOOL "Whether to build S regression SFN backend tests")
+endif()
+
+########################## Load default config #################################
+
+if (TEST_S)
+ include(${CMAKE_CURRENT_LIST_DIR}/default_s_test_config.cmake)
+endif()
+if (TEST_NS)
+ include(${CMAKE_CURRENT_LIST_DIR}/default_ns_test_config.cmake)
+endif()
+
+###################### Test Partition configurations ###########################
+if (TEST_NS_IPC OR TEST_S_IPC)
+ set(TFM_PARTITION_IPC_TEST ON)
+else()
+ set(TFM_PARTITION_IPC_TEST OFF)
+endif()
+
+if (TEST_NS_PS OR TEST_S_PS)
+ set(TFM_PARTITION_PS_TEST ON)
+else()
+ set(TFM_PARTITION_PS_TEST OFF)
+endif()
+
+if (TEST_NS_SFN_BACKEND OR TEST_S_SFN_BACKEND)
+ set(TFM_PARTITION_SFN_BACKEND_TEST ON)
+else()
+ set(TFM_PARTITION_SFN_BACKEND_TEST OFF)
+endif()
+
+# Enable FPU test partition if S or NS FP test enabled
+if (TEST_S_FPU OR TEST_NS_FPU)
+ set(TEST_PARTITION_FPU_TEST ON)
+else()
+ set(TEST_PARTITION_FPU_TEST OFF)
+endif()
+
+if(TEST_NS_FLIH_IRQ)
+ set(TFM_PARTITION_FLIH_TEST ON)
+else()
+ set(TFM_PARTITION_FLIH_TEST OFF)
+endif()
+
+if(TEST_NS_SLIH_IRQ)
+ set(TFM_PARTITION_SLIH_TEST ON)
+else()
+ set(TFM_PARTITION_SLIH_TEST OFF)
+endif()
+
+include(${CMAKE_CURRENT_LIST_DIR}/default_test_config.cmake)
+
+# Test Secure Partition building using out-of-tree build
+list(APPEND TFM_EXTRA_MANIFEST_LIST_FILES ${CONFIG_TFM_TEST_DIR}/../secure_fw/tfm_test_manifest_list.yaml)
+
+set(SECURE_FW_REG_DIR ${CMAKE_CURRENT_LIST_DIR}/../secure_fw)
+
+# Test services are also required by some NS regression tests.
+# Include test services at first no matter whether secure tests are enabled.
+list(APPEND TFM_EXTRA_PARTITION_PATHS
+ ${SECURE_FW_REG_DIR}/suites/spm/ipc/service
+ ${SECURE_FW_REG_DIR}/suites/spm/sfn/service
+ ${SECURE_FW_REG_DIR}/suites/spm/irq/service
+ ${SECURE_FW_REG_DIR}/suites/ps/service
+ ${SECURE_FW_REG_DIR}/suites/fpu/service
+)
+
+if(TFM_S_REG_TEST)
+ # secure test services are required if any secure test is opened
+ list(APPEND TFM_EXTRA_PARTITION_PATHS
+ ${SECURE_FW_REG_DIR}/common_test_services/tfm_secure_client_service
+ ${SECURE_FW_REG_DIR}/common_test_services/tfm_secure_client_2
+)
+endif()
diff --git a/tests_reg/spe/config/config_ns_test.cmake.in b/tests_reg/test/config/config_ns_test.cmake.in
similarity index 84%
rename from tests_reg/spe/config/config_ns_test.cmake.in
rename to tests_reg/test/config/config_ns_test.cmake.in
index 25c6c31..11dc1a3 100644
--- a/tests_reg/spe/config/config_ns_test.cmake.in
+++ b/tests_reg/test/config/config_ns_test.cmake.in
@@ -7,5 +7,3 @@
# This file is consumed by NS test build to get test configurations
@NS_TEST_CONFIG_OPTIONS@
-# Profile test configurations
-include(@PROFILE_TEST_CONFIG_FILE@)
diff --git a/tests_reg/test/config/default_ns_test_config.cmake b/tests_reg/test/config/default_ns_test_config.cmake
new file mode 100644
index 0000000..fbdbe1e
--- /dev/null
+++ b/tests_reg/test/config/default_ns_test_config.cmake
@@ -0,0 +1,25 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2021-2022, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+########################## NS test suites ######################################
+
+set(TEST_NS_ATTESTATION ON CACHE BOOL "Whether to build NS regression Attestation tests")
+set(TEST_NS_T_COSE ON 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 ON CACHE BOOL "Whether to build NS regression FWU tests")
+set(TEST_NS_MULTI_CORE ON CACHE BOOL "Whether to build NS regression multi-core tests")
+set(TEST_NS_MANAGE_NSID ON CACHE BOOL "Whether to build NS regression NSID management tests")
+
+set(TEST_NS_QCBOR OFF CACHE BOOL "Whether to build NS regression QCBOR 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_FPU OFF CACHE BOOL "Whether to build NS regression FPU tests")
+set(TEST_NS_IPC OFF CACHE BOOL "Whether to build NS regression IPC tests")
+set(TEST_NS_SFN_BACKEND OFF CACHE BOOL "Whether to build NS regression SFN backend tests")
diff --git a/tests_reg/test/config/default_s_test_config.cmake b/tests_reg/test/config/default_s_test_config.cmake
new file mode 100644
index 0000000..eb2e622
--- /dev/null
+++ b/tests_reg/test/config/default_s_test_config.cmake
@@ -0,0 +1,19 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2021-2022, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+########################## S test suites #######################################
+
+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_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")
+set(TEST_S_FPU OFF CACHE BOOL "Whether to build S regression FPU tests")
diff --git a/tests_reg/spe/config/enable_dep_config.cmake b/tests_reg/test/config/enable_dep_config.cmake
similarity index 66%
rename from tests_reg/spe/config/enable_dep_config.cmake
rename to tests_reg/test/config/enable_dep_config.cmake
index 957f61f..b31b52d 100755
--- a/tests_reg/spe/config/enable_dep_config.cmake
+++ b/tests_reg/test/config/enable_dep_config.cmake
@@ -5,7 +5,20 @@
#
#-------------------------------------------------------------------------------
-###################### TF-M Secure Partition configurations ###########################
+if(TEST_NS OR TEST_S)
+ # Enable default Secure Partition for tests when secure or non-secure regressions are enabled
+
+ set(TFM_PARTITION_INTERNAL_TRUSTED_STORAGE ON CACHE BOOL "Enable Internal Trusted Storage partition")
+ set(TFM_PARTITION_PROTECTED_STORAGE ON CACHE BOOL "Enable Protected Storage partition")
+ set(TFM_PARTITION_CRYPTO ON CACHE BOOL "Enable Crypto partition")
+ set(TFM_PARTITION_INITIAL_ATTESTATION ON CACHE BOOL "Enable Initial Attestation partition")
+ set(TFM_PARTITION_PLATFORM ON CACHE BOOL "Enable Platform partition")
+
+ if(PLATFORM_HAS_FIRMWARE_UPDATE_SUPPORT)
+ set(TFM_PARTITION_FIRMWARE_UPDATE ON CACHE BOOL "Enable firmware update partition")
+ endif()
+endif()
+
if(TEST_S_CRYPTO OR TEST_NS_CRYPTO)
set(TFM_PARTITION_INTERNAL_TRUSTED_STORAGE ON CACHE BOOL "Enable Internal Trusted Storage partition")
set(TFM_PARTITION_CRYPTO ON CACHE BOOL "Enable Crypto partition")
@@ -17,7 +30,7 @@
set(TFM_PARTITION_CRYPTO ON CACHE BOOL "Enable Crypto partition")
set(TFM_PARTITION_PLATFORM ON CACHE BOOL "Enable Platform partition")
- # TEST_NS_PS relies on TEST_NS_ITS, this should goes to NS test config setup
+ # TEST_NS_PS relies on TEST_NS_ITS
if(TEST_NS_PS)
set(TEST_NS_ITS ON CACHE BOOL "Whether to build NS regression ITS tests")
endif()
@@ -47,35 +60,3 @@
if(TEST_NS_MANAGE_NSID AND NOT TFM_MULTI_CORE_TOPOLOGY)
set(TFM_NS_MANAGE_NSID ON CACHE BOOL "Support NSPE OS providing NSPE client_id")
endif()
-
-###################### Test Partition configurations ###########################
-if(TEST_NS_IPC OR TEST_S_IPC)
- set(TFM_PARTITION_IPC_TEST ON CACHE BOOL "Enable the IPC test Partitions")
-else()
- set(TFM_PARTITION_IPC_TEST OFF CACHE BOOL "Enable the IPC test Partitions")
-endif()
-
-if(TEST_NS_SFN_BACKEND OR TEST_S_SFN_BACKEND)
- set(TFM_PARTITION_SFN_BACKEND_TEST ON CACHE BOOL "Enable the SFN test Partitions")
-else()
- set(TFM_PARTITION_SFN_BACKEND_TEST OFF CACHE BOOL "Enable the SFN test Partitions")
-endif()
-
-if(TEST_S_PS)
- set(TFM_PARTITION_PS_TEST ON CACHE BOOL "Enable the PS test Partition")
-endif()
-
-if(TEST_NS_SLIH_IRQ)
- set(TFM_PARTITION_SLIH_TEST ON CACHE BOOL "Enable the SLIH test Partition")
-endif()
-
-if(TEST_NS_FLIH_IRQ)
- set(TFM_PARTITION_FLIH_TEST ON CACHE BOOL "Enable the FLIH test Partition")
-endif()
-
-# Enable FPU test partition if S or NS FP test enabled
-if (TEST_S_FPU OR TEST_NS_FPU)
- set(TFM_PARTITION_FPU_TEST ON CACHE BOOL "Enable the FPU test Partitions")
-else()
- set(TFM_PARTITION_FPU_TEST OFF CACHE BOOL "Enable the FPU test Partitions")
-endif()
diff --git a/tests_reg/test/framework/CMakeLists.txt b/tests_reg/test/framework/CMakeLists.txt
new file mode 100644
index 0000000..e30a3a1
--- /dev/null
+++ b/tests_reg/test/framework/CMakeLists.txt
@@ -0,0 +1,22 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2020-2022, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+cmake_minimum_required(VERSION 3.13)
+
+add_library(tfm_test_framework_common INTERFACE)
+
+target_sources(tfm_test_framework_common
+ INTERFACE
+ ${CMAKE_CURRENT_SOURCE_DIR}/test_framework.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/test_framework_helpers.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/test_framework_integ_test_helper.c
+)
+
+target_include_directories(tfm_test_framework_common
+ INTERFACE
+ ${CMAKE_CURRENT_LIST_DIR}
+)
diff --git a/tests_reg/test/ns_regression/CMakeLists.txt b/tests_reg/test/ns_regression/CMakeLists.txt
new file mode 100644
index 0000000..5f81c60
--- /dev/null
+++ b/tests_reg/test/ns_regression/CMakeLists.txt
@@ -0,0 +1,83 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2022, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+cmake_minimum_required(VERSION 3.13)
+
+########################## TEST Configuration ##################################
+
+include(utils)
+ dump_options("NS TEST Configuration"
+ "
+ TEST_NS;
+ TEST_NS_ATTESTATION;
+ TEST_NS_CRYPTO;
+ TEST_NS_ITS;
+ TEST_NS_PS;
+ TEST_NS_QCBOR;
+ TEST_NS_T_COSE;
+ TEST_NS_PLATFORM;
+ TEST_NS_FWU;
+ TEST_NS_IPC;
+ TEST_NS_SLIH_IRQ;
+ TEST_NS_FLIH_IRQ;
+ TEST_NS_MULTI_CORE;
+ TEST_NS_MANAGE_NSID;
+ TEST_NS_SFN_BACKEND;
+ TEST_NS_FPU;
+ "
+ )
+
+# Common regression test framework
+add_subdirectory(${CMAKE_SOURCE_DIR}/test/framework ${CMAKE_CURRENT_BINARY_DIR}/framework)
+
+add_library(tfm_ns_tests INTERFACE)
+add_library(tfm_test_framework_ns INTERFACE)
+
+target_compile_definitions(tfm_test_framework_ns
+ INTERFACE
+ DOMAIN_NS=1
+)
+
+target_link_libraries(tfm_test_framework_ns
+ INTERFACE
+ tfm_test_framework_common
+ tfm_api_ns
+ tfm_ns_log
+)
+
+target_sources(tfm_ns_tests
+ INTERFACE
+ non_secure_suites.c
+)
+
+target_link_libraries(tfm_ns_tests
+ INTERFACE
+ tfm_test_framework_ns
+ tfm_config
+)
+
+target_compile_definitions(tfm_ns_tests
+ INTERFACE
+ $<$<BOOL:${TFM_FUZZER_TOOL_TESTS}>:TFM_FUZZER_TOOL_TESTS>
+)
+
+include(test_suite_utils)
+
+# A temporary workaround:
+# Temporarily disable Secure regression test flags to build NS test suites.
+#
+# Alternatively, CMake files in test suites can be seperated into secure ones and non-secure ones.
+pre_ns_suite_build()
+add_subdirectory(${CMAKE_SOURCE_DIR}/test/secure_fw/suites
+ ${CMAKE_CURRENT_BINARY_DIR}/secure_fw/suites
+)
+# Recover Secure regression test filgs.
+post_ns_suite_build()
+
+
+
+
diff --git a/tests_reg/test/secure_fw/non_secure_suites.c b/tests_reg/test/ns_regression/non_secure_suites.c
similarity index 100%
rename from tests_reg/test/secure_fw/non_secure_suites.c
rename to tests_reg/test/ns_regression/non_secure_suites.c
diff --git a/tests_reg/test/secure_fw/CMakeLists.txt b/tests_reg/test/secure_fw/CMakeLists.txt
deleted file mode 100644
index 6f74262..0000000
--- a/tests_reg/test/secure_fw/CMakeLists.txt
+++ /dev/null
@@ -1,77 +0,0 @@
-#-------------------------------------------------------------------------------
-# Copyright (c) 2022, Arm Limited. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
-#
-#-------------------------------------------------------------------------------
-
-cmake_minimum_required(VERSION 3.13)
-
-########################## TEST Configuration ##################################
-
-include(utils)
- dump_options("TEST Configuration"
- "
- TEST_NS;
- TEST_S;
- TEST_NS_ATTESTATION;
- TEST_NS_CRYPTO;
- TEST_NS_ITS;
- TEST_NS_PS;
- TEST_NS_QCBOR;
- TEST_NS_T_COSE;
- TEST_NS_PLATFORM;
- TEST_NS_FWU;
- TEST_NS_IPC;
- TEST_NS_SLIH_IRQ;
- TEST_NS_FLIH_IRQ;
- TEST_NS_MULTI_CORE;
- TEST_NS_MANAGE_NSID;
- TEST_NS_SFN_BACKEND;
- TEST_NS_FPU;
- TEST_S_ATTESTATION;
- TEST_S_CRYPTO;
- TEST_S_ITS;
- TEST_S_PS;
- TEST_S_PLATFORM;
- TEST_S_FWU;
- TEST_S_IPC;
- TEST_S_SFN_BACKEND;
- TEST_S_FPU;
- "
- )
-
-if (TFM_S_REG_TEST)
- 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>
- )
-
- 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/tests_reg/test/secure_fw/suites/CMakeLists.txt b/tests_reg/test/secure_fw/suites/CMakeLists.txt
index 9b7f1e7..9321d0b 100644
--- a/tests_reg/test/secure_fw/suites/CMakeLists.txt
+++ b/tests_reg/test/secure_fw/suites/CMakeLists.txt
@@ -9,40 +9,6 @@
cmake_minimum_required(VERSION 3.13)
-if(TFM_NS_REG_TEST AND NS)
- add_library(tfm_ns_tests INTERFACE)
- add_library(tfm_test_framework_ns INTERFACE)
-
- target_compile_definitions(tfm_test_framework_ns
- INTERFACE
- DOMAIN_NS=1
- )
-
- target_link_libraries(tfm_test_framework_ns
- INTERFACE
- tfm_test_framework_common
- tfm_api_ns
- tfm_log
- )
-
- target_sources(tfm_ns_tests
- INTERFACE
- ../non_secure_suites.c
- )
-
- target_link_libraries(tfm_ns_tests
- INTERFACE
- tfm_test_framework_ns
- tfm_config
- )
-
- target_compile_definitions(tfm_ns_tests
- INTERFACE
- $<$<BOOL:${SYMMETRIC_INITIAL_ATTESTATION}>:SYMMETRIC_INITIAL_ATTESTATION>
- $<$<BOOL:${TFM_FUZZER_TOOL_TESTS}>:TFM_FUZZER_TOOL_TESTS>
- )
-endif()
-
# Add test suites.
# Secure test suite library targets shall already be added in secure_tests.cmake
add_subdirectory(attestation)
diff --git a/tests_reg/test/secure_fw/suites/attestation/CMakeLists.txt b/tests_reg/test/secure_fw/suites/attestation/CMakeLists.txt
index 7904750..e95747e 100644
--- a/tests_reg/test/secure_fw/suites/attestation/CMakeLists.txt
+++ b/tests_reg/test/secure_fw/suites/attestation/CMakeLists.txt
@@ -9,7 +9,7 @@
####################### Non Secure #############################################
-if (TEST_NS_ATTESTATION AND TFM_NS_REG_TEST) # Need TFM_NS_REG_TEST to exclude when building SPE
+if (TEST_NS_ATTESTATION)
add_library(tfm_test_suite_attestation_ns STATIC EXCLUDE_FROM_ALL)
target_sources(tfm_test_suite_attestation_ns
@@ -60,14 +60,17 @@
if (TEST_S_ATTESTATION)
- 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>
+ add_library(tfm_test_suite_attestation_s STATIC EXCLUDE_FROM_ALL)
+
+ 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>
)
target_include_directories(tfm_test_suite_attestation_s
diff --git a/tests_reg/test/secure_fw/suites/crypto/CMakeLists.txt b/tests_reg/test/secure_fw/suites/crypto/CMakeLists.txt
index 811b2cb..b94001a 100644
--- a/tests_reg/test/secure_fw/suites/crypto/CMakeLists.txt
+++ b/tests_reg/test/secure_fw/suites/crypto/CMakeLists.txt
@@ -64,9 +64,12 @@
if (TEST_S_CRYPTO)
- 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
+ add_library(tfm_test_suite_crypto_s STATIC EXCLUDE_FROM_ALL)
+
+ 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
)
target_include_directories(tfm_test_suite_crypto_s
diff --git a/tests_reg/test/secure_fw/suites/fpu/CMakeLists.txt b/tests_reg/test/secure_fw/suites/fpu/CMakeLists.txt
index e1c2f33..c8b7d0c 100644
--- a/tests_reg/test/secure_fw/suites/fpu/CMakeLists.txt
+++ b/tests_reg/test/secure_fw/suites/fpu/CMakeLists.txt
@@ -45,9 +45,13 @@
####################### Secure #################################################
if (TEST_S_FPU)
- 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
+
+ add_library(tfm_test_suite_fpu_s STATIC EXCLUDE_FROM_ALL)
+
+ 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
)
target_include_directories(tfm_test_suite_fpu_s
diff --git a/tests_reg/test/secure_fw/suites/fpu/service/CMakeLists.txt b/tests_reg/test/secure_fw/suites/fpu/service/CMakeLists.txt
index 57c96a3..2cdf772 100644
--- a/tests_reg/test/secure_fw/suites/fpu/service/CMakeLists.txt
+++ b/tests_reg/test/secure_fw/suites/fpu/service/CMakeLists.txt
@@ -36,7 +36,7 @@
.
PRIVATE
${CMAKE_BINARY_DIR}/generated/secure_fw/test_services/tfm_fpu_service
- ${CONFIG_TFM_TEST_DIR}/secure_fw/suites/fpu
+ ${SECURE_FW_REG_DIR}/suites/fpu
)
target_include_directories(tfm_partitions
diff --git a/tests_reg/test/secure_fw/suites/its/CMakeLists.txt b/tests_reg/test/secure_fw/suites/its/CMakeLists.txt
index c87f9f9..da1b603 100644
--- a/tests_reg/test/secure_fw/suites/its/CMakeLists.txt
+++ b/tests_reg/test/secure_fw/suites/its/CMakeLists.txt
@@ -45,10 +45,14 @@
####################### Secure #################################################
if (TEST_S_ITS)
- 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
+
+ add_library(tfm_test_suite_its_s STATIC EXCLUDE_FROM_ALL)
+
+ 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
)
target_include_directories(tfm_test_suite_its_s
diff --git a/tests_reg/test/secure_fw/suites/platform/CMakeLists.txt b/tests_reg/test/secure_fw/suites/platform/CMakeLists.txt
index 543c3c5..fe62b0b 100644
--- a/tests_reg/test/secure_fw/suites/platform/CMakeLists.txt
+++ b/tests_reg/test/secure_fw/suites/platform/CMakeLists.txt
@@ -44,9 +44,13 @@
####################### Secure #################################################
if (TEST_S_PLATFORM)
- 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
+
+ add_library(tfm_test_suite_platform_s STATIC EXCLUDE_FROM_ALL)
+
+ 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
)
target_include_directories(tfm_test_suite_platform_s
diff --git a/tests_reg/test/secure_fw/suites/ps/CMakeLists.txt b/tests_reg/test/secure_fw/suites/ps/CMakeLists.txt
index 2ca1e29..cc5547a 100644
--- a/tests_reg/test/secure_fw/suites/ps/CMakeLists.txt
+++ b/tests_reg/test/secure_fw/suites/ps/CMakeLists.txt
@@ -49,10 +49,14 @@
####################### Secure #################################################
if (TEST_S_PS)
- 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>
+
+ add_library(tfm_test_suite_ps_s STATIC EXCLUDE_FROM_ALL)
+
+ 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>
)
target_sources(tfm_app_rot_partition_ps
diff --git a/tests_reg/test/secure_fw/suites/spm/ipc/CMakeLists.txt b/tests_reg/test/secure_fw/suites/spm/ipc/CMakeLists.txt
index 957f65e..1503889 100644
--- a/tests_reg/test/secure_fw/suites/spm/ipc/CMakeLists.txt
+++ b/tests_reg/test/secure_fw/suites/spm/ipc/CMakeLists.txt
@@ -47,9 +47,13 @@
####################### Secure #################################################
if (TEST_S_IPC)
- 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
+
+ add_library(tfm_test_suite_ipc_s STATIC EXCLUDE_FROM_ALL)
+
+ 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
)
target_include_directories(tfm_test_suite_ipc_s
diff --git a/tests_reg/test/secure_fw/suites/spm/ipc/service/tfm_ipc_client/CMakeLists.txt b/tests_reg/test/secure_fw/suites/spm/ipc/service/tfm_ipc_client/CMakeLists.txt
index 9a8dccb..ccaebae 100644
--- a/tests_reg/test/secure_fw/suites/spm/ipc/service/tfm_ipc_client/CMakeLists.txt
+++ b/tests_reg/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
- ${CONFIG_TFM_TEST_DIR}/secure_fw/common_test_services/tfm_secure_client_2
+ ${SECURE_FW_REG_DIR}/common_test_services/tfm_secure_client_2
)
target_include_directories(tfm_partitions
diff --git a/tests_reg/test/secure_fw/suites/spm/irq/service/tfm_slih_test_service/CMakeLists.txt b/tests_reg/test/secure_fw/suites/spm/irq/service/tfm_slih_test_service/CMakeLists.txt
index fdad447..d54f870 100644
--- a/tests_reg/test/secure_fw/suites/spm/irq/service/tfm_slih_test_service/CMakeLists.txt
+++ b/tests_reg/test/secure_fw/suites/spm/irq/service/tfm_slih_test_service/CMakeLists.txt
@@ -37,6 +37,11 @@
platform_s
)
+target_compile_definitions(tfm_app_rot_partition_slih_test
+ PUBLIC
+ TFM_PARTITION_SLIH_TEST
+)
+
target_link_libraries(tfm_spm
PRIVATE
tfm_app_rot_partition_slih_test
diff --git a/tests_reg/test/secure_fw/suites/t_cose/CMakeLists.txt b/tests_reg/test/secure_fw/suites/t_cose/CMakeLists.txt
index 1d2f04d..f288a17 100644
--- a/tests_reg/test/secure_fw/suites/t_cose/CMakeLists.txt
+++ b/tests_reg/test/secure_fw/suites/t_cose/CMakeLists.txt
@@ -7,20 +7,25 @@
cmake_policy(SET CMP0079 NEW)
-if(TEST_NS_ATTESTATION AND TFM_NS_REG_TEST) # Need TFM_NS_REG_TEST to exclude when building SPE
- include(${CONFIG_SPE_PATH}/t_cose/tfm_t_cose.cmake)
+if (NOT TEST_NS_ATTESTATION AND NOT TEST_NS_T_COSE)
+ return()
+endif()
+
+set(T_COSE_SRC_DIR ${CONFIG_SPE_PATH}/t_cose)
+
+include(${T_COSE_SRC_DIR}/tfm_t_cose.cmake)
############################ t_cose non secure #################################
- add_library(tfm_t_cose_ns STATIC EXCLUDE_FROM_ALL)
- target_link_libraries(tfm_t_cose_ns
- PRIVATE
- tfm_t_cose_common
- tfm_t_cose_defs
- tfm_qcbor_ns
- tfm_api_ns
- )
-endif()
+add_library(tfm_t_cose_ns STATIC EXCLUDE_FROM_ALL)
+
+target_link_libraries(tfm_t_cose_ns
+ PUBLIC
+ tfm_t_cose_common
+ tfm_t_cose_defs
+ tfm_qcbor_ns
+ tfm_api_ns
+)
if (NOT TEST_NS_T_COSE)
return()
@@ -30,8 +35,6 @@
add_library(tfm_t_cose_test STATIC EXCLUDE_FROM_ALL)
-set(T_COSE_SRC_DIR ${CMAKE_SOURCE_DIR}/lib/ext/t_cose)
-
target_sources(tfm_t_cose_test
PRIVATE
${T_COSE_SRC_DIR}/test/run_tests.c
@@ -47,6 +50,11 @@
$<BUILD_INTERFACE:${T_COSE_SRC_DIR}/test>
)
+target_link_libraries(tfm_t_cose_test
+ PUBLIC
+ tfm_t_cose_ns
+)
+
####################### Non Secure #############################################
add_library(tfm_test_suite_t_cose_ns STATIC EXCLUDE_FROM_ALL)
diff --git a/tests_reg/test/secure_regression/CMakeLists.txt b/tests_reg/test/secure_regression/CMakeLists.txt
new file mode 100644
index 0000000..9a09438
--- /dev/null
+++ b/tests_reg/test/secure_regression/CMakeLists.txt
@@ -0,0 +1,70 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2023, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+# Check configuration.
+# Config check shall be performed after all configurations complete.
+# Difficult to insert a hook to perform test config check inside configuration sequence.
+# Put the check here before secure regression tests start.
+include(${CMAKE_CURRENT_LIST_DIR}/../config/check_config.cmake)
+
+if(TFM_S_REG_TEST OR TEST_BL2 OR TEST_BL1_1 OR TEST_BL1_2)
+ # In secure build, if a service/test looks for top-level directories, it will be a very long path.
+ # Define variables of top-level directories to shorten the long paths.
+ # Regresstion test directory
+ set(REG_TEST_DIR ${CMAKE_CURRENT_LIST_DIR}/../)
+ # Root directory of tf-m-tests
+ set(TFM_TESTS_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/../../../)
+
+ list(APPEND CMAKE_MODULE_PATH ${TFM_TESTS_ROOT_DIR}/cmake)
+ list(APPEND CMAKE_MODULE_PATH ${REG_TEST_DIR}/../utils)
+ include(utils)
+
+ add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../framework ${CMAKE_CURRENT_BINARY_DIR}/framework)
+endif()
+
+if(TFM_S_REG_TEST)
+ include(secure_fw.cmake)
+endif()
+
+if(TEST_BL2)
+ add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../bl2 ${CMAKE_CURRENT_BINARY_DIR}/bl2)
+endif()
+
+if(TEST_BL1_1 OR TEST_BL1_2)
+ add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../bl1 ${CMAKE_CURRENT_BINARY_DIR}/bl1)
+endif()
+
+# NS test suites
+get_cmake_property(CACHE_VARS CACHE_VARIABLES)
+foreach(CACHE_VAR ${CACHE_VARS})
+ get_property(HELP_STRING CACHE ${CACHE_VAR} PROPERTY HELPSTRING)
+ get_property(CACHE_TYPE CACHE ${CACHE_VAR} PROPERTY TYPE)
+
+ string(REGEX MATCH "^TEST_NS.+" _NS_TEST_FOUND "${CACHE_VAR}")
+ if (_NS_TEST_FOUND)
+ format_string(FORMATTED_CACHE_VAR ${CACHE_VAR} 25 " ")
+ format_string(FORMATTED_CACHE_VAL ${${CACHE_VAR}} 5 " ")
+ string(APPEND NS_TEST_CONFIG_OPTIONS
+ "set(${FORMATTED_CACHE_VAR} ${FORMATTED_CACHE_VAL} CACHE ${CACHE_TYPE} \"${HELP_STRING}\")\r\n"
+ )
+ endif()
+endforeach()
+
+# Specify TFM_NS_REG_TEST
+string(APPEND NS_TEST_CONFIG_OPTIONS
+ "set(TFM_NS_REG_TEST \"${TFM_NS_REG_TEST}\")\r\n"
+)
+
+# Extra NS test sute path
+string(APPEND NS_TEST_CONFIG_OPTIONS
+ "set(EXTRA_NS_TEST_SUITE_PATH \"${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\")\r\n"
+)
+
+# This file is for NS build
+configure_file(${CMAKE_CURRENT_LIST_DIR}/../config/config_ns_test.cmake.in
+ ${CMAKE_INSTALL_PREFIX}/config_ns_test.cmake
+ @ONLY)
\ No newline at end of file
diff --git a/tests_reg/test/secure_regression/secure_fw.cmake b/tests_reg/test/secure_regression/secure_fw.cmake
new file mode 100644
index 0000000..4714639
--- /dev/null
+++ b/tests_reg/test/secure_regression/secure_fw.cmake
@@ -0,0 +1,86 @@
+#-------------------------------------------------------------------------------
+# 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
+#
+#-------------------------------------------------------------------------------
+
+include(utils)
+ dump_options("TEST Configuration"
+ "
+ TEST_NS;
+ TEST_S;
+ TEST_NS_ATTESTATION;
+ TEST_NS_CRYPTO;
+ TEST_NS_ITS;
+ TEST_NS_PS;
+ TEST_NS_QCBOR;
+ TEST_NS_T_COSE;
+ TEST_NS_PLATFORM;
+ TEST_NS_FWU;
+ TEST_NS_IPC;
+ TEST_NS_SLIH_IRQ;
+ TEST_NS_FLIH_IRQ;
+ TEST_NS_MULTI_CORE;
+ TEST_NS_MANAGE_NSID;
+ TEST_NS_SFN_BACKEND;
+ TEST_NS_FPU;
+ TEST_S_ATTESTATION;
+ TEST_S_CRYPTO;
+ TEST_S_ITS;
+ TEST_S_PS;
+ TEST_S_PLATFORM;
+ TEST_S_FWU;
+ TEST_S_IPC;
+ TEST_S_SFN_BACKEND;
+ TEST_S_FPU;
+ "
+ )
+
+add_library(tfm_test_framework_s INTERFACE)
+add_library(tfm_s_tests STATIC)
+
+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
+)
+
+target_sources(tfm_s_tests
+ PRIVATE
+ ${CMAKE_CURRENT_LIST_DIR}/secure_suites.c
+)
+
+target_link_libraries(tfm_s_tests
+ PUBLIC
+ tfm_test_framework_s
+ tfm_config
+ tfm_spm
+)
+
+target_compile_definitions(tfm_s_tests
+ PRIVATE
+ $<$<BOOL:${PS_TEST_NV_COUNTERS}>:PS_TEST_NV_COUNTERS>
+)
+
+include(test_suite_utils)
+
+# A temporary workaround:
+# Temporarily disable Non-secure regression test flags to build NS test suites.
+#
+# Alternatively, CMake files in test suites can be seperated into secure ones and non-secure ones.
+pre_secure_suite_build()
+add_subdirectory(${SECURE_FW_REG_DIR}/suites
+ ${CMAKE_CURRENT_BINARY_DIR}/secure_fw/suites
+)
+# Recover Non-secure regression test filgs.
+post_secure_suite_build()
diff --git a/tests_reg/test/secure_fw/secure_suites.c b/tests_reg/test/secure_regression/secure_suites.c
similarity index 100%
rename from tests_reg/test/secure_fw/secure_suites.c
rename to tests_reg/test/secure_regression/secure_suites.c
diff --git a/tests_reg/test_app.c b/tests_reg/test_app.c
index bd45b38..d29743c 100644
--- a/tests_reg/test_app.c
+++ b/tests_reg/test_app.c
@@ -7,7 +7,9 @@
#include "test_app.h"
#include "tfm_log.h"
+#ifdef TFM_NS_REG_TEST
#include "test_framework_integ_test.h"
+#endif
/**
* \brief Services test thread
@@ -18,7 +20,9 @@
{
UNUSED_VARIABLE(argument);
+#ifdef TFM_NS_REG_TEST
tfm_non_secure_client_run_tests();
+#endif
/* Output EOT char for test environments like FVP. */
LOG_MSG("\x04");
diff --git a/tests_reg/utils/regression_flag_parse.cmake b/tests_reg/utils/regression_flag_parse.cmake
new file mode 100644
index 0000000..ee05c45
--- /dev/null
+++ b/tests_reg/utils/regression_flag_parse.cmake
@@ -0,0 +1,59 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2021-2023, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+# Set whether Secure and Non-secure regression tests are selected.
+# If any regression test is selected, set corresponding TFM_S_REG_TEST/TEST_NS_REG_TEST to
+# require TF-M build secure tests and test partitions.
+#
+# cmd_line: the output argument to collect the arguments via command line
+#
+function(parse_regression_flag cmd_line)
+
+ set(TFM_NS_REG_TEST OFF)
+ set(TFM_S_REG_TEST OFF)
+
+ get_cmake_property(CACHE_VARS CACHE_VARIABLES)
+
+ # By default all non-secure regression tests are disabled.
+ # If TEST_NS or TEST_NS_XXX flag is passed via command line and set to ON,
+ # selected corresponding features to support non-secure regression tests.
+ foreach(CACHE_VAR ${CACHE_VARS})
+ string(REGEX MATCH "^TEST_NS.*" _NS_TEST_FOUND "${CACHE_VAR}")
+ if (_NS_TEST_FOUND AND "${${CACHE_VAR}}")
+ # TFM_NS_REG_TEST is a TF-M internal cmake flag to manage building
+ # tf-m-tests non-secure regression tests related source
+ set(TFM_NS_REG_TEST ON)
+ break()
+ endif()
+ endforeach()
+
+ foreach(CACHE_VAR ${CACHE_VARS})
+ string(REGEX MATCH "^TEST_S.*" _S_TEST_FOUND "${CACHE_VAR}")
+ if (_S_TEST_FOUND AND "${${CACHE_VAR}}")
+ # TFM_S_REG_TEST is a TF-M internal cmake flag to manage building
+ # tf-m-tests secure regression tests related source
+ set(TFM_S_REG_TEST ON)
+ break()
+ endif()
+ endforeach()
+
+ # By default EXTRA_<NS/S>_TEST_SUITES_PATHS is not set, extra test is also an
+ # out-of-tree build regression test, and if they are enabled,
+ # TFM_<NS/S>_REG_TEST will be enabled.
+ if (EXTRA_NS_TEST_SUITE_PATH)
+ set(TFM_NS_REG_TEST ON)
+ endif()
+
+ if (EXTRA_S_TEST_SUITE_PATH)
+ set(TFM_S_REG_TEST ON)
+ endif()
+
+ set(ns_reg_cmd "-DTFM_NS_REG_TEST:BOOL=${TFM_NS_REG_TEST}")
+ set(s_reg_cmd "-DTFM_S_REG_TEST:BOOL=${TFM_S_REG_TEST}")
+ set(${cmd_line} "${${cmd_line}};${ns_reg_cmd};${s_reg_cmd}" PARENT_SCOPE)
+
+endfunction()
diff --git a/tests_reg/utils/test_suite_utils.cmake b/tests_reg/utils/test_suite_utils.cmake
new file mode 100644
index 0000000..e9e6c66
--- /dev/null
+++ b/tests_reg/utils/test_suite_utils.cmake
@@ -0,0 +1,86 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2023, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+# Temporarily unset NS test flags to skip NS test suites during S build.
+# These flags will be recovered in post_secure_suite_build().
+# Their values are kept in temporary local variables.
+macro(pre_secure_suite_build)
+ 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}}")
+ set(TEMP_${CACHE_VAR} ${${CACHE_VAR}})
+ unset(${CACHE_VAR} CACHE)
+ endif()
+ endforeach()
+
+ if(EXTRA_NS_TEST_SUITE_PATH)
+ set(TEMP_EXTRA_NS_TEST_SUITE_PATH ${EXTRA_NS_TEST_SUITE_PATH})
+ unset(EXTRA_NS_TEST_SUITE_PATH CACHE)
+ endif()
+endmacro()
+
+# Recover test flags unset in pre_secure_suite_build().
+# Their values are restored from temporary local variables and written back.
+macro(post_secure_suite_build)
+ get_cmake_property(TEMP_TEST_VARS VARIABLES)
+
+ foreach(TEMP_TEST ${TEMP_TEST_VARS})
+ string(REGEX MATCH "^TEMP_TEST_NS.*" _NS_TEST_FOUND "${TEMP_TEST}")
+ if(_NS_TEST_FOUND AND "${${TEMP_TEST}}")
+ string(REGEX REPLACE "^TEMP_" "" TEST_NAME ${TEMP_TEST})
+ set(${TEST_NAME} ON CACHE BOOL "")
+ unset(${TEMP_TEST})
+ endif()
+ endforeach()
+
+ if(TEMP_EXTRA_NS_TEST_SUITE_PATH)
+ set(EXTRA_NS_TEST_SUITE_PATH ${TEMP_EXTRA_NS_TEST_SUITE_PATH} CACHE PATH "")
+ unset(TEMP_EXTRA_NS_TEST_SUITE_PATH)
+ endif()
+endmacro()
+
+# Temporarily unset S test flags to skip S test suites during NS build.
+# These flags will be recovered in post_ns_suite_build(). Their values are kept in temporary local
+# variables.
+macro(pre_ns_suite_build)
+ get_cmake_property(CACHE_VARS CACHE_VARIABLES)
+
+ foreach(CACHE_VAR ${CACHE_VARS})
+ string(REGEX MATCH "^TEST_S.*" _S_TEST_FOUND "${CACHE_VAR}")
+ if(_S_TEST_FOUND AND "${${CACHE_VAR}}")
+ set(TEMP_${CACHE_VAR} ${${CACHE_VAR}})
+ unset(${CACHE_VAR} CACHE)
+ endif()
+ endforeach()
+
+ if(EXTRA_S_TEST_SUITE_PATH)
+ set(TEMP_EXTRA_S_TEST_SUITE_PATH ${EXTRA_S_TEST_SUITE_PATH})
+ unset(EXTRA_S_TEST_SUITE_PATH CACHE)
+ endif()
+endmacro()
+
+# Recover test flags unset in pre_ns_suite_build().
+# Their values are restored from temporary local variables and written back.
+macro(post_ns_suite_build)
+ get_cmake_property(TEMP_TEST_VARS VARIABLES)
+
+ foreach(TEMP_TEST ${TEMP_TEST_VARS})
+ string(REGEX MATCH "^TEMP_TEST_S.*" _S_TEST_FOUND "${TEMP_TEST}")
+ if(_S_TEST_FOUND AND "${${TEMP_TEST}}")
+ string(REGEX REPLACE "^TEMP_" "" TEST_NAME ${TEMP_TEST})
+ set(${TEST_NAME} ON CACHE BOOL "")
+ unset(${TEMP_TEST})
+ endif()
+ endforeach()
+
+ if(TEMP_EXTRA_S_TEST_SUITE_PATH)
+ set(EXTRA_S_TEST_SUITE_PATH ${TEMP_EXTRA_S_TEST_SUITE_PATH} CACHE PATH "")
+ unset(TEMP_EXTRA_S_TEST_SUITE_PATH)
+ endif()
+endmacro()