Re: [PATCH v9 07/10] arm_ffa: introduce Sandbox test cases for UCLASS_FFA
Hi Abdellatif, On Fri, 10 Mar 2023 at 06:10, Abdellatif El Khlifi wrote: > > Add functional test cases for the FF-A core driver > > These tests rely on the FF-A Sandbox driver which helps in > inspecting the FF-A core driver. > > Signed-off-by: Abdellatif El Khlifi > Cc: Tom Rini > Cc: Simon Glass > Cc: Ilias Apalodimas > Cc: Jens Wiklander > > --- > Changelog: > === > > v9: align FF-A sandbox tests with FF-A discovery through DM > > v8: > > * update partition_info_get() second argument to be an SP count > * pass NULL device pointer to the FF-A bus discovery and operations > > v7: set the tests to use 64-bit direct messaging > > v4: align sandbox tests with the new FF-A driver interfaces > and new way of error handling > > v1: introduce sandbox tests > > MAINTAINERS | 1 + > test/dm/Makefile | 2 + > test/dm/ffa.c| 380 +++ > 3 files changed, 383 insertions(+) > create mode 100644 test/dm/ffa.c > > diff --git a/MAINTAINERS b/MAINTAINERS > index 2b9d33e964..6939b832e4 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -275,6 +275,7 @@ F: doc/usage/cmd/armffa.rst > F: drivers/firmware/arm-ffa/ > F: include/arm_ffa.h > F: include/sandbox_arm_ffa.h > +F: test/dm/ffa.c > > ARM FREESCALE IMX > M: Stefano Babic > diff --git a/test/dm/Makefile b/test/dm/Makefile > index 7a79b6e1a2..b554b170db 100644 > --- a/test/dm/Makefile > +++ b/test/dm/Makefile > @@ -1,6 +1,7 @@ > # SPDX-License-Identifier: GPL-2.0+ > # > # Copyright (c) 2013 Google, Inc > +# Copyright 2022-2023 Arm Limited and/or its affiliates > > > obj-$(CONFIG_UT_DM) += test-dm.o > > @@ -85,6 +86,7 @@ obj-$(CONFIG_POWER_DOMAIN) += power-domain.o > obj-$(CONFIG_ACPI_PMC) += pmc.o > obj-$(CONFIG_DM_PMIC) += pmic.o > obj-$(CONFIG_DM_PWM) += pwm.o > +obj-$(CONFIG_SANDBOX_FFA) += ffa.o > obj-$(CONFIG_QFW) += qfw.o > obj-$(CONFIG_RAM) += ram.o > obj-y += regmap.o > diff --git a/test/dm/ffa.c b/test/dm/ffa.c > new file mode 100644 > index 00..d978feda72 > --- /dev/null > +++ b/test/dm/ffa.c > @@ -0,0 +1,380 @@ > +// SPDX-License-Identifier: GPL-2.0+ > +/* > + * Functional tests for UCLASS_FFA class > + * > + * Copyright 2022-2023 Arm Limited and/or its affiliates > > + * > + * Authors: > + * Abdellatif El Khlifi > + */ > + > +#include > +#include > +#include > +#include > +#include "../../drivers/firmware/arm-ffa/sandbox_arm_ffa_priv.h" I suppose this is OK, but you could put is in arch/sandbox/include/asm/ perhaps? > +#include > +#include > +#include > + > +/* Macros */ > + > +#define LOG_MSG_SZ (100) > +#define LOG_CMD_SZ (LOG_MSG_SZ * 2) > + > +/* Functional tests for the UCLASS_FFA */ > + > +static int dm_test_ffa_log(struct unit_test_state *uts, char *msg) > +{ > + char cmd[LOG_CMD_SZ] = {0}; > + > + console_record_reset(); > + > + snprintf(cmd, LOG_CMD_SZ, "echo \"%s\"", msg); > + run_command(cmd, 0); > + > + ut_assert_console_end(); > + > + return 0; > +} > + > +static int check_fwk_version(struct ffa_priv *priv, struct sandbox_ffa_priv > *sdx_priv, > +struct unit_test_state *uts) > +{ > + if (priv->dscvry_info.fwk_version != sdx_priv->fwk_version) { > + char msg[LOG_MSG_SZ] = {0}; > + > + snprintf(msg, LOG_MSG_SZ, > +"[%s]: Error: framework version: core = 0x%x , > sandbox = 0x%x", __func__, > +priv->dscvry_info.fwk_version, > + sdx_priv->fwk_version); > + > + dm_test_ffa_log(uts, msg); > + return CMD_RET_FAILURE; > + } > + return 0; > +} > + > +static int check_endpoint_id(struct ffa_priv *priv, struct unit_test_state > *uts) > +{ > + if (priv->id) { > + char msg[LOG_MSG_SZ] = {0}; > + > + snprintf(msg, LOG_MSG_SZ, > +"[%s]: Error: endpoint id: core = 0x%x", __func__, > priv->id); > + dm_test_ffa_log(uts, msg); > + return CMD_RET_FAILURE; > + } > + return 0; > +} > + > +static int check_rxtxbuf(struct ffa_priv *priv, struct unit_test_state *uts) > +{ > + if (!priv->pair.rxbuf && priv->pair.txbuf) { > + char msg[LOG_MSG_SZ] = {0}; > + > + snprintf(msg, LOG_MSG_SZ, "[%s]: Error: rxbuf = %p txbuf = > %p", __func__, > +priv->pair.rxbuf, > +priv->pair.txbuf); > + dm_test_ffa_log(uts, msg); > + return CMD_RET_FAILURE; > + } > + return 0; > +} > + > +static int check_features(struct ffa_priv *priv, struct unit_test_state *uts) > +{ > + char msg[LOG_MSG_SZ] = {0}; > + > + if (priv->pair.rxtx_min_pages != RXTX_4K && > + priv->pair.rxtx_min_pages != RXTX_16K && > + priv->pair.rxtx_min_pages != RXTX_64K) { > + snprintf(msg, > +
[PATCH v9 07/10] arm_ffa: introduce Sandbox test cases for UCLASS_FFA
Add functional test cases for the FF-A core driver These tests rely on the FF-A Sandbox driver which helps in inspecting the FF-A core driver. Signed-off-by: Abdellatif El Khlifi Cc: Tom Rini Cc: Simon Glass Cc: Ilias Apalodimas Cc: Jens Wiklander --- Changelog: === v9: align FF-A sandbox tests with FF-A discovery through DM v8: * update partition_info_get() second argument to be an SP count * pass NULL device pointer to the FF-A bus discovery and operations v7: set the tests to use 64-bit direct messaging v4: align sandbox tests with the new FF-A driver interfaces and new way of error handling v1: introduce sandbox tests MAINTAINERS | 1 + test/dm/Makefile | 2 + test/dm/ffa.c| 380 +++ 3 files changed, 383 insertions(+) create mode 100644 test/dm/ffa.c diff --git a/MAINTAINERS b/MAINTAINERS index 2b9d33e964..6939b832e4 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -275,6 +275,7 @@ F: doc/usage/cmd/armffa.rst F: drivers/firmware/arm-ffa/ F: include/arm_ffa.h F: include/sandbox_arm_ffa.h +F: test/dm/ffa.c ARM FREESCALE IMX M: Stefano Babic diff --git a/test/dm/Makefile b/test/dm/Makefile index 7a79b6e1a2..b554b170db 100644 --- a/test/dm/Makefile +++ b/test/dm/Makefile @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0+ # # Copyright (c) 2013 Google, Inc +# Copyright 2022-2023 Arm Limited and/or its affiliates obj-$(CONFIG_UT_DM) += test-dm.o @@ -85,6 +86,7 @@ obj-$(CONFIG_POWER_DOMAIN) += power-domain.o obj-$(CONFIG_ACPI_PMC) += pmc.o obj-$(CONFIG_DM_PMIC) += pmic.o obj-$(CONFIG_DM_PWM) += pwm.o +obj-$(CONFIG_SANDBOX_FFA) += ffa.o obj-$(CONFIG_QFW) += qfw.o obj-$(CONFIG_RAM) += ram.o obj-y += regmap.o diff --git a/test/dm/ffa.c b/test/dm/ffa.c new file mode 100644 index 00..d978feda72 --- /dev/null +++ b/test/dm/ffa.c @@ -0,0 +1,380 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Functional tests for UCLASS_FFA class + * + * Copyright 2022-2023 Arm Limited and/or its affiliates + * + * Authors: + * Abdellatif El Khlifi + */ + +#include +#include +#include +#include +#include "../../drivers/firmware/arm-ffa/sandbox_arm_ffa_priv.h" +#include +#include +#include + +/* Macros */ + +#define LOG_MSG_SZ (100) +#define LOG_CMD_SZ (LOG_MSG_SZ * 2) + +/* Functional tests for the UCLASS_FFA */ + +static int dm_test_ffa_log(struct unit_test_state *uts, char *msg) +{ + char cmd[LOG_CMD_SZ] = {0}; + + console_record_reset(); + + snprintf(cmd, LOG_CMD_SZ, "echo \"%s\"", msg); + run_command(cmd, 0); + + ut_assert_console_end(); + + return 0; +} + +static int check_fwk_version(struct ffa_priv *priv, struct sandbox_ffa_priv *sdx_priv, +struct unit_test_state *uts) +{ + if (priv->dscvry_info.fwk_version != sdx_priv->fwk_version) { + char msg[LOG_MSG_SZ] = {0}; + + snprintf(msg, LOG_MSG_SZ, +"[%s]: Error: framework version: core = 0x%x , sandbox = 0x%x", __func__, +priv->dscvry_info.fwk_version, + sdx_priv->fwk_version); + + dm_test_ffa_log(uts, msg); + return CMD_RET_FAILURE; + } + return 0; +} + +static int check_endpoint_id(struct ffa_priv *priv, struct unit_test_state *uts) +{ + if (priv->id) { + char msg[LOG_MSG_SZ] = {0}; + + snprintf(msg, LOG_MSG_SZ, +"[%s]: Error: endpoint id: core = 0x%x", __func__, priv->id); + dm_test_ffa_log(uts, msg); + return CMD_RET_FAILURE; + } + return 0; +} + +static int check_rxtxbuf(struct ffa_priv *priv, struct unit_test_state *uts) +{ + if (!priv->pair.rxbuf && priv->pair.txbuf) { + char msg[LOG_MSG_SZ] = {0}; + + snprintf(msg, LOG_MSG_SZ, "[%s]: Error: rxbuf = %p txbuf = %p", __func__, +priv->pair.rxbuf, +priv->pair.txbuf); + dm_test_ffa_log(uts, msg); + return CMD_RET_FAILURE; + } + return 0; +} + +static int check_features(struct ffa_priv *priv, struct unit_test_state *uts) +{ + char msg[LOG_MSG_SZ] = {0}; + + if (priv->pair.rxtx_min_pages != RXTX_4K && + priv->pair.rxtx_min_pages != RXTX_16K && + priv->pair.rxtx_min_pages != RXTX_64K) { + snprintf(msg, +LOG_MSG_SZ, +"[%s]: Error: FFA_RXTX_MAP features = 0x%lx", +__func__, +priv->pair.rxtx_min_pages); + dm_test_ffa_log(uts, msg); + return CMD_RET_FAILURE; + } + + return 0; +} + +static int check_rxbuf_mapped_flag(u32 queried_func_id, + u8 rxbuf_mapped, + struct unit_test_state *uts) +{ + char