Service: Add a new SLIH test
This patch adds a new SLIH test Partition and new IRQ test suite.
The test logic for SLIH - previously IRQ test - is simplified a lot
as well.
This service is intended to replace the tfm_irq_test_1 service.
Change-Id: Ie319bd57121f73125819bcfbb80943cc557533d9
Signed-off-by: Kevin Peng <kevin.peng@arm.com>
diff --git a/test/suites/irq/CMakeLists.txt b/test/suites/irq/CMakeLists.txt
new file mode 100644
index 0000000..17a2755
--- /dev/null
+++ b/test/suites/irq/CMakeLists.txt
@@ -0,0 +1,43 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2021, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+cmake_policy(SET CMP0079 NEW)
+
+if (NOT TFM_ENABLE_SLIH_TEST)
+ return()
+endif()
+
+####################### Non Secure #############################################
+
+add_library(tfm_test_suite_irq STATIC EXCLUDE_FROM_ALL)
+
+target_sources(tfm_test_suite_irq
+ PRIVATE
+ ./irq_testsuite.c
+)
+
+target_include_directories(tfm_test_suite_irq
+ PUBLIC
+ ./
+)
+
+target_compile_definitions(tfm_test_suite_irq
+ PUBLIC
+ $<$<BOOL:${TFM_ENABLE_SLIH_TEST}>:TFM_ENABLE_SLIH_TEST>
+)
+
+target_link_libraries(tfm_test_suite_irq
+ PRIVATE
+ tfm_test_framework_ns
+ $<$<BOOL:${TFM_ENABLE_SLIH_TEST}>:tfm_slih_test_service_interface>
+ platform_ns
+)
+
+target_link_libraries(tfm_ns_tests
+ INTERFACE
+ tfm_test_suite_irq
+)
diff --git a/test/suites/irq/irq_testsuite.c b/test/suites/irq/irq_testsuite.c
new file mode 100644
index 0000000..3956258
--- /dev/null
+++ b/test/suites/irq/irq_testsuite.c
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2021, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#include "cmsis.h"
+#include "psa_manifest/sid.h"
+#include "psa/client.h"
+#include "test_framework.h"
+#include "tfm_peripherals_def.h"
+#include "tfm_plat_test.h"
+#ifdef TFM_ENABLE_SLIH_TEST
+#include "tfm_slih_test_service_types.h"
+#endif /* TFM_ENABLE_SLIH_TEST */
+
+#ifdef TFM_ENABLE_SLIH_TEST
+/*
+ * Test process:
+ * - NSPE starts testing
+ * - Test Partition starts timer
+ * - Test Partition waits for the timer signal
+ * - Test Partition receives the signal and stop timer
+ * - Test Partition returns to NSPE
+ * - Test finishes
+ */
+static void tfm_irq_test_slih_case_1(struct test_result_t *ret) {
+ psa_status_t status;
+
+ status = psa_call(TFM_SLIH_TEST_CASE_HANDLE,
+ TFM_SLIH_TEST_CASE_1, NULL, 0, NULL, 0);
+ if (status != PSA_SUCCESS) {
+ TEST_FAIL("TFM_NS_IRQ_TEST_SLIH_HANDLING FAILED\r\n");
+ return;
+ }
+
+ ret->val = TEST_PASSED;
+}
+#endif /* TFM_ENABLE_SLIH_TEST */
+
+static struct test_t irq_test_cases[] = {
+#ifdef TFM_ENABLE_SLIH_TEST
+ {&tfm_irq_test_slih_case_1, "TFM_NS_IRQ_TEST_SLIH_1001",
+ "SLIH HANDLING Case 1", {TEST_PASSED}},
+#endif /* TFM_ENABLE_SLIH_TEST */
+};
+
+void register_testsuite_irq_test(struct test_suite_t *p_test_suite)
+{
+ uint32_t list_size;
+
+ list_size = (sizeof(irq_test_cases) / sizeof(irq_test_cases[0]));
+
+ set_testsuite("TFM IRQ Test (TFM_IRQ_TEST_1xxx)",
+ irq_test_cases, list_size, p_test_suite);
+}
diff --git a/test/suites/irq/irq_testsuite.h b/test/suites/irq/irq_testsuite.h
new file mode 100644
index 0000000..934965f
--- /dev/null
+++ b/test/suites/irq/irq_testsuite.h
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2021, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#ifndef __IRQ_TESTSUITE_H__
+#define __IRQ_TESTSUITE_H__
+
+#include "test_framework.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void register_testsuite_irq_test(struct test_suite_t *p_test_suite);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __IRQ_TESTSUITE_H__ */