Build: Support building IPC model without tests

Refactors the build configuration variables so that the Core IPC tests
are only built if either CORE_TEST or REGRESSION is enabled (as well as
CORE_IPC). This matches the build behaviour for library model.

Adds a TFM_PARTITION_TEST_CORE_IPC build variable to make it possible
to compile-out the Core IPC test partition when the Core IPC tests are
not built.

Removes some unneeded build system behaviour that was conditional on
CORE_TEST to avoid causing problems when CORE_IPC is enabled.

Change-Id: Ia88bd3785817cc2dcedf88b737690fc32cc3266e
Signed-off-by: Jamie Fox <jamie.fox@arm.com>
diff --git a/CommonConfig.cmake b/CommonConfig.cmake
index eb37566..bfcdf18 100644
--- a/CommonConfig.cmake
+++ b/CommonConfig.cmake
@@ -103,6 +103,7 @@
 #Settings which shall be set for all projects the same way based
 # on the variables above.
 set (TFM_PARTITION_TEST_CORE OFF)
+set (TFM_PARTITION_TEST_CORE_IPC OFF)
 set (CORE_TEST_POSITIVE OFF)
 set (CORE_TEST_INTERACTIVE OFF)
 set (REFERENCE_PLATFORM OFF)
@@ -130,7 +131,6 @@
 
 if (CORE_IPC)
 	set(TFM_PSA_API ON)
-	set(CORE_TEST_IPC ON)
 endif()
 
 if (TFM_PSA_API)
@@ -144,14 +144,20 @@
 if (SERVICES_TEST_ENABLED)
 	set(SERVICE_TEST_S ON)
 	set(SERVICE_TEST_NS ON)
-	if (REFERENCE_PLATFORM AND NOT CORE_IPC)
+	if (CORE_IPC)
+		set(CORE_TEST_IPC ON)
+	elseif (REFERENCE_PLATFORM)
 		set(CORE_TEST_POSITIVE ON)
 	endif()
 endif()
 
 if (CORE_TEST)
-	set(CORE_TEST_POSITIVE ON)
-	set(CORE_TEST_INTERACTIVE OFF)
+	if (CORE_IPC)
+		set(CORE_TEST_IPC ON)
+	elseif (REFERENCE_PLATFORM)
+		set(CORE_TEST_POSITIVE ON)
+		set(CORE_TEST_INTERACTIVE OFF)
+	endif()
 endif()
 
 if (CORE_TEST_INTERACTIVE)
@@ -168,12 +174,14 @@
 
 if (CORE_TEST_IPC)
 	add_definitions(-DCORE_TEST_IPC)
-	# If PSA_API_TEST is enabled, don't run TF-M test framework from NS
-	if (PSA_API_TEST)
-	  set(TEST_FRAMEWORK_NS OFF)
-	else()
-	  set(TEST_FRAMEWORK_NS ON)
-	endif()
+	set(TEST_FRAMEWORK_NS ON)
+	set(TFM_PARTITION_TEST_CORE_IPC ON)
+elseif (CORE_IPC AND (NOT PSA_API_TEST) AND (TFM_LVL EQUAL 1))
+	# FIXME: Running the Core IPC tests in this config is deprecated and will
+	# be removed in the future.
+	set(CORE_TEST_IPC ON)
+	add_definitions(-DCORE_TEST_IPC)
+	set(TEST_FRAMEWORK_NS ON)
 endif()
 
 if (SERVICE_TEST_S)
@@ -213,6 +221,10 @@
 	add_definitions(-DTFM_PARTITION_TEST_CORE)
 endif()
 
+if (TFM_PARTITION_TEST_CORE_IPC)
+	add_definitions(-DTFM_PARTITION_TEST_CORE_IPC)
+endif()
+
 if (TFM_PARTITION_TEST_SECURE_SERVICES)
 	add_definitions(-DTFM_PARTITION_TEST_SECURE_SERVICES)
 endif()