aboutsummaryrefslogtreecommitdiff
path: root/tftf/tests/runtime_services/secure_service/spm_common.c
diff options
context:
space:
mode:
authorJ-Alves <joao.alves@arm.com>2021-03-11 10:01:36 +0000
committerJ-Alves <joao.alves@arm.com>2021-10-04 09:17:20 +0100
commit227065a75718bb8c56ccfe5ea5218662e836712e (patch)
tree264e2b272aaafcb8ae691b86777769abec8584e8 /tftf/tests/runtime_services/secure_service/spm_common.c
parent7a59528478c90824acd9e6d7f673da18ce033579 (diff)
downloadtf-a-tests-227065a75718bb8c56ccfe5ea5218662e836712e.tar.gz
feat(spm): Test helper to verify response
Added function helper to validate the response sent by Cactus SP is as expected. Change-Id: Ia0118063f1af65daed19443b6951b338bae7d668 Signed-off-by: J-Alves <joao.alves@arm.com>
Diffstat (limited to 'tftf/tests/runtime_services/secure_service/spm_common.c')
-rw-r--r--tftf/tests/runtime_services/secure_service/spm_common.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/tftf/tests/runtime_services/secure_service/spm_common.c b/tftf/tests/runtime_services/secure_service/spm_common.c
index cd8b632c6..6a9369aa7 100644
--- a/tftf/tests/runtime_services/secure_service/spm_common.c
+++ b/tftf/tests/runtime_services/secure_service/spm_common.c
@@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <cactus_test_cmds.h>
#include <debug.h>
#include <ffa_endpoints.h>
#include <ffa_svc.h>
@@ -32,6 +33,19 @@ bool is_ffa_call_error(smc_ret_values ret)
return false;
}
+bool is_expected_ffa_error(smc_ret_values ret, int32_t error_code)
+{
+ if (ffa_func_id(ret) == FFA_ERROR &&
+ ffa_error_code(ret) == error_code) {
+ return true;
+ }
+
+ ERROR("Expected FFA_ERROR(%x), code: %d, got %x %d\n",
+ FFA_ERROR, error_code, ffa_func_id(ret), ffa_error_code(ret));
+
+ return false;
+}
+
/**
* Helper to verify return of FF-A call is an FFA_MSG_SEND_DIRECT_RESP.
* Should be used after FFA_MSG_SEND_DIRECT_REQ, or after sending a test command
@@ -64,6 +78,26 @@ bool is_expected_ffa_return(smc_ret_values ret, uint32_t func_id)
return false;
}
+
+bool is_expected_cactus_response(smc_ret_values ret, uint32_t expected_resp,
+ uint32_t arg)
+{
+ if (!is_ffa_direct_response(ret)) {
+ return false;
+ }
+
+ if (cactus_get_response(ret) != expected_resp ||
+ (uint32_t)ret.ret4 != arg) {
+ ERROR("Expected response %x and %x; "
+ "Obtained %x and %x\n",
+ expected_resp, arg, cactus_get_response(ret),
+ (int32_t)ret.ret4);
+ return false;
+ }
+
+ return true;
+}
+
void fill_simd_vector_regs(const simd_vector_t v[SIMD_NUM_VECTORS])
{
#ifdef __aarch64__