[PATCH 08/12] test: dm: add sandbox FF-A runtime transport tests
Simon Glass
sjg at chromium.org
Tue Apr 28 20:05:59 CEST 2026
Hi Harsimran,
On 2026-04-24T17:31:50, Harsimran Singh Tungal
<harsimransingh.tungal at arm.com> wrote:
> test: dm: add sandbox FF-A runtime transport tests
>
> Exercise FF-A runtime helpers via sandbox DM tests
>
> Add driver-model unit tests that exercise the FF-A runtime helpers on
> sandbox. The new tests reuse the sandbox emulator to validate both the
> positive direct-request flow and failure handling, priming the emulator
> state so the runtime path can be executed.
>
> Signed-off-by: Harsimran Singh Tungal <harsimransingh.tungal at arm.com>
>
> arch/sandbox/include/asm/sandbox_arm_ffa.h | 16 +++++-
> test/dm/Makefile | 3 +-
> test/dm/ffa_runtime.c | 82 ++++++++++++++++++++++++++++++
> 3 files changed, 99 insertions(+), 2 deletions(-)
> diff --git a/test/dm/ffa_runtime.c b/test/dm/ffa_runtime.c
> @@ -0,0 +1,82 @@
> +static int dm_test_ffa_runtime_nack(struct unit_test_state *uts)
> +{
> + struct ffa_send_direct_data msg = {0};
> + u16 sp_id;
> +
> + ut_assertok(ffa_runtime_get_sp_id(uts, &sp_id));
> +
> + ffa_copy_runtime_priv(&(struct ffa_priv_runtime){
> + .id = NS_PHYS_ENDPOINT_ID,
> + });
> + ffa_enable_runtime_context();
> +
> + /* Ensure runtime context is available before attempting runtime-only paths */
> + ut_assert(ffa_get_status_runtime_context());
> +
> + /* Invalid partition IDs must be rejected and mapped to -EINVAL */
> + ut_asserteq(-EINVAL, ffa_sync_send_receive_runtime(0, &msg, true));
sp_id is fetched here but never used - the test sends to id 0
directly. Please drop the call to ffa_runtime_get_sp_id() in this
test, or use the discovered id for a positive comparison.
> diff --git a/test/dm/ffa_runtime.c b/test/dm/ffa_runtime.c
> @@ -0,0 +1,82 @@
> +static int dm_test_ffa_runtime_ack(struct unit_test_state *uts)
> +{
> + struct ffa_send_direct_data msg = {0};
> + u16 sp_id;
> + u8 cnt;
> +
> + ut_assertok(ffa_runtime_get_sp_id(uts, &sp_id));
> +
> + ffa_copy_runtime_priv(&(struct ffa_priv_runtime){
> + .id = NS_PHYS_ENDPOINT_ID,
> + });
> + ffa_enable_runtime_context();
ffa_enable_runtime_context() flips a global static flag in
arm-ffa-runtime.c that is never reset. Once either test has run,
ffa_get_status_runtime_context() returns true for the rest of the
process, which leaks state into other tests and means a
missing-context path can never be reached. Please add a case that
calls ffa_sync_send_receive_runtime() before enabling the context and
verifies it returns -EPERM (that branch is currently untested) and
provide a way to reset the runtime priv between tests.
> diff --git a/test/dm/ffa_runtime.c b/test/dm/ffa_runtime.c
> @@ -0,0 +1,82 @@
> + /* Validate FF-A error to errno translation helpers */
> + ut_asserteq(-EINVAL, ffa_to_std_errno(-INVALID_PARAMETERS));
> + ut_asserteq(-EOPNOTSUPP, ffa_to_std_errno(-NOT_SUPPORTED));
Just to clarify, ffa_to_std_errno() is a pure helper unrelated to the
messaging round-trip - please split this into its own dm_test, so a
regression in the table doesn't look like a transport failure, and add
coverage for at least the boundary cases (e.g. 0, MAX_NUMBER_FFA_ERR,
an out-of-range value) which all should map to -EINVAL.
Regards,
Simon
More information about the U-Boot
mailing list