diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/cmd/Makefile | 1 | ||||
-rw-r--r-- | test/cmd/i3c.c | 50 | ||||
-rw-r--r-- | test/dm/Makefile | 1 | ||||
-rw-r--r-- | test/dm/i3c.c | 34 |
4 files changed, 86 insertions, 0 deletions
diff --git a/test/cmd/Makefile b/test/cmd/Makefile index 595e4cfcada..e71c80a5b2e 100644 --- a/test/cmd/Makefile +++ b/test/cmd/Makefile @@ -19,6 +19,7 @@ obj-$(CONFIG_CMD_FDT) += fdt.o obj-$(CONFIG_CONSOLE_TRUETYPE) += font.o obj-$(CONFIG_CMD_HASH) += hash.o obj-$(CONFIG_CMD_HISTORY) += history.o +obj-$(CONFIG_CMD_I3C) += i3c.o obj-$(CONFIG_CMD_LOADM) += loadm.o obj-$(CONFIG_CMD_MEMINFO) += meminfo.o obj-$(CONFIG_CMD_MEMORY) += mem_copy.o 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 diff --git a/test/dm/Makefile b/test/dm/Makefile index d15859eca30..474e77a2151 100644 --- a/test/dm/Makefile +++ b/test/dm/Makefile @@ -58,6 +58,7 @@ obj-$(CONFIG_FWU_MDATA_GPT_BLK) += fwu_mdata.o obj-$(CONFIG_SANDBOX) += host.o obj-$(CONFIG_DM_HWSPINLOCK) += hwspinlock.o obj-$(CONFIG_DM_I2C) += i2c.o +obj-$(CONFIG_I3C) += i3c.o obj-$(CONFIG_SOUND) += i2s.o obj-$(CONFIG_CLK_K210_SET_RATE) += k210_pll.o obj-$(CONFIG_IOMMU) += iommu.o diff --git a/test/dm/i3c.c b/test/dm/i3c.c new file mode 100644 index 00000000000..81336e67555 --- /dev/null +++ b/test/dm/i3c.c @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2025 Altera Corporation <www.altera.com> + */ + +#include <dm.h> +#include <i3c.h> +#include <dm/test.h> +#include <test/ut.h> + +DECLARE_GLOBAL_DATA_PTR; + +/* Basic test of the i3c uclass */ +static int dm_test_i3c_base(struct unit_test_state *uts) +{ + struct udevice *dev; + + ut_assertok(uclass_get_device(UCLASS_I3C, 0, &dev)); + ut_assertok(dm_i3c_read(dev, 0, NULL, 1)); + ut_assertok(dm_i3c_read(dev, 0, NULL, 4)); + ut_assertok(dm_i3c_write(dev, 0, "AABB", 2)); + ut_assertok(dm_i3c_write(dev, 0, "AABBCCDD", 4)); + + ut_assertok(uclass_get_device(UCLASS_I3C, 1, &dev)); + ut_assertok(dm_i3c_read(dev, 1, NULL, 1)); + ut_assertok(dm_i3c_read(dev, 1, NULL, 4)); + ut_assertok(dm_i3c_write(dev, 1, "AABB", 2)); + ut_assertok(dm_i3c_write(dev, 1, "AABBCCDD", 4)); + + ut_asserteq(-ENODEV, uclass_get_device(UCLASS_I3C, 2, &dev)); + + return 0; +} +DM_TEST(dm_test_i3c_base, UTF_SCAN_PDATA | UTF_SCAN_FDT); |