Build: Support NS Attestation test

Change-Id: I9a6322487339705e00d70ae9ed31951ba57f24ba
Signed-off-by: Kevin Peng <kevin.peng@arm.com>
diff --git a/tests_reg/spe/CMakeLists.txt b/tests_reg/spe/CMakeLists.txt
index b9b7ac8..df4a8fb 100644
--- a/tests_reg/spe/CMakeLists.txt
+++ b/tests_reg/spe/CMakeLists.txt
@@ -45,3 +45,16 @@
 add_dependencies(tfm_s_test TF-M)
 
 install(DIRECTORY ${CMAKE_BINARY_DIR}/build-spe/bin DESTINATION ${CMAKE_BINARY_DIR})
+
+install(DIRECTORY   ${CONFIG_TFM_SOURCE_PATH}/secure_fw/partitions/initial_attestation
+        DESTINATION ${CMAKE_BINARY_DIR}/api_ns
+        FILES_MATCHING PATTERN "*.h")
+
+install(FILES       ${CONFIG_TFM_SOURCE_PATH}/secure_fw/spm/include/boot/tfm_boot_status.h
+        DESTINATION ${CMAKE_BINARY_DIR}/api_ns/initial_attestation)
+
+install(DIRECTORY   ${CONFIG_TFM_SOURCE_PATH}/lib/ext/t_cose
+        DESTINATION ${CMAKE_BINARY_DIR}/api_ns)
+
+install(FILES       ${CONFIG_TFM_SOURCE_PATH}/lib/ext/qcbor/q_useful_buf.h
+        DESTINATION ${CMAKE_BINARY_DIR}/api_ns/qcbor/inc)
diff --git a/tests_reg/test/secure_fw/suites/CMakeLists.txt b/tests_reg/test/secure_fw/suites/CMakeLists.txt
index 10d2f2d..afb98be 100644
--- a/tests_reg/test/secure_fw/suites/CMakeLists.txt
+++ b/tests_reg/test/secure_fw/suites/CMakeLists.txt
@@ -56,9 +56,8 @@
 add_subdirectory(extra)
 add_subdirectory(its)
 add_subdirectory(ps)
-# Do we need to test these external components?
-# add_subdirectory(qcbor)
-# add_subdirectory(t_cose)
+add_subdirectory(qcbor)
+add_subdirectory(t_cose)
 add_subdirectory(platform)
 add_subdirectory(fwu)
 add_subdirectory(multi_core/non_secure)
diff --git a/tests_reg/test/secure_fw/suites/attestation/CMakeLists.txt b/tests_reg/test/secure_fw/suites/attestation/CMakeLists.txt
index 657937b..7904750 100644
--- a/tests_reg/test/secure_fw/suites/attestation/CMakeLists.txt
+++ b/tests_reg/test/secure_fw/suites/attestation/CMakeLists.txt
@@ -9,7 +9,7 @@
 
 ####################### Non Secure #############################################
 
-if (TEST_NS_ATTESTATION)
+if (TEST_NS_ATTESTATION AND TFM_NS_REG_TEST) # Need TFM_NS_REG_TEST to exclude when building SPE
     add_library(tfm_test_suite_attestation_ns STATIC EXCLUDE_FROM_ALL)
 
     target_sources(tfm_test_suite_attestation_ns
@@ -29,6 +29,8 @@
             ${CMAKE_CURRENT_SOURCE_DIR}/ext/qcbor_util
         PRIVATE
             .
+            ${CONFIG_SPE_PATH}/initial_attestation
+            ${CONFIG_SPE_PATH}/t_cose/inc
     )
 
     target_compile_definitions(tfm_test_suite_attestation_ns
@@ -45,9 +47,6 @@
             tfm_qcbor_ns
             tfm_t_cose_ns
             tfm_test_framework_ns
-            #TODO I'm not sure this should _really_ be linked here
-            tfm_attestation_defs
-            tfm_boot_status
             platform_ns
     )
 
diff --git a/tests_reg/test/secure_fw/suites/qcbor/CMakeLists.txt b/tests_reg/test/secure_fw/suites/qcbor/CMakeLists.txt
index 036310a..e26f3d2 100644
--- a/tests_reg/test/secure_fw/suites/qcbor/CMakeLists.txt
+++ b/tests_reg/test/secure_fw/suites/qcbor/CMakeLists.txt
@@ -6,6 +6,10 @@
 #-------------------------------------------------------------------------------
 cmake_policy(SET CMP0079 NEW)
 
+if (NOT TEST_NS_QCBOR AND NOT TEST_NS_ATTESTATION)
+    return()
+endif()
+
 # Adding qcbor and qcbor_test libraries manually as logical target names
 # must be globally unique in CMake. The Secure image also relies on the qcbor
 # library (including its own CMake files), but a separate Non Secure library
@@ -27,6 +31,7 @@
 target_include_directories(tfm_qcbor_ns
     PUBLIC
         $<BUILD_INTERFACE:${QCBOR_PATH}/inc>
+        ${CONFIG_SPE_PATH}/qcbor/inc
 )
 
 target_compile_definitions(tfm_qcbor_ns
diff --git a/tests_reg/test/secure_fw/suites/t_cose/CMakeLists.txt b/tests_reg/test/secure_fw/suites/t_cose/CMakeLists.txt
index ae83e25..1d2f04d 100644
--- a/tests_reg/test/secure_fw/suites/t_cose/CMakeLists.txt
+++ b/tests_reg/test/secure_fw/suites/t_cose/CMakeLists.txt
@@ -7,17 +7,20 @@
 
 cmake_policy(SET CMP0079 NEW)
 
+if(TEST_NS_ATTESTATION AND TFM_NS_REG_TEST) # Need TFM_NS_REG_TEST to exclude when building SPE
+    include(${CONFIG_SPE_PATH}/t_cose/tfm_t_cose.cmake)
+
 ############################ t_cose non secure #################################
+    add_library(tfm_t_cose_ns STATIC EXCLUDE_FROM_ALL)
 
-add_library(tfm_t_cose_ns STATIC EXCLUDE_FROM_ALL)
-
-target_link_libraries(tfm_t_cose_ns
-    PUBLIC
-        tfm_t_cose_common
-        tfm_t_cose_defs
-        tfm_qcbor_ns
-        tfm_api_ns
-)
+    target_link_libraries(tfm_t_cose_ns
+        PRIVATE
+            tfm_t_cose_common
+            tfm_t_cose_defs
+            tfm_qcbor_ns
+            tfm_api_ns
+    )
+endif()
 
 if (NOT TEST_NS_T_COSE)
     return()