[PATCH v7 10/12] test: cmd: Add simple test for i3c
Heiko Schocher
hs at denx.de
Tue Aug 5 13:52:02 CEST 2025
Hello Dinesh,
On 28.07.25 08:56, dinesh.maniyam at altera.com wrote:
> From: Dinesh Maniyam <dinesh.maniyam at altera.com>
>
> Add simple test to check i3c controller defined in sandbox test DT.
> Basically, this test case will check validity of the i3c controller
> by probing it and perform basic commands of cmd/i3c.c
>
> Signed-off-by: Dinesh Maniyam <dinesh.maniyam at altera.com>
> ---
> test/cmd/Makefile | 1 +
> test/cmd/i3c.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 51 insertions(+)
> create mode 100644 test/cmd/i3c.c
Reviewed-by: Heiko Schocher <hs at denx.de>
some nitpick below:
> diff --git a/test/cmd/Makefile b/test/cmd/Makefile
> index d8a5e77402d..d1c49e2c97a 100644
> --- a/test/cmd/Makefile
> +++ b/test/cmd/Makefile
> @@ -34,6 +34,7 @@ obj-$(CONFIG_CMD_PWM) += pwm.o
> obj-$(CONFIG_CMD_READ) += rw.o
> obj-$(CONFIG_CMD_SETEXPR) += setexpr.o
> obj-$(CONFIG_CMD_TEMPERATURE) += temperature.o
> +obj-$(CONFIG_CMD_I3C) += i3c.o
Nitpick: please sort alphabetical, thanks!
> ifdef CONFIG_NET
> obj-$(CONFIG_CMD_WGET) += wget.o
> endif
> diff --git a/test/cmd/i3c.c b/test/cmd/i3c.c
> new file mode 100644
> index 00000000000..04baad2a4b2
> --- /dev/null
> +++ b/test/cmd/i3c.c
> @@ -0,0 +1,50 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * Copyright (C) 2025 Altera Corporation <www.altera.com>
> + */
> +
> +#include <dm.h>
> +#include <dm/test.h>
> +#include <test/test.h>
> +#include <test/ut.h>
> +
> +/* Basic test for probing i3c controller with invalid name */
> +static int dm_test_i3c_cmd_probe_invalid_master(struct unit_test_state *uts)
> +{
> + ut_asserteq(1, run_command("i3c any", 0));
> + ut_assert_nextline("i3c0 (i3c_sandbox)");
> + ut_assert_nextline("i3c1 (i3c_sandbox)");
> + ut_assert_nextline("i3c: Host controller not initialized: any");
> + ut_assert_console_end();
> +
> + return 0;
> +}
> +DM_TEST(dm_test_i3c_cmd_probe_invalid_master, UTF_SCAN_PDATA | UTF_SCAN_FDT | UTF_DM);
> +
> +/* Basic test of the i3c controller for valid name as per test DT */
> +static int dm_test_i3c_cmd_probe_valid_master(struct unit_test_state *uts)
> +{
> + ut_asserteq(0, run_command("i3c i3c0", 0));
> + ut_assert_nextline("i3c: Current controller: i3c0");
> + ut_assert_console_end();
> +
> + ut_asserteq(0, run_command("i3c current", 0));
> + ut_assert_nextline("i3c: Current controller: i3c0");
> + ut_assert_console_end();
> +
> + ut_asserteq(0, run_command("i3c i3c1", 0));
> + ut_assert_nextline("i3c: Current controller: i3c1");
> + ut_assert_console_end();
> +
> + ut_asserteq(0, run_command("i3c current", 0));
> + ut_assert_nextline("i3c: Current controller: i3c1");
> + ut_assert_console_end();
> +
> + ut_asserteq(0, run_command("i3c list", 0));
> + ut_assert_nextline("i3c0 (i3c_sandbox)");
> + ut_assert_nextline("i3c1 (i3c_sandbox)");
> + ut_assert_console_end();
> +
> + return 0;
> +}
> +DM_TEST(dm_test_i3c_cmd_probe_valid_master, UTF_SCAN_PDATA | UTF_SCAN_FDT | UTF_DM);
> \ No newline at end of file
>
bye,
Heiko
--
DENX Software Engineering GmbH, Managing Director: Johanna Denk, Tabea Lutz
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs at denx.de
More information about the U-Boot
mailing list