Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 1 | #/** @file |
Avi Nawal | dcef734 | 2025-07-12 01:23:45 +0530 | [diff] [blame] | 2 | # * Copyright (c) 2019-2025, Arm Limited or its affiliates. All rights reserved. |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 3 | # * SPDX-License-Identifier : Apache-2.0 |
jothikumar mani | 36b2b86 | 2023-05-05 13:51:27 +0530 | [diff] [blame] | 4 | # * Copyright 2023 NXP |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 5 | # * |
| 6 | # * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | # * you may not use this file except in compliance with the License. |
| 8 | # * You may obtain a copy of the License at |
| 9 | # * |
| 10 | # * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # * |
| 12 | # * Unless required by applicable law or agreed to in writing, software |
| 13 | # * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | # * See the License for the specific language governing permissions and |
| 16 | # * limitations under the License. |
| 17 | #**/ |
| 18 | |
| 19 | # Set the minimum required version of CMake for the project |
| 20 | cmake_minimum_required(VERSION 3.10) |
| 21 | |
| 22 | # cmake_policy |
| 23 | cmake_policy(SET CMP0057 NEW) |
| 24 | |
| 25 | # Find python interpreter version 3 or greater |
| 26 | find_package(PythonInterp 3 REQUIRED) |
| 27 | # Find Git package |
| 28 | find_package(Git REQUIRED) |
| 29 | |
| 30 | get_filename_component(PSA_ROOT_DIR . ABSOLUTE) |
| 31 | |
Lingkai Dong | 9d4e7df | 2021-01-13 16:57:54 +0000 | [diff] [blame] | 32 | include(${PSA_ROOT_DIR}/tools/cmake/common/Utils.cmake) |
Avi Nawal | dcef734 | 2025-07-12 01:23:45 +0530 | [diff] [blame] | 33 | include(${PSA_ROOT_DIR}/tools/cmake/common/CommonVAL.cmake) |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 34 | include(${PSA_ROOT_DIR}/tools/cmake/common/CMakeSettings.cmake) |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 35 | include(${PSA_ROOT_DIR}/tools/cmake/common/CMakeExternal.cmake) |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 36 | |
jotman01 | 6d7dd4e | 2020-11-10 17:32:28 +0800 | [diff] [blame] | 37 | if(NOT DEFINED TFM_PROFILE) |
| 38 | message(STATUS "[PSA] : Building Default profile") |
| 39 | list(APPEND PSA_SUITES |
| 40 | "IPC" |
| 41 | "CRYPTO" |
| 42 | "INTERNAL_TRUSTED_STORAGE" |
| 43 | "PROTECTED_STORAGE" |
| 44 | "STORAGE" |
| 45 | "INITIAL_ATTESTATION" |
| 46 | ) |
| 47 | else() |
| 48 | |
| 49 | if("${TFM_PROFILE}" STREQUAL "profile_small") |
| 50 | # list of supported suites |
| 51 | list(APPEND PSA_SUITES |
| 52 | "CRYPTO" |
| 53 | "INTERNAL_TRUSTED_STORAGE" |
| 54 | "INITIAL_ATTESTATION" |
| 55 | ) |
| 56 | else() |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 57 | # list of supported suites |
| 58 | list(APPEND PSA_SUITES |
| 59 | "IPC" |
| 60 | "CRYPTO" |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 61 | "INTERNAL_TRUSTED_STORAGE" |
jotman01 | 6d7dd4e | 2020-11-10 17:32:28 +0800 | [diff] [blame] | 62 | "PROTECTED_STORAGE" |
Vinay Kumar Kotegowder | 18fcd40 | 2020-04-27 17:38:41 +0530 | [diff] [blame] | 63 | "STORAGE" |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 64 | "INITIAL_ATTESTATION" |
| 65 | ) |
jotman01 | 6d7dd4e | 2020-11-10 17:32:28 +0800 | [diff] [blame] | 66 | endif() |
| 67 | endif() |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 68 | # list of ipc files required |
| 69 | list(APPEND PSA_IPC_FILES |
| 70 | "psa/client.h" |
| 71 | "psa/service.h" |
Jaykumar Pitambarbhai Patel | 1c2b028 | 2019-11-06 11:29:13 +0530 | [diff] [blame] | 72 | "psa/lifecycle.h" |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 73 | "psa_manifest/sid.h" |
| 74 | "psa_manifest/pid.h" |
Jaykumar Pitambarbhai Patel | 1c2b028 | 2019-11-06 11:29:13 +0530 | [diff] [blame] | 75 | "psa_manifest/driver_partition_psa.h" |
| 76 | "psa_manifest/client_partition_psa.h" |
| 77 | "psa_manifest/server_partition_psa.h" |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 78 | ) |
| 79 | |
| 80 | # list of crypto files required |
| 81 | list(APPEND PSA_CRYPTO_FILES |
| 82 | "psa/crypto.h" |
| 83 | ) |
| 84 | |
| 85 | # list of protected_storage files required |
| 86 | list(APPEND PSA_PROTECTED_STORAGE_FILES |
| 87 | "psa/protected_storage.h" |
| 88 | ) |
| 89 | |
| 90 | # list of internal_trusted_storage files required |
| 91 | list(APPEND PSA_INTERNAL_TRUSTED_STORAGE_FILES |
| 92 | "psa/internal_trusted_storage.h" |
| 93 | ) |
| 94 | |
Vinay Kumar Kotegowder | 18fcd40 | 2020-04-27 17:38:41 +0530 | [diff] [blame] | 95 | # list of storage files required |
| 96 | list(APPEND PSA_STORAGE_FILES |
| 97 | ${PSA_INTERNAL_TRUSTED_STORAGE_FILES} |
| 98 | ${PSA_PROTECTED_STORAGE_FILES} |
| 99 | ) |
| 100 | |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 101 | # list of initial_attestation files required |
| 102 | list(APPEND PSA_INITIAL_ATTESTATION_FILES |
| 103 | "psa/initial_attestation.h" |
| 104 | "psa/crypto.h" |
| 105 | ) |
| 106 | |
| 107 | # list of supported toolchains |
| 108 | list(APPEND PSA_TOOLCHAIN_SUPPORT |
| 109 | GNUARM |
| 110 | ARMCLANG |
| 111 | HOST_GCC |
jk-arm | 7e6145a | 2021-07-19 19:36:14 +0530 | [diff] [blame] | 112 | GCC_LINUX |
| 113 | INHERIT |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 114 | ) |
| 115 | |
Øyvind Rønningstad | c50804e | 2021-03-12 12:43:25 +0100 | [diff] [blame] | 116 | # list of supported CROSS_COMPILE toolchains |
| 117 | list(APPEND CROSS_COMPILE_TOOLCHAIN_SUPPORT |
| 118 | GNUARM |
jk-arm | 7e6145a | 2021-07-19 19:36:14 +0530 | [diff] [blame] | 119 | ARMCLANG |
| 120 | INHERIT |
Øyvind Rønningstad | c50804e | 2021-03-12 12:43:25 +0100 | [diff] [blame] | 121 | ) |
| 122 | |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 123 | # list of suported CPU arch |
| 124 | list(APPEND PSA_CPU_ARCH_SUPPORT |
| 125 | armv8m_ml |
| 126 | armv8m_bl |
Dávid Házi | 330c4b1 | 2023-05-03 11:20:02 +0200 | [diff] [blame] | 127 | armv81m_ml |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 128 | armv7m |
jothikumar mani | 4a27416 | 2023-07-18 00:31:22 +0800 | [diff] [blame] | 129 | armv7a |
jotman01 | bed7a15 | 2021-05-25 22:57:17 +0800 | [diff] [blame] | 130 | armv8a |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 131 | ) |
| 132 | |
Avi Nawal | dcef734 | 2025-07-12 01:23:45 +0530 | [diff] [blame] | 133 | # list of VERBOSITY options |
| 134 | list(APPEND PSA_VERBOSITY_OPTIONS 1 2 3 4 5) |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 135 | |
Jaykumar Pitambarbhai Patel | ccf5bf2 | 2019-12-06 11:58:32 +0530 | [diff] [blame] | 136 | # list of PLATFORM_PSA_ISOLATION_LEVEL options |
jotman01 | 6d7dd4e | 2020-11-10 17:32:28 +0800 | [diff] [blame] | 137 | if("${TFM_PROFILE}" STREQUAL "profile_medium") |
| 138 | list(APPEND PLATFORM_PSA_ISOLATION_LEVEL_OPTIONS 1 2) |
| 139 | else() |
Jaykumar Pitambarbhai Patel | ccf5bf2 | 2019-12-06 11:58:32 +0530 | [diff] [blame] | 140 | list(APPEND PLATFORM_PSA_ISOLATION_LEVEL_OPTIONS 1 2 3) |
jotman01 | 6d7dd4e | 2020-11-10 17:32:28 +0800 | [diff] [blame] | 141 | endif() |
Jaykumar Pitambarbhai Patel | ccf5bf2 | 2019-12-06 11:58:32 +0530 | [diff] [blame] | 142 | |
jk-arm | 01ee3ff | 2021-10-18 22:41:47 +0530 | [diff] [blame] | 143 | #list of INCLUDE_PANIC_TESTS options |
| 144 | list(APPEND PSA_INCLUDE_PANIC_TESTS_OPTIONS 0 1) |
| 145 | |
jk-arm | bf532fd | 2021-05-07 13:58:22 +0530 | [diff] [blame] | 146 | # list of available spec version |
| 147 | if("${SUITE}" STREQUAL "STORAGE" OR ${SUITE} STREQUAL "INTERNAL_TRUSTED_STORAGE" OR ${SUITE} STREQUAL "PROTECTED_STORAGE") |
| 148 | list(APPEND PSA_SPEC_VERSION |
| 149 | 1.0-BETA2 |
| 150 | 1.0 |
| 151 | ) |
| 152 | elseif("${SUITE}" STREQUAL "CRYPTO") |
| 153 | list(APPEND PSA_SPEC_VERSION |
| 154 | 1.0-BETA1 |
| 155 | 1.0-BETA2 |
| 156 | 1.0-BETA3 |
Avi Nawal | 5e72bf9 | 2024-03-14 18:39:09 +0800 | [diff] [blame] | 157 | 1.0.0 |
| 158 | 1.0.1 |
| 159 | 1.1.0 |
jk-arm | bf532fd | 2021-05-07 13:58:22 +0530 | [diff] [blame] | 160 | ) |
| 161 | elseif("${SUITE}" STREQUAL "INITIAL_ATTESTATION") |
| 162 | list(APPEND PSA_SPEC_VERSION |
| 163 | 1.0-BETA0 |
| 164 | 1.0.0 |
| 165 | 1.0.1 |
| 166 | 1.0.2 |
| 167 | ) |
jk-arm | 957cfea | 2021-06-18 15:52:12 +0530 | [diff] [blame] | 168 | elseif("${SUITE}" STREQUAL "IPC") |
| 169 | list(APPEND PSA_SPEC_VERSION |
| 170 | 1.0 |
| 171 | 1.1 |
| 172 | ) |
jk-arm | 957cfea | 2021-06-18 15:52:12 +0530 | [diff] [blame] | 173 | endif() |
| 174 | |
| 175 | #list of values available for connection based |
| 176 | if(${SUITE} STREQUAL "IPC") |
| 177 | list(APPEND PSA_STATELESS_ROT 0 1) |
jk-arm | bf532fd | 2021-05-07 13:58:22 +0530 | [diff] [blame] | 178 | endif() |
| 179 | |
jk-arm | 01ee3ff | 2021-10-18 22:41:47 +0530 | [diff] [blame] | 180 | #list of TESTS_COVERAGE available options |
| 181 | list(APPEND PSA_TESTS_COVERAGE_OPTIONS |
| 182 | "ALL" |
| 183 | "PASS" |
| 184 | ) |
| 185 | |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 186 | message(STATUS "[PSA] : ----------Process input arguments- start-------------") |
| 187 | |
| 188 | # Check for TARGET command line argument |
| 189 | _check_arguments("TARGET") |
| 190 | # Check for SUTIE command line argument |
| 191 | _check_arguments("SUITE") |
| 192 | # Check for PSA_INCLUDE_PATHS command line argument |
| 193 | _check_arguments("PSA_INCLUDE_PATHS") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 194 | |
| 195 | string(TOLOWER ${SUITE} SUITE_LOWER) |
| 196 | |
| 197 | # Check for valid targets |
| 198 | _get_sub_dir_list(PSA_TARGET_LIST ${PSA_ROOT_DIR}/platform/targets) |
| 199 | if(NOT ${TARGET} IN_LIST PSA_TARGET_LIST) |
Øyvind Rønningstad | abbb727 | 2020-11-09 14:50:54 +0100 | [diff] [blame] | 200 | message(FATAL_ERROR "[PSA] : Error: Unsupported value for -DTARGET=${TARGET}, supported targets are : ${PSA_TARGET_LIST}") |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 201 | else() |
| 202 | message(STATUS "[PSA] : TARGET is set to ${TARGET}") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 203 | endif() |
| 204 | |
| 205 | # Check for the presence of required test suite directories |
| 206 | if((NOT IS_DIRECTORY ${PSA_ROOT_DIR}/dev_apis) OR (NOT IS_DIRECTORY ${PSA_ROOT_DIR}/ff)) |
| 207 | message(STATUS "[PSA] : Error: Could not find architecture test suite directories in psa root path ${PSA_ROOT_DIR}") |
| 208 | endif() |
| 209 | |
| 210 | if(FALSE) |
| 211 | # Check for build directory specified |
| 212 | if(NOT DEFINED BUILD) |
| 213 | set(BUILD ${CMAKE_CURRENT_BINARY_DIR}/BUILD CACHE INTERNAL "Defaulting build directory to ${BUILD}" FORCE) |
| 214 | else() |
| 215 | set(BUILD ${CMAKE_CURRENT_BINARY_DIR}/${BUILD}/BUILD CACHE INTERNAL "Defaulting build directory to ${BUILD}" FORCE) |
| 216 | endif() |
| 217 | endif() |
| 218 | |
| 219 | # Check for valid suite cmake argument passed |
| 220 | if(NOT ${SUITE} IN_LIST PSA_SUITES) |
Øyvind Rønningstad | abbb727 | 2020-11-09 14:50:54 +0100 | [diff] [blame] | 221 | message(FATAL_ERROR "[PSA] : Error: Unsupported value for -DSUITE=${SUITE}, select one from supported suites which are : ${PSA_SUITES}") |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 222 | else() |
| 223 | message(STATUS "[PSA] : SUITE is set to ${SUITE}") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 224 | endif() |
| 225 | |
| 226 | # Project variables |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 227 | if(${SUITE} STREQUAL "INITIAL_ATTESTATION") |
Gyorgy Szing | 42d6233 | 2022-02-08 17:50:04 +0000 | [diff] [blame] | 228 | set(PSA_TARGET_QCBOR ${CMAKE_CURRENT_BINARY_DIR}/psa_qcbor CACHE PATH "Location of Q_CBOR sources.") |
Shruti Ghadge | 1221473 | 2024-10-28 14:22:47 +0530 | [diff] [blame] | 229 | |
| 230 | if(NOT DEFINED INITIAL_ATTESTATION_PROFILE_FORMAT) |
| 231 | add_definitions(-DPSA_ATTESTATION_PROFILE_1) |
| 232 | message(STATUS "[PSA] : Testing ${SUITE} for default Profile-1 token format compliant") |
| 233 | else() |
| 234 | if(${INITIAL_ATTESTATION_PROFILE_FORMAT} EQUAL 1) |
| 235 | add_definitions(-DPSA_ATTESTATION_PROFILE_1) |
| 236 | message(STATUS "[PSA] : Testing ${SUITE} for Profile-1 token format compliant") |
| 237 | elseif(${INITIAL_ATTESTATION_PROFILE_FORMAT} EQUAL 2) |
| 238 | add_definitions(-DPSA_ATTESTATION_PROFILE_2) |
| 239 | message(STATUS "[PSA] : Testing ${SUITE} for Profile-2 token format compliant") |
| 240 | else() |
| 241 | message(FATAL_ERROR "[PSA] : Error: Unsupported value for -DINITIAL_ATTESTATION_PROFILE_FORMAT=${INITIAL_ATTESTATION_PROFILE_FORMAT}") |
| 242 | endif() |
| 243 | endif() |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 244 | endif() |
Avi Nawal | dcef734 | 2025-07-12 01:23:45 +0530 | [diff] [blame] | 245 | set(PSA_TARGET_PAL_NSPE_LIB pal_nspe) |
| 246 | set(COMMON_VAL_LIB common_val_lib) |
| 247 | set(PSA_TARGET_VAL_NSPE_LIB val_nspe) |
| 248 | set(PSA_TARGET_TEST_COMBINE_LIB test_combine) |
jk-arm | bf532fd | 2021-05-07 13:58:22 +0530 | [diff] [blame] | 249 | set(PSA_TARGET_DRIVER_PARTITION_LIB tfm_psa_rot_partition_driver_partition) |
| 250 | set(PSA_TARGET_CLIENT_PARTITION_LIB tfm_app_rot_partition_client_partition) |
| 251 | set(PSA_TARGET_SERVER_PARTITION_LIB tfm_app_rot_partition_server_partition) |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 252 | if(${SUITE} STREQUAL "IPC") |
| 253 | set(PSA_SUITE_DIR ${PSA_ROOT_DIR}/ff/${SUITE_LOWER}) |
| 254 | set(PSA_SUITE_OUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/ff/${SUITE_LOWER}) |
Vinay Kumar Kotegowder | 18fcd40 | 2020-04-27 17:38:41 +0530 | [diff] [blame] | 255 | elseif((${SUITE} STREQUAL "INTERNAL_TRUSTED_STORAGE") OR (${SUITE} STREQUAL "PROTECTED_STORAGE")) |
| 256 | set(PSA_SUITE_DIR ${PSA_ROOT_DIR}/dev_apis/storage) |
| 257 | set(PSA_SUITE_OUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/dev_apis/storage) |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 258 | else() |
| 259 | set(PSA_SUITE_DIR ${PSA_ROOT_DIR}/dev_apis/${SUITE_LOWER}) |
| 260 | set(PSA_SUITE_OUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/dev_apis/${SUITE_LOWER}) |
| 261 | endif() |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 262 | set(PSA_TESTLIST_GENERATOR ${PSA_ROOT_DIR}/tools/scripts/gen_tests_list.py) |
jk-arm | bf532fd | 2021-05-07 13:58:22 +0530 | [diff] [blame] | 263 | if(NOT DEFINED SPEC_VERSION) |
| 264 | if(${SUITE} STREQUAL "INTERNAL_TRUSTED_STORAGE") |
| 265 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/its_testsuite.db) |
| 266 | elseif((${SUITE} STREQUAL "PROTECTED_STORAGE") OR (${SUITE} STREQUAL "STORAGE")) |
| 267 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/ps_testsuite.db) |
jothikumar mani | 18b98e0 | 2023-04-05 00:39:23 +0800 | [diff] [blame] | 268 | elseif(${SUITE} STREQUAL "CRYPTO") |
| 269 | if(DEFINED BESPOKE_SUITE_TESTS) |
| 270 | set(TESTSUITE_DB ${PSA_ROOT_DIR}/platform/targets/${TARGET}/${BESPOKE_SUITE_TESTS}) |
| 271 | else() |
| 272 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/testsuite.db) |
| 273 | endif() |
jk-arm | bf532fd | 2021-05-07 13:58:22 +0530 | [diff] [blame] | 274 | else() |
| 275 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/testsuite.db) |
| 276 | endif() |
jothikumar mani | 18b98e0 | 2023-04-05 00:39:23 +0800 | [diff] [blame] | 277 | message(STATUS "[PSA] : Selected test database file : ${TESTSUITE_DB}") |
Vinay Kumar Kotegowder | 18fcd40 | 2020-04-27 17:38:41 +0530 | [diff] [blame] | 278 | else() |
jk-arm | bf532fd | 2021-05-07 13:58:22 +0530 | [diff] [blame] | 279 | if(${SUITE} STREQUAL "INTERNAL_TRUSTED_STORAGE") |
| 280 | if(${SPEC_VERSION} STREQUAL "1.0-BETA2") |
| 281 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/its_1.0-beta2_testsuite.db) |
| 282 | endif() |
| 283 | if(${SPEC_VERSION} STREQUAL "1.0") |
| 284 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/its_1.0_testsuite.db) |
| 285 | endif() |
| 286 | elseif((${SUITE} STREQUAL "PROTECTED_STORAGE") OR (${SUITE} STREQUAL "STORAGE")) |
| 287 | if(${SPEC_VERSION} STREQUAL "1.0-BETA2") |
| 288 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/ps_1.0-beta2_testsuite.db) |
| 289 | endif() |
| 290 | if(${SPEC_VERSION} STREQUAL "1.0") |
| 291 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/ps_1.0_testsuite.db) |
| 292 | endif() |
| 293 | elseif(${SUITE} STREQUAL "CRYPTO") |
| 294 | if(${SPEC_VERSION} STREQUAL "1.0-BETA1") |
| 295 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/1.0-beta1_testsuite.db) |
| 296 | endif() |
| 297 | if(${SPEC_VERSION} STREQUAL "1.0-BETA2") |
| 298 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/1.0-beta2_testsuite.db) |
| 299 | endif() |
| 300 | if(${SPEC_VERSION} STREQUAL "1.0-BETA3") |
| 301 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/1.0-beta3_testsuite.db) |
| 302 | endif() |
Avi Nawal | 5e72bf9 | 2024-03-14 18:39:09 +0800 | [diff] [blame] | 303 | if(${SPEC_VERSION} STREQUAL "1.0.0") |
| 304 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/1.0.0_testsuite.db) |
| 305 | endif() |
| 306 | if(${SPEC_VERSION} STREQUAL "1.0.1") |
| 307 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/1.0.1_testsuite.db) |
| 308 | endif() |
| 309 | if(${SPEC_VERSION} STREQUAL "1.1.0") |
| 310 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/1.1.0_testsuite.db) |
| 311 | endif() |
jk-arm | bf532fd | 2021-05-07 13:58:22 +0530 | [diff] [blame] | 312 | elseif(${SUITE} STREQUAL "INITIAL_ATTESTATION") |
| 313 | if(${SPEC_VERSION} STREQUAL "1.0-BETA0") |
| 314 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/1.0-beta0_testsuite.db) |
| 315 | endif() |
| 316 | if(${SPEC_VERSION} STREQUAL "1.0.0") |
| 317 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/1.0.0_testsuite.db) |
| 318 | endif() |
| 319 | if(${SPEC_VERSION} STREQUAL "1.0.1") |
| 320 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/1.0.1_testsuite.db) |
| 321 | endif() |
| 322 | if(${SPEC_VERSION} STREQUAL "1.0.2") |
| 323 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/1.0.2_testsuite.db) |
| 324 | endif() |
jk-arm | 957cfea | 2021-06-18 15:52:12 +0530 | [diff] [blame] | 325 | elseif(${SUITE} STREQUAL "IPC") |
| 326 | if(${SPEC_VERSION} STREQUAL "1.1") |
| 327 | if(DEFINED STATELESS_ROT_TESTS) |
| 328 | if(${STATELESS_ROT_TESTS} EQUAL 1) |
| 329 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/stateless_rot_testsuite.db) |
| 330 | else() |
| 331 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/testsuite.db) |
| 332 | endif() |
| 333 | else() |
| 334 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/testsuite.db) |
| 335 | endif() |
| 336 | else() |
| 337 | set(TESTSUITE_DB ${PSA_SUITE_DIR}/testsuite.db) |
| 338 | endif() |
| 339 | endif() |
Vinay Kumar Kotegowder | 18fcd40 | 2020-04-27 17:38:41 +0530 | [diff] [blame] | 340 | endif() |
| 341 | set(PSA_TESTLIST_FILE ${CMAKE_CURRENT_BINARY_DIR}/${SUITE_LOWER}_testlist.txt) |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 342 | set(PSA_TEST_ENTRY_LIST_INC ${CMAKE_CURRENT_BINARY_DIR}/test_entry_list.inc) |
| 343 | set(PSA_TEST_ENTRY_FUN_DECLARE_INC ${CMAKE_CURRENT_BINARY_DIR}/test_entry_fn_declare_list.inc) |
| 344 | set(PSA_CLIENT_TEST_LIST_DELCARE_INC ${CMAKE_CURRENT_BINARY_DIR}/client_tests_list_declare.inc) |
| 345 | set(PSA_CLIENT_TEST_LIST_INC ${CMAKE_CURRENT_BINARY_DIR}/client_tests_list.inc) |
| 346 | set(PSA_SERVER_TEST_LIST_DECLARE_INC ${CMAKE_CURRENT_BINARY_DIR}/server_tests_list_declare.inc) |
| 347 | set(PSA_SERVER_TEST_LIST ${CMAKE_CURRENT_BINARY_DIR}/server_tests_list.inc) |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 348 | if(${SUITE} STREQUAL "INITIAL_ATTESTATION") |
Gyorgy Szing | 42d6233 | 2022-02-08 17:50:04 +0000 | [diff] [blame] | 349 | set(PSA_QCBOR_INCLUDE_PATH ${PSA_TARGET_QCBOR}/inc) |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 350 | endif() |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 351 | |
| 352 | # Validity check for required files for a given suite |
| 353 | if(NOT DEFINED PSA_${SUITE}_FILES) |
| 354 | message(FATAL_ERROR "[PSA] : List of file/s to verify against ${suite} is not defined") |
| 355 | endif() |
| 356 | foreach(file_item ${PSA_${SUITE}_FILES}) |
| 357 | set(PSA_FILE_FOUND FALSE) |
| 358 | foreach(include_path ${PSA_INCLUDE_PATHS}) |
| 359 | if((EXISTS ${include_path}/${file_item}) AND |
| 360 | (NOT PSA_FILE_FOUND)) |
| 361 | set(PSA_FILE_FOUND TRUE) |
| 362 | break() |
| 363 | endif() |
| 364 | endforeach() |
| 365 | if(NOT PSA_FILE_FOUND) |
| 366 | message(FATAL_ERROR "[PSA] : Couldn't find ${file_item} in ${PSA_INCLUDE_PATHS}") |
| 367 | endif() |
| 368 | endforeach() |
| 369 | |
| 370 | # Check for TOOLCHAIN command line argument |
| 371 | if(NOT DEFINED TOOLCHAIN) |
| 372 | set(TOOLCHAIN "GNUARM" CACHE INTERNAL "Compiler used" FORCE) |
| 373 | message(STATUS "[PSA] : Defaulting compiler to ${TOOLCHAIN}") |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 374 | else() |
| 375 | message(STATUS "[PSA] : TOOLCHAIN is set to ${TOOLCHAIN}") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 376 | endif() |
| 377 | |
Gowtham Siddarth | 1d6d469 | 2019-09-16 11:47:29 +0530 | [diff] [blame] | 378 | if(${TOOLCHAIN} STREQUAL "ARMCLANG" OR ${TOOLCHAIN} STREQUAL "GNUARM") |
| 379 | if(NOT DEFINED CPU_ARCH) |
| 380 | message(FATAL_ERROR "[PSA] : Error: -DCPU_ARCH option missing") |
| 381 | else() |
| 382 | # Check for CPU architecture |
| 383 | if(NOT ${CPU_ARCH} IN_LIST PSA_CPU_ARCH_SUPPORT) |
Øyvind Rønningstad | abbb727 | 2020-11-09 14:50:54 +0100 | [diff] [blame] | 384 | message(FATAL_ERROR "[PSA] : Error: Unsupported value for -DCPU_ARCH=${CPU_ARCH}, supported CPU arch are : ${PSA_CPU_ARCH_SUPPORT}") |
Gowtham Siddarth | 1d6d469 | 2019-09-16 11:47:29 +0530 | [diff] [blame] | 385 | endif() |
| 386 | endif() |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 387 | message(STATUS "[PSA] : CPU_ARCH is set to ${CPU_ARCH}") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 388 | endif() |
| 389 | |
Avi Nawal | dcef734 | 2025-07-12 01:23:45 +0530 | [diff] [blame] | 390 | # Check for VERBOSITY |
| 391 | if(NOT DEFINED VERBOSITY) |
| 392 | set(VERBOSITY 3 CACHE INTERNAL "Default VERBOSITY value" FORCE) |
| 393 | message(STATUS "[PSA] : Defaulting VERBOSITY to ${VERBOSITY}") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 394 | else() |
Avi Nawal | dcef734 | 2025-07-12 01:23:45 +0530 | [diff] [blame] | 395 | if(NOT ${VERBOSITY} IN_LIST PSA_VERBOSITY_OPTIONS) |
| 396 | message(FATAL_ERROR "[PSA] : Error: Unsupported value for -DVERBOSITY=${VERBOSITY}, supported values are : ${PSA_VERBOSITY_OPTIONS}") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 397 | endif() |
Avi Nawal | dcef734 | 2025-07-12 01:23:45 +0530 | [diff] [blame] | 398 | message(STATUS "[PSA] : VERBOSITY is set to ${VERBOSITY}") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 399 | endif() |
| 400 | |
Jaykumar Pitambarbhai Patel | ccf5bf2 | 2019-12-06 11:58:32 +0530 | [diff] [blame] | 401 | # Check for PLATFORM_PSA_ISOLATION_LEVEL |
| 402 | if(NOT DEFINED PLATFORM_PSA_ISOLATION_LEVEL) |
jotman01 | 6d7dd4e | 2020-11-10 17:32:28 +0800 | [diff] [blame] | 403 | if("${TFM_PROFILE}" STREQUAL "profile_medium") |
| 404 | set(PLATFORM_PSA_ISOLATION_LEVEL 2 CACHE INTERNAL "Default PLATFORM_PSA_ISOLATION_LEVEL value" FORCE) |
| 405 | else() |
Jaykumar Pitambarbhai Patel | ccf5bf2 | 2019-12-06 11:58:32 +0530 | [diff] [blame] | 406 | set(PLATFORM_PSA_ISOLATION_LEVEL 3 CACHE INTERNAL "Default PLATFORM_PSA_ISOLATION_LEVEL value" FORCE) |
jotman01 | 6d7dd4e | 2020-11-10 17:32:28 +0800 | [diff] [blame] | 407 | endif() |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 408 | if(${SUITE} STREQUAL "IPC") |
| 409 | message(STATUS "[PSA] : Defaulting PLATFORM_PSA_ISOLATION_LEVEL to ${PLATFORM_PSA_ISOLATION_LEVEL}") |
| 410 | endif() |
Jaykumar Pitambarbhai Patel | ccf5bf2 | 2019-12-06 11:58:32 +0530 | [diff] [blame] | 411 | else() |
| 412 | if(NOT ${PLATFORM_PSA_ISOLATION_LEVEL} IN_LIST PLATFORM_PSA_ISOLATION_LEVEL_OPTIONS) |
Øyvind Rønningstad | abbb727 | 2020-11-09 14:50:54 +0100 | [diff] [blame] | 413 | message(FATAL_ERROR "[PSA] : Error: Unsupported value for -DPLATFORM_PSA_ISOLATION_LEVEL=${PLATFORM_PSA_ISOLATION_LEVEL}, supported values are : ${PLATFORM_PSA_ISOLATION_LEVEL_OPTIONS}") |
Jaykumar Pitambarbhai Patel | ccf5bf2 | 2019-12-06 11:58:32 +0530 | [diff] [blame] | 414 | endif() |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 415 | if(${SUITE} STREQUAL "IPC") |
| 416 | message(STATUS "[PSA] : PLATFORM_PSA_ISOLATION_LEVEL is set to ${PLATFORM_PSA_ISOLATION_LEVEL}") |
| 417 | endif() |
Jaykumar Pitambarbhai Patel | ccf5bf2 | 2019-12-06 11:58:32 +0530 | [diff] [blame] | 418 | endif() |
| 419 | |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 420 | if(NOT DEFINED INCLUDE_PANIC_TESTS) |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 421 | #By default panic tests are disabled |
| 422 | set(INCLUDE_PANIC_TESTS 0 CACHE INTERNAL "Default INCLUDE_PANIC_TESTS value" FORCE) |
| 423 | message(STATUS "[PSA] : Defaulting INCLUDE_PANIC_TESTS to ${INCLUDE_PANIC_TESTS}") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 424 | else() |
jk-arm | 01ee3ff | 2021-10-18 22:41:47 +0530 | [diff] [blame] | 425 | if(NOT ${INCLUDE_PANIC_TESTS} IN_LIST PSA_INCLUDE_PANIC_TESTS_OPTIONS) |
| 426 | message(FATAL_ERROR "[PSA] : Error: Unsupported value for -DINCLUDE_PANIC_TESTS=${INCLUDE_PANIC_TESTS}, supported values are : ${PSA_INCLUDE_PANIC_TESTS_OPTIONS}") |
| 427 | endif() |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 428 | if(INCLUDE_PANIC_TESTS EQUAL 1) |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 429 | message(STATUS "[PSA] : " |
| 430 | "INCLUDE_PANIC_TESTS set to 1, therefore including PSA APIs panic tests into the regression,\n" |
Avi Nawal | dcef734 | 2025-07-12 01:23:45 +0530 | [diff] [blame] | 431 | "\tensure that WATCHDOG_NUM is set to 1 in ${PSA_ROOT_DIR}/platform/targets/${TARGET}/nspe/pal_config.h") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 432 | endif() |
| 433 | endif() |
| 434 | |
| 435 | if(NOT DEFINED WATCHDOG_AVAILABLE) |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 436 | #Assuming watchdog is available to program by test suite |
| 437 | set(WATCHDOG_AVAILABLE 1 CACHE INTERNAL "Default WATCHDOG_AVAILABLE value" FORCE) |
| 438 | message(STATUS "[PSA] : Defaulting WATCHDOG_AVAILABLE to ${WATCHDOG_AVAILABLE}") |
| 439 | else() |
| 440 | message(STATUS "[PSA] : WATCHDOG_AVAILABLE is set to ${WATCHDOG_AVAILABLE}") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 441 | endif() |
| 442 | |
| 443 | if((INCLUDE_PANIC_TESTS EQUAL 1) AND |
| 444 | (WATCHDOG_AVAILABLE EQUAL 0)) |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 445 | message(WARNING "[PSA]: " |
| 446 | "Note that to test PSA APIs panic conditions, test harness may require to access" |
| 447 | "the watchdog timer in oder to recover from panic and to be able to continue with" |
| 448 | "next test. Ignore this warning if system under test has capability to reset the" |
| 449 | "system when it encounters panic condition.") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 450 | endif() |
| 451 | |
| 452 | if(NOT DEFINED SP_HEAP_MEM_SUPP) |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 453 | #Are dynamic memory functions available to secure partition? |
| 454 | set(SP_HEAP_MEM_SUPP 1 CACHE INTERNAL "Default SP_HEAP_MEM_SUPP value" FORCE) |
| 455 | message(STATUS "[PSA] : Defaulting SP_HEAP_MEM_SUPP to ${SP_HEAP_MEM_SUPP}") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 456 | endif() |
| 457 | |
Vinay Kumar Kotegowder | ac21899 | 2020-04-03 12:56:00 +0530 | [diff] [blame] | 458 | if(NOT DEFINED SUITE_TEST_RANGE) |
| 459 | set(SUITE_TEST_RANGE_MIN None) |
| 460 | set(SUITE_TEST_RANGE_MAX None) |
| 461 | else() |
| 462 | list(LENGTH SUITE_TEST_RANGE SUITE_TEST_RANGE_LENGTH) |
| 463 | if(${SUITE_TEST_RANGE_LENGTH} GREATER "2") |
| 464 | message(FATAL_ERROR "[PSA] : -DSUITE_TEST_RANGE=<...> value error! accepts two " |
| 465 | " numbers in quotes separated with ';'") |
| 466 | endif() |
| 467 | if(${SUITE_TEST_RANGE_LENGTH} EQUAL "2") |
| 468 | list(GET SUITE_TEST_RANGE 0 SUITE_TEST_RANGE_MIN) |
| 469 | list(GET SUITE_TEST_RANGE 1 SUITE_TEST_RANGE_MAX) |
| 470 | message(STATUS "[PSA] : Testing (${SUITE_TEST_RANGE_MIN}, ${SUITE_TEST_RANGE_MAX}) of ${SUITE} suite") |
| 471 | endif() |
| 472 | if(${SUITE_TEST_RANGE_LENGTH} EQUAL "1") |
| 473 | set(SUITE_TEST_RANGE_MIN ${SUITE_TEST_RANGE}) |
| 474 | set(SUITE_TEST_RANGE_MAX ${SUITE_TEST_RANGE}) |
| 475 | message(STATUS "[PSA] : Testing ${SUITE_TEST_RANGE_MIN} of ${SUITE} suite") |
| 476 | endif() |
| 477 | endif() |
| 478 | |
jk-arm | bf532fd | 2021-05-07 13:58:22 +0530 | [diff] [blame] | 479 | if(NOT DEFINED SPEC_VERSION) |
| 480 | message(STATUS "[PSA] : Default spec version") |
| 481 | else() |
| 482 | if(NOT ${SPEC_VERSION} IN_LIST PSA_SPEC_VERSION) |
| 483 | message(FATAL_ERROR "[PSA] : Error: Unsupported value for -DSPEC_VERSION=${SPEC_VERSION}, supported values are : ${PSA_SPEC_VERSION} for ${SUITE}") |
| 484 | else() |
| 485 | message(STATUS "[PSA] : Testing ${SUITE} for spec version ${SPEC_VERSION}") |
| 486 | endif() |
| 487 | endif() |
| 488 | |
jk-arm | 957cfea | 2021-06-18 15:52:12 +0530 | [diff] [blame] | 489 | if(DEFINED STATELESS_ROT_TESTS) |
| 490 | if(NOT ${STATELESS_ROT_TESTS} IN_LIST PSA_STATELESS_ROT) |
| 491 | message(FATAL_ERROR "[PSA] : Error: Unsupported value for -DSTATELESS_ROT_TESTS=${STATELESS_ROT_TESTS}, supported values are : ${PSA_STATELESS_ROT}") |
| 492 | elseif(${STATELESS_ROT_TESTS} EQUAL 1) |
| 493 | message(STATUS "[PSA] : Testing ${SUITE} for stateless rot") |
| 494 | elseif(${STATELESS_ROT_TESTS} EQUAL 0) |
| 495 | message(STATUS "[PSA] : Testing ${SUITE} for connection based") |
| 496 | endif() |
| 497 | |
| 498 | if(NOT DEFINED SPEC_VERSION) |
| 499 | message(FATAL_ERROR "[PSA] : Error: SPEC_VERSION is require for STATELESS_ROT_TESTS.") |
| 500 | elseif(${SUITE} STREQUAL "IPC") |
| 501 | if(${SPEC_VERSION} STREQUAL "1.0") |
| 502 | message(FATAL_ERROR "[PSA] : Error: STATELESS_ROT_TESTS is only valid for SPEC_VERSION=1.1.") |
| 503 | elseif(${SPEC_VERSION} STREQUAL "1.1") |
| 504 | add_definitions(-DSPEC_VERSION=11) |
| 505 | if(${STATELESS_ROT_TESTS} EQUAL 1) |
| 506 | add_definitions(-DSTATELESS_ROT=1) |
| 507 | elseif(${STATELESS_ROT_TESTS} EQUAL 0) |
| 508 | add_definitions(-DSTATELESS_ROT=0) |
| 509 | endif() |
| 510 | endif() |
| 511 | else() |
| 512 | message(FATAL_ERROR "[PSA] : Error: STATELESS_ROT_TESTS is only applicable to IPC Test Suite.") |
| 513 | endif() |
| 514 | else() |
| 515 | add_definitions(-DSTATELESS_ROT=0) |
| 516 | if(DEFINED SPEC_VERSION) |
| 517 | if(${SUITE} STREQUAL "IPC") |
| 518 | if(${SPEC_VERSION} STREQUAL "1.0") |
| 519 | add_definitions(-DSPEC_VERSION=10) |
| 520 | endif() |
| 521 | if(${SPEC_VERSION} STREQUAL "1.1") |
| 522 | add_definitions(-DSPEC_VERSION=11) |
| 523 | endif() |
| 524 | endif() |
| 525 | endif() |
| 526 | endif() |
| 527 | |
jk-arm | 01ee3ff | 2021-10-18 22:41:47 +0530 | [diff] [blame] | 528 | if(NOT DEFINED TESTS_COVERAGE) |
| 529 | #By default all tests are included |
| 530 | set(TESTS_COVERAGE "ALL" CACHE INTERNAL "Default TESTS_COVERAGE value" FORCE) |
| 531 | message(STATUS "[PSA] : Defaulting TESTS_COVERAGE to ${TESTS_COVERAGE}") |
| 532 | else() |
| 533 | if(NOT ${TESTS_COVERAGE} IN_LIST PSA_TESTS_COVERAGE_OPTIONS) |
| 534 | message(FATAL_ERROR "[PSA] : Error: Unsupported value for -DTESTS_COVERAGE=${TESTS_COVERAGE}, supported values are : ${PSA_TESTS_COVERAGE_OPTIONS}") |
| 535 | endif() |
| 536 | if(TESTS_COVERAGE STREQUAL ALL) |
| 537 | message(STATUS "[PSA] : " |
| 538 | "TESTS_COVERAGE set to ALL, therefore all tests are included.") |
| 539 | endif() |
| 540 | if(TESTS_COVERAGE STREQUAL PASS) |
| 541 | message(STATUS "[PSA] : " |
| 542 | "TESTS_COVERAGE set to PASS, therefore known failure tests are not included.") |
| 543 | add_definitions(-DTESTS_COVERAGE) |
| 544 | endif() |
| 545 | endif() |
| 546 | |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 547 | message(STATUS "[PSA] : ----------Process input arguments- complete-------------") |
| 548 | |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 549 | |
Gyorgy Szing | 42d6233 | 2022-02-08 17:50:04 +0000 | [diff] [blame] | 550 | if((${SUITE} STREQUAL "INITIAL_ATTESTATION") AND (NOT EXISTS ${PSA_TARGET_QCBOR})) |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 551 | # Clone QCBOR and move to specified tag |
| 552 | execute_process(COMMAND ${GIT_EXECUTABLE} clone ${PSA_QCBOR_GIT_REPO_LINK} ${PSA_TARGET_QCBOR} |
Gyorgy Szing | 42d6233 | 2022-02-08 17:50:04 +0000 | [diff] [blame] | 553 | RESULT_VARIABLE qcbor_clone_result |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 554 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) |
Gyorgy Szing | 42d6233 | 2022-02-08 17:50:04 +0000 | [diff] [blame] | 555 | if(qcbor_clone_result) |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 556 | message(FATAL_ERROR "git clone failed for ${PSA_QCBOR_GIT_REPO_LINK}") |
| 557 | endif() |
| 558 | |
Gyorgy Szing | 42d6233 | 2022-02-08 17:50:04 +0000 | [diff] [blame] | 559 | if(NOT qcbor_clone_result) |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 560 | execute_process(COMMAND ${GIT_EXECUTABLE} checkout -q "${PSA_QCBOR_GIT_REPO_TAG}" |
Gyorgy Szing | 42d6233 | 2022-02-08 17:50:04 +0000 | [diff] [blame] | 561 | RESULT_VARIABLE qcbor_checkout_result |
| 562 | WORKING_DIRECTORY ${PSA_TARGET_QCBOR}) |
| 563 | if(qcbor_checkout_result) |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 564 | message(FATAL_ERROR "git checkout failed for Repo : ${PSA_QCBOR_GIT_REPO_LINK}, Tag : ${PSA_QCBOR_GIT_REPO_TAG}") |
| 565 | endif() |
| 566 | endif() |
| 567 | endif() |
gowtham siddarth | 1283304 | 2020-02-10 22:11:11 +0530 | [diff] [blame] | 568 | |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 569 | # Create PSA clean list |
| 570 | list(APPEND PSA_CLEAN_LIST |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 571 | ${PSA_TESTLIST_FILE} |
| 572 | ${PSA_TEST_ENTRY_LIST_INC} |
| 573 | ${PSA_TEST_ENTRY_FUN_DECLARE_INC} |
| 574 | ${PSA_CLIENT_TEST_LIST_DELCARE_INC} |
| 575 | ${PSA_CLIENT_TEST_LIST_INC} |
| 576 | ${PSA_SERVER_TEST_LIST_DECLARE_INC} |
| 577 | ${PSA_SERVER_TEST_LIST} |
| 578 | ) |
| 579 | |
| 580 | # Process testsuite.db |
| 581 | message(STATUS "[PSA] : Creating testlist.txt 'available at ${PSA_TESTLIST_FILE}'") |
| 582 | execute_process(COMMAND ${PYTHON_EXECUTABLE} ${PSA_TESTLIST_GENERATOR} |
| 583 | ${SUITE_LOWER} |
| 584 | ${TESTSUITE_DB} |
| 585 | ${INCLUDE_PANIC_TESTS} |
jk-arm | 01ee3ff | 2021-10-18 22:41:47 +0530 | [diff] [blame] | 586 | ${TESTS_COVERAGE} |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 587 | ${PSA_TESTLIST_FILE} |
| 588 | ${PSA_TEST_ENTRY_LIST_INC} |
| 589 | ${PSA_TEST_ENTRY_FUN_DECLARE_INC} |
| 590 | ${PSA_CLIENT_TEST_LIST_DELCARE_INC} |
| 591 | ${PSA_CLIENT_TEST_LIST_INC} |
| 592 | ${PSA_SERVER_TEST_LIST_DECLARE_INC} |
Vinay Kumar Kotegowder | ac21899 | 2020-04-03 12:56:00 +0530 | [diff] [blame] | 593 | ${PSA_SERVER_TEST_LIST} |
| 594 | ${SUITE_TEST_RANGE_MIN} |
| 595 | ${SUITE_TEST_RANGE_MAX}) |
Jaykumar Pitambarbhai Patel | ccf5bf2 | 2019-12-06 11:58:32 +0530 | [diff] [blame] | 596 | |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 597 | # Creating CMake list variable from file |
| 598 | file(READ ${PSA_TESTLIST_FILE} PSA_TEST_LIST) |
Vinay Kumar Kotegowder | ac21899 | 2020-04-03 12:56:00 +0530 | [diff] [blame] | 599 | if(NOT PSA_TEST_LIST) |
| 600 | message(FATAL_ERROR "[PSA] : Invalid test number!") |
| 601 | endif() |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 602 | string(REGEX REPLACE "\n" ";" PSA_TEST_LIST "${PSA_TEST_LIST}") |
| 603 | |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 604 | # Check for supported toolchain/s |
| 605 | if(${TOOLCHAIN} IN_LIST PSA_TOOLCHAIN_SUPPORT) |
jk-arm | bf532fd | 2021-05-07 13:58:22 +0530 | [diff] [blame] | 606 | if (DEFINED CROSS_COMPILE) |
jk-arm | 7e6145a | 2021-07-19 19:36:14 +0530 | [diff] [blame] | 607 | if(NOT (${TOOLCHAIN} IN_LIST CROSS_COMPILE_TOOLCHAIN_SUPPORT)) |
| 608 | message(FATAL_ERROR "[PSA] : Error: CROSS_COMPILE not supported for this toolchain, supported toolchain are : ${CROSS_COMPILE_TOOLCHAIN_SUPPORT}") |
| 609 | endif() |
jk-arm | bf532fd | 2021-05-07 13:58:22 +0530 | [diff] [blame] | 610 | endif() |
jk-arm | 7e6145a | 2021-07-19 19:36:14 +0530 | [diff] [blame] | 611 | include(${PSA_ROOT_DIR}/tools/cmake/compiler/${TOOLCHAIN}.cmake) |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 612 | else() |
jk-arm | 7e6145a | 2021-07-19 19:36:14 +0530 | [diff] [blame] | 613 | message(FATAL_ERROR "[PSA] : Error: Unsupported value for -DTOOLCHAIN=${TOOLCHAIN}, supported toolchain are : ${PSA_TOOLCHAIN_SUPPORT}") |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 614 | endif() |
| 615 | |
| 616 | # Global macro to identify the PSA test suite cmake build |
| 617 | add_definitions(-DPSA_CMAKE_BUILD) |
| 618 | add_definitions(-D${SUITE}) |
Avi Nawal | dcef734 | 2025-07-12 01:23:45 +0530 | [diff] [blame] | 619 | add_definitions(-DVERBOSITY=${VERBOSITY}) |
Jaykumar Pitambarbhai Patel | ccf5bf2 | 2019-12-06 11:58:32 +0530 | [diff] [blame] | 620 | add_definitions(-DPLATFORM_PSA_ISOLATION_LEVEL=${PLATFORM_PSA_ISOLATION_LEVEL}) |
Vinay Kumar Kotegowder | 52bbfc9 | 2020-07-03 17:23:59 +0530 | [diff] [blame] | 621 | add_definitions(-D${TARGET}) |
jotman01 | 6d7dd4e | 2020-11-10 17:32:28 +0800 | [diff] [blame] | 622 | if("${TFM_PROFILE}" STREQUAL "profile_small") |
| 623 | message(STATUS "[PSA] : Building SMALL profile") |
| 624 | add_definitions(-DTF_M_PROFILE_SMALL) |
| 625 | elseif("${TFM_PROFILE}" STREQUAL "profile_medium") |
| 626 | message(STATUS "[PSA] : Building MEDIUM profile") |
| 627 | add_definitions(-DTF_M_PROFILE_MEDIUM) |
| 628 | endif() |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 629 | if(${SP_HEAP_MEM_SUPP} EQUAL 1) |
| 630 | add_definitions(-DSP_HEAP_MEM_SUPP) |
| 631 | endif() |
jotman01 | 38cb53a | 2023-02-14 16:27:06 +0800 | [diff] [blame] | 632 | |
Summer Qin | 937a1ed | 2022-07-13 10:29:26 +0800 | [diff] [blame] | 633 | if(${CC312_LEGACY_DRIVER_API_ENABLED}) |
| 634 | add_definitions(-DCC312_LEGACY_DRIVER_API_ENABLED) |
| 635 | endif() |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 636 | |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 637 | # Build PAL NSPE LIB |
Bruno De Smet | 593db41 | 2023-03-15 18:47:19 +0100 | [diff] [blame] | 638 | include(${PSA_ROOT_DIR}/platform/targets/common/nspe/pal_nspe.cmake) |
Jaykumar Pitambarbhai Patel | 6c3b808 | 2020-02-26 19:51:37 +0530 | [diff] [blame] | 639 | include(${PSA_ROOT_DIR}/platform/targets/${TARGET}/target.cmake) |
Avi Nawal | dcef734 | 2025-07-12 01:23:45 +0530 | [diff] [blame] | 640 | # Build COMMON VAL LIB |
| 641 | add_definitions(-DSTATIC_ASSERT_CHECKS) |
| 642 | include(${COMMON_VAL_PATH}/common_val.cmake) |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 643 | # Build VAL NSPE LIB |
| 644 | #add_definitions(-DVAL_NSPE_BUILD) |
| 645 | include(${PSA_ROOT_DIR}/val/val_nspe.cmake) |
| 646 | # Build test |
| 647 | include(${PSA_SUITE_DIR}/suite.cmake) |
| 648 | if(${SUITE} STREQUAL "IPC") |
| 649 | # Build SPE LIB |
| 650 | include(${PSA_ROOT_DIR}/val/val_spe.cmake) |
| 651 | endif() |
| 652 | |
Avi Nawal | dcef734 | 2025-07-12 01:23:45 +0530 | [diff] [blame] | 653 | # Link Common VAL library to both Non-secure and Secure VAL libraries |
| 654 | target_link_libraries(val_nspe PRIVATE common_val_lib) |
| 655 | if(${SUITE} STREQUAL "IPC") |
| 656 | target_link_libraries(tfm_psa_rot_partition_driver_partition PRIVATE common_val_lib) |
| 657 | endif() |
| 658 | |
| 659 | add_dependencies(${COMMON_VAL_LIB} ${PSA_TARGET_PAL_NSPE_LIB}) |
| 660 | add_dependencies(${PSA_TARGET_VAL_NSPE_LIB} ${COMMON_VAL_LIB}) |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 661 | add_dependencies(${PSA_TARGET_TEST_COMBINE_LIB} ${PSA_TARGET_VAL_NSPE_LIB}) |
| 662 | if(${SUITE} STREQUAL "IPC") |
| 663 | add_dependencies(${PSA_TARGET_DRIVER_PARTITION_LIB} ${PSA_TARGET_TEST_COMBINE_LIB}) |
| 664 | add_dependencies(${PSA_TARGET_CLIENT_PARTITION_LIB} ${PSA_TARGET_DRIVER_PARTITION_LIB}) |
| 665 | add_dependencies(${PSA_TARGET_SERVER_PARTITION_LIB} ${PSA_TARGET_CLIENT_PARTITION_LIB}) |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 666 | endif() |
| 667 | |
| 668 | # Include the files for make clean |
| 669 | foreach(clean_item ${PSA_CLEAN_LIST}) |
| 670 | set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${clean_item}) |
| 671 | endforeach() |
| 672 | |
| 673 | set_property(TARGET ${PSA_TARGET_VAL_NSPE_LIB} PROPERTY ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/val) |
| 674 | set_property(TARGET ${PSA_TARGET_PAL_NSPE_LIB} PROPERTY ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/platform) |
Avi Nawal | dcef734 | 2025-07-12 01:23:45 +0530 | [diff] [blame] | 675 | set_property(TARGET ${COMMON_VAL_LIB} PROPERTY ARCHIVE_OUTPUT_DIRECTORY ${COMMON_VAL_PATH}) |
Vinay Kumar Kotegowder | 9982f90 | 2019-07-15 09:13:54 +0530 | [diff] [blame] | 676 | set_property(TARGET ${PSA_TARGET_TEST_COMBINE_LIB} PROPERTY ARCHIVE_OUTPUT_DIRECTORY ${PSA_SUITE_OUT_DIR}) |
| 677 | if(${SUITE} STREQUAL "IPC") |
| 678 | set_property(TARGET ${PSA_TARGET_DRIVER_PARTITION_LIB} PROPERTY ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/partition) |
| 679 | set_property(TARGET ${PSA_TARGET_CLIENT_PARTITION_LIB} PROPERTY ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/partition) |
| 680 | set_property(TARGET ${PSA_TARGET_SERVER_PARTITION_LIB} PROPERTY ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/partition) |
| 681 | endif() |