Improve extra test suites interface
Previously platform was only able to add one extra test case.
With this update platform is able to add as many test cases as it needs
to.
Also updated interface is simpler and more flexible than previous one.
Signed-off-by: Bohdan Burian <bohdan.burian@infineon.com>
Signed-off-by: Chris Brand <chris.brand@cypress.com>
Change-Id: Iadc5358a9130c012683dec7ebd2e1dd61111cb3f
diff --git a/test/secure_fw/suites/extra/CMakeLists.txt b/test/secure_fw/suites/extra/CMakeLists.txt
index 96090c1..21d1bfb 100644
--- a/test/secure_fw/suites/extra/CMakeLists.txt
+++ b/test/secure_fw/suites/extra/CMakeLists.txt
@@ -1,5 +1,7 @@
#-------------------------------------------------------------------------------
# Copyright (c) 2021-2022, Arm Limited. All rights reserved.
+# Copyright (c) 2022 Cypress Semiconductor Corporation (an Infineon company)
+# or an affiliate of Cypress Semiconductor Corporation. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -11,34 +13,14 @@
return()
endif()
-####################### Common library #########################################
-
-add_library(tfm_test_suite_extra_common STATIC EXCLUDE_FROM_ALL)
-
-target_sources(tfm_test_suite_extra_common
- PRIVATE
- ${CMAKE_CURRENT_SOURCE_DIR}/extra_tests_common.c
-)
-
-target_include_directories(tfm_test_suite_extra_common
- PUBLIC
- ${CMAKE_CURRENT_SOURCE_DIR}
-)
-
####################### Non-Secure extra test library ##########################
if (EXTRA_NS_TEST_SUITES_PATHS)
add_library(tfm_test_suite_extra_ns STATIC EXCLUDE_FROM_ALL)
- target_sources(tfm_test_suite_extra_ns
- PRIVATE
- ${CMAKE_CURRENT_SOURCE_DIR}/non_secure/extra_ns_tests.c
- )
-
target_include_directories(tfm_test_suite_extra_ns
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/non_secure
- ${CMAKE_CURRENT_SOURCE_DIR}
)
target_compile_definitions(tfm_test_suite_extra_ns
@@ -49,7 +31,6 @@
target_link_libraries(tfm_test_suite_extra_ns
PRIVATE
tfm_test_framework_ns
- tfm_test_suite_extra_common
)
target_link_libraries(tfm_ns_tests
@@ -61,15 +42,9 @@
####################### Secure extra test library ##############################
if (EXTRA_S_TEST_SUITES_PATHS)
- target_sources(tfm_test_suite_extra_s
- PRIVATE
- ${CMAKE_CURRENT_SOURCE_DIR}/secure/extra_s_tests.c
- )
-
target_include_directories(tfm_test_suite_extra_s
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/secure
- ${CMAKE_CURRENT_SOURCE_DIR}
)
target_compile_definitions(tfm_test_suite_extra_s
@@ -81,7 +56,6 @@
PRIVATE
tfm_test_framework_s
platform_s
- tfm_test_suite_extra_common
)
target_link_libraries(tfm_s_tests
diff --git a/test/secure_fw/suites/extra/extra_tests_common.c b/test/secure_fw/suites/extra/extra_tests_common.c
deleted file mode 100644
index 37cb559..0000000
--- a/test/secure_fw/suites/extra/extra_tests_common.c
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (c) 2021, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- *
- */
-
-#include "extra_tests_common.h"
-
-int32_t register_extra_tests(struct extra_tests_t *internal_test_t,
- const struct extra_tests_t *platform_test_t)
-{
- if (internal_test_t == NULL || platform_test_t == NULL ||
- platform_test_t->test_entry == NULL) {
- return EXTRA_TEST_FAILED;
- }
-
- internal_test_t->test_entry = platform_test_t->test_entry;
- internal_test_t->expected_ret = platform_test_t->expected_ret;
-
- return EXTRA_TEST_SUCCESS;
-}
diff --git a/test/secure_fw/suites/extra/extra_tests_common.h b/test/secure_fw/suites/extra/extra_tests_common.h
deleted file mode 100644
index 9cfeb49..0000000
--- a/test/secure_fw/suites/extra/extra_tests_common.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2021, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- *
- */
-
-#ifndef __EXTRA_TESTS_COMMON_H__
-#define __EXTRA_TESTS_COMMON_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stdint.h>
-#include <stddef.h>
-
-#define EXTRA_TEST_SUCCESS 0
-#define EXTRA_TEST_FAILED -1
-
-struct extra_tests_t
-{
- int32_t (*test_entry)(void); /* Entry function to call */
- int32_t expected_ret; /* Expected return value */
-};
-
-/**
- * \brief A function for extra test to init.
- *
- * \param[out] internal_test_t An internal pointer used to copy platform test.
- *
- * \returns Return EXTRA_TEST_SUCCESS if succeeds. Otherwise, return
- * EXTRA_TEST_FAILED.
- */
-int32_t extra_tests_init(struct extra_tests_t *internal_test_t);
-
-/**
- * \brief A function for platform to register test entry.
- *
- * \param[out] internal_test_t An internal pointer used to copy platform test.
- * \param[in] platform_test_t An external pointer to transfer platform test.
- *
- * \returns Return EXTRA_TEST_SUCCESS if succeeds. Otherwise, return
- * EXTRA_TEST_FAILED.
- */
-int32_t register_extra_tests(struct extra_tests_t *internal_test_t,
- const struct extra_tests_t *platform_test_t);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __EXTRA_TESTS_COMMON_H__ */
diff --git a/test/secure_fw/suites/extra/non_secure/extra_ns_tests.c b/test/secure_fw/suites/extra/non_secure/extra_ns_tests.c
deleted file mode 100644
index a842226..0000000
--- a/test/secure_fw/suites/extra/non_secure/extra_ns_tests.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2021-2022, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- *
- */
-
-#include "extra_ns_tests.h"
-
-void extra_ns_tests_entry(struct test_result_t *ret)
-{
- struct extra_tests_t extra_ns_test_t;
-
- if (extra_tests_init(&extra_ns_test_t) != TEST_SUITE_ERR_NO_ERROR) {
- ret->val = TEST_FAILED;
- }
-
- if (extra_ns_test_t.test_entry == NULL) {
- ret->val = TEST_FAILED;
- }
-
- if (extra_ns_test_t.test_entry() == extra_ns_test_t.expected_ret) {
- ret->val = TEST_PASSED;
- }else {
- ret->val = TEST_FAILED;
- }
-}
-
-static struct test_t extra_ns_interface_tests[] = {
- {&extra_ns_tests_entry, "TFM_EXTRA_TEST_1001",
- "Extra Non-Secure test"},
-};
-
-void register_testsuite_extra_ns_interface(struct test_suite_t *p_test_suite)
-{
- uint32_t list_size;
-
- list_size = (sizeof(extra_ns_interface_tests) /
- sizeof(extra_ns_interface_tests[0]));
-
- set_testsuite("Extra Non-Secure interface tests"
- "(TFM_NS_EXTRA_TEST_1XXX)",
- extra_ns_interface_tests, list_size, p_test_suite);
-}
diff --git a/test/secure_fw/suites/extra/non_secure/extra_ns_tests.h b/test/secure_fw/suites/extra/non_secure/extra_ns_tests.h
index 36f4ce2..15bba59 100644
--- a/test/secure_fw/suites/extra/non_secure/extra_ns_tests.h
+++ b/test/secure_fw/suites/extra/non_secure/extra_ns_tests.h
@@ -1,11 +1,12 @@
/*
* Copyright (c) 2021, Arm Limited. All rights reserved.
+ * Copyright (c) 2022 Cypress Semiconductor Corporation (an Infineon company)
+ * or an affiliate of Cypress Semiconductor Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
*/
-
#ifndef __EXTRA_NS_TESTS_H__
#define __EXTRA_NS_TESTS_H__
@@ -13,17 +14,9 @@
extern "C" {
#endif
-#include "extra_tests_common.h"
#include "test_framework.h"
/**
- * \brief Entry function used for extra non-secure test.
- *
- * \param[out] ret Returns error code as specified in \ref test_result_t.
- */
-void extra_ns_tests_entry(struct test_result_t *ret);
-
-/**
* \brief Register testsuite for the extra non-secure test.
*
* \param[in] p_test_suite The test suite to be executed.
diff --git a/test/secure_fw/suites/extra/secure/extra_s_tests.c b/test/secure_fw/suites/extra/secure/extra_s_tests.c
deleted file mode 100644
index 89c016c..0000000
--- a/test/secure_fw/suites/extra/secure/extra_s_tests.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2021-2022, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- *
- */
-
-#include "extra_s_tests.h"
-
-void extra_s_tests_entry(struct test_result_t *ret)
-{
- struct extra_tests_t extra_s_test_t;
-
- if (extra_tests_init(&extra_s_test_t) != TEST_SUITE_ERR_NO_ERROR) {
- ret->val = TEST_FAILED;
- }
-
- if (extra_s_test_t.test_entry == NULL) {
- ret->val = TEST_FAILED;
- }
-
- if (extra_s_test_t.test_entry() == extra_s_test_t.expected_ret) {
- ret->val = TEST_PASSED;
- }else {
- ret->val = TEST_FAILED;
- }
-}
-
-static struct test_t extra_s_interface_tests[] = {
- {&extra_s_tests_entry, "TFM_EXTRA_TEST_1001",
- "Extra Secure test"},
-};
-
-void register_testsuite_extra_s_interface(struct test_suite_t *p_test_suite)
-{
- uint32_t list_size;
-
- list_size = (sizeof(extra_s_interface_tests) /
- sizeof(extra_s_interface_tests[0]));
-
- set_testsuite("Extra Secure interface tests"
- "(TFM_S_EXTRA_TEST_1XXX)",
- extra_s_interface_tests, list_size, p_test_suite);
-}
diff --git a/test/secure_fw/suites/extra/secure/extra_s_tests.h b/test/secure_fw/suites/extra/secure/extra_s_tests.h
index ca4792c..2561c5f 100644
--- a/test/secure_fw/suites/extra/secure/extra_s_tests.h
+++ b/test/secure_fw/suites/extra/secure/extra_s_tests.h
@@ -1,5 +1,7 @@
/*
* Copyright (c) 2021, Arm Limited. All rights reserved.
+ * Copyright (c) 2022 Cypress Semiconductor Corporation (an Infineon company)
+ * or an affiliate of Cypress Semiconductor Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -12,17 +14,9 @@
extern "C" {
#endif
-#include "extra_tests_common.h"
#include "test_framework.h"
/**
- * \brief Entry function used for extra secure test.
- *
- * \param[out] ret Returns error code as specified in \ref test_result_t.
- */
-void extra_s_tests_entry(struct test_result_t *ret);
-
-/**
* \brief Register testsuite for the extra secure test.
*
* \param[in] p_test_suite The test suite to be executed.