summaryrefslogtreecommitdiff
path: root/include/test
Commit message (Collapse)AuthorAgeFilesLines
* video: Add commands to list and change fontsSimon Glass2022-10-301-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>
* dm: core: Complete phandle implementation using the other FDTSimon Glass2022-09-291-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>
* sandbox: test: Provide an easy way to use the other FDTSimon Glass2022-09-291-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>
* sandbox: Support setting up the other FDT for testingSimon Glass2022-09-291-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>
* test: Drop the UT_TESTF_LIVE_OR_FLAT flagSimon Glass2022-09-291-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>
* test: Make a copy of the device tree before running a testSimon Glass2022-09-291-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>
* test: Fix missing livetree test runsSimon Glass2022-09-291-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>
* test: Allow running tests multiple timesSimon Glass2022-09-022-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>
* dm: core: Prepare for updating the device tree with ofnodeSimon Glass2022-08-121-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>
* fdt: Start a test for the fdt commandSimon Glass2022-07-261-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>
* test: fuzz: Add framework for fuzzingAndrew Scull2022-06-231-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>
* cmd: load: add load command for memory mappedRui Miguel Silva2022-06-221-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>
* bootstd: Add tests for bootstd including all uclassesSimon Glass2022-04-251-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>
* doc: replace @return by Return:Heinrich Schuchardt2022-01-192-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>
* test: Add a way to skip console checking until a string matchesSimon Glass2021-09-161-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>
* test: add first autoboot unit testsSteffen Jaeckel2021-07-232-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>
* test: Add a test for print_buffer()Simon Glass2021-06-081-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>
* test: Convert print tests to use ut frameworkSimon Glass2021-06-081-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>
* test: Remove duplicate macroSean Anderson2021-05-261-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>
* test: Allow tests to run on any boardSimon Glass2021-04-061-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>
* Merge tag 'v2021.04-rc4' into nextTom Rini2021-03-151-0/+2
|\ | | | | | | Prepare v2021.04-rc4
| * test: cmd: Add a basic test for 'addrmap' commandBin Meng2021-03-051-0/+2
| | | | | | | | | | | | | | | | | | 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>
* | test: Allow SPL to run any available testSimon Glass2021-03-121-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>
* | test: Rename all linker lists to have a ut_ prefixSimon Glass2021-03-121-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>
* | test: Add a macros for finding tests in linker_listsSimon Glass2021-03-121-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>
* | test: Run driver-model tests using ut_run_list()Simon Glass2021-03-121-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>
* | test: Use a local variable for test stateSimon Glass2021-03-121-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>
* | test: Add ut_run_test_live_flat() to run tests twiceSimon Glass2021-03-121-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>
* | test: Use ut_run_test() to run driver model testsSimon Glass2021-03-121-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>
* | test: Move test running into a separate functionSimon Glass2021-03-121-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>
* | test: Move dm_test_init() into test-main.cSimon Glass2021-03-121-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>
* | test: Drop struct dm_test_stateSimon Glass2021-03-121-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>
* | test: Handle driver model reinit in test_pre_run()Simon Glass2021-03-122-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>
* | test: Move delay skipping to test_pre_run()Simon Glass2021-03-121-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>
* | test: Create pre/post-run functionsSimon Glass2021-03-121-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>
* | test: Add an overall test runnerSimon Glass2021-03-121-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>
* | test: Rename test-main.c to test-dm.cSimon Glass2021-03-121-2/+2
| | | | | | | | | | | | | | 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>
* | test: Mark all driver model tests with a flagSimon Glass2021-03-121-0/+2
|/ | | | | | | Add a flag for driver model tests, so we can do special processing for them. Signed-off-by: Simon Glass <sjg@chromium.org>
* test: Avoid assuming sandbox board for bloblist testSimon Glass2021-01-161-0/+18
| | | | | | | | | This tests assumes it is running on sandbox. Add a few functions to handle silencing the console on any board and use those instead. Reported-by: Kever Yang <kever.yang@rock-chips.com> Signed-off-by: Simon Glass <sjg@chromium.org>
* test: Move some test drivers into their own fileSimon Glass2021-01-051-0/+9
| | | | | | | | | | | At present several test drivers are part of the test file itself. Some of these are useful for of-platdata tests. Separate them out so we can use them for other things also. A few adjustments are needed so this driver can build for sandbox_spl as well. Signed-off-by: Simon Glass <sjg@chromium.org>
* bootm: Add tests for fixup_silent_linux()Simon Glass2020-12-041-0/+1
| | | | | | | | This function currently has no tests. Export it so that we can implement a simple test on sandbox. Use IS_ENABLED() to remove the unused code, instead #ifdef. Signed-off-by: Simon Glass <sjg@chromium.org>
* test: Add some tests for setexprSimon Glass2020-12-011-0/+2
| | | | | | | | | | | This command currently has no tests. Add some for basic assignment and the integer operations. Note that the default size for setexpr is ulong, which varies depending on the build machine. So for sandbox on a 64-bit host, this means that the default size is 64 bits. Signed-off-by: Simon Glass <sjg@chromium.org>
* Merge tag 'dm-pull-30oct20' of ↵Tom Rini2020-10-301-0/+11
|\ | | | | | | | | | | | | | | https://gitlab.denx.de/u-boot/custodians/u-boot-dm of-platdata and dtoc improvements sandbox SPL tests binman support for compressed sections
| * dm: test: Add a way to run SPL testsSimon Glass2020-10-291-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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. Signed-off-by: Simon Glass <sjg@chromium.org>
* | test: Add a test for log filter-*Sean Anderson2020-10-301-0/+1
| | | | | | | | | | | | | | | | | | | | This exercises a few success and failure modes of the log filter-* commands. log filter-list is not tested because it's purely informational. I don't think there's a good way to test it except by testing if the output of the command exactly matches a sample run. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* | test: log: Convert log_test from python to CSean Anderson2020-10-301-0/+2
|/ | | | | | | | | | | | | | | | When rebasing this series I had to renumber all my log tests because someone made another log test in the meantime. This involved updaing a number in several places (C and python), and it wasn't checked by the compiler. So I though "how hard could it be to just rewrite in C?" And though it wasn't hard, it *was* tedious. Tests are numbered the same as before to allow for easier review. A note that if a test fails, everything after it will probably also fail. This is because that test won't clean up its filters. There's no easy way to do the cleanup, except perhaps removing all filters in a wrapper function. Signed-off-by: Sean Anderson <seanga2@gmail.com>
* bloblist: Compare addresses rather than pointers in testsSimon Glass2020-10-061-0/+13
| | | | | | | | When running these tests on sandbox any failures result in very large or long pointer values which are a pain to work with. Map them to an address so it is easier to diagnose failures. Signed-off-by: Simon Glass <sjg@chromium.org>
* cmd: Update the memory-search commandSimon Glass2020-08-071-0/+1
| | | | | | | | | | | | | | Add various fixes and improvements to this command that were missed in the original version. Unfortunately I forgot to send v2. - Fix Kconfig name - Use a separate variable for the remaining search length - Correct a minor bug - Move into a separate test suite - Add -q flag to the 'quiet' test to test operation when console is enabled - Enable the feature for sandbox Signed-off-by: Simon Glass <sjg@chromium.org>
* test: Add a flag for tests that need console recordingSimon Glass2020-08-071-0/+1
| | | | | | | Allow tests that need console recording to be marked, so they can be skipped if it is not available. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: Rename DM test flags to make them more genericSimon Glass2020-08-071-0/+10
| | | | | | | | | | The test flags used by driver model are currently not available to other tests. Rather than creating two sets of flags, make these flags generic by changing the DM_ prefix to UT_ and moving them to the test.h header. This will allow adding other test flags without confusion. Signed-off-by: Simon Glass <sjg@chromium.org>