Test: Decouple control logic between Core test, IPC test and Regression test

Decouple the control flag and logic between Core test, IPC test and
Regression test.
CORE_TEST, IPC_TEST, REGRESSION can control Core test, IPC test and
Regression test respectively.

Change-Id: I0952e7572abe0229b9a09022484573e8805b16b3
Signed-off-by: David Hu <david.hu@arm.com>
diff --git a/CommonConfig.cmake b/CommonConfig.cmake
index aa261c0..259136b 100644
--- a/CommonConfig.cmake
+++ b/CommonConfig.cmake
@@ -11,6 +11,8 @@
 	message(FATAL_ERROR "ERROR: Incomplete Configuration: CORE_TEST not defined, Include this file from a Config*.cmake")
 elseif(NOT DEFINED TFM_LVL)
 	message(FATAL_ERROR "ERROR: Incomplete Configuration: TFM_LVL not defined, Include this file from a Config*.cmake")
+elseif(NOT DEFINED CORE_IPC)
+	message(FATAL_ERROR "ERROR: Incomplete Configuration: CORE_IPC not deinfed. Include this file from a Config*.cmake")
 endif()
 
 if(NOT DEFINED COMPILER)
@@ -111,7 +113,6 @@
 set (TEST_FRAMEWORK_NS OFF)
 set (TFM_PSA_API OFF)
 set (TFM_LEGACY_API ON)
-set (CORE_TEST_IPC OFF)
 
 option(TFM_PARTITION_AUDIT_LOG "Enable the TF-M Audit Log partition" ON)
 option(TFM_PARTITION_PLATFORM "Enable the TF-M Platform partition" ON)
@@ -129,6 +130,14 @@
 
 if (CORE_IPC)
 	set(TFM_PSA_API ON)
+
+	# Disable IPC Test by default if the config or platform doesn't explicitly
+	# require it
+	if (NOT DEFINED IPC_TEST)
+		set(IPC_TEST OFF)
+	endif()
+else()
+	set(IPC_TEST OFF)
 endif()
 
 if (TFM_PSA_API)
@@ -142,16 +151,9 @@
 if (SERVICES_TEST_ENABLED)
 	set(SERVICE_TEST_S ON)
 	set(SERVICE_TEST_NS ON)
-	if (CORE_IPC)
-		set(CORE_TEST_IPC ON)
-	endif()
-	set(CORE_TEST_POSITIVE ON)
 endif()
 
 if (CORE_TEST)
-	if (CORE_IPC)
-		set(CORE_TEST_IPC ON)
-	endif()
 	set(CORE_TEST_POSITIVE ON)
 	set(CORE_TEST_INTERACTIVE OFF)
 endif()
@@ -182,8 +184,8 @@
 	set(TFM_ENABLE_IRQ_TEST OFF)
 endif()
 
-if (CORE_TEST_IPC)
-	add_definitions(-DCORE_TEST_IPC)
+if (IPC_TEST)
+	add_definitions(-DENABLE_IPC_TEST)
 	set(TEST_FRAMEWORK_NS ON)
 	set(TFM_PARTITION_TEST_CORE_IPC ON)
 endif()
diff --git a/configs/ConfigCoreIPC.cmake b/configs/ConfigCoreIPC.cmake
index 87b0c67..16b032b 100644
--- a/configs/ConfigCoreIPC.cmake
+++ b/configs/ConfigCoreIPC.cmake
@@ -29,12 +29,15 @@
 	message(FATAL_ERROR "ERROR: Target \"${TARGET_PLATFORM}\" is not supported.")
 endif()
 
+# Select IPC model
+set (CORE_IPC True)
+
 ##These variables select how the projects are built. Each project will set
 #various project specific settings (e.g. what files to build, macro
 #definitions) based on these.
 set (REGRESSION False)
 set (CORE_TEST False)
-set (CORE_IPC True)
+set (IPC_TEST False)
 set (PSA_API_TEST False)
 
 # TF-M isolation level: 1, 2
diff --git a/configs/ConfigCoreIPCTfmLevel2.cmake b/configs/ConfigCoreIPCTfmLevel2.cmake
index 12eb09b..11b316f 100644
--- a/configs/ConfigCoreIPCTfmLevel2.cmake
+++ b/configs/ConfigCoreIPCTfmLevel2.cmake
@@ -29,12 +29,15 @@
 	message(FATAL_ERROR "ERROR: Target \"${TARGET_PLATFORM}\" is not supported.")
 endif()
 
+# Select IPC model
+set (CORE_IPC True)
+
 ##These variables select how the projects are built. Each project will set
 #various project specific settings (e.g. what files to build, macro
 #definitions) based on these.
 set (REGRESSION False)
 set (CORE_TEST False)
-set (CORE_IPC True)
+set (IPC_TEST False)
 set (PSA_API_TEST False)
 
 # TF-M isolation level: 1, 2
diff --git a/configs/ConfigRegressionIPC.cmake b/configs/ConfigRegressionIPC.cmake
index 23b90c7..ed8c7ab 100644
--- a/configs/ConfigRegressionIPC.cmake
+++ b/configs/ConfigRegressionIPC.cmake
@@ -29,12 +29,15 @@
 	message(FATAL_ERROR "ERROR: Target \"${TARGET_PLATFORM}\" is not supported.")
 endif()
 
+# Select IPC model
+set (CORE_IPC True)
+
 ##These variables select how the projects are built. Each project will set
 #various project specific settings (e.g. what files to build, macro
 #definitions) based on these.
 set (REGRESSION True)
 set (CORE_TEST True)
-set (CORE_IPC True)
+set (IPC_TEST True)
 set (PSA_API_TEST False)
 
 # TF-M isolation level: 1, 2
diff --git a/configs/ConfigRegressionIPCTfmLevel2.cmake b/configs/ConfigRegressionIPCTfmLevel2.cmake
index a83249f..992e6ae 100644
--- a/configs/ConfigRegressionIPCTfmLevel2.cmake
+++ b/configs/ConfigRegressionIPCTfmLevel2.cmake
@@ -29,12 +29,15 @@
 	message(FATAL_ERROR "ERROR: Target \"${TARGET_PLATFORM}\" is not supported.")
 endif()
 
+# Select IPC model
+set (CORE_IPC True)
+
 ##These variables select how the projects are built. Each project will set
 #various project specific settings (e.g. what files to build, macro
 #definitions) based on these.
 set (REGRESSION True)
 set (CORE_TEST True)
-set (CORE_IPC True)
+set (IPC_TEST True)
 set (PSA_API_TEST False)
 
 # TF-M isolation level: 1, 2
diff --git a/test/framework/non_secure_suites.c b/test/framework/non_secure_suites.c
index 5f29e2d..b32d227 100644
--- a/test/framework/non_secure_suites.c
+++ b/test/framework/non_secure_suites.c
@@ -65,7 +65,7 @@
     {&register_testsuite_ns_core_interactive, 0, 0, 0},
 #endif
 
-#ifdef CORE_TEST_IPC
+#ifdef ENABLE_IPC_TEST
     /* Non-secure IPC test cases */
     {&register_testsuite_ns_ipc_interface, 0, 0, 0},
 #endif
diff --git a/test/framework/secure_suites.c b/test/framework/secure_suites.c
index 1d51793..5042e11 100644
--- a/test/framework/secure_suites.c
+++ b/test/framework/secure_suites.c
@@ -52,7 +52,7 @@
     {&register_testsuite_s_invert_interface, 0, 0, 0},
 #endif /* TFM_PARTITION_TEST_CORE*/
 
-#ifdef CORE_TEST_IPC
+#ifdef ENABLE_IPC_TEST
     /* Secure IPC test cases */
     {&register_testsuite_s_ipc_interface, 0, 0, 0},
 #endif
diff --git a/test/suites/ipc/CMakeLists.inc b/test/suites/ipc/CMakeLists.inc
index c88de5b..c7a48be 100644
--- a/test/suites/ipc/CMakeLists.inc
+++ b/test/suites/ipc/CMakeLists.inc
@@ -1,5 +1,5 @@
 #-------------------------------------------------------------------------------
-# Copyright (c) 2018, Arm Limited. All rights reserved.
+# Copyright (c) 2018-2019, Arm Limited. All rights reserved.
 #
 # SPDX-License-Identifier: BSD-3-Clause
 #
@@ -24,9 +24,9 @@
 	message(FATAL_ERROR "Please set TFM_ROOT_DIR before including this file.")
 endif()
 
-if (NOT DEFINED CORE_TEST_IPC)
-	message(FATAL_ERROR "Incomplete build configuration: CORE_TEST_IPC is undefined. ")
-elseif(CORE_TEST_IPC)
+if (NOT DEFINED IPC_TEST)
+	message(FATAL_ERROR "Incomplete build configuration: IPC_TEST is undefined. ")
+elseif(IPC_TEST)
 	list(APPEND ALL_SRC_C_S "${IPC_TEST_DIR}/secure/ipc_s_interface_testsuite.c")
 	list(APPEND ALL_SRC_C_NS "${IPC_TEST_DIR}/non_secure/ipc_ns_interface_testsuite.c")