TFTF: helpers for SPM tests
Added functions and macros to help check at the beginning of the test,
that system is as expected for SPM tests in which Hafnium is deployed as
SPMC.
This includes:
- Checking SPMC has expected FFA_VERSION;
- Checking that expected FF-A endpoints are deployed in the system;
- Getting global TFTF mailbox.
Signed-off-by: J-Alves <joao.alves@arm.com>
Change-Id: I9195bcff8ed93156e838b192bb70a9634e18fbbf
diff --git a/include/common/test_helpers.h b/include/common/test_helpers.h
index a6ec074..4be9aba 100644
--- a/include/common/test_helpers.h
+++ b/include/common/test_helpers.h
@@ -4,8 +4,8 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#ifndef __TEST_HELPERS_H__
-#define __TEST_HELPERS_H__
+#ifndef TEST_HELPERS_H__
+#define TEST_HELPERS_H__
#include <uuid.h>
#include <arch_features.h>
@@ -202,9 +202,8 @@
} \
} while (0)
-#define SKIP_TEST_IF_FFA_ENDPOINT_NOT_DEPLOYED(mb, uuid) \
+#define SKIP_TEST_IF_FFA_ENDPOINT_NOT_DEPLOYED(mb, ffa_uuid) \
do { \
- const uint32_t ffa_uuid[4] = uuid; \
smc_ret_values smc_ret = ffa_partition_info_get(ffa_uuid); \
ffa_rx_release(); \
if (smc_ret.ret0 == FFA_ERROR && \
@@ -217,6 +216,28 @@
} \
} while (0)
+#define GET_TFTF_MAILBOX(mb) \
+ do { \
+ if (!get_tftf_mailbox(&mb)) { \
+ ERROR("Mailbox not configured!\nThis test relies on" \
+ " test suite \"FF-A RXTX Mapping\" to map/configure" \
+ " RXTX buffers\n"); \
+ return TEST_RESULT_FAIL; \
+ } \
+ } while (false);
+
+#define CHECK_HAFNIUM_SPMC_TESTING_SETUP(ffa_major, ffa_minor, expected_uuids) \
+ do { \
+ const size_t expected_uuids_size = \
+ sizeof(expected_uuids) / sizeof(struct ffa_uuid); \
+ test_result_t ret = check_hafnium_spmc_testing_set_up( \
+ ffa_major, ffa_minor, expected_uuids, \
+ expected_uuids_size); \
+ if (ret != TEST_RESULT_SUCCESS) { \
+ return ret; \
+ } \
+ } while (false);
+
/* Helper macro to verify if system suspend API is supported */
#define is_psci_sys_susp_supported() \
(tftf_get_psci_feature_info(SMC_PSCI_SYSTEM_SUSPEND) \
@@ -282,4 +303,8 @@
*/
bool get_tftf_mailbox(struct mailbox_buffers *mb);
+test_result_t check_hafnium_spmc_testing_set_up(uint32_t ffa_version_major,
+ uint32_t ffa_version_minor, const struct ffa_uuid *ffa_uuids,
+ size_t ffa_uuids_size);
+
#endif /* __TEST_HELPERS_H__ */