aboutsummaryrefslogtreecommitdiff
path: root/test
AgeCommit message (Collapse)AuthorFilesLines
2021-03-22dtoc: Assign a sequence number to each nodeSimon Glass1-3/+3
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 <sjg@chromium.org>
2021-03-22test: print_ut: Fix potential build errorBin Meng1-1/+1
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 <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-03-22test: cmd: setexpr: Fix a typoBin Meng1-1/+1
SETEXPR_TEST is for a new setexpr test, not mem. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-03-15Merge tag 'v2021.04-rc4' into nextTom Rini5-2/+161
Prepare v2021.04-rc4
2021-03-14test: py: add initial coverage for scp03 cmdIgor Opaniuk1-0/+27
Add initial test coverage for SCP03 command. Signed-off-by: Igor Opaniuk <igor.opaniuk@foundries.io> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-03-13test: acpi: Fix warnings on 32-bit buildSimon Glass1-6/+6
Some format strings use the wrong type. Fix them. Example warnings: In file included from test/dm/acpi.c:22: test/dm/acpi.c: In function ‘dm_test_acpi_cmd_list’: test/dm/acpi.c:362:21: warning: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘unsigned int’ [-Wformat=] ut_assert_nextline("RSDP %08lx %06lx (v02 U-BOOT)", addr, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sizeof(struct acpi_rsdp)); ~~~~~~~~~~~~~~~~~~~~~~~~ include/test/ut.h:282:33: note: in definition of macro ‘ut_assert_nextline’ if (ut_check_console_line(uts, fmt, ##args)) { \ ^~~ Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-12log: Handle line continuationSimon Glass1-4/+15
When multiple log() calls are used which don't end in newline, the log prefix is prepended multiple times in the same line. This makes the output look strange. Fix this by detecting when the previous log record did not end in newline. In that case, setting a flag. Drop the unused BUFFSIZE in the test while we are here. As an example implementation, update log_console to check the flag and produce the expected output. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-12spl: test: Add a test for spl_load_simple_fit()Simon Glass3-0/+97
As an example of an SPL test, add a new test for loading a FIT within SPL. This runs on sandbox_spl. For this to work, the text base is adjusted so that there is plenty of space available. While we are here, document struct spl_load_info properly, since this is currently ambiguous. This test only verifies the logic path. It does not actually check that the image is loaded correctly. It is not possible for sandbox's SPL to actually run u-boot.img since it currently includes u-boot.bin rather than u-boot. Further work could expand the test in that direction. The need for this was noted at: http://patchwork.ozlabs.org/project/uboot/patch/20201216000944.2832585-3-mr.nuke.me@gmail.com/ Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-12test: Allow SPL to run any available testSimon Glass2-5/+23
At present SPL only runs driver model tests. Update it to run all available tests, i.e. in any test suite. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-12test: Rename all linker lists to have a ut_ prefixSimon Glass1-1/+1
At present each test suite has its own portion of the linker_list section of the image, but other lists are interspersed. This makes it hard to enumerate all the available tests without knowing the suites that each one is in. Place all tests together in a single contiguous list by giving them common prefix not used elsewhere in U-Boot. This makes it possible to find the start and end of all tests. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-12test: Add a macros for finding tests in linker_listsSimon Glass13-32/+26
At present we use the linker list directly. This is not very friendly, so add a helpful macro instead. This will also allow us to change the naming later without updating this code. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-12test: log: Rename log main test file to log_ut.cSimon Glass2-1/+1
The current name is the same as the main test runner file. Rename it to avoid confusion. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-03-12test: Move restoring of driver model state to ut_run_list()Simon Glass2-12/+29
Add this functionality to ut_run_list() so it can be removed from dm_test_run(). At this point all tests are run through ut_run_list(). Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-12test: Move the devicetree check into ut_run_list()Simon Glass2-13/+32
Add a check to ut_run_list() as to whether a list has driver model tests. Move the logic for the test devicetree into that function, in an effort to eventually remove all logic from dm_test_run(). Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-12test: Use return values in dm_test_run()Simon Glass1-8/+6
Update this function to use the return value of ut_run_list() to check for success/failure, so that they are in sync. Also return a command success code so that the caller gets what it expects. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-12test: Run driver-model tests using ut_run_list()Simon Glass2-51/+81
Use this function instead of implementing it separately for driver model. Make ut_run_tests() private since it is only used in test-main.c Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-12test: Use a local variable for test stateSimon Glass4-6/+33
At present we use a global test state for all driver-model tests. Make use of a local struct like we do with the other tests. To make this work, add functions to get and set this state. When a test starts, the state is set (so it can be used in the test). When a test finishes, the state is unset, so it cannot be used by mistake. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-12test: Add ut_run_test_live_flat() to run tests twiceSimon Glass2-39/+65
Driver model tests are generally run twice, once with livetree enable and again with it disabled. Add a function to handle this and call it from the driver model test runner. Make ut_run_test() private since it is not used outside test-main.c now. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-12test: Drop dm_do_test()Simon Glass1-11/+4
In an effort to make use of a common test runner, use ut_run_test() directly to run driver model tests. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-12test: Use ut_run_test() to run driver model testsSimon Glass2-13/+24
Instead of having a separate function for running driver model tests, use the common one. Make the pre/post-run functions private since we don't need these outside of test-main.c Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-12test: Move test running into a separate functionSimon Glass1-9/+23
Add a function to handle the preparation for running a test and the post-test clean-up. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-12test: Move dm_test_destroy() into test-main.cSimon Glass2-22/+23
Move this function into the common test runner and rename it to dm_test_post_run() so that its purpose is clear. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-12test: Move dm_test_init() into test-main.cSimon Glass2-23/+32
Move this function into test-main so that all the init is in one place. Rename it so that its purpose is clearer. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-12test: Drop struct dm_test_stateSimon Glass4-44/+31
Driver model is a core part of U-Boot. We don't really need to have a separate test structure for the driver model tests and it makes it harder to write a test if you have to think about which type of test it is. Subsume the fields from struct dm_test_state into struct unit_test_state and delete the former. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-12test: Handle driver model reinit in test_pre_run()Simon Glass2-3/+6
For driver model tests we want to reinit the data structures so that everything is in a known state before the test runs. This avoids one test changing something that breaks a subsequent tests. Move the call for this into test_pre_run(). Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-12test: Move delay skipping to test_pre_run()Simon Glass3-2/+9
This allows delays to be skipped in sandbox tests. Move it to the common pre-init function. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-12test: Move console silencing to test_pre_run()Simon Glass2-5/+2
We already have a function for silencing the console during tests. Use this from test_pre_run() and drop this code from the driver model tests. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-12test: Drop mallinfo() work-aroundSimon Glass2-5/+1
This is not needed now. Drop it. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-12test: Move dm_scan_plat() to test_pre_run()Simon Glass2-2/+3
Move this step over to the pre-run function. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-12test: Move do_autoprobe() to test_pre_run()Simon Glass2-17/+18
Move this step over to the pre-run function. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-12test: Move dm_extended_scan() to test_pre_run()Simon Glass2-3/+7
Move this step over to the pre-run function. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-12test: Call test_pre/post_run() from driver model testsSimon Glass2-6/+12
Ultimately we want to get rid of the special driver model test init and use test_pre_run() and test_post_run() for all tests. As a first step, use those function to handle console recording. For now we need a special case for setting uts->start, but that wil go away once all init is in one place. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-12test: Create pre/post-run functionsSimon Glass1-10/+31
Split out the test preparation into a separation function before expanding it. Add a post-run function as well, currently empty. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-12test: Add an overall test runnerSimon Glass3-33/+73
Add a new test runner that will eventually be able to run any test. For now, have it run the 'command' unit tests, so that the functionality in cmd_ut_category() moves into it. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-12test: Rename test-main.c to test-dm.cSimon Glass2-3/+3
This is the main test function for driver model but not for other tests. Rename the file and the function so this is clear. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-12test: Correct setexpr test prefixSimon Glass1-4/+19
This prefix should be for setexpr, not mem. This means that trying to select just these tests to run does not work. Fix it. For some reason this provokes an assertion failure due to memory not being freed. Move the env_set() in setexpr_test_str() to before the malloc() heap size size is recorded and disable the rest in setexpr_test_str_oper(). Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-12test: Re-enable test_ofplatdataSimon Glass1-1/+1
This was inadvertently disabled after a recent change. Re-enable it. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-12sandbox: Drop the 'starting...' messageSimon Glass1-1/+0
This message is annoying since it is only useful for testing. Drop it and update the test to cope. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-07efi_loader: correct uboot_bin_env.its file formatHeinrich Schuchardt1-2/+2
Up to now the EFI capsule Python tests were always skipped. The reason is that mkimage fails with: uboot_bin_env.its:13.21-23.5: Warning (unit_address_vs_reg): /images/u-boot-bin@100000: node has a unit name, but no reg property uboot_bin_env.its:24.21-34.5: Warning (unit_address_vs_reg): /images/u-boot-env@150000: node has a unit name, but no reg property If a unit in a device-tree has an address, a reg property must be provided. But adding a reg property is not the solution here. Since 2017 unit addresses are disallowed for FIT, cf. common/image-fit.c:1624. So remove the unit addresses in uboot_bin_env.its. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-03-07lib/charset: UTF-8 stream conversionHeinrich Schuchardt1-0/+78
Provide functions to convert an UTF-8 stream to code page 437 or UTF-32. Add unit tests. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-03-07lib/charset: utf8_get() should return errorHeinrich Schuchardt1-0/+7
utf8_get() should return an error if hitting an illegal UTF-8 sequence and not silently convert the input to a question mark. Correct utf_8() and the its unit test. console_read_unicode() now will ignore illegal UTF-8 sequences. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-03-07efi_loader: carve out utf_to_cp()Heinrich Schuchardt1-0/+29
Carve out a function to translate a Unicode code point to an 8bit codepage. Provide a unit test for the new function. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-03-05test: cmd: Add a basic test for 'addrmap' commandBin Meng3-0/+45
This adds a basic test for the newly introduced 'addrmap' command. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org> [Rebase] Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
2021-03-03gpio: Add a way to read 3-way strapping pinsWIP/2021-03-03-gpio-improvementsSimon Glass1-0/+98
Using the internal vs. external pull resistors it is possible to get 27 different combinations from 3 strapping pins. Add an implementation of this. This involves updating the sandbox GPIO driver to model external and (weaker) internal pull resistors. The get_value() method now takes account of what is driving a pin: sandbox: GPIOD_EXT_DRIVEN - in which case GPIO_EXT_HIGH provides the value outside source - in which case GPIO_EXT_PULL_UP/DOWN indicates the external state and we work the final state using those flags and the internal GPIOD_PULL_UP/DOWN flags Of course the outside source does not really exist in sandbox. We are just modelling it for test purpose. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-03dm: gpio: Add a way to update flagsSimon Glass1-17/+115
It is convenient to be able to adjust some of the flags for a GPIO while leaving others alone. Add a function for this. Update dm_gpio_set_dir_flags() to make use of this. Also update dm_gpio_set_value() to use this also, since this allows the open-drain / open-source features to be implemented directly in the driver, rather than using the uclass workaround. Update the sandbox tests accordingly. This involves a lot of changes to dm_test_gpio_opendrain_opensource() since we no-longer have the direciion being reported differently depending on the open drain/open source flags. Also update the STM32 drivers to let the uclass handle the active low/high logic. Drop the GPIOD_FLAGS_OUTPUT() macro which is no-longer used. Signed-off-by: Simon Glass <sjg@chromium.org> Tested-by: Kory Maincent <kory.maincent@bootlin.com> Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Tested-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Tested-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
2021-03-03gpio: sandbox: Rename GPIO dir_flags to flagsSimon Glass1-9/+9
Adjust the terminology in this driver to reflect that fact that all flags are handled, not just direction flags. Create a new access function to get the full GPIO state, not just the direction flags. Drop the static invalid_dir_flags since we can rely on a segfault if something is wrong. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
2021-03-03gpio: Rename dm_gpio_get_dir_flags() to dm_gpio_get_flags()Simon Glass1-6/+6
This function can be used to get any flags, not just direction flags. Rename it to avoid confusion. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Pratyush Yadav <p.yadav@ti.com>
2021-03-03dm: gpio: Rename set_dir_flags() method to update_flags()Simon Glass1-4/+4
The current method is a misnomer since it is also used (e.g. by stm32) to update pull settings and open source/open drain. Rename it and expand the documentation to cover a few more details. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Pratyush Yadav <p.yadav@ti.com> Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
2021-02-26fastboot: Allow u-boot-style partitionsSean Anderson1-3/+34
This adds support for partitions of the form "dev.hwpart:part" and "dev#partname". This allows one to flash to eMMC boot partitions without having to use CONFIG_FASTBOOT_MMC_BOOT1_SUPPORT. It also allows one to flash to an entire device without needing CONFIG_FASTBOOT_MMC_USER_NAME. Lastly, one can also flash MMC devices other than CONFIG_FASTBOOT_FLASH_MMC_DEV. Because devices can be specified explicitly, CONFIG_FASTBOOT_FLASH_MMC_DEV is used only when necessary for existing functionality. For those cases, fastboot_mmc_get_dev has been added as a helper function. This allows There should be no conflicts with the existing system, but just in case, I have ordered detection of these names after all existing names. The fastboot_mmc_part test has been updated for these new names. Signed-off-by: Sean Anderson <sean.anderson@seco.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-02-26test: dm: Add test for fastboot mmc partition namingSean Anderson2-0/+67
This test verifies the mapping between fastboot partitions and partitions as understood by U-Boot. It also tests the creation of GPT partitions, though that is not the primary goal. Signed-off-by: Sean Anderson <sean.anderson@seco.com> Reviewed-by: Simon Glass <sjg@chromium.org>