Build: Enable linking with PSA API compliance tests in the NS app
This change modifies the build system to support linking
the PSA API compliance test static libraries. It introduces
a new build configuration ConfigPsaApiTest.cmake for this purpose.
The build instructions are updated to show an example of how
to use this new build configuration.
Change-Id: Iabf4876504e690826fe80b467a91fa53bffb0b47
Signed-off-by: Jamie Fox <jamie.fox@arm.com>
Co-Authored-by: Antonio de Angelis <antonio.deangelis@arm.com>
diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt
index 59d1713..ed968a5 100755
--- a/app/CMakeLists.txt
+++ b/app/CMakeLists.txt
@@ -1,5 +1,5 @@
#-------------------------------------------------------------------------------
-# Copyright (c) 2017-2018, Arm Limited. All rights reserved.
+# Copyright (c) 2017-2019, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -60,6 +60,10 @@
)
endif()
+if (PSA_API_TEST_NS)
+ list(APPEND NS_APP_SRC "${APP_DIR}/psa_api_test.c")
+endif()
+
set(BUILD_CMSIS_CORE On)
set(BUILD_RETARGET On)
set(BUILD_NATIVE_DRIVERS On)
@@ -174,6 +178,25 @@
endif()
target_link_libraries(${EXE_NAME} "${RTX_LIB_PATH}")
+ #Add the PSA API compliance test libraries
+ if(NOT DEFINED PSA_API_TEST_BUILD_PATH)
+ #If not specified, assume it's the default build folder checked out at the same level of TFM root dir
+ set(PSA_API_TEST_BUILD_PATH "${TFM_ROOT_DIR}/../psa-arch-tests/api-tests/BUILD")
+ endif()
+ if(PSA_API_TEST_NS)
+ target_link_libraries(${EXE_NAME} "${PSA_API_TEST_BUILD_PATH}/val/val_nspe.a")
+ target_link_libraries(${EXE_NAME} "${PSA_API_TEST_BUILD_PATH}/platform/pal_nspe.a")
+ endif()
+ if(PSA_API_TEST_NS AND PSA_API_TEST_SECURE_STORAGE)
+ target_link_libraries(${EXE_NAME} "${PSA_API_TEST_BUILD_PATH}/dev_apis/protected_storage/test_combine.a")
+ endif()
+ if(PSA_API_TEST_NS AND PSA_API_TEST_CRYPTO)
+ target_link_libraries(${EXE_NAME} "${PSA_API_TEST_BUILD_PATH}/dev_apis/crypto/test_combine.a")
+ endif()
+ if(PSA_API_TEST_NS AND PSA_API_TEST_ATTESTATION)
+ target_link_libraries(${EXE_NAME} "${PSA_API_TEST_BUILD_PATH}/dev_apis/initial_attestation/test_combine.a")
+ endif()
+
if(NOT DEFINED PLATFORM_LINK_INCLUDES)
message(FATAL_ERROR "ERROR: Incomplete Configuration: PLATFORM_LINK_INCLUDES is not defined.")
endif()
diff --git a/app/main_ns.c b/app/main_ns.c
index 1e23f16..b6f1786 100644
--- a/app/main_ns.c
+++ b/app/main_ns.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2018, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -18,7 +18,9 @@
#ifdef TEST_FRAMEWORK_NS
#include "test/framework/test_framework_integ_test.h"
#endif
-
+#ifdef PSA_API_TEST_NS
+#include "psa_api_test.h"
+#endif
#include "target_cfg.h"
#include "Driver_USART.h"
@@ -83,6 +85,11 @@
.name = "test_app",
.stack_size = 1024U
};
+#elif PSA_API_TEST_NS
+static const osThreadAttr_t psa_api_test_attr = {
+ .name = "psa_api_test",
+ .stack_size = 3072U
+};
#endif
/**
@@ -110,6 +117,8 @@
#ifdef TEST_FRAMEWORK_NS
thread_id = osThreadNew(test_app, NULL, &tserv_test);
+#elif PSA_API_TEST_NS
+ thread_id = osThreadNew(psa_api_test, NULL, &psa_api_test_attr);
#else
UNUSED_VARIABLE(thread_id);
#endif
diff --git a/app/psa_api_test.c b/app/psa_api_test.c
new file mode 100644
index 0000000..3a6cc53
--- /dev/null
+++ b/app/psa_api_test.c
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#include "psa_api_test.h"
+#include "tfm_nspm_api.h"
+#include "tfm_integ_test.h"
+
+/**
+ * \brief This symbol is the entry point provided by the PSA API compliance
+ * test libraries
+ */
+extern void val_entry(void);
+
+__attribute__((noreturn))
+void psa_api_test(void *arg)
+{
+ UNUSED_VARIABLE(arg);
+
+#ifdef TFM_NS_CLIENT_IDENTIFICATION
+ tfm_nspm_register_client_id();
+#endif /* TFM_NS_CLIENT_IDENTIFICATION */
+
+ val_entry();
+
+ for (;;) {
+ }
+}
diff --git a/app/psa_api_test.h b/app/psa_api_test.h
new file mode 100644
index 0000000..5423b15
--- /dev/null
+++ b/app/psa_api_test.h
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#ifndef __PSA_API_TEST_H__
+#define __PSA_API_TEST_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * \brief Main test application for the PSA API compliance tests
+ *
+ */
+void psa_api_test(void *arg);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __PSA_API_TEST_H__ */