Test: Build TF-M SPE alone with NS test flags selected
Some usage scenarios, such as multi-core platforms, require to build
non-secure side and secure side separately. TF-M currently supports to
build TF-M secure side with secure tests only.
However, some non-secure tests also require secure test services.
Therefore, NS test flags shall be selected even during TF-M secure build
alone.
But if NS tests flags are selected while building TF-M secure side only,
the TF-M build with current tf-m-tests will fail since the tf-m-tests is
not decoupled well.
This commit supports to build TF-M secure side only with NS test flags
selected, to include secure test services to support NS tests.
If NS is not selected, skip NS test framework and test suites build by
temporarily unsetting corresponding flags.
Signed-off-by: David Hu <david.hu@arm.com>
Change-Id: I2ae1caab9d5b63f43bb17453a3392cb22963f85d
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 7d568d2..0427d99 100755
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -7,59 +7,13 @@
cmake_minimum_required(VERSION 3.13)
-add_library(tfm_ns_tests INTERFACE)
-add_library(tfm_test_framework_ns INTERFACE)
-add_library(tfm_test_framework_s INTERFACE)
-
-# 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 (TFM_MULTI_CORE_TOPOLOGY)
- include(${CMAKE_SOURCE_DIR}/platform/ext/target/${TFM_PLATFORM}/preload_ns.cmake)
- tfm_toolchain_reload_compiler()
-endif()
-
-add_subdirectory(test_services)
-
-add_subdirectory(suites/attestation)
-add_subdirectory(suites/audit)
-add_subdirectory(suites/core)
-add_subdirectory(suites/crypto)
-add_subdirectory(suites/extra)
-add_subdirectory(suites/its)
-add_subdirectory(suites/qcbor)
-add_subdirectory(suites/ps)
-add_subdirectory(suites/t_cose)
-add_subdirectory(suites/platform)
-add_subdirectory(suites/fwu)
-add_subdirectory(suites/irq)
-add_subdirectory(suites/nsid)
-
-if(TFM_PSA_API)
- add_subdirectory(suites/ipc)
-endif()
-if(TEST_NS_MULTI_CORE)
- add_subdirectory(suites/multi_core/non_secure)
-endif()
-
-if (TFM_FUZZER_TOOL_TESTS)
- 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()
-
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
+ ${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
@@ -67,60 +21,8 @@
framework
)
-target_compile_definitions(tfm_test_framework_ns
- INTERFACE
- DOMAIN_NS=1
-)
+# Build test services and add secure test suite targets
+include(secure_tests.cmake)
-target_link_libraries(tfm_test_framework_ns
- INTERFACE
- tfm_test_framework_common
- tfm_api_ns
- tfm_ns_interface
- tfm_ns_log
-)
-
-target_sources(tfm_ns_tests
- INTERFACE
- ${CMAKE_CURRENT_SOURCE_DIR}/framework/non_secure_suites.c
-)
-
-target_link_libraries(tfm_ns_tests
- INTERFACE
- tfm_test_framework_ns
- tfm_partition_defs
-)
-
-target_compile_definitions(tfm_ns_tests
- INTERFACE
- $<$<BOOL:${SYMMETRIC_INITIAL_ATTESTATION}>:SYMMETRIC_INITIAL_ATTESTATION>
- $<$<BOOL:${TFM_FUZZER_TOOL_TESTS}>:TFM_FUZZER_TOOL_TESTS>
-)
-
-####################### Secure #################################################
-
-target_link_libraries(tfm_test_framework_s
- INTERFACE
- psa_interface
- tfm_test_framework_common
- tfm_sp_log_raw
-)
-
-if (TEST_FRAMEWORK_S)
- target_sources(tfm_s_tests
- INTERFACE
- ${CMAKE_CURRENT_SOURCE_DIR}/framework/secure_suites.c
- )
-
- target_link_libraries(tfm_s_tests
- INTERFACE
- tfm_test_framework_s
- tfm_partition_defs
- tfm_spm
- )
-
- target_compile_definitions(tfm_s_tests
- INTERFACE
- $<$<BOOL:${PS_TEST_NV_COUNTERS}>:PS_TEST_NV_COUNTERS>
- )
-endif()
+# Include test suites at last after other targets are setup.
+add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/suites)