Test: Restructure PSA arch tests
PSA arch tests build split on 2 steps:
1. A secure (SPE) built from TF-M source code and PSA arch tests in
case of IPC suit.
2. A non-Secure build from PSA arch tests
NSPE is dependant on SPE (platform, PSA Suit name) so SPE is located
under NSPE and shall be build first and than we can build NSPE on 2nd
step using SPE artifacts and settings.
To build SPE:
cmake -S . -B build -DTFM_PLATFORM=arm/mps2/an521
-DCONFIG_TFM_SOURCE_PATH=<>/trusted-firmware-m
-DTEST_PSA_API=STORAGE
cmake --build build -- install
To build NSPE:
cmake -S . -B build -DCONFIG_SPE_PATH=<>/spe/build/api_ns
cmake --build build -- tfm_app_binaries
Signed-off-by: Anton Komlev <anton.komlev@arm.com>
Change-Id: I3a5c8497ca00ceccb70662318a2b433d743f062a
diff --git a/app_test_psa_arch/CMakeLists.txt b/app_test_psa_arch/CMakeLists.txt
deleted file mode 100644
index dbfa886..0000000
--- a/app_test_psa_arch/CMakeLists.txt
+++ /dev/null
@@ -1,140 +0,0 @@
-#-------------------------------------------------------------------------------
-# Copyright (c) 2023, Arm Limited. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
-#
-#-------------------------------------------------------------------------------
-cmake_minimum_required(VERSION 3.15)
-
-#--- SPE artifacts -------------------------------------------------------------
-
-if (NOT DEFINED CONFIG_SPE_PATH OR NOT EXISTS ${CONFIG_SPE_PATH})
- message(FATAL_ERROR "CONFIG_SPE_PATH = ${CONFIG_SPE_PATH} is not defined or incorrect. Please provide full path to TF-M build artifacts using -DCONFIG_SPE_PATH=")
-endif()
-
-if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)
- set(CROSS_COMPILE arm-none-eabi)
- set(CMAKE_TOOLCHAIN_FILE ${CONFIG_SPE_PATH}/cmake/toolchain_ns_GNUARM.cmake)
-endif()
-
-set(CPU_ARCH ${PSA_API_TEST_CPU_ARCH})
-set(SUITE ${TEST_PSA_API})
-
-#--- NSPE side project ---------------------------------------------------------
-
-list(APPEND CMAKE_MODULE_PATH ${CONFIG_SPE_PATH}/cmake)
-
-project("TF-M PSA Arch tests" LANGUAGES C)
-
-add_executable(tfm_ns)
-
-add_subdirectory(../ns_interface ${CMAKE_BINARY_DIR}/ns_interface)
-
-list(APPEND PSA_INCLUDE_PATHS ${CONFIG_SPE_PATH}/interface/include)
-
-if(NOT TARGET)
- if (NOT "${TEST_PSA_API}" STREQUAL "IPC")
- set(TARGET tgt_dev_apis_tfm_${PSA_API_TEST_TARGET})
- else()
- set(TARGET tgt_ff_tfm_${PSA_API_TEST_TARGET})
- endif()
-endif()
-
-if(NOT PSA_INCLUDE_PATHS)
- set(PSA_INCLUDE_PATHS ${INTERFACE_INC_DIR}/
- ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/
- ${CMAKE_BINARY_DIR}/generated/interface/include
- )
-endif()
-
-set(SP_HEAP_MEM_SUPP 0)
-set(PLATFORM_PSA_ISOLATION_LEVEL ${TFM_ISOLATION_LEVEL})
-
-add_subdirectory(${PSA_ARCH_TESTS_PATH}/api-tests ${CMAKE_CURRENT_BINARY_DIR}/psa_api_tests)
-
-if (TEST_PSA_API STREQUAL IPC)
- target_include_directories(tfm_partitions
- INTERFACE
- ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests
- )
-
- target_sources(tfm_psa_rot_partition_driver_partition
- PRIVATE
- ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/intermedia_driver_partition_psa.c
- )
- target_link_libraries(tfm_psa_rot_partition_driver_partition
- PRIVATE
- psa_interface
- platform_s
- )
- target_compile_definitions(tfm_psa_rot_partition_driver_partition
- PRIVATE
- CONFIG_TFM_BUILDING_SPE=1
- TFM_ISOLATION_LEVEL=${TFM_ISOLATION_LEVEL}
- )
-
- target_sources(tfm_app_rot_partition_client_partition
- PRIVATE
- ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/intermedia_client_partition_psa.c
- )
- target_link_libraries(tfm_app_rot_partition_client_partition
- PRIVATE
- psa_interface
- platform_s
- )
- target_compile_definitions(tfm_app_rot_partition_client_partition
- PRIVATE
- CONFIG_TFM_BUILDING_SPE=1
- TFM_ISOLATION_LEVEL=${TFM_ISOLATION_LEVEL}
- )
-
- target_sources(tfm_app_rot_partition_server_partition
- PRIVATE
- ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/intermedia_server_partition_psa.c
- )
- target_link_libraries(tfm_app_rot_partition_server_partition
- PRIVATE
- psa_interface
- platform_s
- )
- target_compile_definitions(tfm_app_rot_partition_server_partition
- PRIVATE
- CONFIG_TFM_BUILDING_SPE=1
- TFM_ISOLATION_LEVEL=${TFM_ISOLATION_LEVEL}
- )
-
- target_sources(tfm_partitions
- INTERFACE
- ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/load_info_driver_partition_psa.c
- ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/load_info_client_partition_psa.c
- ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/load_info_server_partition_psa.c
- )
-
- target_link_libraries(tfm_partitions
- INTERFACE
- tfm_psa_rot_partition_driver_partition
- tfm_app_rot_partition_client_partition
- tfm_app_rot_partition_server_partition
- )
-endif()
-
-############################# TFM NS main app ##################################
-
-target_sources(tfm_ns
- PRIVATE
- test_app.c
-)
-
-target_link_libraries(tfm_ns
- PRIVATE
- tfm_test_broker
- val_nspe
- pal_nspe
- test_combine
-)
-
-set_target_properties(tfm_ns PROPERTIES
- SUFFIX ".axf"
- RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
-)
-
diff --git a/app_test_s/localrepos.cmake b/app_test_s/localrepos.cmake
deleted file mode 100644
index 1d7393a..0000000
--- a/app_test_s/localrepos.cmake
+++ /dev/null
@@ -1,12 +0,0 @@
-#-------------------------------------------------------------------------------
-# Copyright (c) 2020-2022, Arm Limited. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
-#
-#-------------------------------------------------------------------------------
-
-message(WARNING "Local repositries are used for MBEDCRYPTO_PATH, MCUBOOT_PATH, QCBOR_PATH")
-
-set(MBEDCRYPTO_PATH /home/antkom01/x-temp/repos/mbedcrypto-src CACHE PATH "" FORCE)
-set(MCUBOOT_PATH /home/antkom01/x-temp/repos/mcuboot-src CACHE PATH "" FORCE)
-set(QCBOR_PATH /home/antkom01/x-temp/repos/qcbor-src CACHE PATH "" FORCE)
diff --git a/cmake/remote_library.cmake b/cmake/remote_library.cmake
new file mode 100644
index 0000000..e2f762a
--- /dev/null
+++ b/cmake/remote_library.cmake
@@ -0,0 +1,295 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2022 Cypress Semiconductor Corporation (an Infineon company)
+# or an affiliate of Cypress Semiconductor Corporation. All rights reserved.
+# Copyright (c) 2023 Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+include(FetchContent)
+set(FETCHCONTENT_QUIET FALSE)
+
+find_package(Git)
+
+# This function applies patches if they are not applied yet.
+# It assumes that patches have not been applied if it's not possible to revert them.
+#
+# WORKING_DIRECTORY - working directory where patches should be applied.
+# PATCH_FILES - list of patches. Patches will be applied in alphabetical order.
+function(apply_patches WORKING_DIRECTORY PATCH_FILES)
+ # Validate if patches are already applied by reverting patches in reverse order
+ # Step 1 - keep changes in stash with random message/name to detect
+ # that stash has been created by git
+ string(RANDOM LENGTH 16 STASH_NAME)
+ set(STASH_NAME "tfm-remote_library-apply_patches-${STASH_NAME}")
+ execute_process(COMMAND "${GIT_EXECUTABLE}" stash push -u -m "${STASH_NAME}"
+ WORKING_DIRECTORY ${WORKING_DIRECTORY}
+ RESULT_VARIABLE VALIDATION_STATUS
+ ERROR_QUIET OUTPUT_QUIET
+ )
+ # Step 2 - get list of stashes to validate that stash has been created
+ if (VALIDATION_STATUS EQUAL 0)
+ execute_process(COMMAND "${GIT_EXECUTABLE}" stash list
+ WORKING_DIRECTORY ${WORKING_DIRECTORY}
+ OUTPUT_VARIABLE STASH_LIST
+ RESULT_VARIABLE VALIDATION_STATUS
+ ERROR_QUIET
+ )
+ # Look for stash message to detect stash creation
+ string(FIND "${STASH_LIST}" "${STASH_NAME}" STASH_INDEX)
+ if (STASH_INDEX LESS 0)
+ # Stash is not created, most probably because there is no changes
+ set(VALIDATION_STATUS 0)
+ else()
+ # Step 3 - restore changes with git stash apply
+ if (VALIDATION_STATUS EQUAL 0)
+ execute_process(COMMAND "${GIT_EXECUTABLE}" stash apply
+ WORKING_DIRECTORY ${WORKING_DIRECTORY}
+ RESULT_VARIABLE VALIDATION_STATUS
+ ERROR_QUIET OUTPUT_QUIET
+ )
+ endif()
+ endif()
+ endif()
+ # Step 4 - revert patches in reverse order
+ if (VALIDATION_STATUS EQUAL 0)
+ # Sort list of patches in descending order for validation
+ list(SORT PATCH_FILES ORDER DESCENDING)
+ foreach(PATCH ${PATCH_FILES})
+ execute_process(COMMAND "${GIT_EXECUTABLE}" apply --reverse --verbose "${PATCH}"
+ WORKING_DIRECTORY ${WORKING_DIRECTORY}
+ RESULT_VARIABLE VALIDATION_STATUS
+ ERROR_QUIET OUTPUT_QUIET
+ )
+ if (NOT VALIDATION_STATUS EQUAL 0)
+ # patch failed to be applied, assume that we need to restore and
+ # apply all patch set
+ break()
+ endif()
+ endforeach()
+ endif()
+ # Step 5 - pop stash to restore original state
+ if (STASH_INDEX GREATER_EQUAL 0)
+ # Clear index before restore
+ execute_process(COMMAND "${GIT_EXECUTABLE}" clean -df
+ WORKING_DIRECTORY ${WORKING_DIRECTORY}
+ ERROR_QUIET OUTPUT_QUIET
+ )
+ execute_process(COMMAND "${GIT_EXECUTABLE}" reset --hard
+ WORKING_DIRECTORY ${WORKING_DIRECTORY}
+ ERROR_QUIET OUTPUT_QUIET
+ )
+ execute_process(COMMAND "${GIT_EXECUTABLE}" stash pop --index
+ WORKING_DIRECTORY ${WORKING_DIRECTORY}
+ ERROR_QUIET OUTPUT_QUIET
+ )
+ else()
+ # There is no stash, restore commit by clearing index
+ execute_process(COMMAND "${GIT_EXECUTABLE}" clean -df
+ WORKING_DIRECTORY ${WORKING_DIRECTORY}
+ ERROR_QUIET OUTPUT_QUIET
+ )
+ execute_process(COMMAND "${GIT_EXECUTABLE}" reset --hard
+ WORKING_DIRECTORY ${WORKING_DIRECTORY}
+ ERROR_QUIET OUTPUT_QUIET
+ )
+ endif()
+
+ if (NOT VALIDATION_STATUS EQUAL 0)
+ # Validation has been failed, so we assume that patches should be applied
+ # Sort list of patches in ascending order
+ list(SORT PATCH_FILES ORDER ASCENDING)
+
+ set(EXECUTE_COMMAND "${GIT_EXECUTABLE}" apply --verbose ${PATCH_FILES})
+ execute_process(COMMAND ${EXECUTE_COMMAND}
+ WORKING_DIRECTORY ${WORKING_DIRECTORY}
+ RESULT_VARIABLE PATCH_STATUS
+ COMMAND_ECHO STDOUT
+ )
+ if (NOT PATCH_STATUS EQUAL 0)
+ message( FATAL_ERROR "Failed to apply patches at ${WORKING_DIRECTORY}" )
+ endif()
+ endif()
+endfunction()
+
+
+# Returns a repository URL and a reference to the commit used to checkout the repository.
+#
+# REPO_URL_VAR - name of variable which receives repository URL.
+# TAG_VAR - name of variable which receives reference to commit.
+function(_get_fetch_remote_properties REPO_URL_VAR TAG_VAR)
+ # Parse arguments
+ set(options "")
+ set(oneValueArgs GIT_REPOSITORY GIT_TAG)
+ set(multiValueArgs "")
+ cmake_parse_arguments(PARSE_ARGV 2 ARG "${options}" "${oneValueArgs}" "${multiValueArgs}")
+
+ if (ARG_GIT_REPOSITORY)
+ set(${REPO_URL_VAR} ${ARG_GIT_REPOSITORY} PARENT_SCOPE)
+ set(${TAG_VAR} ${ARG_GIT_TAG} PARENT_SCOPE)
+ endif()
+endfunction()
+
+
+# This function helps to handle options with an empty string values.
+# There is a feature/bug in CMake that result in problem with the empty string arguments.
+# See https://gitlab.kitware.com/cmake/cmake/-/issues/16341 for details
+#
+# Arguments:
+# [in] KEY - option name
+# [out] KEY_VAR - name of variable that is set to ${KEY} on exit if value is not
+# an empty string otherwise to the empty string.
+# [out] VALUE_VAR - name of variable that is set to option value for ${KEY}.
+# [in/out] ARG_LIST_VAR - name of variable that holds list of key/value pairs - arguments.
+# Function looks for key/value pair specified by ${KEY} variable in
+# this list. Function removes key/value pair specified by ${KEY} on
+# exit.
+#
+# Example #1:
+# # We have following key/options:
+# # GIT_SUBMODULES ""
+# # BOO "abc"
+# # HEY "hi"
+# set(ARGS GIT_SUBMODULES "" BOO "abc" HEY "hi")
+# # Extract key/value for option "GIT_SUBMODULES"
+# extract_key_value(GIT_SUBMODULES GIT_SUBMODULES_VAR GIT_SUBMODULES_VALUE_VAR ARGS)
+# # ${GIT_SUBMODULES_VAR} is equal to ""
+# # ${GIT_SUBMODULES_VALUE_VAR} is equal to ""
+#
+# Example #2:
+# # We have following key/options:
+# # GIT_SUBMODULES "name"
+# # BOO "abc"
+# # HEY "hi"
+# set(ARGS GIT_SUBMODULES "name" BOO "abc" HEY "hi")
+# # Extract key/value for option "GIT_SUBMODULES"
+# extract_key_value(GIT_SUBMODULES GIT_SUBMODULES_VAR GIT_SUBMODULES_VALUE_VAR ARGS)
+# # ${GIT_SUBMODULES_VAR} is equal to "GIT_SUBMODULES"
+# # ${GIT_SUBMODULES_VALUE_VAR} is equal to "name"
+function(extract_key_value KEY KEY_VAR VALUE_VAR ARG_LIST_VAR)
+ list(FIND ${ARG_LIST_VAR} ${KEY} KEY_INDEX)
+ if(${KEY_INDEX} GREATER_EQUAL 0)
+ # Variable has been set, remove KEY
+ list(REMOVE_AT ${ARG_LIST_VAR} ${KEY_INDEX})
+
+ # Validate that there is an option value in the list of arguments
+ list(LENGTH ${ARG_LIST_VAR} ARG_LIST_LENGTH)
+ if(${KEY_INDEX} GREATER_EQUAL ${ARG_LIST_LENGTH})
+ message(FATAL_ERROR "Missing option value for ${KEY}")
+ endif()
+
+ # Get value
+ list(GET ${ARG_LIST_VAR} ${KEY_INDEX} VALUE)
+
+ # Remove value in the list
+ list(REMOVE_AT ${ARG_LIST_VAR} ${KEY_INDEX})
+
+ # Update argument list
+ set(${ARG_LIST_VAR} ${${ARG_LIST_VAR}} PARENT_SCOPE)
+
+ # Set KEY_VAR & VALUE_VAR
+ set(${KEY_VAR} ${KEY} PARENT_SCOPE)
+ set(${VALUE_VAR} ${VALUE} PARENT_SCOPE)
+ else()
+ # Variable is not defined, set KEY_VAR & VALUE_VAR to empty strings
+ set(${KEY_VAR} "" PARENT_SCOPE)
+ set(${VALUE_VAR} "" PARENT_SCOPE)
+ endif()
+endfunction()
+
+
+# This function allows to fetch library from a remote repository or use a local
+# library copy.
+#
+# You can specify location of directory with patches. Patches are applied in
+# alphabetical order.
+#
+# Arguments:
+# [in] LIB_NAME <name> - library name
+# [in/out] LIB_SOURCE_PATH_VAR <var> - name of variable which holds path to library source
+# or "DOWNLOAD" if sources should be fetched from the remote repository. This
+# variable is updated in case if library is downloaded. It will point
+# to the path where FetchContent_Populate will locate local library copy.
+# [out] LIB_BINARY_PATH_VAR <var> - optional name of variable which is updated to
+# directory intended for use as a corresponding build directory if
+# library is fetched from the remote repository.
+# [in] LIB_BASE_DIR <path> - is used to set FETCHCONTENT_BASE_DIR.
+# [in] LIB_PATCH_DIR <path> - optional path to local folder which contains patches
+# that should be applied.
+# [in] LIB_FORCE_PATCH - optional argument to force applying patches when the path
+# is a local folder instead of fetching from the remote repository.
+# [in] GIT_REPOSITORY, GIT_TAG, ... - see https://cmake.org/cmake/help/latest/module/ExternalProject.html
+# for more details
+#
+# This function set CMP0097 to NEW if CMAKE_VERSION is greater or equal than 3.18.0.
+# Because of https://gitlab.kitware.com/cmake/cmake/-/issues/20579 CMP0097 is
+# non-functional until cmake 3.18.0.
+# See https://cmake.org/cmake/help/latest/policy/CMP0097.html for more info.
+function(fetch_remote_library)
+ # Parse arguments
+ set(options "")
+ set(oneValueArgs LIB_NAME LIB_SOURCE_PATH_VAR LIB_BINARY_PATH_VAR LIB_BASE_DIR LIB_PATCH_DIR LIB_FORCE_PATCH)
+ set(multiValueArgs FETCH_CONTENT_ARGS)
+ cmake_parse_arguments(PARSE_ARGV 0 ARG "${options}" "${oneValueArgs}" "${multiValueArgs}")
+
+ if(ARG_LIB_BASE_DIR)
+ set(FETCHCONTENT_BASE_DIR "${ARG_LIB_BASE_DIR}")
+ endif()
+
+ # Set to not download submodules if that option is available
+ if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.18.0")
+ cmake_policy(SET CMP0097 NEW)
+ endif()
+
+ if ("${${ARG_LIB_SOURCE_PATH_VAR}}" STREQUAL "DOWNLOAD")
+ set(SOURCE_PATH_IS_DOWNLOAD TRUE)
+ # Process arguments which can be an empty string
+ # There is a feature/bug in CMake that result in problem with empty string arguments
+ # See https://gitlab.kitware.com/cmake/cmake/-/issues/16341 for details
+ extract_key_value(GIT_SUBMODULES GIT_SUBMODULES GIT_SUBMODULES_VALUE ARG_FETCH_CONTENT_ARGS)
+
+ # Validate that there is no empty arguments to FetchContent_Declare
+ LIST(FIND ARG_FETCH_CONTENT_ARGS "" EMPTY_VALUE_INDEX)
+ if(${EMPTY_VALUE_INDEX} GREATER_EQUAL 0)
+ # There is an unsupported empty string argument, FATAL ERROR!
+ math(EXPR EMPTY_KEY_INDEX "${EMPTY_VALUE_INDEX} - 1")
+ list(GET ARG_FETCH_CONTENT_ARGS ${EMPTY_KEY_INDEX} EMPTY_KEY)
+ # TODO: Use extract_key_value if you have argument with empty value (see GIT_SUBMODULES above)
+ message(FATAL_ERROR "fetch_remote_library: Unexpected empty string value for ${EMPTY_KEY}. "
+ "Please, validate arguments or update fetch_remote_library to support empty value for ${EMPTY_KEY}!!!")
+ endif()
+
+ # Content fetching
+ FetchContent_Declare(${ARG_LIB_NAME}
+ ${ARG_FETCH_CONTENT_ARGS}
+ "${GIT_SUBMODULES}" "${GIT_SUBMODULES_VALUE}"
+ )
+
+ FetchContent_GetProperties(${ARG_LIB_NAME})
+ if(NOT ${ARG_LIB_NAME}_POPULATED)
+ FetchContent_Populate(${ARG_LIB_NAME})
+
+ # Get remote properties
+ _get_fetch_remote_properties(REPO_URL_VAR TAG_VAR ${ARG_FETCH_CONTENT_ARGS})
+ set(${ARG_LIB_SOURCE_PATH_VAR} ${${ARG_LIB_NAME}_SOURCE_DIR} CACHE PATH "Library has been downloaded from ${REPO_URL_VAR}, tag ${TAG_VAR}" FORCE)
+ if (DEFINED ARG_LIB_BINARY_PATH_VAR)
+ set(${ARG_LIB_BINARY_PATH_VAR} ${${ARG_LIB_NAME}_BINARY_DIR} CACHE PATH "Path to build directory of ${ARG_LIB_NAME}")
+ endif()
+ endif()
+ endif()
+
+ if (ARG_LIB_FORCE_PATCH)
+ set(FORCE_PATCH ${${ARG_LIB_FORCE_PATCH}})
+ endif()
+
+ if (ARG_LIB_PATCH_DIR AND (SOURCE_PATH_IS_DOWNLOAD OR FORCE_PATCH))
+ # look for patch files
+ file(GLOB PATCH_FILES "${ARG_LIB_PATCH_DIR}/*.patch")
+
+ if(PATCH_FILES)
+ # Apply patches for existing sources
+ apply_patches("${${ARG_LIB_SOURCE_PATH_VAR}}" "${PATCH_FILES}")
+ endif()
+ endif()
+endfunction()
diff --git a/tests_psa_arch/CMakeLists.txt b/tests_psa_arch/CMakeLists.txt
new file mode 100644
index 0000000..cd63454
--- /dev/null
+++ b/tests_psa_arch/CMakeLists.txt
@@ -0,0 +1,75 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2023, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+cmake_minimum_required(VERSION 3.15)
+
+#--- SPE artifacts -------------------------------------------------------------
+
+if (NOT DEFINED CONFIG_SPE_PATH OR NOT EXISTS ${CONFIG_SPE_PATH})
+ message(FATAL_ERROR "CONFIG_SPE_PATH = ${CONFIG_SPE_PATH} is not defined or incorrect. Please provide full path to TF-M build artifacts using -DCONFIG_SPE_PATH=")
+endif()
+
+list(APPEND CMAKE_MODULE_PATH ${CONFIG_SPE_PATH}/cmake)
+include(spe_config)
+include(${CONFIG_SPE_PATH}/platform/config.cmake)
+
+set(CPU_ARCH ${PSA_API_TEST_CPU_ARCH})
+set(SUITE ${TEST_PSA_API})
+
+if (NOT "${TEST_PSA_API}" STREQUAL "IPC")
+ set(TARGET tgt_dev_apis_tfm_${PSA_API_TEST_TARGET})
+else()
+ set(TARGET tgt_ff_tfm_${PSA_API_TEST_TARGET})
+endif()
+
+#--- NSPE side project ---------------------------------------------------------
+
+if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)
+ set(CROSS_COMPILE arm-none-eabi)
+ set(CMAKE_TOOLCHAIN_FILE ${CONFIG_SPE_PATH}/cmake/toolchain_ns_GNUARM.cmake)
+endif()
+
+list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/../cmake)
+
+project("TF-M PSA Arch tests" LANGUAGES C)
+
+add_executable(tfm_ns)
+
+add_subdirectory(../app_broker ${CMAKE_BINARY_DIR}/app_broker)
+
+list(APPEND PSA_INCLUDE_PATHS ${CONFIG_SPE_PATH}/interface/include)
+
+if(NOT PSA_INCLUDE_PATHS)
+ set(PSA_INCLUDE_PATHS ${INTERFACE_INC_DIR}/
+ ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/
+ ${CMAKE_BINARY_DIR}/generated/interface/include
+ )
+endif()
+
+set(PLATFORM_PSA_ISOLATION_LEVEL ${TFM_ISOLATION_LEVEL})
+
+add_subdirectory(${PSA_ARCH_TESTS_PATH}/api-tests ${CMAKE_BINARY_DIR}/api-tests)
+
+############################# TFM NS main app ##################################
+
+target_sources(tfm_ns
+ PRIVATE
+ test_app.c
+)
+
+target_link_libraries(tfm_ns
+ PRIVATE
+ tfm_test_broker
+ val_nspe
+ pal_nspe
+ test_combine
+)
+
+set_target_properties(tfm_ns PROPERTIES
+ SUFFIX ".axf"
+ RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
+)
+
diff --git a/tests_psa_arch/spe/CMakeLists.txt b/tests_psa_arch/spe/CMakeLists.txt
new file mode 100644
index 0000000..31cf237
--- /dev/null
+++ b/tests_psa_arch/spe/CMakeLists.txt
@@ -0,0 +1,91 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2023, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+cmake_minimum_required(VERSION 3.15)
+
+# Force cross compilation and avoid compiler search and test
+set(CMAKE_SYSTEM_NAME Generic)
+set(CMAKE_C_COMPILER_FORCED TRUE)
+set(CMAKE_CXX_COMPILER_FORCED TRUE)
+
+project("TF-M SPE for PSA tests" LANGUAGES C)
+
+# use tf-m-tests/cmake folder
+list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/../../cmake)
+include(remote_library)
+
+# User must specify which TEST_PSA_API suit name
+if (NOT DEFINED TEST_PSA_API)
+ message(FATAL_ERROR "TEST_PSA_API is not defined. Please provide desired test suit name provide.")
+endif()
+
+if (NOT DEFINED CONFIG_TFM_SOURCE_PATH OR NOT EXISTS ${CONFIG_TFM_SOURCE_PATH})
+ set(CONFIG_TFM_SOURCE_PATH "DOWNLOAD" CACHE PATH "Path to TF-M source")
+ set(CONFIG_TFM_SOURCE_VERSION "TF-Mv1.8.0" CACHE STRING "TF-M version for test")
+ fetch_remote_library(
+ LIB_NAME tf-m_source
+ LIB_SOURCE_PATH_VAR CONFIG_TFM_SOURCE_PATH
+ LIB_PATCH_DIR ${CMAKE_CURRENT_SOURCE_DIR}
+ LIB_FORCE_PATCH ""
+ FETCH_CONTENT_ARGS
+ GIT_REPOSITORY https://git.trustedfirmware.org/TF-M/trusted-firmware-m.git
+ GIT_TAG ${CONFIG_TFM_SOURCE_VERSION}
+ GIT_SHALLOW FALSE
+ GIT_PROGRESS TRUE
+ GIT_SUBMODULES ""
+ )
+endif()
+
+if (NOT DEFINED PSA_ARCH_TESTS_PATH OR NOT EXISTS ${PSA_ARCH_TESTS_PATH})
+ set(PSA_ARCH_TESTS_PATH "DOWNLOAD" CACHE PATH "Path to PSA arch test repository used for SPE build")
+ set(PSA_ARCH_TESTS_VERSION "5c57920" CACHE STRING "The version of PSA arch tests to use")
+ fetch_remote_library(
+ LIB_NAME psa_arch_tests
+ LIB_SOURCE_PATH_VAR PSA_ARCH_TESTS_PATH
+ LIB_PATCH_DIR ${CMAKE_CURRENT_SOURCE_DIR}
+ LIB_FORCE_PATCH PSA_ARCH_TESTS_FORCE_PATCH
+ FETCH_CONTENT_ARGS
+ GIT_REPOSITORY https://github.com/ARM-software/psa-arch-tests.git
+ GIT_TAG ${PSA_ARCH_TESTS_VERSION}
+ GIT_SHALLOW FALSE
+ GIT_PROGRESS TRUE
+ GIT_SUBMODULES ""
+ )
+endif()
+
+if (NOT DEFINED CMAKE_TOOLCHAIN_FILE)
+ set(CROSS_COMPILE arm-none-eabi CACHE STRING "Cross-compiler prefix")
+ set(CMAKE_TOOLCHAIN_FILE ${CONFIG_TFM_SOURCE_PATH}/toolchain_GNUARM.cmake)
+endif()
+
+configure_file(${CMAKE_SOURCE_DIR}/tfm_psa_ff_test_manifest_list.yaml
+ ${CMAKE_BINARY_DIR}/tfm_psa_ff_test_manifest_list.yaml)
+list(APPEND TFM_EXTRA_MANIFEST_LIST_FILES ${CMAKE_BINARY_DIR}/tfm_psa_ff_test_manifest_list.yaml)
+
+#------------------------------------------------------------------------------
+
+# tfm_s_test is IMPORTED to inform CMake that it has no source files.
+add_executable(tfm_test_spe IMPORTED)
+
+include(ExternalProject)
+ExternalProject_Add(TF-M
+ SOURCE_DIR ${CONFIG_TFM_SOURCE_PATH}
+ BINARY_DIR build-spe
+ INSTALL_DIR api_ns
+ CMAKE_ARGS -DTFM_PLATFORM=${TFM_PLATFORM}
+ CMAKE_ARGS -DTEST_PSA_API=${TEST_PSA_API}
+ CMAKE_ARGS -DTFM_EXTRA_CONFIG_PATH=${CMAKE_SOURCE_DIR}/config_spe.cmake
+ CMAKE_ARGS -DPROJECT_CONFIG_HEADER_FILE=${CMAKE_SOURCE_DIR}/config_test_psa_api.h
+ CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>
+ CMAKE_ARGS -DTFM_EXTRA_MANIFEST_LIST_FILES=${TFM_EXTRA_MANIFEST_LIST_FILES}
+ CMAKE_ARGS -DPSA_ARCH_TESTS_PATH=${PSA_ARCH_TESTS_PATH}
+ CMAKE_ARGS -DTFM_REG_TEST_PATH=${CMAKE_SOURCE_DIR}/partitions
+ PREFIX "temp"
+)
+
+add_dependencies(tfm_test_spe TF-M)
+
+install(DIRECTORY ${CMAKE_BINARY_DIR}/build-spe/bin DESTINATION ${CMAKE_BINARY_DIR})
diff --git a/app_test_psa_arch/config_spe.cmake b/tests_psa_arch/spe/config_spe.cmake
similarity index 100%
rename from app_test_psa_arch/config_spe.cmake
rename to tests_psa_arch/spe/config_spe.cmake
diff --git a/app_test_psa_arch/config_test_psa_api.h b/tests_psa_arch/spe/config_test_psa_api.h
similarity index 100%
rename from app_test_psa_arch/config_test_psa_api.h
rename to tests_psa_arch/spe/config_test_psa_api.h
diff --git a/tests_psa_arch/spe/partitions/CMakeLists.txt b/tests_psa_arch/spe/partitions/CMakeLists.txt
new file mode 100644
index 0000000..657fd33
--- /dev/null
+++ b/tests_psa_arch/spe/partitions/CMakeLists.txt
@@ -0,0 +1,102 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2023, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+cmake_minimum_required(VERSION 3.15)
+
+if (NOT "${TEST_PSA_API}" STREQUAL IPC)
+ # The extra 3 TF-M partitions are necesary only for IPC tests
+ return()
+endif()
+
+set(SP_HEAP_MEM_SUPP 0)
+
+set(TARGET tgt_ff_tfm_${PSA_API_TEST_TARGET})
+set(CPU_ARCH ${PSA_API_TEST_CPU_ARCH})
+set(SUITE ${TEST_PSA_API})
+set(PLATFORM_PSA_ISOLATION_LEVEL ${TFM_ISOLATION_LEVEL})
+
+list(APPEND PSA_INCLUDE_PATHS ${CMAKE_SOURCE_DIR}/interface/include)
+list(APPEND PSA_INCLUDE_PATHS ${CMAKE_BINARY_DIR}/generated/interface/include)
+list(APPEND PSA_INCLUDE_PATHS ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests)
+
+add_subdirectory(${PSA_ARCH_TESTS_PATH}/api-tests ${CMAKE_BINARY_DIR}/api-tests)
+
+target_include_directories(tfm_partitions
+ INTERFACE
+ ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests
+)
+
+target_sources(tfm_psa_rot_partition_driver_partition
+ PRIVATE
+ ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/intermedia_driver_partition_psa.c
+)
+target_link_libraries(tfm_psa_rot_partition_driver_partition
+ PRIVATE
+ psa_interface
+ platform_s
+)
+target_compile_definitions(tfm_psa_rot_partition_driver_partition
+ PRIVATE
+ CONFIG_TFM_BUILDING_SPE=1
+ TFM_ISOLATION_LEVEL=${TFM_ISOLATION_LEVEL}
+)
+
+target_sources(tfm_app_rot_partition_client_partition
+ PRIVATE
+ ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/intermedia_client_partition_psa.c
+)
+target_link_libraries(tfm_app_rot_partition_client_partition
+ PRIVATE
+ psa_interface
+ platform_s
+)
+target_compile_definitions(tfm_app_rot_partition_client_partition
+ PRIVATE
+ CONFIG_TFM_BUILDING_SPE=1
+ TFM_ISOLATION_LEVEL=${TFM_ISOLATION_LEVEL}
+)
+
+target_sources(tfm_app_rot_partition_server_partition
+ PRIVATE
+ ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/intermedia_server_partition_psa.c
+)
+target_link_libraries(tfm_app_rot_partition_server_partition
+ PRIVATE
+ psa_interface
+ platform_s
+)
+target_compile_definitions(tfm_app_rot_partition_server_partition
+ PRIVATE
+ CONFIG_TFM_BUILDING_SPE=1
+ TFM_ISOLATION_LEVEL=${TFM_ISOLATION_LEVEL}
+)
+
+target_sources(tfm_partitions
+ INTERFACE
+ ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/load_info_driver_partition_psa.c
+ ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/load_info_client_partition_psa.c
+ ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/auto_generated/load_info_server_partition_psa.c
+)
+
+target_link_libraries(tfm_partitions
+ INTERFACE
+ tfm_psa_rot_partition_driver_partition
+ tfm_app_rot_partition_client_partition
+ tfm_app_rot_partition_server_partition
+)
+
+# Extra files required for IPC suit.
+
+install(FILES ${CMAKE_BINARY_DIR}/generated/interface/include/psa_manifest/pid.h
+ ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/psa_manifest/client_partition_psa.h
+ ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/psa_manifest/driver_partition_psa.h
+ ${CMAKE_BINARY_DIR}/generated/api-tests/platform/manifests/psa_manifest/server_partition_psa.h
+ DESTINATION ${CMAKE_INSTALL_PREFIX}/interface/include/psa_manifest)
+
+# TODO: Those fils should not be required by NSPE build.
+install(FILES ${CMAKE_SOURCE_DIR}/interface/include/psa/service.h
+ ${CMAKE_SOURCE_DIR}/interface/include/psa/lifecycle.h
+ DESTINATION ${CMAKE_INSTALL_PREFIX}/interface/include/psa)
diff --git a/tests_psa_arch/spe/tfm_psa_ff_test_manifest_list.yaml b/tests_psa_arch/spe/tfm_psa_ff_test_manifest_list.yaml
new file mode 100644
index 0000000..1151b9e
--- /dev/null
+++ b/tests_psa_arch/spe/tfm_psa_ff_test_manifest_list.yaml
@@ -0,0 +1,68 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2020-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
+#
+#-------------------------------------------------------------------------------
+
+{
+ "description": "PSA FF Test secure partition manifests",
+ "type": "manifest_list",
+ "version_major": 0,
+ "version_minor": 1,
+ "manifest_list": [
+ {
+ "description": "PSA FF Test Client Partition",
+ "manifest": "${PSA_ARCH_TESTS_PATH}/api-tests/platform/manifests/client_partition_psa.json",
+ "output_path": "api-tests/platform/manifests",
+ "conditional": "TFM_PARTITION_FF_TEST",
+ "version_major": 0,
+ "version_minor": 1,
+ "pid": 5000,
+ "linker_pattern": {
+ "library_list":[
+ "*client_partition.a"
+ ],
+ "object_list":[
+ "*intermedia_client_partition_psa.*"
+ ]
+ }
+ },
+ {
+ "description": "PSA FF Test Server Partition",
+ "manifest": "${PSA_ARCH_TESTS_PATH}/api-tests/platform/manifests/server_partition_psa.json",
+ "output_path": "api-tests/platform/manifests",
+ "conditional": "TFM_PARTITION_FF_TEST",
+ "version_major": 0,
+ "version_minor": 1,
+ "pid": 5001,
+ "linker_pattern": {
+ "library_list":[
+ "*server_partition.a"
+ ],
+ "object_list":[
+ "*intermedia_server_partition_psa.*"
+ ]
+ }
+ },
+ {
+ "description": "PSA FF Test Driver Partition",
+ "manifest": "${PSA_ARCH_TESTS_PATH}/api-tests/platform/manifests/driver_partition_psa.json",
+ "output_path": "api-tests/platform/manifests",
+ "conditional": "TFM_PARTITION_FF_TEST",
+ "version_major": 0,
+ "version_minor": 1,
+ "pid": 5002,
+ "linker_pattern": {
+ "library_list":[
+ "*driver_partition.a"
+ ],
+ "object_list":[
+ "*intermedia_driver_partition_psa.*"
+ ]
+ }
+ }
+ ]
+}
diff --git a/app_test_psa_arch/test_app.c b/tests_psa_arch/test_app.c
similarity index 100%
rename from app_test_psa_arch/test_app.c
rename to tests_psa_arch/test_app.c