Build: Split NS and Secure regression tests build

Seperate NS and Secure regressin test builds.

  - TF-M secure build integrates secure regression tests and test
    services via test/secure_regression.
  - Non-secure regression tests are built via test/ns_regression.
  - Pass tf-m-tests test config to TF-M secure build via argument
    CONFIG_TFM_TEST_CONFIG_FILE.
  - Fix issues when no regression test is enabled.

Signed-off-by: David Hu <david.hu@arm.com>
Change-Id: I1e550bf6d6a36a220275743c3312a61f7ae2c78e
diff --git a/tests_reg/CMakeLists.txt b/tests_reg/CMakeLists.txt
index a60f744..cf33c84 100644
--- a/tests_reg/CMakeLists.txt
+++ b/tests_reg/CMakeLists.txt
@@ -21,6 +21,7 @@
 
 list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/../cmake)
 list(APPEND CMAKE_MODULE_PATH ${CONFIG_SPE_PATH}/cmake)
+list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/utils)
 include(remote_library)
 include(toolchain_selection)
 
@@ -29,24 +30,28 @@
 # Platform abilities for example IRQ test support status
 include(${CONFIG_SPE_PATH}/platform/config.cmake OPTIONAL)
 
-set(TFM_NS_REG_TEST       ON)
-set(NS                    ON)
+include(${TFM_TOOLCHAIN_FILE})
+project(tfm_ns LANGUAGES C ASM)
+tfm_toolchain_reload_compiler()
+
+# Include configs exported from TF-M
+include(${CONFIG_SPE_PATH}/cmake/spe_config.cmake)
 
 # Test suite configurations - set up by SPE build
 include(${CONFIG_SPE_PATH}/config_ns_test.cmake)
 
-# Test configurations
+# Default test configurations
 include(${CMAKE_CURRENT_LIST_DIR}/test/config/default_test_config.cmake)
-
-include(${TFM_TOOLCHAIN_FILE})
-project(tfm_ns LANGUAGES C ASM)
-tfm_toolchain_reload_compiler()
+# Config check in case additional test configs passed in via command line.
+include(${CMAKE_CURRENT_LIST_DIR}/test/config/check_config.cmake)
 
 add_executable(tfm_ns)
 
 add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../lib/ext ${CMAKE_BINARY_DIR}/lib/ext)
 add_subdirectory(../app_broker ${CMAKE_BINARY_DIR}/app_broker)
-add_subdirectory(test)
+if(TFM_NS_REG_TEST)
+    add_subdirectory(test/ns_regression)
+endif()
 
 ############################# TFM NS main app ##################################
 
@@ -58,8 +63,12 @@
 target_link_libraries(tfm_ns
     PRIVATE
         tfm_test_broker
-        tfm_ns_tests
-        tfm_test_framework_common
+        $<$<BOOL:${TFM_NS_REG_TEST}>:tfm_ns_tests>
+)
+
+target_compile_definitions(tfm_ns
+    PUBLIC
+        $<$<BOOL:${TFM_NS_REG_TEST}>:TFM_NS_REG_TEST>
 )
 
 set_target_properties(tfm_ns PROPERTIES