diff options
author | Tom Rini <trini@konsulko.com> | 2020-07-23 15:56:06 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2020-07-23 15:56:06 -0400 |
commit | 5d3a21df6694ebd66d5c34c9d62a26edc7456fc7 (patch) | |
tree | 5de77f2861f6856866c5bf4ffa7cab22d371ccf3 /test | |
parent | 56d37f1c564107e27d873181d838571b7d7860e7 (diff) | |
parent | 60e7fa8b3b8538aae1e644dac61d5e4076901edb (diff) |
Merge tag 'dm-pull-20jul20' of git://git.denx.de/u-boot-dm
binman support for FIT
new UCLASS_SOC
patman switch 'test' command
minor fdt fixes
patman usability improvements
Diffstat (limited to 'test')
-rw-r--r-- | test/dm/Makefile | 1 | ||||
-rw-r--r-- | test/dm/acpi.c | 3 | ||||
-rw-r--r-- | test/dm/core.c | 10 | ||||
-rw-r--r-- | test/dm/devres.c | 1 | ||||
-rw-r--r-- | test/dm/soc.c | 120 | ||||
-rw-r--r-- | test/dm/test-fdt.c | 2 | ||||
-rw-r--r-- | test/dm/virtio.c | 7 | ||||
-rwxr-xr-x | test/run | 2 |
8 files changed, 140 insertions, 6 deletions
diff --git a/test/dm/Makefile b/test/dm/Makefile index b03c96da06..839111791b 100644 --- a/test/dm/Makefile +++ b/test/dm/Makefile @@ -68,6 +68,7 @@ obj-$(CONFIG_AXI) += axi.o obj-$(CONFIG_MISC) += misc.o obj-$(CONFIG_DM_SERIAL) += serial.o obj-$(CONFIG_CPU) += cpu.o +obj-$(CONFIG_SOC_DEVICE) += soc.o obj-$(CONFIG_SOUND) += sound.o obj-$(CONFIG_TEE) += tee.o obj-$(CONFIG_VIRTIO_SANDBOX) += virtio.o diff --git a/test/dm/acpi.c b/test/dm/acpi.c index b94c4ba4d1..bb8550ffb1 100644 --- a/test/dm/acpi.c +++ b/test/dm/acpi.c @@ -190,7 +190,10 @@ DM_TEST(dm_test_acpi_get_table_revision, static int dm_test_acpi_create_dmar(struct unit_test_state *uts) { struct acpi_dmar dmar; + struct udevice *cpu; + ut_assertok(uclass_first_device(UCLASS_CPU, &cpu)); + ut_assertnonnull(cpu); ut_assertok(acpi_create_dmar(&dmar, DMAR_INTR_REMAP)); ut_asserteq(DMAR_INTR_REMAP, dmar.flags); ut_asserteq(32 - 1, dmar.host_address_width); diff --git a/test/dm/core.c b/test/dm/core.c index 6a930ae31a..d20c48443f 100644 --- a/test/dm/core.c +++ b/test/dm/core.c @@ -158,7 +158,7 @@ static int dm_test_autobind_uclass_pdata_alloc(struct unit_test_state *uts) for (uclass_find_first_device(UCLASS_TEST, &dev); dev; uclass_find_next_device(&dev)) { - ut_assert(dev); + ut_assertnonnull(dev); uc_pdata = dev_get_uclass_platdata(dev); ut_assert(uc_pdata); @@ -181,7 +181,7 @@ static int dm_test_autobind_uclass_pdata_valid(struct unit_test_state *uts) for (uclass_find_first_device(UCLASS_TEST, &dev); dev; uclass_find_next_device(&dev)) { - ut_assert(dev); + ut_assertnonnull(dev); uc_pdata = dev_get_uclass_platdata(dev); ut_assert(uc_pdata); @@ -747,11 +747,11 @@ static int dm_test_uclass_devices_find(struct unit_test_state *uts) dev; ret = uclass_find_next_device(&dev)) { ut_assert(!ret); - ut_assert(dev); + ut_assertnonnull(dev); } ut_assertok(uclass_find_first_device(UCLASS_TEST_DUMMY, &dev)); - ut_assert(!dev); + ut_assertnull(dev); return 0; } @@ -778,7 +778,7 @@ static int dm_test_uclass_devices_find_by_name(struct unit_test_state *uts) testdev; ret = uclass_find_next_device(&testdev)) { ut_assertok(ret); - ut_assert(testdev); + ut_assertnonnull(testdev); findret = uclass_find_device_by_name(UCLASS_TEST_FDT, testdev->name, diff --git a/test/dm/devres.c b/test/dm/devres.c index b5de0cb191..550787495d 100644 --- a/test/dm/devres.c +++ b/test/dm/devres.c @@ -153,6 +153,7 @@ static int dm_test_devres_phase(struct unit_test_state *uts) * allocation created in the bind() method. */ ut_assertok(uclass_find_first_device(UCLASS_TEST_DEVRES, &dev)); + ut_assertnonnull(dev); devres_get_stats(dev, &stats); ut_asserteq(1, stats.allocs); ut_asserteq(TEST_DEVRES_SIZE, stats.total_size); diff --git a/test/dm/soc.c b/test/dm/soc.c new file mode 100644 index 0000000000..3ad0f561f2 --- /dev/null +++ b/test/dm/soc.c @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Test for the SOC uclass + * + * (C) Copyright 2020 - Texas Instruments Incorporated - http://www.ti.com/ + * Dave Gerlach <d-gerlach@ti.com> + */ + +#include <common.h> +#include <dm.h> +#include <dm/test.h> +#include <dm/uclass-internal.h> +#include <soc.h> +#include <test/ut.h> + +struct sb_soc_data { + unsigned long param; +}; + +static int dm_test_soc(struct unit_test_state *uts) +{ + struct udevice *dev; + char text[128]; + const struct soc_attr *soc_data; + const struct sb_soc_data *match_data; + + static const struct sb_soc_data soc_sandbox1_sr10_data = { 0x91919191 }; + static const struct sb_soc_data soc_sandbox123_data = { 0x84848484 }; + + static const struct soc_attr sb_soc_devices_full[] = { + { + .family = "SANDBOX0xx", + .machine = "SANDBOX012", + .revision = "1.0", + .data = NULL, + }, + { + .family = "SANDBOX1xx", + .machine = "SANDBOX107", + .revision = "1.0", + .data = NULL, + }, + { + .family = "SANDBOX1xx", + .machine = "SANDBOX123", + .revision = "1.0", + .data = &soc_sandbox123_data, + }, + { + .family = "SANDBOX1xx", + .machine = "SANDBOX131", + .revision = "2.0", + .data = NULL, + }, + { /* sentinel */ } + }; + + static const struct soc_attr sb_soc_devices_partial[] = { + { + .family = "SANDBOX0xx", + .revision = "1.0", + .data = NULL, + }, + { + .family = "SANDBOX1xx", + .revision = "1.0", + .data = &soc_sandbox1_sr10_data, + }, + { + .family = "SANDBOX1xx", + .revision = "2.0", + .data = NULL, + }, + { /* sentinel */ } + }; + + static const struct soc_attr sb_soc_devices_nomatch[] = { + { + .family = "SANDBOX0xx", + .revision = "1.0", + .data = NULL, + }, + { + .family = "SANDBOX1xx", + .revision = "2.0", + .data = NULL, + }, + { /* sentinel */ } + }; + + ut_assertok(soc_get(&dev)); + + ut_assertok(soc_get_machine(dev, text, sizeof(text))); + ut_assertok(strcmp(text, "SANDBOX123")); + + ut_assertok(soc_get_family(dev, text, sizeof(text))); + ut_assertok(strcmp(text, "SANDBOX1xx")); + + ut_assertok(soc_get_revision(dev, text, sizeof(text))); + ut_asserteq_str(text, "1.0"); + + soc_data = soc_device_match(sb_soc_devices_full); + ut_assert(soc_data); + + match_data = soc_data->data; + ut_asserteq(match_data->param, 0x84848484); + + soc_data = soc_device_match(sb_soc_devices_partial); + ut_assert(soc_data); + + match_data = soc_data->data; + ut_asserteq(match_data->param, 0x91919191); + + soc_data = soc_device_match(sb_soc_devices_nomatch); + ut_asserteq_ptr(soc_data, NULL); + + return 0; +} + +DM_TEST(dm_test_soc, DM_TESTF_SCAN_FDT); diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c index 51f2547409..8ef7c7a88e 100644 --- a/test/dm/test-fdt.c +++ b/test/dm/test-fdt.c @@ -832,10 +832,12 @@ static int dm_test_fdt_phandle(struct unit_test_state *uts) struct udevice *back, *dev, *dev2; ut_assertok(uclass_find_first_device(UCLASS_PANEL_BACKLIGHT, &back)); + ut_assertnonnull(back); ut_asserteq(-ENOENT, uclass_find_device_by_phandle(UCLASS_REGULATOR, back, "missing", &dev)); ut_assertok(uclass_find_device_by_phandle(UCLASS_REGULATOR, back, "power-supply", &dev)); + ut_assertnonnull(dev); ut_asserteq(0, device_active(dev)); ut_asserteq_str("ldo1", dev->name); ut_assertok(uclass_get_device_by_phandle(UCLASS_REGULATOR, back, diff --git a/test/dm/virtio.c b/test/dm/virtio.c index 4b317d2ec3..4a0c0b23b8 100644 --- a/test/dm/virtio.c +++ b/test/dm/virtio.c @@ -22,9 +22,11 @@ static int dm_test_virtio_base(struct unit_test_state *uts) /* check probe success */ ut_assertok(uclass_first_device(UCLASS_VIRTIO, &bus)); + ut_assertnonnull(bus); /* check the child virtio-blk device is bound */ ut_assertok(device_find_first_child(bus, &dev)); + ut_assertnonnull(dev); ut_assertok(strcmp(dev->name, "virtio-blk#0")); /* check driver status */ @@ -49,15 +51,18 @@ static int dm_test_virtio_all_ops(struct unit_test_state *uts) /* check probe success */ ut_assertok(uclass_first_device(UCLASS_VIRTIO, &bus)); + ut_assertnonnull(bus); /* check the child virtio-blk device is bound */ ut_assertok(device_find_first_child(bus, &dev)); + ut_assertnonnull(dev); /* * fake the virtio device probe by filling in uc_priv->vdev * which is used by virtio_find_vqs/virtio_del_vqs. */ uc_priv = dev_get_uclass_priv(bus); + ut_assertnonnull(uc_priv); uc_priv->vdev = dev; /* test virtio_xxx APIs */ @@ -106,9 +111,11 @@ static int dm_test_virtio_remove(struct unit_test_state *uts) /* check probe success */ ut_assertok(uclass_first_device(UCLASS_VIRTIO, &bus)); + ut_assertnonnull(bus); /* check the child virtio-blk device is bound */ ut_assertok(device_find_first_child(bus, &dev)); + ut_assertnonnull(dev); /* set driver status to VIRTIO_CONFIG_S_DRIVER_OK */ ut_assertok(virtio_set_status(dev, VIRTIO_CONFIG_S_DRIVER_OK)); @@ -48,7 +48,7 @@ export DTC=${DTC_DIR}/dtc TOOLS_DIR=build-sandbox_spl/tools run_test "binman" ./tools/binman/binman --toolpath ${TOOLS_DIR} test -run_test "patman" ./tools/patman/patman --test +run_test "patman" ./tools/patman/patman test run_test "buildman" ./tools/buildman/buildman -t ${skip} run_test "fdt" ./tools/dtoc/test_fdt -t |