summaryrefslogtreecommitdiffstats
path: root/include/test/test.h
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* 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: 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-121-0/+2
| | | | | | | | | | 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: 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: 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>
* 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 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>
* test: describe naming conventions for macro UNIT_TESTHeinrich Schuchardt2020-05-081-1/+23
| | | | | | | | | | | | Strict naming conventions have to be followed for Python function generate_ut_subtest() to collect C unit tests to be executed via command 'ut'. Describe the requirements both on the C as well on the Python side. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Stephen Warren <swarren@nvidia.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* test: Add a way to check each line of console outputSimon Glass2020-02-051-0/+4
| | | | | | | | | | | | | When writing tests to check the output from commands it is useful to be able to check the output line by line using an assertion. Add helper macros to support this and to check that there is no unexpected trailing data. Also some commands produce a dump using print_buffer(). Add a way to check that the correct number of bytes are dumped (ignoring the actual contents). Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: devres: Add a new OFDATA phaseSimon Glass2020-01-071-1/+2
| | | | | | | Since the ofdata_to_platdata() method can allocate resources, add it as a new devres phase. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: test: Add a test driver for devresSimon Glass2020-01-071-0/+9
| | | | | | | Add a driver which does devres allocations so that we can write tests for devres. Signed-off-by: Simon Glass <sjg@chromium.org>
* SPDX: Convert all of our single license tags to Linux Kernel styleTom Rini2018-05-071-2/+1
| | | | | | | | | | | | | | | | | | | | When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>
* dm: core: Run tests with both livetree and flat treeSimon Glass2017-06-011-0/+2
| | | | | | | | | | | Some tests require either livetree or flat tree. Add flags to allow the tests to specify this. Adjust the test runner to run with livetree (if supported) and then flat tree. Some video tests are quite slow and running on flat tree adds little extra test value, so run these on livetree only. Signed-off-by: Simon Glass <sjg@chromium.org>
* dm: test: Show the test filename when runningSimon Glass2017-06-011-0/+2
| | | | | | | Show the filename of the test being run. Skip the path and show just the base name. Signed-off-by: Simon Glass <sjg@chromium.org>
* test: Generalize the unit test frameworkJoe Hershberger2015-05-211-0/+47
Separate the ability to define tests and assert status of test functions from the dm tests so they can be used more consistently throughout all tests. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Reviewed-by: Simon Glass <sjg@chromium.org>