aboutsummaryrefslogtreecommitdiff
path: root/include/common/test_helpers.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/common/test_helpers.h')
-rw-r--r--include/common/test_helpers.h221
1 files changed, 153 insertions, 68 deletions
diff --git a/include/common/test_helpers.h b/include/common/test_helpers.h
index 3ee2b5318..8cddc72d3 100644
--- a/include/common/test_helpers.h
+++ b/include/common/test_helpers.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2021, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2024, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -8,10 +8,9 @@
#define TEST_HELPERS_H__
#include <arch_features.h>
-#include <ffa_svc.h>
#include <plat_topology.h>
#include <psci.h>
-#include <spm_common.h>
+#include <sme.h>
#include <tftf_lib.h>
#include <trusted_os.h>
#include <tsp.h>
@@ -89,6 +88,15 @@ typedef test_result_t (*test_function_arg_t)(void *arg);
} \
} while (0)
+#define SKIP_TEST_IF_DIT_NOT_SUPPORTED() \
+ do { \
+ if (!is_armv8_4_dit_present()) { \
+ tftf_testcase_printf( \
+ "DIT not supported\n"); \
+ return TEST_RESULT_SKIPPED; \
+ } \
+ } while (0)
+
#define SKIP_TEST_IF_PAUTH_NOT_SUPPORTED() \
do { \
if (!is_armv8_3_pauth_present()) { \
@@ -107,6 +115,14 @@ typedef test_result_t (*test_function_arg_t)(void *arg);
} \
} while (0)
+#define SKIP_TEST_IF_SVE_NOT_SUPPORTED() \
+ do { \
+ if (!is_armv8_2_sve_present()) { \
+ tftf_testcase_printf("SVE not supported\n"); \
+ return TEST_RESULT_SKIPPED; \
+ } \
+ } while (0)
+
#define SKIP_TEST_IF_ECV_NOT_SELF_SYNC() \
do { \
if (get_armv8_6_ecv_support() != \
@@ -162,33 +178,6 @@ typedef test_result_t (*test_function_arg_t)(void *arg);
version & MM_VERSION_MINOR_MASK); \
} while (0)
-#define SKIP_TEST_IF_FFA_VERSION_LESS_THAN(major, minor) \
- do { \
- smc_ret_values smc_ret = ffa_version( \
- MAKE_FFA_VERSION(major, minor)); \
- uint32_t version = smc_ret.ret0; \
- \
- if (version == FFA_ERROR_NOT_SUPPORTED) { \
- tftf_testcase_printf("FFA_VERSION not supported.\n"); \
- return TEST_RESULT_SKIPPED; \
- } \
- \
- if ((version & FFA_VERSION_BIT31_MASK) != 0U) { \
- tftf_testcase_printf("FFA_VERSION bad response: %x\n", \
- version); \
- return TEST_RESULT_FAIL; \
- } \
- \
- if (version < MAKE_FFA_VERSION(major, minor)) { \
- tftf_testcase_printf("FFA_VERSION returned %u.%u\n" \
- "The required version is %u.%u\n", \
- version >> FFA_VERSION_MAJOR_SHIFT, \
- version & FFA_VERSION_MINOR_MASK, \
- major, minor); \
- return TEST_RESULT_SKIPPED; \
- } \
- } while (0)
-
#define SKIP_TEST_IF_ARCH_DEBUG_VERSION_LESS_THAN(version) \
do { \
uint32_t debug_ver = arch_get_debug_version(); \
@@ -202,41 +191,141 @@ typedef test_result_t (*test_function_arg_t)(void *arg);
} \
} while (0)
-#define SKIP_TEST_IF_FFA_ENDPOINT_NOT_DEPLOYED(mb, ffa_uuid) \
+#define SKIP_TEST_IF_TRBE_NOT_SUPPORTED() \
do { \
- smc_ret_values smc_ret = ffa_partition_info_get(ffa_uuid); \
- ffa_rx_release(); \
- if (smc_ret.ret0 == FFA_ERROR && \
- smc_ret.ret2 == FFA_ERROR_INVALID_PARAMETER) { \
- tftf_testcase_printf("FFA endpoint not deployed!\n"); \
+ if (!get_armv9_0_trbe_support()) { \
+ tftf_testcase_printf("ARMv9-TRBE not supported\n"); \
return TEST_RESULT_SKIPPED; \
- } else if (smc_ret.ret0 != FFA_SUCCESS_SMC32) { \
- ERROR("ffa_partition_info_get failed!\n"); \
- return TEST_RESULT_FAIL; \
} \
- } while (0)
+ } while (false)
+
+#define SKIP_TEST_IF_TRF_NOT_SUPPORTED() \
+ do { \
+ if (!get_armv8_4_trf_support()) { \
+ tftf_testcase_printf("ARMv8.4-TRF not supported\n"); \
+ return TEST_RESULT_SKIPPED; \
+ } \
+ } while (false)
-#define GET_TFTF_MAILBOX(mb) \
+#define SKIP_TEST_IF_SYS_REG_TRACE_NOT_SUPPORTED() \
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; \
+ if (!get_armv8_0_sys_reg_trace_support()) { \
+ tftf_testcase_printf("ARMv8-system register" \
+ "trace not supported\n"); \
+ return TEST_RESULT_SKIPPED; \
} \
- } while (false);
+ } while (false)
-#define CHECK_SPMC_TESTING_SETUP(ffa_major, ffa_minor, expected_uuids) \
+#define SKIP_TEST_IF_AFP_NOT_SUPPORTED() \
do { \
- const size_t expected_uuids_size = \
- sizeof(expected_uuids) / sizeof(struct ffa_uuid); \
- test_result_t ret = check_spmc_testing_set_up( \
- ffa_major, ffa_minor, expected_uuids, \
- expected_uuids_size); \
- if (ret != TEST_RESULT_SUCCESS) { \
- return ret; \
+ if (!get_feat_afp_present()) { \
+ tftf_testcase_printf("ARMv8.7-afp not supported\n"); \
+ return TEST_RESULT_SKIPPED; \
+ } \
+ } while (false)
+
+#define SKIP_TEST_IF_MPAM_NOT_SUPPORTED() \
+ do { \
+ if(!is_feat_mpam_supported()){ \
+ tftf_testcase_printf("ARMv8.4-mpam not supported\n"); \
+ return TEST_RESULT_SKIPPED; \
+ } \
+ } while (false)
+
+#ifdef __aarch64__
+#define SKIP_TEST_IF_PA_SIZE_LESS_THAN(n) \
+ do { \
+ static const unsigned int pa_range_bits_arr[] = { \
+ PARANGE_0000, PARANGE_0001, PARANGE_0010, PARANGE_0011,\
+ PARANGE_0100, PARANGE_0101, PARANGE_0110 \
+ }; \
+ if (pa_range_bits_arr[get_pa_range()] < n) { \
+ tftf_testcase_printf("PA size less than %d bit\n", n); \
+ return TEST_RESULT_SKIPPED; \
+ } \
+ } while (false)
+#else
+#define SKIP_TEST_IF_PA_SIZE_LESS_THAN(n) \
+ do { \
+ return TEST_RESULT_SKIPPED; \
+ } while (false)
+#endif
+
+#define SKIP_TEST_IF_BRBE_NOT_SUPPORTED() \
+ do { \
+ if (!get_feat_brbe_support()) { \
+ tftf_testcase_printf("FEAT_BRBE not supported\n"); \
+ return TEST_RESULT_SKIPPED; \
+ } \
+ } while (false)
+
+#define SKIP_TEST_IF_WFXT_NOT_SUPPORTED() \
+ do { \
+ if (!get_feat_wfxt_present()) { \
+ tftf_testcase_printf("ARMv8.7-WFxT not supported\n"); \
+ return TEST_RESULT_SKIPPED; \
+ } \
+ } while (false)
+
+#define SKIP_TEST_IF_RNG_TRAP_NOT_SUPPORTED() \
+ do { \
+ if (!is_feat_rng_trap_present()) { \
+ tftf_testcase_printf("ARMv8.5-RNG_TRAP not" \
+ "supported\n"); \
+ return TEST_RESULT_SKIPPED; \
+ } \
+ } while (false)
+
+#define SKIP_TEST_IF_PMUV3_NOT_SUPPORTED() \
+ do { \
+ if (!get_feat_pmuv3_supported()) { \
+ tftf_testcase_printf("FEAT_PMUv3 not supported\n"); \
+ return TEST_RESULT_SKIPPED; \
+ } \
+ } while (false)
+
+#define SKIP_TEST_IF_SME_NOT_SUPPORTED() \
+ do { \
+ if(!is_feat_sme_supported()) { \
+ tftf_testcase_printf("FEAT_SME not supported\n"); \
+ return TEST_RESULT_SKIPPED; \
+ } \
+ } while (false)
+
+#define SKIP_TEST_IF_SME2_NOT_SUPPORTED() \
+ do { \
+ if(!is_feat_sme2_supported()) { \
+ tftf_testcase_printf("FEAT_SME2 not supported\n"); \
+ return TEST_RESULT_SKIPPED; \
+ } \
+ } while (false)
+
+#define SKIP_TEST_IF_RME_NOT_SUPPORTED_OR_RMM_IS_TRP() \
+ do { \
+ u_register_t retrmm = 0U; \
+ \
+ if (!get_armv9_2_feat_rme_support()) { \
+ tftf_testcase_printf("FEAT_RME not supported\n"); \
+ return TEST_RESULT_SKIPPED; \
+ } \
+ \
+ host_rmi_init_cmp_result(); \
+ retrmm = host_rmi_version(RMI_ABI_VERSION_VAL); \
+ \
+ VERBOSE("RMM version is: %lu.%lu\n", \
+ RMI_ABI_VERSION_GET_MAJOR(retrmm), \
+ RMI_ABI_VERSION_GET_MINOR(retrmm)); \
+ \
+ /* \
+ * TODO: Remove this once SMC_RMM_REALM_CREATE is implemented \
+ * in TRP. For the moment skip the test if RMM is TRP, TRP \
+ * version is always 0. \
+ */ \
+ if (retrmm == 0U) { \
+ tftf_testcase_printf("RMM is TRP\n"); \
+ return TEST_RESULT_SKIPPED; \
} \
- } while (false);
+ } while (false)
/* Helper macro to verify if system suspend API is supported */
#define is_psci_sys_susp_supported() \
@@ -289,22 +378,18 @@ test_result_t map_test_unmap(const map_args_unmap_t *args,
test_function_arg_t test);
/*
- * Helper function to set TFTF global mailbox for SPM related tests.
- * This function should be invoked by the first TFTF test that requires
- * RX and/or TX buffers.
+ * Utility function to wait for all CPUs other than the caller to be
+ * OFF.
*/
-void set_tftf_mailbox(const struct mailbox_buffers *mb);
+void wait_for_non_lead_cpus(void);
/*
- * Helper function to get TFTF global mailbox for SPM related tests.
- * This function should be called by all tests that require access to RX or TX
- * buffers, after the function 'set_tftf_mailbox' has been used by the first
- * test to rely on RX and TX buffers.
+ * Utility function to wait for a given CPU other than the caller to be
+ * OFF.
*/
-bool get_tftf_mailbox(struct mailbox_buffers *mb);
+void wait_for_core_to_turn_off(unsigned int mpidr);
-test_result_t check_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);
+/* Generate 64-bit random number */
+unsigned long long rand64(void);
#endif /* __TEST_HELPERS_H__ */