summaryrefslogtreecommitdiff
path: root/include/test
AgeCommit message (Collapse)AuthorFilesLines
2023-07-14expo: Support building an expo from a description fileSimon Glass1-0/+29
The only way to create an expo at present is by calling the functions to create each object. It is useful to have more data-driven approach, where the objects can be specified in a suitable file format and created from that. This makes testing easier as well. Add support for describing an expo in a devicetree node. This allows more complex tests to be set up, as well as providing an easier format for users. It also provides a better basis for the upcoming configuration editor. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-07-14test: Restore test behaviour on failureSimon Glass1-18/+18
A recent change makes test continue to run after failure. This results in a lot of useless output and may lead to a segfault. Fix this by adding back the 'return' statement. Fixes: fa847bb409d ("test: Wrap assert macros in ({ ... }) and fix") Signed-off-by: Simon Glass <sjg@chromium.org>
2023-06-20test: bdinfo: Add test for command bdinfoMarek Vasut1-0/+1
Add test for command bdinfo . Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-03-30test: Add test for new command pci_mpsStephen Carlson1-0/+2
Adds a test for the new pci_mps command to ensure that it can set the Maximum Payload Size (MPS) of all devices to 256 bytes in the sandbox environment. Enables the pci_mps command in the sandbox environment so that this test can be run. Signed-off-by: Stephen Carlson <stcarlso@linux.microsoft.com>
2023-03-15test: Wrap assert macros in ({ ... }) and fix missing semicolonsMarek Vasut1-50/+102
Wrap the assert macros in ({ ... }) so they can be safely used both as right side argument as well as in conditionals without curly brackets around them. In the process, find a bunch of missing semicolons, fix them. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
2023-03-08test: Add ut_assert_nextline_empty() empty line helperMarek Vasut1-0/+4
Add helper macro to test for empty lines, which is an inobvious wrapper around ut_assert_nextline("%s", "") . Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-02-07cmd: Add a SEAMA image load commandLinus Walleij1-0/+1
Add a command to load SEAMA (Seattle Image), a NAND flash on-flash storage format. This type of flash image is found in some D-Link routers such as DIR-645, DIR-842, DIR-859, DIR-860L, DIR-885L, DIR890L and DCH-M225, as well as in WD and NEC routers on the ath79 (MIPS), Broadcom BCM53xx, and RAMIPS platforms. This U-Boot command will read and decode a SEAMA image from raw NAND flash on any platform. As it is always using big endian format for the data decoding is always necessary on platforms such as ARM. The command is needed to read a SEAMA-encoded boot image on the D-Link DIR-890L router for boot from NAND flash in an upcoming port of U-Boot to the Broadcom Northstar (BCM4709, BCM53xx) architecture. A basic test and documentation is added as well. The test must be run on a target with NAND flash support and at least one resident SEAMA image in flash. Cc: Rafał Miłecki <rafal@milecki.pl> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2023-01-24sandbox: Allow SPI flash bootdevs to be disabled for testsSimon Glass1-0/+19
Most tests don't want these and they can create a lot of noise. Add a way to disable them. Use that in tests, with a flag provided to enable them for tests that need this feature. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-24test: Add a generic function to skip delaysSimon Glass1-0/+16
At present this feature is sandbox-specific. For running tests on boards, we need a nop version. Add one. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-24sandbox: Allow ethernet bootdevs to be disabled for testsSimon Glass1-0/+12
Most tests don't want these and can create a lot of noise. Add a way to disable them. Use that in tests, with a flag provided to enable them for tests that need this feature. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-24sandbox: Allow ethernet to be disabled at runtimeSimon Glass1-0/+25
For bootstd tests it is seldom useful to have ethernet enabled. Add a way to disable it, so that ethernet operations like tftpboot do nothing. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-11test: cmd: exit: Add unit test for exit and partly run commandsMarek Vasut1-0/+1
Add a test which validates that exit from environment script works as expected, including return value propagation and clipping to positive integers. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Marek Vasut <marex@denx.de>
2022-11-08test: Add a way to detect a test that breaks anotherSimon Glass1-1/+6
When running unit tests, some may have side effects which cause a subsequent test to break. This can sometimes be seen when using 'ut dm' or similar. Add a new argument which allows a particular (failing) test to be run immediately after a certain number of tests have run. This allows the test causing the failure to be determined. Update the documentation also. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-10-31test: Support tests which can only be run manuallySimon Glass2-1/+11
At present we normally write tests either in Python or in C. But most Python tests end up doing a lot of checks which would be better done in C. Checks done in C are orders of magnitude faster and it is possible to get full access to U-Boot's internal workings, rather than just relying on the command line. The model is to have a Python test set up some things and then use C code (in a unit test) to check that they were done correctly. But we don't want those checks to happen as part of normal test running, since each C unit tests is dependent on the associate Python tests, so cannot run without it. To acheive this, add a new UT_TESTF_MANUAL flag to use with the C 'check' tests, so that they can be skipped by default when the 'ut' command is used. Require that tests have a name ending with '_norun', so that pytest knows to skip them. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-10-31test: Report skippped testsSimon Glass1-0/+2
At present it is possible for a test to skip itself by returning -EAGAIN but this is not recorded. An existing example is in test_pre_run() with the "Console recording disabled" check. Keep a track of skipped tests and report the total at the end. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2022-10-30video: Add commands to list and change fontsSimon Glass1-0/+1
Add a new 'font' command which allows the fonts to be listed as well as selecting a different font and size. Allow the test to run on sandbox, where multiple font/size combinations are supported, as well as sandbox_flattree, where they are not. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-30dm: core: Complete phandle implementation using the other FDTSimon Glass1-0/+5
We need to be able to look up phandles in any FDT, not just the control FDT. Use the 'other' FDT to test this, with a helper function which gets this as an oftree that can then we used as needed. Add a few more tests and some comments at the top of the file, to explain what is going on. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-29sandbox: test: Provide an easy way to use the other FDTSimon Glass1-0/+3
Add a test flag which indicates that the 'other' FDT should be set up ready for use. Handle this by copying in the FDT, unflattening it for livetree tests. Free the structures when the tests have run. We cannot use the other FDT unless we are using live tree or OFNODE_MULTI_TREE is enabled, since only one tree is supported by the ofnode interface in that case. Add this condition into ut_run_test_live_flat() and update the comments. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-29sandbox: Support setting up the other FDT for testingSimon Glass1-2/+17
Provide a way to copy over the 'other' FDT when running tests. This loads it and allocates memory for the copy, if not done already, then does the copy. Avoid using U-Boot's malloc() pool for these copies, at least for now, since they are part of the test system. Tidy up the cpu.c header files while here. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-29test: Drop the UT_TESTF_LIVE_OR_FLAT flagSimon Glass1-2/+0
This was a workaround for a rare situation. Now that it will be more common and we have a proper fix, drop the flag. We can run both types of tests in the same sandbox executable, even if the flat device tree is modified. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-29test: Make a copy of the device tree before running a testSimon Glass1-0/+6
When the flat device tree changes it can mess up the live tree since that uses the flat tree for its strings. This affects only a few sandbox tests which modify the device tree, but the number will grow as ofnode support for writing improves. While the control FDT is not intended to change while U-Boot is running, some tests do so. For example, the ofnode interface only supports modifying properties in the control FDT, so tests must use that. To solve this problem, keep a copy of the FDT and restore it as needed when the test is finished. The copy only happens on sandbox (except SPL builds), to reduce memory usage and because these tests are not useful on other boards. For other boards, a checksum is taken to ensure that nothing changes. It would be possible to always checksum the FDT on sandbox and only restore it if needed, but this is slightly slower than restoring it every time, at least with crc8. Move the code which checks for success to the very end, for clarity. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-29test: Fix missing livetree test runsSimon Glass1-1/+1
At present the live tree tests are not run on sandbox. This bug is in two parts, with a duplicate flag value and incorrect logic in the test runner. This was not noticed because the bug was fixed in a later commit and does not cause test failures. Fix this. Fixes: 7b1dfc9fd7e ("dm: core: Prepare for updating the device tree with ofnode") Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-02test: Allow running tests multiple timesSimon Glass2-1/+4
Some tests can have race conditions which are hard to detect on a single one. Add a way to run tests more than once, to help with this. Each individual test is run the requested number of times before moving to the next test. If any runs failed, a message is shown. This is most useful when running a single test, since running all tests multiple times can take a while. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-08-12dm: core: Prepare for updating the device tree with ofnodeSimon Glass1-0/+2
Add some documentation and a new flag so that we can safely enabled using the ofnode interface to write to the device tree. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-07-26fdt: Start a test for the fdt commandSimon Glass1-0/+1
Add a basic test of the 'fdt addr' command, to kick things off. This includes a new convenience function to run a command from a printf() string. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-06-23test: fuzz: Add framework for fuzzingAndrew Scull1-0/+51
Add the basic infrastructure for declaring fuzz tests and a command to invoke them. Signed-off-by: Andrew Scull <ascull@google.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-06-22cmd: load: add load command for memory mappedRui Miguel Silva1-0/+1
cp.b is used a lot as a way to load binaries to memory and execute them, however we may need to integrate this with the efi subsystem to set it up as a bootdev. So, introduce a loadm command that will be consistent with the other loadX commands and will call the efi API's. ex: loadm $kernel_addr $kernel_addr_r $kernel_size with this a kernel with CONFIG_EFI_STUB enabled will be loaded and then subsequently booted with bootefi command. Signed-off-by: Rui Miguel Silva <rui.silva@linaro.org> Reviewed-by: Tom Rini <trini@konsulko.com>
2022-04-25bootstd: Add tests for bootstd including all uclassesSimon Glass1-0/+2
Add a set of combined tests for the bootdev, bootflow and bootmeth commands, along with associated functionality. Expand the sandbox console-recording limit so that these can work. These tests rely on a filesystem script which is not yet added to the Python tests. It is included here as a shell script. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-01-19doc: replace @return by Return:Heinrich Schuchardt2-11/+11
Sphinx expects Return: and not @return to indicate a return value. find . -name '*.c' -exec \ sed -i 's/^\(\s\)\*\(\s*\)@return\(\s\)/\1*\2Return:\3/' {} \; find . -name '*.h' -exec \ sed -i 's/^\(\s\)\*\(\s*\)@return\(\s\)/\1*\2Return:\3/' {} \; Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2021-09-16test: Add a way to skip console checking until a string matchesSimon Glass1-0/+24
Some tests produce a lot of output that does not need to be individually checked by an assertion. Add a macro to handle this. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-07-23test: add first autoboot unit testsSteffen Jaeckel2-0/+16
This adds tests for the crypt-based and plain SHA256-based password hashing algorithms in the autoboot flow. Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-06-08test: Add a test for print_buffer()Simon Glass1-2/+2
Add a test for this function, to cover the various features. Expand the expect_str length to take acount of the ~300-bytes lines generated in one case. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-06-08test: Convert print tests to use ut frameworkSimon Glass1-0/+1
This test predates the test framework in U-Boot. It uses #define DEBUG and assert() to check the result. Update it to use the framework so it can report failure constitent with other tests. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-05-27test: Remove duplicate macroSean Anderson1-17/+0
ut_asserteq_strn is defined twice. Remove one definition. Fixes: 33d7edfd5f ("test: Add a way to check part of a console line or skip it") Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-04-06test: Allow tests to run on any boardSimon Glass1-0/+9
Due to a recent change, tests are limited to running on sandbox only. Correct this so that any architecture can run them. Signed-off-by: Simon Glass <sjg@chromium.org> Reported-by: Sean Anderson <seanga2@gmail.com> Fixes: c79705ea938 ("test: Move dm_test_init() into test-main.c") Tested-by: Sean Anderson <seanga2@gmail.com>
2021-03-15Merge tag 'v2021.04-rc4' into nextTom Rini1-0/+2
Prepare v2021.04-rc4
2021-03-12test: Allow SPL to run any available testSimon Glass1-11/+5
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-4/+4
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 Glass1-0/+6
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: Run driver-model tests using ut_run_list()Simon Glass1-42/+0
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 Glass1-0/+14
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 Glass1-5/+8
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: Use ut_run_test() to run driver model testsSimon Glass1-20/+0
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-0/+16
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_init() into test-main.cSimon Glass1-9/+0
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 Glass1-2/+8
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-0/+12
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 Glass1-0/+11
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: Create pre/post-run functionsSimon Glass1-0/+20
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 Glass1-0/+42
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>