blob: 7d568d222b2c6c4d60b9ddcc13e6b9b5e9b58454 [file] [log] [blame]
Kevin Peng62a87112020-07-07 15:07:46 +08001#-------------------------------------------------------------------------------
David Hub8dd1712021-02-09 15:07:46 +08002# Copyright (c) 2020-2021, Arm Limited. All rights reserved.
Kevin Peng62a87112020-07-07 15:07:46 +08003#
4# SPDX-License-Identifier: BSD-3-Clause
5#
6#-------------------------------------------------------------------------------
7
Raef Coles652bb8a2020-09-24 11:27:38 +01008cmake_minimum_required(VERSION 3.13)
Kevin Peng62a87112020-07-07 15:07:46 +08009
Raef Coles652bb8a2020-09-24 11:27:38 +010010add_library(tfm_ns_tests INTERFACE)
David Hu73f259b2020-12-07 10:58:41 +080011add_library(tfm_test_framework_ns INTERFACE)
12add_library(tfm_test_framework_s INTERFACE)
Raef Coles652bb8a2020-09-24 11:27:38 +010013
14# For multi-core projects, the NS app can be run on a different CPU to the
15# Secure code. To facilitate this, we once again reload the compiler to load the
16# setting for the NS CPU. Cmake settings are directory scoped so this affects
17# anything loaded from or declared in this dir.
18if (TFM_MULTI_CORE_TOPOLOGY)
19 include(${CMAKE_SOURCE_DIR}/platform/ext/target/${TFM_PLATFORM}/preload_ns.cmake)
Raef Coles34cffa72020-10-28 10:27:19 +000020 tfm_toolchain_reload_compiler()
Kevin Pengae997e42020-07-08 17:06:37 +080021endif()
Kevin Peng62a87112020-07-07 15:07:46 +080022
Raef Coles652bb8a2020-09-24 11:27:38 +010023add_subdirectory(test_services)
Kevin Peng62a87112020-07-07 15:07:46 +080024
Raef Coles652bb8a2020-09-24 11:27:38 +010025add_subdirectory(suites/attestation)
26add_subdirectory(suites/audit)
27add_subdirectory(suites/core)
28add_subdirectory(suites/crypto)
Jianliang Shen2959c1f2021-09-01 10:14:06 +080029add_subdirectory(suites/extra)
Raef Coles652bb8a2020-09-24 11:27:38 +010030add_subdirectory(suites/its)
31add_subdirectory(suites/qcbor)
32add_subdirectory(suites/ps)
33add_subdirectory(suites/t_cose)
34add_subdirectory(suites/platform)
Sherry Zhang92c499a2021-03-08 18:14:15 +080035add_subdirectory(suites/fwu)
Kevin Penga8604332021-04-23 17:33:30 +080036add_subdirectory(suites/irq)
Xinyu Zhang92fe7582021-09-24 17:11:49 +080037add_subdirectory(suites/nsid)
Sherry Zhang92c499a2021-03-08 18:14:15 +080038
Raef Coles652bb8a2020-09-24 11:27:38 +010039if(TFM_PSA_API)
40 add_subdirectory(suites/ipc)
41endif()
shejia01e0dd80a2021-07-12 17:47:50 +080042if(TEST_NS_MULTI_CORE)
David Hub0bce472021-05-20 14:06:52 +080043 add_subdirectory(suites/multi_core/non_secure)
Kevin Peng62a87112020-07-07 15:07:46 +080044endif()
45
Mate Toth-Palb3f96d22021-05-12 08:42:34 +020046if (TFM_FUZZER_TOOL_TESTS)
47 if(NOT DEFINED TFM_FUZZER_TOOL_TESTS_CMAKE_INC_PATH)
48 # The location of the file needs to be defined either from command line
49 # or from config cmake file.
50 message(FATAL_ERROR "Incomplete build configuration: TFM_FUZZER_TOOL_TESTS_CMAKE_INC_PATH is undefined.")
51 else()
52 add_subdirectory(${TFM_FUZZER_TOOL_TESTS_CMAKE_INC_PATH} ${CMAKE_BINARY_DIR}/suites/tfm_fuzz)
53 endif()
54endif()
55
David Hu73f259b2020-12-07 10:58:41 +080056add_library(tfm_test_framework_common INTERFACE)
57
58target_sources(tfm_test_framework_common
Raef Coles652bb8a2020-09-24 11:27:38 +010059 INTERFACE
60 ${CMAKE_CURRENT_SOURCE_DIR}/framework/test_framework.c
61 ${CMAKE_CURRENT_SOURCE_DIR}/framework/test_framework_helpers.c
62 ${CMAKE_CURRENT_SOURCE_DIR}/framework/test_framework_integ_test_helper.c
63)
Kevin Peng62a87112020-07-07 15:07:46 +080064
David Hu73f259b2020-12-07 10:58:41 +080065target_include_directories(tfm_test_framework_common
Raef Coles652bb8a2020-09-24 11:27:38 +010066 INTERFACE
67 framework
68)
Kevin Peng62a87112020-07-07 15:07:46 +080069
David Hu1a74bc52021-08-19 11:17:42 +080070target_compile_definitions(tfm_test_framework_ns
71 INTERFACE
72 DOMAIN_NS=1
73)
74
David Hu73f259b2020-12-07 10:58:41 +080075target_link_libraries(tfm_test_framework_ns
Raef Coles652bb8a2020-09-24 11:27:38 +010076 INTERFACE
David Hu73f259b2020-12-07 10:58:41 +080077 tfm_test_framework_common
David Hub8dd1712021-02-09 15:07:46 +080078 tfm_api_ns
David Hu73f259b2020-12-07 10:58:41 +080079 tfm_ns_interface
Kevin Pengaf602292020-10-20 17:49:52 +080080 tfm_ns_log
Raef Coles652bb8a2020-09-24 11:27:38 +010081)
Kevin Peng62a87112020-07-07 15:07:46 +080082
Raef Coles652bb8a2020-09-24 11:27:38 +010083target_sources(tfm_ns_tests
84 INTERFACE
85 ${CMAKE_CURRENT_SOURCE_DIR}/framework/non_secure_suites.c
86)
Kevin Peng62a87112020-07-07 15:07:46 +080087
Raef Coles652bb8a2020-09-24 11:27:38 +010088target_link_libraries(tfm_ns_tests
89 INTERFACE
David Hu73f259b2020-12-07 10:58:41 +080090 tfm_test_framework_ns
Raef Coles652bb8a2020-09-24 11:27:38 +010091 tfm_partition_defs
92)
Kevin Peng62a87112020-07-07 15:07:46 +080093
Raef Coles652bb8a2020-09-24 11:27:38 +010094target_compile_definitions(tfm_ns_tests
95 INTERFACE
96 $<$<BOOL:${SYMMETRIC_INITIAL_ATTESTATION}>:SYMMETRIC_INITIAL_ATTESTATION>
Mate Toth-Palb3f96d22021-05-12 08:42:34 +020097 $<$<BOOL:${TFM_FUZZER_TOOL_TESTS}>:TFM_FUZZER_TOOL_TESTS>
Raef Coles652bb8a2020-09-24 11:27:38 +010098)
Kevin Peng62a87112020-07-07 15:07:46 +080099
Raef Coles652bb8a2020-09-24 11:27:38 +0100100####################### Secure #################################################
Kevin Peng62a87112020-07-07 15:07:46 +0800101
David Hu73f259b2020-12-07 10:58:41 +0800102target_link_libraries(tfm_test_framework_s
103 INTERFACE
104 psa_interface
105 tfm_test_framework_common
David Hu1a74bc52021-08-19 11:17:42 +0800106 tfm_sp_log_raw
David Hu73f259b2020-12-07 10:58:41 +0800107)
108
shejia01e0dd80a2021-07-12 17:47:50 +0800109if (TEST_FRAMEWORK_S)
David Hu4f538e42020-11-09 16:46:17 +0800110 target_sources(tfm_s_tests
111 INTERFACE
112 ${CMAKE_CURRENT_SOURCE_DIR}/framework/secure_suites.c
113 )
Kevin Peng62a87112020-07-07 15:07:46 +0800114
David Hu4f538e42020-11-09 16:46:17 +0800115 target_link_libraries(tfm_s_tests
116 INTERFACE
David Hu73f259b2020-12-07 10:58:41 +0800117 tfm_test_framework_s
David Hu4f538e42020-11-09 16:46:17 +0800118 tfm_partition_defs
119 tfm_spm
120 )
Jamie Fox9d688172020-10-22 23:26:24 +0100121
David Hu4f538e42020-11-09 16:46:17 +0800122 target_compile_definitions(tfm_s_tests
123 INTERFACE
124 $<$<BOOL:${PS_TEST_NV_COUNTERS}>:PS_TEST_NV_COUNTERS>
125 )
126endif()