From f0d04972973e1a35a8b4de997b0ec4aede526b7d Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Wed, 17 Feb 2021 17:04:06 +0800 Subject: test: cmd: setexpr: Fix a typo SETEXPR_TEST is for a new setexpr test, not mem. Signed-off-by: Bin Meng Reviewed-by: Simon Glass --- test/cmd/setexpr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/cmd/setexpr.c b/test/cmd/setexpr.c index 27113c0..c537e89 100644 --- a/test/cmd/setexpr.c +++ b/test/cmd/setexpr.c @@ -15,7 +15,7 @@ #define BUF_SIZE 0x100 -/* Declare a new mem test */ +/* Declare a new setexpr test */ #define SETEXPR_TEST(_name, _flags) UNIT_TEST(_name, _flags, setexpr_test) /* Test 'setexpr' command with simply setting integers */ -- cgit v1.1 From 3a03553aaaaee68c0807867a7ff518146c19d10e Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Wed, 17 Feb 2021 17:31:47 +0800 Subject: test: print_ut: Fix potential build error This files uses the macro U_BOOT_CMD which is defined in command.h, but command.h is conditionally included. Fix it. Signed-off-by: Bin Meng Reviewed-by: Simon Glass --- test/print_ut.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/print_ut.c b/test/print_ut.c index a456a44..61ea432 100644 --- a/test/print_ut.c +++ b/test/print_ut.c @@ -6,8 +6,8 @@ #define DEBUG #include -#if CONFIG_IS_ENABLED(EFI_LOADER) && !defined(API_BUILD) #include +#if CONFIG_IS_ENABLED(EFI_LOADER) && !defined(API_BUILD) #include #endif #include -- cgit v1.1 From 074197aadfef2cfe437ecc1fe057ef21f4eef0da Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 3 Feb 2021 06:01:09 -0700 Subject: dtoc: Assign a sequence number to each node Now that we have the alias information we can assign a sequence number to each device in the uclass. Store this in the node associated with each device. This requires renaming the sandbox test drivers to have the right name. Note that test coverage is broken with this patch, but fixed in the next one. Signed-off-by: Simon Glass --- test/dm/test-fdt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c index 6e83aee..6552d09 100644 --- a/test/dm/test-fdt.c +++ b/test/dm/test-fdt.c @@ -330,7 +330,7 @@ static int dm_test_fdt_uclass_seq_more(struct unit_test_state *uts) /* Check creating a device with an alias */ node = ofnode_path("/some-bus/c-test@1"); - ut_assertok(device_bind(dm_root(), DM_DRIVER_GET(testfdt_drv), + ut_assertok(device_bind(dm_root(), DM_DRIVER_GET(denx_u_boot_fdt_test), "c-test@1", NULL, node, &dev)); ut_asserteq(12, dev_seq(dev)); ut_assertok(uclass_get_device_by_seq(UCLASS_TEST_FDT, 12, &dev)); @@ -350,11 +350,11 @@ static int dm_test_fdt_uclass_seq_more(struct unit_test_state *uts) * * So next available is 19 */ - ut_assertok(device_bind(dm_root(), DM_DRIVER_GET(testfdt_drv), + ut_assertok(device_bind(dm_root(), DM_DRIVER_GET(denx_u_boot_fdt_test), "fred", NULL, ofnode_null(), &dev)); ut_asserteq(19, dev_seq(dev)); - ut_assertok(device_bind(dm_root(), DM_DRIVER_GET(testfdt_drv), + ut_assertok(device_bind(dm_root(), DM_DRIVER_GET(denx_u_boot_fdt_test), "fred2", NULL, ofnode_null(), &dev)); ut_asserteq(20, dev_seq(dev)); -- cgit v1.1 From e8c023c3f95622dace696be2f671a5eb01572c07 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 15 Mar 2021 17:25:21 +1300 Subject: dm: test: Avoid destroying uclasses with of-platdata-inst It is not possible to destroy the uclasses when they are created at build time. Skip this step so that SPL test can complete successfully. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- test/test-main.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'test') diff --git a/test/test-main.c b/test/test-main.c index e1b49e0..46a0c2e 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -62,17 +62,25 @@ static int dm_test_post_run(struct unit_test_state *uts) { int id; - for (id = 0; id < UCLASS_COUNT; id++) { - struct uclass *uc; - - /* - * If the uclass doesn't exist we don't want to create it. So - * check that here before we call uclass_find_device(). - */ - uc = uclass_find(id); - if (!uc) - continue; - ut_assertok(uclass_destroy(uc)); + /* + * With of-platdata-inst the uclasses are created at build time. If we + * destroy them we cannot get them back since uclass_add() is not + * supported. So skip this. + */ + if (!CONFIG_IS_ENABLED(OF_PLATDATA_INST)) { + for (id = 0; id < UCLASS_COUNT; id++) { + struct uclass *uc; + + /* + * If the uclass doesn't exist we don't want to create + * it. So check that here before we call + * uclass_find_device(). + */ + uc = uclass_find(id); + if (!uc) + continue; + ut_assertok(uclass_destroy(uc)); + } } return 0; -- cgit v1.1 From 8813986dfde89ae2eab2a2315e1d23e4784c3d88 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 15 Mar 2021 17:25:24 +1300 Subject: clk: sandbox: Create a special fixed-rate driver Create a version of this driver for sandbox so that it can use the of-platdata struct. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- test/dm/of_platdata.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/dm/of_platdata.c b/test/dm/of_platdata.c index e9804cc..93ad572 100644 --- a/test/dm/of_platdata.c +++ b/test/dm/of_platdata.c @@ -185,7 +185,7 @@ static int dm_test_of_plat_phandle(struct unit_test_state *uts) plat = dev_get_plat(dev); ut_assertok(device_get_by_driver_info_idx(plat->clocks[0].idx, &clk)); - ut_asserteq_str("fixed_clock", clk->name); + ut_asserteq_str("sandbox_fixed_clock", clk->name); ut_assertok(device_get_by_driver_info_idx(plat->clocks[1].idx, &clk)); ut_asserteq_str("sandbox_clk", clk->name); -- cgit v1.1 From 6ba46a0f21df1804e1c98334215ac57a495d9655 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 15 Mar 2021 17:25:25 +1300 Subject: dm: core: Drop device_get_by_driver_info() This function is now only used in a test. Drop it. Also drop DM_DRVINFO_GET() which was the only purpose for having the function. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- test/dm/of_platdata.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/dm/of_platdata.c b/test/dm/of_platdata.c index 93ad572..d68c591 100644 --- a/test/dm/of_platdata.c +++ b/test/dm/of_platdata.c @@ -142,8 +142,6 @@ static int find_driver_info(struct unit_test_state *uts, struct udevice *parent, /* Check that every device is recorded in its driver_info struct */ static int dm_test_of_plat_dev(struct unit_test_state *uts) { - const struct driver_info *info = - ll_entry_start(struct driver_info, driver_info); const int n_ents = ll_entry_count(struct driver_info, driver_info); bool found[n_ents]; uint i; @@ -155,18 +153,17 @@ static int dm_test_of_plat_dev(struct unit_test_state *uts) /* Make sure that the driver entries without devices have no ->dev */ for (i = 0; i < n_ents; i++) { const struct driver_rt *drt = gd_dm_driver_rt() + i; - const struct driver_info *entry = info + i; struct udevice *dev; if (found[i]) { /* Make sure we can find it */ ut_assertnonnull(drt->dev); - ut_assertok(device_get_by_driver_info(entry, &dev)); + ut_assertok(device_get_by_driver_info_idx(i, &dev)); ut_asserteq_ptr(dev, drt->dev); } else { ut_assertnull(drt->dev); ut_asserteq(-ENOENT, - device_get_by_driver_info(entry, &dev)); + device_get_by_driver_info_idx(i, &dev)); } } -- cgit v1.1 From cc469b708667d24fc2a2c285e52d0d8ef5b14909 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 15 Mar 2021 17:25:28 +1300 Subject: dm: Rename device_get_by_driver_info_idx() This function finds a device by its driver_info index. With of-platdata-inst we do not use driver_info, but instead instantiate udevice records at build-time. However the semantics of using the function are the same in each case: the caller provides an index and gets back a device. So rename the function to device_get_by_ofplat_idx(), so that it can be used for both situations. The caller does not really need to worry about the details. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- test/dm/of_platdata.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'test') diff --git a/test/dm/of_platdata.c b/test/dm/of_platdata.c index d68c591..e5f32a0 100644 --- a/test/dm/of_platdata.c +++ b/test/dm/of_platdata.c @@ -158,12 +158,11 @@ static int dm_test_of_plat_dev(struct unit_test_state *uts) if (found[i]) { /* Make sure we can find it */ ut_assertnonnull(drt->dev); - ut_assertok(device_get_by_driver_info_idx(i, &dev)); + ut_assertok(device_get_by_ofplat_idx(i, &dev)); ut_asserteq_ptr(dev, drt->dev); } else { ut_assertnull(drt->dev); - ut_asserteq(-ENOENT, - device_get_by_driver_info_idx(i, &dev)); + ut_asserteq(-ENOENT, device_get_by_ofplat_idx(i, &dev)); } } @@ -181,22 +180,22 @@ static int dm_test_of_plat_phandle(struct unit_test_state *uts) ut_asserteq_str("sandbox_clk_test", dev->name); plat = dev_get_plat(dev); - ut_assertok(device_get_by_driver_info_idx(plat->clocks[0].idx, &clk)); + ut_assertok(device_get_by_ofplat_idx(plat->clocks[0].idx, &clk)); ut_asserteq_str("sandbox_fixed_clock", clk->name); - ut_assertok(device_get_by_driver_info_idx(plat->clocks[1].idx, &clk)); + ut_assertok(device_get_by_ofplat_idx(plat->clocks[1].idx, &clk)); ut_asserteq_str("sandbox_clk", clk->name); ut_asserteq(1, plat->clocks[1].arg[0]); - ut_assertok(device_get_by_driver_info_idx(plat->clocks[2].idx, &clk)); + ut_assertok(device_get_by_ofplat_idx(plat->clocks[2].idx, &clk)); ut_asserteq_str("sandbox_clk", clk->name); ut_asserteq(0, plat->clocks[2].arg[0]); - ut_assertok(device_get_by_driver_info_idx(plat->clocks[3].idx, &clk)); + ut_assertok(device_get_by_ofplat_idx(plat->clocks[3].idx, &clk)); ut_asserteq_str("sandbox_clk", clk->name); ut_asserteq(3, plat->clocks[3].arg[0]); - ut_assertok(device_get_by_driver_info_idx(plat->clocks[4].idx, &clk)); + ut_assertok(device_get_by_ofplat_idx(plat->clocks[4].idx, &clk)); ut_asserteq_str("sandbox_clk", clk->name); ut_asserteq(2, plat->clocks[4].arg[0]); -- cgit v1.1 From 3a825d3fa7122a92020b9a85a8bad0b27d55e6a7 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 15 Mar 2021 17:25:31 +1300 Subject: Revert "sandbox: Disable I2C emulators in SPL" With recent changes this can be supported again. Add it back. This reverts commit d85f2c4f2970d0ec2f5f075de734afd11200d153. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- test/dm/of_platdata.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/dm/of_platdata.c b/test/dm/of_platdata.c index e5f32a0..7cbb116 100644 --- a/test/dm/of_platdata.c +++ b/test/dm/of_platdata.c @@ -207,11 +207,11 @@ DM_TEST(dm_test_of_plat_phandle, UT_TESTF_SCAN_PDATA); /* Test that device parents are correctly set up */ static int dm_test_of_plat_parent(struct unit_test_state *uts) { - struct udevice *dev, *bus; + struct udevice *rtc, *i2c; - ut_assertok(uclass_first_device_err(UCLASS_SIMPLE_BUS, &bus)); - ut_assertok(device_first_child_err(bus, &dev)); - ut_asserteq_ptr(bus, dev_get_parent(dev)); + ut_assertok(uclass_first_device_err(UCLASS_RTC, &rtc)); + ut_assertok(uclass_first_device_err(UCLASS_I2C, &i2c)); + ut_asserteq_ptr(i2c, dev_get_parent(rtc)); return 0; } -- cgit v1.1 From 424994c48f2bea5c9abd84e0a7b30e698484b8b9 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 15 Mar 2021 17:25:32 +1300 Subject: sandbox: Create a new sandbox_noinst build Move sandbox_spl over to use OF_PLATDATA_INST. Create a new board to test the case when this is not enabled, since we will be keeping that code around for several months and want to avoid regressions. Skip the dm_test_of_plat_dev() test since driver info is not available for OF_PLATDATA_INST. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- test/dm/of_platdata.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'test') diff --git a/test/dm/of_platdata.c b/test/dm/of_platdata.c index 7cbb116..f2b45b9 100644 --- a/test/dm/of_platdata.c +++ b/test/dm/of_platdata.c @@ -146,6 +146,10 @@ static int dm_test_of_plat_dev(struct unit_test_state *uts) bool found[n_ents]; uint i; + /* Skip this test if there is no platform data */ + if (CONFIG_IS_ENABLED(OF_PLATDATA_INST)) + return 0; + /* Record the indexes that are found */ memset(found, '\0', sizeof(found)); ut_assertok(find_driver_info(uts, gd->dm_root, found)); -- cgit v1.1 From c25b8dcd3c12d6004db0838b43b6c0d2e53b0383 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 15 Mar 2021 17:25:33 +1300 Subject: test: Run sandbox_spl tests on sandbox_noinst Run the tests on this build too, to prevent regressions. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- test/run | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'test') diff --git a/test/run b/test/run index 735628e..869406c 100755 --- a/test/run +++ b/test/run @@ -30,6 +30,10 @@ fi run_test "sandbox_spl" ./test/py/test.py --bd sandbox_spl --build \ -k 'test_ofplatdata or test_handoff or test_spl' +# Run the sane tests with sandbox_noinst (i.e. without OF_PLATDATA_INST) +run_test "sandbox_spl" ./test/py/test.py --bd sandbox_noinst --build \ + -k 'test_ofplatdata or test_handoff or test_spl' + if [ -z "$tools_only" ]; then # Run tests for the flat-device-tree version of sandbox. This is a special # build which does not enable CONFIG_OF_LIVE for the live device tree, so we can -- cgit v1.1 From ab933d802643ca51d276f0f449921a047126f8a1 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Mon, 15 Mar 2021 17:25:36 +1300 Subject: dm: core: Create a struct for device runtime info At present when driver model needs to change a device it simply updates the struct udevice structure. But with of-platdata-inst most of the fields are not modified at runtime. In fact, typically only the flags need to change. For systems running SPL from read-only memory it is convenient to separate out the runtime information, so that the devices don't need to be copied before being used. Create a new udevice_rt table, similar to the existing driver_rt. For now it just holds the flags, although they are not used in this patch. Add a new Kconfig for the driver_rt data, since this is not needed when of-platdata-inst is used. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- test/dm/of_platdata.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/dm/of_platdata.c b/test/dm/of_platdata.c index f2b45b9..0f89c7a 100644 --- a/test/dm/of_platdata.c +++ b/test/dm/of_platdata.c @@ -147,7 +147,7 @@ static int dm_test_of_plat_dev(struct unit_test_state *uts) uint i; /* Skip this test if there is no platform data */ - if (CONFIG_IS_ENABLED(OF_PLATDATA_INST)) + if (!CONFIG_IS_ENABLED(OF_PLATDATA_DRIVER_RT)) return 0; /* Record the indexes that are found */ -- cgit v1.1