Build: Add tf-m-tests specific config setting
Move tf-m-tests specific config setting to test/config/ from TF-M repo.
It decouples tf-m-tests specific config setting from TF-M.
Signed-off-by: David Hu <david.hu@arm.com>
Change-Id: Iceecd0d97b4319c79acc576a3a66c06ae6bff795
diff --git a/test/config/check_config.cmake b/test/config/check_config.cmake
new file mode 100644
index 0000000..cae376a
--- /dev/null
+++ b/test/config/check_config.cmake
@@ -0,0 +1,58 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2021, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+########################## TEST Configuration ##################################
+
+message(STATUS "---------- Display TEST Configuration - start --------------")
+
+message(STATUS "TEST_NS is set as ${TEST_NS}")
+message(STATUS "TEST_S is set as ${TEST_S}")
+message(STATUS "TEST_NS_ATTESTATION is set as ${TEST_NS_ATTESTATION}")
+message(STATUS "TEST_NS_AUDIT is set as ${TEST_NS_AUDIT}")
+message(STATUS "TEST_NS_CORE is set as ${TEST_NS_CORE}")
+message(STATUS "TEST_NS_CRYPTO is set as ${TEST_NS_CRYPTO}")
+message(STATUS "TEST_NS_ITS is set as ${TEST_NS_ITS}")
+message(STATUS "TEST_NS_QCBOR is set as ${TEST_NS_QCBOR}")
+message(STATUS "TEST_NS_PS is set as ${TEST_NS_PS}")
+message(STATUS "TEST_NS_T_COSE is set as ${TEST_NS_T_COSE}")
+message(STATUS "TEST_NS_PLATFORM is set as ${TEST_NS_PLATFORM}")
+message(STATUS "TEST_NS_FWU is set as ${TEST_NS_FWU}")
+message(STATUS "TEST_NS_IPC is set as ${TEST_NS_IPC}")
+message(STATUS "TEST_NS_SLIH_IRQ is set as ${TEST_NS_SLIH_IRQ}")
+message(STATUS "TEST_NS_FLIH_IRQ is set as ${TEST_NS_FLIH_IRQ}")
+message(STATUS "TEST_NS_MULTI_CORE is set as ${TEST_NS_MULTI_CORE}")
+message(STATUS "TEST_S_ATTESTATION is set as ${TEST_S_ATTESTATION}")
+message(STATUS "TEST_S_AUDIT is set as ${TEST_S_AUDIT}")
+message(STATUS "TEST_S_CRYPTO is set as ${TEST_S_CRYPTO}")
+message(STATUS "TEST_S_ITS is set as ${TEST_S_ITS}")
+message(STATUS "TEST_S_PS is set as ${TEST_S_PS}")
+message(STATUS "TEST_S_PLATFORM is set as ${TEST_S_PLATFORM}")
+message(STATUS "TEST_S_FWU is set as ${TEST_S_FWU}")
+message(STATUS "TEST_S_IPC is set as ${TEST_S_IPC}")
+
+message(STATUS "---------- Display TEST Configuration - stop ---------------")
+
+########################## Check Flags Input ###################################
+
+tfm_invalid_config((NOT TFM_PARTITION_PROTECTED_STORAGE AND NOT FORWARD_PROT_MSG) AND (TEST_NS_PS OR TEST_S_PS))
+tfm_invalid_config((NOT TFM_PARTITION_INTERNAL_TRUSTED_STORAGE AND NOT FORWARD_PROT_MSG) AND (TEST_NS_ITS OR TEST_S_ITS OR TEST_NS_PS))
+tfm_invalid_config((NOT TFM_PARTITION_CRYPTO AND NOT FORWARD_PROT_MSG) AND (TEST_NS_CRYPTO OR TEST_S_CRYPTO))
+tfm_invalid_config((NOT TFM_PARTITION_INITIAL_ATTESTATION AND NOT FORWARD_PROT_MSG) AND (TEST_NS_ATTESTATION OR TEST_S_ATTESTATION OR TEST_NS_QCBOR OR TEST_NS_T_COSE))
+tfm_invalid_config((NOT TFM_PARTITION_PLATFORM AND NOT FORWARD_PROT_MSG) AND (TEST_NS_PLATFORM OR TEST_S_PLATFORM))
+tfm_invalid_config(NOT TFM_PARTITION_FIRMWARE_UPDATE AND (TEST_NS_FWU OR TEST_S_FWU))
+tfm_invalid_config(NOT TFM_PARTITION_AUDIT_LOG AND (TEST_NS_AUDIT OR TEST_S_AUDIT))
+tfm_invalid_config((NOT TFM_PSA_API) AND (TEST_NS_IPC OR TEST_S_IPC OR TEST_NS_SLIH_IRQ OR TEST_NS_FLIH_IRQ))
+tfm_invalid_config((NOT TFM_MULTI_CORE_TOPOLOGY) AND TEST_NS_MULTI_CORE)
+tfm_invalid_config(TEST_NS_T_COSE AND SYMMETRIC_INITIAL_ATTESTATION)
+
+# So far all regression tests are triggered from NS app
+tfm_invalid_config(NOT NS)
+
+########################## Check suites dependence #############################
+
+tfm_invalid_config(TEST_NS_PS AND NOT TEST_NS_ITS)
+tfm_invalid_config(TEST_NS_SLIH_IRQ AND TEST_NS_FLIH_IRQ)
diff --git a/test/config/default_ns_test_config.cmake b/test/config/default_ns_test_config.cmake
new file mode 100644
index 0000000..e0ff37c
--- /dev/null
+++ b/test/config/default_ns_test_config.cmake
@@ -0,0 +1,27 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2021, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+########################## NS test framework ###################################
+
+set(TEST_FRAMEWORK_NS ON CACHE BOOL "Whether to build NS regression tests framework")
+
+########################## 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_QCBOR ON CACHE BOOL "Whether to build NS regression QCBOR tests")
+set(TEST_NS_AUDIT ON CACHE BOOL "Whether to build NS regression Audit log tests")
+set(TEST_NS_CORE ON CACHE BOOL "Whether to build NS regression Core 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_IPC ON CACHE BOOL "Whether to build NS regression IPC 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_MULTI_CORE ON CACHE BOOL "Whether to build NS regression multi-core tests")
diff --git a/test/config/default_s_test_config.cmake b/test/config/default_s_test_config.cmake
new file mode 100644
index 0000000..4a38da7
--- /dev/null
+++ b/test/config/default_s_test_config.cmake
@@ -0,0 +1,21 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2021, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+########################## S test framework ####################################
+
+set(TEST_FRAMEWORK_S ON CACHE BOOL "Whether to build S regression tests framework")
+
+########################## S test suites #######################################
+
+set(TEST_S_ATTESTATION ON CACHE BOOL "Whether to build S regression Attestation tests")
+set(TEST_S_AUDIT ON CACHE BOOL "Whether to build S regression Audit log 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 ON CACHE BOOL "Whether to build S regression IPC tests")
diff --git a/test/config/default_test_config.cmake b/test/config/default_test_config.cmake
new file mode 100644
index 0000000..7d38666
--- /dev/null
+++ b/test/config/default_test_config.cmake
@@ -0,0 +1,42 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2021, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+########################## NS test framework ###################################
+
+set(TEST_FRAMEWORK_NS OFF CACHE BOOL "Whether to build NS regression tests framework")
+
+########################## NS test suites ######################################
+
+set(TEST_NS_ATTESTATION OFF CACHE BOOL "Whether to build NS regression Attestation 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")
+set(TEST_NS_AUDIT OFF CACHE BOOL "Whether to build NS regression Audit log tests")
+set(TEST_NS_CORE OFF CACHE BOOL "Whether to build NS regression Core tests")
+set(TEST_NS_CRYPTO OFF CACHE BOOL "Whether to build NS regression Crypto tests")
+set(TEST_NS_ITS OFF CACHE BOOL "Whether to build NS regression ITS tests")
+set(TEST_NS_PS OFF CACHE BOOL "Whether to build NS regression PS tests")
+set(TEST_NS_PLATFORM OFF CACHE BOOL "Whether to build NS regression Platform tests")
+set(TEST_NS_FWU OFF CACHE BOOL "Whether to build NS regression FWU tests")
+set(TEST_NS_IPC OFF CACHE BOOL "Whether to build NS regression IPC 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_MULTI_CORE OFF CACHE BOOL "Whether to build NS regression multi-core tests")
+
+########################## S test framework ####################################
+
+set(TEST_FRAMEWORK_S OFF CACHE BOOL "Whether to build S regression tests framework")
+
+########################## S test suites #######################################
+
+set(TEST_S_ATTESTATION OFF CACHE BOOL "Whether to build S regression Attestation tests")
+set(TEST_S_AUDIT OFF CACHE BOOL "Whether to build S regression Audit log tests")
+set(TEST_S_CRYPTO OFF CACHE BOOL "Whether to build S regression Crypto tests")
+set(TEST_S_ITS OFF CACHE BOOL "Whether to build S regression ITS tests")
+set(TEST_S_PS OFF CACHE BOOL "Whether to build S regression PS tests")
+set(TEST_S_PLATFORM OFF 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")
diff --git a/test/config/set_config.cmake b/test/config/set_config.cmake
new file mode 100644
index 0000000..958076f
--- /dev/null
+++ b/test/config/set_config.cmake
@@ -0,0 +1,96 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2021, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+########################## TEST SYNC ###########################################
+
+if ((NOT TFM_PARTITION_PROTECTED_STORAGE AND NOT FORWARD_PROT_MSG))
+ 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 AND NOT FORWARD_PROT_MSG)
+ 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 AND NOT FORWARD_PROT_MSG)
+ 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 AND NOT FORWARD_PROT_MSG)
+ 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 AND NOT FORWARD_PROT_MSG)
+ 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_PARTITION_AUDIT_LOG)
+ set(TEST_NS_AUDIT OFF CACHE BOOL "Whether to build NS regression Audit log tests")
+ set(TEST_S_AUDIT OFF CACHE BOOL "Whether to build S regression Audit log tests")
+endif()
+
+if (NOT TFM_PSA_API)
+ set(TEST_NS_IPC OFF CACHE BOOL "Whether to build NS regression IPC tests")
+ set(TEST_S_IPC OFF CACHE BOOL "Whether to build S regression IPC 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")
+endif()
+
+if (NOT TFM_MULTI_CORE_TOPOLOGY)
+ set(TEST_NS_MULTI_CORE OFF CACHE BOOL "Whether to build NS regression multi-core tests")
+endif()
+
+########################## Test framework sync #################################
+
+get_cmake_property(CACHE_VARS CACHE_VARIABLES)
+# Force TEST_FRAMEWORK_NS ON if single NS test ON
+foreach(CACHE_VAR ${CACHE_VARS})
+ string(REGEX MATCH "^TEST_NS_.*" _NS_TEST_FOUND "${CACHE_VAR}")
+ if (_NS_TEST_FOUND AND "${${CACHE_VAR}}")
+ set(TEST_FRAMEWORK_NS ON CACHE BOOL "Whether to build NS regression tests framework")
+ break()
+ endif()
+endforeach()
+
+# Force TEST_FRAMEWORK_S ON if single S test ON
+foreach(CACHE_VAR ${CACHE_VARS})
+ string(REGEX MATCH "^TEST_S_.*" _S_TEST_FOUND "${CACHE_VAR}")
+ if (_S_TEST_FOUND AND "${${CACHE_VAR}}")
+ set(TEST_FRAMEWORK_S ON CACHE BOOL "Whether to build S regression tests framework")
+ break()
+ endif()
+endforeach()
+
+########################## Load default config #################################
+
+if (TEST_S)
+ include(${TFM_TEST_PATH}/config/default_s_test_config.cmake)
+endif()
+if (TEST_NS)
+ include(${TFM_TEST_PATH}/config/default_ns_test_config.cmake)
+endif()
+
+include(${TFM_TEST_PATH}/config/default_test_config.cmake)