dm: test: Add unit tests for SPL
Subsystems (2)
v2 cover dm: test: Add unit tests for SPL
U-Boot has about 700 tests but only a handful of these target SPL. This is partly because SPL has limited functionality and does not have a command interface to initiate tests.
The current SPL tests are targeted at sandbox_spl and are initiated from pytest.
With SPL tests written in C, we can check the behaviour of of-platdata more easily, since the test can check things directly rather than printing out information for pytest to check.
This series adds support for SPL tests written in C, targeted at the sandbox_spl build.
It includes quite a bit of minor refactoring to get everything working.
Changes in v2:
- Drop debug print()
- Restart U-Boot after each SPL test
- Separate out this patch from the next series and include it here
Simon Glass (11):
dm: test: Build tests for SPL
dm: test: Update the test runner to support of-platdata
dm: test: Add a way to run SPL tests
dm: test: Add a very simple of-platadata test
Makefile: Generate a symbol file for u-boot-spl
pytest: Collect SPL unit tests
test: Run SPL unit tests
sandbox: Allow selection of SPL unit tests
test: Run only the selected SPL test
dm: test: Drop of-platdata pytest Azure/GitLab/Travis: Add SPL unit tests
.azure-pipelines.yml | 2 +- .gitlab-ci.yml | 2 +- .travis.yml | 2 +- arch/sandbox/cpu/spl.c | 18 +++++------- arch/sandbox/cpu/start.c | 15 ++++++++-- arch/sandbox/include/asm/state.h | 3 +- configs/sandbox_spl_defconfig | 2 +- drivers/misc/spltest_sandbox.c | 35 ------------------------ include/test/test.h | 11 ++++++++ scripts/Makefile.spl | 8 +++++- test/Kconfig | 10 +++++++ test/dm/Makefile | 4 ++- test/dm/of_platdata.c | 19 +++++++++++++ test/dm/test-main.c | 29 ++++++++++++-------- test/py/conftest.py | 13 +++++---- test/py/tests/test_ofplatdata.py | 47 -------------------------------- test/py/tests/test_spl.py | 34 +++++++++++++++++++++++ test/run | 2 +- 18 files changed, 135 insertions(+), 121 deletions(-) create mode 100644 test/dm/of_platdata.c create mode 100644 test/py/tests/test_spl.py
Signature · 1 line
2.29.0.rc2.309.g374f81d7ae-goog
PATCH v2 1/11 dm: test: Build tests for SPL
We want to run unit tests in SPL. Add a new Kconfig to control this and enable it for sandbox_spl
---
(no changes since v1)
configs/sandbox_spl_defconfig | 2 +- scripts/Makefile.spl | 1 + test/Kconfig | 10 ++++++++++ 3 files changed, 12 insertions(+), 1 deletion(-)
configs/sandbox_spl_defconfig +1 -1
@@ -22,7 +22,6 @@ CONFIG_BOOTSTAGE_STASH=y CONFIG_BOOTSTAGE_STASH_SIZE=0x4096 CONFIG_CONSOLE_RECORD=y CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000 -CONFIG_SILENT_CONSOLE=y CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_HANDOFF=y CONFIG_SPL_BOARD_INIT=y
@@ -221,5 +220,6 @@ CONFIG_TPM=y CONFIG_LZ4=y CONFIG_ERRNO_STR=y CONFIG_UNIT_TEST=y +CONFIG_SPL_UNIT_TEST=y CONFIG_UT_TIME=y CONFIG_UT_DM=y
scripts/Makefile.spl +1 -0
@@ -99,6 +99,7 @@ libs-y += dts/ libs-y += fs/ libs-$(CONFIG_SPL_POST_MEM_SUPPORT) += post/drivers/ libs-$(CONFIG_SPL_NET_SUPPORT) += net/ +libs-$(CONFIG_SPL_UNIT_TEST) += test/ head-y := $(addprefix $(obj)/,$(head-y)) libs-y := $(addprefix $(obj)/,$(libs-y))
test/Kconfig +10 -0
@@ -6,6 +6,16 @@ menuconfig UNIT_TEST This does not require sandbox to be included, but it is most often used there. +config SPL_UNIT_TEST + bool "Unit tests in SPL" + # We need to be able to unbind devices for tests to work + select SPL_DM_DEVICE_REMOVE + help + Select this to enable unit tests in SPL. Most test are designed for + running in U-Boot proper, but some are intended for SPL, such as + of-platdata and SPL handover. To run these tests with the sandbox_spl + board, use the -u (unit test) option. + config UT_LIB bool "Unit tests for library functions" depends on UNIT_TEST
Signature · 1 line
2.29.0.rc2.309.g374f81d7ae-goog
PATCH v2 2/11 dm: test: Update the test runner to support of-platdata
In reply to Simon GlassAt present DM tests assume that a devicetree is available. This is not the case with of-platadata.
Update the code to add this condition.
---
(no changes since v1)
test/dm/test-main.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-)
test/dm/test-main.c +16 -11
@@ -30,7 +30,8 @@ static int dm_test_init(struct unit_test_state *uts, bool of_live)memset (dms,'\0' ,sizeof (*dms)); gd->dm_root =NULL ; -memset (dm_testdrv_op_count,'\0' ,sizeof (dm_testdrv_op_count)); +if (!CONFIG_IS_ENABLED (OF_PLATDATA )) +memset (dm_testdrv_op_count,'\0' ,sizeof (dm_testdrv_op_count));state_reset_for_test (state_get_current ());/* Determine whether to make the live tree available */
@@ -91,7 +92,8 @@ static int dm_do_test(struct unit_test_state *uts, struct unit_test *test,ut_assertok (dm_scan_platdata (false));if (test->flags &UT_TESTF_PROBE_TEST )ut_assertok (do_autoprobe (uts)); -if (test->flags &UT_TESTF_SCAN_FDT ) +if (!CONFIG_IS_ENABLED (OF_PLATDATA ) && + (test->flags &UT_TESTF_SCAN_FDT ))ut_assertok (dm_extended_scan_fdt (gd->fdt_blob, false));/*
@@ -136,14 +138,16 @@ static int dm_test_main(const char *test_name) uts->priv = &_global_priv_dm_test_state; uts->fail_count =0 ; -/* -* If we have no device tree, or it only has a root node, then these -* tests clearly aren't going to work... -*/ -if (!gd->fdt_blob ||fdt_next_node (gd->fdt_blob,0 ,NULL ) <0 ) { -puts ("Please run with test device tree:\n" -" ./u-boot -d arch/sandbox/dts/test.dtb\n" ); -ut_assert (gd->fdt_blob); +if (!CONFIG_IS_ENABLED (OF_PLATDATA )) { +/* +* If we have no device tree, or it only has a root node, then +* these * tests clearly aren't going to work... +*/ +if (!gd->fdt_blob ||fdt_next_node (gd->fdt_blob,0 ,NULL ) <0 ) { +puts ("Please run with test device tree:\n" +" ./u-boot -d arch/sandbox/dts/test.dtb\n" ); +ut_assert (gd->fdt_blob); + } }if (!test_name)
@@ -192,7 +196,8 @@ static int dm_test_main(const char *test_name) gd->dm_root =NULL ;ut_assertok (dm_init (CONFIG_IS_ENABLED (OF_LIVE )));dm_scan_platdata (false); -dm_scan_fdt (gd->fdt_blob, false); +if (!CONFIG_IS_ENABLED (OF_PLATDATA )) +dm_scan_fdt (gd->fdt_blob, false);return uts->fail_count ?CMD_RET_FAILURE :0 ; }
Signature · 1 line
2.29.0.rc2.309.g374f81d7ae-goog
PATCH v2 2/11 dm: test: Update the test runner to support of-platdata
At present DM tests assume that a devicetree is available. This is not the case with of-platadata.
Update the code to add this condition.
---
(no changes since v1)
test/dm/test-main.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-)
Applied to u-boot-dm, thanks!
PATCH v2 3/11 dm: test: Add a way to run SPL tests
In reply to Simon GlassAdd a -u flag for U-Boot SPL which requests that unit tests be run. To make this work, export dm_test_main() and update it to skip test features that are not used with of-platdata.
To run the tests:
$ spl/u-boot-spl -u U-Boot SPL 2020.10-rc5 (Oct 01 2020 - 07:35:39 -0600) Running 0 driver model tests Failures: 0
At present there are no SPL unit tests.
Note that there is one wrinkle with these tests. SPL has limited memory available for allocation. Also malloc_simple does not free memory (free() is a nop) and running tests repeatedly causes driver-model to reinit multiple times and allocate memory. Therefore it is not possible to run more than a few tests at a time. One solution is to increase the amount of malloc space in sandbox_spl. This is not a problem for pytest, since it runs each test individually, so for now this is left as is.
---
(no changes since v1)
arch/sandbox/cpu/spl.c | 8 ++++++++ arch/sandbox/cpu/start.c | 9 +++++++++ arch/sandbox/include/asm/state.h | 1 + include/test/test.h | 11 +++++++++++ test/dm/test-main.c | 2 +- 5 files changed, 30 insertions(+), 1 deletion(-)
arch/sandbox/cpu/spl.c +8 -0
@@ -12,6 +12,7 @@#include <spl.h> #include <asm/spl.h> #include <asm/state.h> +#include <test/test.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -67,6 +68,13 @@ void spl_board_init(void) uclass_next_device(&dev)) ; } + +if (state->run_unittests) { +int ret; + + ret =dm_test_main (NULL ); +/* continue execution into U-Boot */ + } }void __noreturn jump_to_image_no_args (struct spl_image_info *spl_image)
arch/sandbox/cpu/start.c +9 -0
@@ -374,6 +374,15 @@ static int sandbox_cmdline_cb_show_of_platdata(struct sandbox_state *state, }SANDBOX_CMDLINE_OPT (show_of_platdata,0 ,"Show of-platdata in SPL" ); +static int sandbox_cmdline_cb_unittests (struct sandbox_state *state, +const char *arg) +{ + state->run_unittests = true; + +return 0 ; +} +SANDBOX_CMDLINE_OPT_SHORT (unittests,'u' ,0 ,"Run unit tests" ); +static void setup_ram_buf (struct sandbox_state *state) {/* Zero the RAM buffer if we didn't read it, to keep valgrind happy */
arch/sandbox/include/asm/state.h +1 -0
@@ -92,6 +92,7 @@ struct sandbox_state {int default_log_level;/* Default log level for sandbox */ bool show_of_platdata;/* Show of-platdata in SPL */ bool ram_buf_read;/* true if we read the RAM buffer */ +bool run_unittests;/* Run unit tests */ /* Pointer to information for each SPI bus/cs */ struct sandbox_spi_info spi[CONFIG_SANDBOX_SPI_MAX_BUS ]
include/test/test.h +11 -0
@@ -94,4 +94,15 @@ enum { TEST_DEVRES_SIZE3 = 37, }; +/** +* dm_test_main() - Run driver model tests +* +* Run all the available driver model tests, or a selection +* +* @test_name: Name of single test to run (e.g. "dm_test_fdt_pre_reloc" or just +* "fdt_pre_reloc"), or NULL to run all +* @return 0 if all tests passed, 1 if not +*/ +int dm_test_main (const char *test_name); +#endif /* __TEST_TEST_H */
test/dm/test-main.c +1 -1
@@ -127,7 +127,7 @@ static bool dm_test_run_on_flattree(struct unit_test *test)return !strstr (fname,"video" ) ||strstr (test->name,"video_base" ); } -static int dm_test_main (const char *test_name) +int dm_test_main (const char *test_name) { struct unit_test *tests = ll_entry_start(struct unit_test, dm_test); const int n_ents = ll_entry_count(struct unit_test, dm_test);
Signature · 1 line
2.29.0.rc2.309.g374f81d7ae-goog
PATCH v2 3/11 dm: test: Add a way to run SPL tests
Add a -u flag for U-Boot SPL which requests that unit tests be run. To make this work, export dm_test_main() and update it to skip test features that are not used with of-platdata.
To run the tests:
$ spl/u-boot-spl -u U-Boot SPL 2020.10-rc5 (Oct 01 2020 - 07:35:39 -0600) Running 0 driver model tests Failures: 0
At present there are no SPL unit tests.
Note that there is one wrinkle with these tests. SPL has limited memory available for allocation. Also malloc_simple does not free memory (free() is a nop) and running tests repeatedly causes driver-model to reinit multiple times and allocate memory. Therefore it is not possible to run more than a few tests at a time. One solution is to increase the amount of malloc space in sandbox_spl. This is not a problem for pytest, since it runs each test individually, so for now this is left as is.
---
(no changes since v1)
arch/sandbox/cpu/spl.c | 8 ++++++++ arch/sandbox/cpu/start.c | 9 +++++++++ arch/sandbox/include/asm/state.h | 1 + include/test/test.h | 11 +++++++++++ test/dm/test-main.c | 2 +- 5 files changed, 30 insertions(+), 1 deletion(-)
Applied to u-boot-dm, thanks!
PATCH v2 4/11 dm: test: Add a very simple of-platadata test
In reply to Simon GlassAt present we have a pytest that covers of-platadata. Add a very simple unit test that just checks that a device can be found. This shows the ability to write these tests in C.
---
(no changes since v1)
test/dm/Makefile | 4 +++- test/dm/of_platdata.c | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 test/dm/of_platdata.c
test/dm/Makefile +3 -1
@@ -6,7 +6,9 @@ obj-$(CONFIG_UT_DM) += test-main.o # Tests for particular subsystems - when enabling driver model for a new # subsystem you must add sandbox tests here. -ifeq ($(CONFIG_SPL_BUILD),) +ifeq ($(CONFIG_SPL_BUILD),y) +obj-$(CONFIG_SPL_OF_PLATDATA) += of_platdata.o +else obj-$(CONFIG_UT_DM) += bus.o obj-$(CONFIG_UT_DM) += test-driver.o obj-$(CONFIG_UT_DM) += test-fdt.o
test/dm/of_platdata.c new file +19 -0
@@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0+ + +#include <common.h> +#include <dm.h> +#include <dm/test.h> +#include <test/test.h> +#include <test/ut.h> + +/* Test that we can find a device using of-platdata */ +static int dm_test_of_platdata_base (struct unit_test_state *uts) +{ +struct udevice *dev; + +ut_assertok (uclass_first_device_err (UCLASS_SERIAL , &dev)); +ut_asserteq_str ("sandbox_serial" , dev->name); + +return 0 ; +} +DM_TEST (dm_test_of_platdata_base,UT_TESTF_SCAN_PDATA );
Signature · 1 line
2.29.0.rc2.309.g374f81d7ae-goog
PATCH v2 4/11 dm: test: Add a very simple of-platadata test
At present we have a pytest that covers of-platadata. Add a very simple unit test that just checks that a device can be found. This shows the ability to write these tests in C.
---
(no changes since v1)
test/dm/Makefile | 4 +++- test/dm/of_platdata.c | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 test/dm/of_platdata.c
Applied to u-boot-dm, thanks!
PATCH v2 5/11 Makefile: Generate a symbol file for u-boot-spl
In reply to Simon GlassAdd a rule to generate u-boot-spl.sym so that pytest can discover the available unit tests.
---
(no changes since v1)
scripts/Makefile.spl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
scripts/Makefile.spl +6 -1
@@ -214,7 +214,7 @@ spl/boot.bin: $(obj)/$(SPL_BIN)-align.bin FORCE $(call if_changed,mkimage) endif -INPUTS-y += $(obj)/$(SPL_BIN).bin +INPUTS-y += $(obj)/$(SPL_BIN).bin $(obj)/$(SPL_BIN).sym ifdef CONFIG_SAMSUNG INPUTS-y += $(obj)/$(BOARD)-spl.bin
@@ -408,6 +408,11 @@ MKIMAGEFLAGS_u-boot-spl-mtk.bin = -T mtk_image \ $(obj)/u-boot-spl-mtk.bin: $(obj)/u-boot-spl.bin FORCE $(call if_changed,mkimage) +quiet_cmd_sym ?= SYM $@ + cmd_sym ?= $(OBJDUMP) -t $< > $@ +$(obj)/$(SPL_BIN).sym: $(obj)/$(SPL_BIN) FORCE + $(call if_changed,sym) + # Rule to link u-boot-spl # May be overridden by arch/$(ARCH)/config.mk quiet_cmd_u-boot-spl ?= LD $@
Signature · 1 line
2.29.0.rc2.309.g374f81d7ae-goog
PATCH v2 5/11 Makefile: Generate a symbol file for u-boot-spl
Add a rule to generate u-boot-spl.sym so that pytest can discover the available unit tests.
---
(no changes since v1)
scripts/Makefile.spl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
Applied to u-boot-dm, thanks!
PATCH v2 6/11 pytest: Collect SPL unit tests
In reply to Simon GlassAdd a new test_spl fixture to handle running SPL unit tests.
---
Changes in v2:
- Drop debug print()
- Restart U-Boot after each SPL test
test/py/conftest.py | 13 ++++++++----- test/py/tests/test_spl.py | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 test/py/tests/test_spl.py
test/py/conftest.py +8 -5
@@ -227,7 +227,7 @@ def pytest_configure(config): console = u_boot_console_exec_attach.ConsoleExecAttach(log, ubconfig) re_ut_test_list = re.compile(r'_u_boot_list_2_(.*)_test_2_\1_test_(.*)\s*$') -def generate_ut_subtest(metafunc, fixture_name): +def generate_ut_subtest(metafunc, fixture_name, sym_path): """Provide parametrization for a ut_subtest fixture. Determines the set of unit tests built into a U-Boot binary by parsing the
@@ -237,12 +237,13 @@ def generate_ut_subtest(metafunc, fixture_name): Args: metafunc: The pytest test function. fixture_name: The fixture name to test. + sym_path: Relative path to the symbol file with preceding '/' + (e.g. '/u-boot.sym') Returns: Nothing. """ - - fn = console.config.build_dir + '/u-boot.sym' + fn = console.config.build_dir + sym_path try: with open(fn, 'rt') as f: lines = f.readlines()
@@ -317,10 +318,12 @@ def pytest_generate_tests(metafunc): Returns: Nothing. """ - for fn in metafunc.fixturenames: if fn == 'ut_subtest': - generate_ut_subtest(metafunc, fn) + generate_ut_subtest(metafunc, fn, '/u-boot.sym') + continue + if fn == 'ut_spl_subtest': + generate_ut_subtest(metafunc, fn, '/spl/u-boot-spl.sym') continue generate_config(metafunc, fn)
test/py/tests/test_spl.py new file +34 -0
@@ -0,0 +1,34 @@ +# SPDX-License-Identifier: GPL-2.0 +# Copyright 2020 Google LLC +# Written by Simon Glass <[email protected]> + +import os.path +import pytest + +def test_spl(u_boot_console, ut_spl_subtest): + """Execute a "ut" subtest. + + The subtests are collected in function generate_ut_subtest() from linker + generated lists by applying a regular expression to the lines of file + spl/u-boot-spl.sym. The list entries are created using the C macro + UNIT_TEST(). + + Strict naming conventions have to be followed to match the regular + expression. Use UNIT_TEST(foo_test_bar, _flags, foo_test) for a test bar in + test suite foo that can be executed via command 'ut foo bar' and is + implemented in C function foo_test_bar(). + + Args: + u_boot_console (ConsoleBase): U-Boot console + ut_subtest (str): SPL test to be executed (e.g. 'dm platdata_phandle') + """ + try: + cons = u_boot_console + cons.restart_uboot_with_flags(['-u', ut_spl_subtest]) + output = cons.get_spawn_output().replace('\r', '') + assert 'Failures: 0' in output + finally: + # Restart afterward in case a non-SPL test is run next. This should not + # happen since SPL tests are run in their own invocation of test.py, but + # the cost of doing this is not too great at present. + u_boot_console.restart_uboot()
Signature · 1 line
2.29.0.rc2.309.g374f81d7ae-goog
PATCH v2 6/11 pytest: Collect SPL unit tests
Add a new test_spl fixture to handle running SPL unit tests.
---
Changes in v2:
- Drop debug print()
- Restart U-Boot after each SPL test
test/py/conftest.py | 13 ++++++++----- test/py/tests/test_spl.py | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 test/py/tests/test_spl.py
Applied to u-boot-dm, thanks!
PATCH v2 7/11 test: Run SPL unit tests
In reply to Simon GlassUpdate the 'run' script to include SPL unit tests.
---
(no changes since v1)
test/run | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
test/run +1 -1
@@ -28,7 +28,7 @@ fi # Run tests which require sandbox_spl run_test "sandbox_spl" ./test/py/test.py --bd sandbox_spl --build \ - -k 'test_ofplatdata or test_handoff' + -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
Signature · 1 line
2.29.0.rc2.309.g374f81d7ae-goog
PATCH v2 7/11 test: Run SPL unit tests
Update the 'run' script to include SPL unit tests.
---
(no changes since v1)
test/run | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied to u-boot-dm, thanks!
PATCH v2 8/11 sandbox: Allow selection of SPL unit tests
In reply to Simon GlassNow that we have more than one test, add a way to select the test to run.
---
(no changes since v1)
arch/sandbox/cpu/spl.c | 2 +- arch/sandbox/cpu/start.c | 9 +++++++++ arch/sandbox/include/asm/state.h | 1 + 3 files changed, 11 insertions(+), 1 deletion(-)
arch/sandbox/cpu/spl.c +1 -1
@@ -72,7 +72,7 @@ void spl_board_init(void)if (state->run_unittests) {int ret; - ret =dm_test_main (NULL ); + ret =dm_test_main (state->select_unittests);/* continue execution into U-Boot */ } }
arch/sandbox/cpu/start.c +9 -0
@@ -383,6 +383,15 @@ static int sandbox_cmdline_cb_unittests(struct sandbox_state *state, }SANDBOX_CMDLINE_OPT_SHORT (unittests,'u' ,0 ,"Run unit tests" ); +static int sandbox_cmdline_cb_select_unittests (struct sandbox_state *state, +const char *arg) +{ + state->select_unittests = arg; + +return 0 ; +} +SANDBOX_CMDLINE_OPT_SHORT (select_unittests,'k' ,1 ,"Select unit tests to run" ); +static void setup_ram_buf (struct sandbox_state *state) {/* Zero the RAM buffer if we didn't read it, to keep valgrind happy */
arch/sandbox/include/asm/state.h +1 -0
@@ -93,6 +93,7 @@ struct sandbox_state {bool show_of_platdata;/* Show of-platdata in SPL */ bool ram_buf_read;/* true if we read the RAM buffer */ bool run_unittests;/* Run unit tests */ +const char *select_unittests;/* Unit test to run */ /* Pointer to information for each SPI bus/cs */ struct sandbox_spi_info spi[CONFIG_SANDBOX_SPI_MAX_BUS ]
Signature · 1 line
2.29.0.rc2.309.g374f81d7ae-goog
PATCH v2 8/11 sandbox: Allow selection of SPL unit tests
Now that we have more than one test, add a way to select the test to run.
---
(no changes since v1)
arch/sandbox/cpu/spl.c | 2 +- arch/sandbox/cpu/start.c | 9 +++++++++ arch/sandbox/include/asm/state.h | 1 + 3 files changed, 11 insertions(+), 1 deletion(-)
Applied to u-boot-dm, thanks!
PATCH v2 9/11 test: Run only the selected SPL test
In reply to Simon GlassUse the new -k option to select the test to run.
---
Changes in v2:
- Separate out this patch from the next series and include it here
test/py/tests/test_spl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
test/py/tests/test_spl.py +1 -1
@@ -24,7 +24,7 @@ def test_spl(u_boot_console, ut_spl_subtest): """ try: cons = u_boot_console - cons.restart_uboot_with_flags(['-u', ut_spl_subtest]) + cons.restart_uboot_with_flags(['-u', '-k', ut_spl_subtest.split()[1]]) output = cons.get_spawn_output().replace('\r', '') assert 'Failures: 0' in output finally:
Signature · 1 line
2.29.0.rc2.309.g374f81d7ae-goog
PATCH v2 10/11 dm: test: Drop of-platdata pytest
In reply to Simon GlassNow that we have a C version of this test, drop the Python implementation.
---
(no changes since v1)
arch/sandbox/cpu/spl.c | 12 -------- arch/sandbox/cpu/start.c | 9 ------ arch/sandbox/include/asm/state.h | 1 - drivers/misc/spltest_sandbox.c | 35 ------------------------ test/py/tests/test_ofplatdata.py | 47 -------------------------------- 5 files changed, 104 deletions(-)
arch/sandbox/cpu/spl.c +0 -12
@@ -54,20 +54,8 @@ SPL_LOAD_IMAGE_METHOD("sandbox", 9, BOOT_DEVICE_BOARD, spl_board_load_image);void spl_board_init (void ) {struct sandbox_state *state =state_get_current (); -struct udevice *dev;preloader_console_init (); -if (state->show_of_platdata) { -/* -* Scan all the devices so that we can output their platform -* data. See sandbox_spl_probe(). -*/ -printf ("Scanning misc devices\n" ); -for (uclass_first_device (UCLASS_MISC , &dev); - dev; -uclass_next_device (&dev)) - ; - }if (state->run_unittests) {int ret;
arch/sandbox/cpu/start.c +0 -9
@@ -365,15 +365,6 @@ static int sandbox_cmdline_cb_log_level(struct sandbox_state *state,SANDBOX_CMDLINE_OPT_SHORT (log_level,'L' ,1 ,"Set log level (0=panic, 7=debug)" ); -static int sandbox_cmdline_cb_show_of_platdata (struct sandbox_state *state, -const char *arg) -{ - state->show_of_platdata = true; - -return 0 ; -} -SANDBOX_CMDLINE_OPT (show_of_platdata,0 ,"Show of-platdata in SPL" ); -static int sandbox_cmdline_cb_unittests (struct sandbox_state *state,const char *arg) {
arch/sandbox/include/asm/state.h +0 -1
@@ -90,7 +90,6 @@ struct sandbox_state {bool skip_delays;/* Ignore any time delays (for test) */ bool show_test_output;/* Don't suppress stdout in tests */ int default_log_level;/* Default log level for sandbox */ -bool show_of_platdata;/* Show of-platdata in SPL */ bool ram_buf_read;/* true if we read the RAM buffer */ bool run_unittests;/* Run unit tests */ const char *select_unittests;/* Unit test to run */
drivers/misc/spltest_sandbox.c +0 -35
@@ -8,43 +8,8 @@#include <dm.h> #include <dt-structs.h> -static int sandbox_spl_probe (struct udevice *dev) -{ -struct dtd_sandbox_spl_test *plat =dev_get_platdata (dev); -int i; - -printf ("of-platdata probe:\n" ); -printf ("bool %d\n" , plat->boolval); - -printf ("byte %02x\n" , plat->byteval); -printf ("bytearray" ); -for (i =0 ; i <sizeof (plat->bytearray); i++) -printf (" %02x" , plat->bytearray[i]); -printf ("\n" ); - -printf ("int %d\n" , plat->intval); -printf ("intarray" ); -for (i =0 ; i <ARRAY_SIZE (plat->intarray); i++) -printf (" %d" , plat->intarray[i]); -printf ("\n" ); - -printf ("longbytearray" ); -for (i =0 ; i <sizeof (plat->longbytearray); i++) -printf (" %02x" , plat->longbytearray[i]); -printf ("\n" ); - -printf ("string %s\n" , plat->stringval); -printf ("stringarray" ); -for (i =0 ; i <ARRAY_SIZE (plat->stringarray); i++) -printf (" \"%s\"" , plat->stringarray[i]); -printf ("\n" ); - -return 0 ; -} -U_BOOT_DRIVER (sandbox_spl_test) = { .name ="sandbox_spl_test" , .id =UCLASS_MISC , .flags =DM_FLAG_PRE_RELOC , - .probe = sandbox_spl_probe, };
test/py/tests/test_ofplatdata.py +0 -47
53 lines not on this page · raw message
Signature · 1 line
2.29.0.rc2.309.g374f81d7ae-goog
PATCH v2 10/11 dm: test: Drop of-platdata pytest
Now that we have a C version of this test, drop the Python implementation.
---
(no changes since v1)
arch/sandbox/cpu/spl.c | 12 -------- arch/sandbox/cpu/start.c | 9 ------ arch/sandbox/include/asm/state.h | 1 - drivers/misc/spltest_sandbox.c | 35 ------------------------ test/py/tests/test_ofplatdata.py | 47 -------------------------------- 5 files changed, 104 deletions(-)
Applied to u-boot-dm, thanks!
PATCH v2 11/11 Azure/GitLab/Travis: Add SPL unit tests
In reply to Simon GlassRun SPL unit tests in all test environments.
---
(no changes since v1)
.azure-pipelines.yml | 2 +- .gitlab-ci.yml | 2 +- .travis.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
.azure-pipelines.yml +1 -1
@@ -182,7 +182,7 @@ jobs: OVERRIDE: "-O clang-10" sandbox_spl: TEST_PY_BD: "sandbox_spl" - TEST_PY_TEST_SPEC: "test_ofplatdata or test_handoff" + TEST_PY_TEST_SPEC: "test_ofplatdata or test_handoff or test_spl" sandbox_flattree: TEST_PY_BD: "sandbox_flattree" evb_ast2500:
.gitlab-ci.yml +1 -1
@@ -198,7 +198,7 @@ sandbox_spl test.py: tags: [ 'all' ] variables: TEST_PY_BD: "sandbox_spl" - TEST_PY_TEST_SPEC: "test_ofplatdata or test_handoff" + TEST_PY_TEST_SPEC: "test_ofplatdata or test_handoff or test_spl" <<: *buildman_and_testpy_dfn evb-ast2500 test.py:
.travis.yml +1 -1
@@ -512,7 +512,7 @@ matrix: - name: "test/py sandbox_spl" env: - TEST_PY_BD="sandbox_spl" - TEST_PY_TEST_SPEC="test_ofplatdata or test_handoff" + TEST_PY_TEST_SPEC="test_ofplatdata or test_handoff or test_spl" TOOLCHAIN="i386" TEST_PY_TOOLS="yes" - name: "test/py sandbox_flattree"
Signature · 1 line
2.29.0.rc2.309.g374f81d7ae-goog
PATCH v2 11/11 Azure/GitLab/Travis: Add SPL unit tests
Run SPL unit tests in all test environments.
---
(no changes since v1)
.azure-pipelines.yml | 2 +- .gitlab-ci.yml | 2 +- .travis.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
Applied to u-boot-dm, thanks!