Test: Simplify regression test build control

Remove TEST_FRAMEWORK_S/NS.
TEST_FRAMEWORK_NS/S can be replaced by the pair of TEST_NS/S_REG_TEST
and NS. It can remove duplicated test flags

Signed-off-by: David Hu <david.hu@arm.com>
Change-Id: Ida6b6dd951c29e0483a276c411d67874317e08ba
diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt
index 3a3ee09..d71ad6f 100755
--- a/app/CMakeLists.txt
+++ b/app/CMakeLists.txt
@@ -275,7 +275,7 @@
 
 target_link_libraries(tfm_test_app
     PRIVATE
-        $<$<BOOL:${TEST_FRAMEWORK_NS}>:tfm_ns_tests>
+        $<$<BOOL:${TFM_NS_REG_TEST}>:tfm_ns_tests>
         $<$<BOOL:${TEST_PSA_API}>:val_nspe>
         $<$<BOOL:${TEST_PSA_API}>:pal_nspe>
         $<$<BOOL:${TEST_PSA_API}>:test_combine>
@@ -286,8 +286,7 @@
 
 target_compile_definitions(tfm_test_app
     PRIVATE
-        $<$<BOOL:${TEST_FRAMEWORK_NS}>:TEST_FRAMEWORK_NS>
-        $<$<BOOL:${TEST_FRAMEWORK_S}>:TEST_FRAMEWORK_S>
+        $<$<BOOL:${TFM_NS_REG_TEST}>:TFM_NS_REG_TEST>
         $<$<BOOL:${TEST_PSA_API}>:PSA_API_TEST_NS>
 )
 
diff --git a/app/test_app.c b/app/test_app.c
index 1efc45f..0e26e89 100644
--- a/app/test_app.c
+++ b/app/test_app.c
@@ -8,7 +8,7 @@
 #include "test_app.h"
 #include "tfm_log.h"
 
-#ifdef TEST_FRAMEWORK_NS
+#ifdef TFM_NS_REG_TEST
 #include "test_framework_integ_test.h"
 #endif
 
@@ -29,7 +29,7 @@
 {
     UNUSED_VARIABLE(argument);
 
-#ifdef TEST_FRAMEWORK_NS
+#ifdef TFM_NS_REG_TEST
     tfm_non_secure_client_run_tests();
 #endif
 
diff --git a/docs/tfm_test_suites_addition.rst b/docs/tfm_test_suites_addition.rst
index 9682311..b27ed74 100644
--- a/docs/tfm_test_suites_addition.rst
+++ b/docs/tfm_test_suites_addition.rst
@@ -224,11 +224,9 @@
 
 .. code-block:: cmake
 
-    if (TEST_FRAMEWORK_S)
-        # ...
-        if (TEST_S_<TEST_NAME>)
-            add_library(tfm_test_suite_<test_name>_s STATIC EXCLUDE_FROM_ALL)
-        endif()
+    # ...
+    if (TEST_S_<TEST_NAME>)
+        add_library(tfm_test_suite_<test_name>_s STATIC EXCLUDE_FROM_ALL)
     endif()
 
 ************************************
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index cc67a2b..a0a018b 100755
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -26,7 +26,7 @@
         tfm_log_interface
 )
 
-if(TEST_FRAMEWORK_S OR TEST_FRAMEWORK_NS)
+if(TFM_S_REG_TEST OR TFM_NS_REG_TEST)
     add_subdirectory(secure_fw)
 endif()
 
diff --git a/test/config/check_config.cmake b/test/config/check_config.cmake
index 7eeb3d1..919740c 100644
--- a/test/config/check_config.cmake
+++ b/test/config/check_config.cmake
@@ -22,9 +22,6 @@
 tfm_invalid_config(TEST_NS_T_COSE AND SYMMETRIC_INITIAL_ATTESTATION)
 tfm_invalid_config((NOT TFM_NS_MANAGE_NSID) AND TEST_NS_MANAGE_NSID)
 
-# So far all NS regression tests are triggered from NS app
-tfm_invalid_config(NOT NS AND TEST_FRAMEWORK_NS)
-
 ########################## Check suites dependence #############################
 
 tfm_invalid_config(TEST_NS_PS AND NOT TEST_NS_ITS)
diff --git a/test/config/default_ns_test_config.cmake b/test/config/default_ns_test_config.cmake
index bedf691..fbdbe1e 100644
--- a/test/config/default_ns_test_config.cmake
+++ b/test/config/default_ns_test_config.cmake
@@ -5,10 +5,6 @@
 #
 #-------------------------------------------------------------------------------
 
-########################## 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")
diff --git a/test/config/default_s_test_config.cmake b/test/config/default_s_test_config.cmake
index a0fa9ec..eb2e622 100644
--- a/test/config/default_s_test_config.cmake
+++ b/test/config/default_s_test_config.cmake
@@ -5,10 +5,6 @@
 #
 #-------------------------------------------------------------------------------
 
-########################## 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")
diff --git a/test/config/default_test_config.cmake b/test/config/default_test_config.cmake
index 9c1f862..8eab410 100644
--- a/test/config/default_test_config.cmake
+++ b/test/config/default_test_config.cmake
@@ -5,10 +5,6 @@
 #
 #-------------------------------------------------------------------------------
 
-########################## 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")
@@ -27,10 +23,6 @@
 set(TEST_NS_SFN_BACKEND     OFF        CACHE BOOL      "Whether to build NS regression SFN backend tests")
 set(TEST_NS_FPU             OFF        CACHE BOOL      "Whether to build NS regression FPU 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")
diff --git a/test/config/set_config.cmake b/test/config/set_config.cmake
index ae3064d..0407a2d 100644
--- a/test/config/set_config.cmake
+++ b/test/config/set_config.cmake
@@ -59,40 +59,6 @@
     set(TEST_NS_FPU                      OFF        CACHE BOOL      "Whether to build NS regression FPU tests")
 endif()
 
-########################## Test framework sync #################################
-
-get_cmake_property(CACHE_VARS CACHE_VARIABLES)
-
-if (NS)
-    # 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()
-endif()
-
-# 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()
-
-########################## Extra test suites ###################################
-
-if (EXTRA_NS_TEST_SUITE_PATH)
-    set(TEST_FRAMEWORK_NS           ON        CACHE BOOL      "Whether to build NS regression tests framework")
-endif()
-
-if (EXTRA_S_TEST_SUITE_PATH)
-    set(TEST_FRAMEWORK_S            ON        CACHE BOOL      "Whether to build S regression tests framework")
-endif()
-
 ########################## Test profile ########################################
 
 if (TFM_PROFILE)
@@ -137,13 +103,6 @@
     include(${TFM_TEST_PATH}/config/default_s_test_config.cmake)
 endif()
 if (TEST_NS)
-    if (NOT NS)
-        # In this case, TEST_NS is used to configure corresponding test secure
-        # services during SPE build alone.
-        # Disable TEST_FRAMEWORK_NS if NS is OFF as NS test framework shall
-        # run inside NS environment
-        set(TEST_FRAMEWORK_NS       OFF        CACHE BOOL      "Whether to build NS regression tests framework")
-    endif()
     include(${TFM_TEST_PATH}/config/default_ns_test_config.cmake)
 endif()
 
diff --git a/test/secure_fw/secure_tests.cmake b/test/secure_fw/secure_tests.cmake
index c942c28..c16b8d1 100644
--- a/test/secure_fw/secure_tests.cmake
+++ b/test/secure_fw/secure_tests.cmake
@@ -27,7 +27,7 @@
 add_subdirectory(suites/ps/service ${CMAKE_BINARY_DIR}/tf-m-tests/ps_srv)
 add_subdirectory(suites/fpu/service ${CMAKE_BINARY_DIR}/tf-m-tests/fpu_srv)
 
-if (NOT TEST_FRAMEWORK_S)
+if (NOT TFM_S_REG_TEST)
     return()
 endif()
 
diff --git a/test/secure_fw/suites/CMakeLists.txt b/test/secure_fw/suites/CMakeLists.txt
index 268b790..3158f00 100644
--- a/test/secure_fw/suites/CMakeLists.txt
+++ b/test/secure_fw/suites/CMakeLists.txt
@@ -18,7 +18,7 @@
     tfm_toolchain_reload_compiler()
 endif()
 
-if (TEST_FRAMEWORK_NS)
+if(TFM_NS_REG_TEST AND NS)
     add_library(tfm_ns_tests INTERFACE)
     add_library(tfm_test_framework_ns INTERFACE)
 
@@ -52,7 +52,7 @@
             $<$<BOOL:${TFM_FUZZER_TOOL_TESTS}>:TFM_FUZZER_TOOL_TESTS>
     )
 else()
-    # Skip building NS regresstion test suites if TEST_FRAMEWORK_NS is OFF.
+    # Skip building NS regresstion test suites if NS is OFF.
     # NS test flags are kept to select corresponding test services. They are
     # unset here to skip building NS regression test suites.
     get_cmake_property(CACHE_VARS CACHE_VARIABLES)
@@ -81,7 +81,7 @@
 add_subdirectory(fpu)
 add_subdirectory(spm)
 
-if (TFM_FUZZER_TOOL_TESTS AND TEST_FRAMEWORK_NS)
+if(TFM_FUZZER_TOOL_TESTS AND TFM_NS_REG_TEST AND NS)
     if (NOT DEFINED TFM_FUZZER_TOOL_TESTS_CMAKE_INC_PATH)
         # The location of the file needs to be defined either from command line
         # or from config cmake file.
diff --git a/test/secure_fw/tfm_test_manifest_list.yaml b/test/secure_fw/tfm_test_manifest_list.yaml
index f85837f..95a818b 100644
--- a/test/secure_fw/tfm_test_manifest_list.yaml
+++ b/test/secure_fw/tfm_test_manifest_list.yaml
@@ -17,7 +17,7 @@
       "description": "TFM Secure Client Partition",
       "manifest": "common_test_services/tfm_secure_client_service/tfm_secure_client_service.yaml",
       "output_path": "secure_fw/test_services/tfm_secure_client_service",
-      "conditional": "TEST_FRAMEWORK_S",
+      "conditional": "TFM_S_REG_TEST",
       "version_major": 0,
       "version_minor": 1,
       "pid": 3002,
@@ -73,7 +73,7 @@
       "description": "TF-M Secure Client 2 Partition",
       "manifest": "common_test_services/tfm_secure_client_2/tfm_secure_client_2.yaml",
       "output_path": "secure_fw/test_services/tfm_secure_client_2",
-      "conditional": "TEST_FRAMEWORK_S",
+      "conditional": "TFM_S_REG_TEST",
       "version_major": 0,
       "version_minor": 1,
       "pid": 3006,