aboutsummaryrefslogtreecommitdiff
path: root/test/test-main.c
AgeCommit message (Collapse)AuthorFilesLines
2021-04-29test: Use positive conditional in test_matches()Andy Shevchenko1-6/+6
It is easier to read the positive conditional. While at it, convert hard coded length of "_test_" to strlen("_test_") which will be converted to a constant bu optimizing compiler. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-04-29test: Allow simple glob pattern in the test nameAndy Shevchenko1-2/+9
When run `ut dm [test name]` allow to use simple pattern to run all tests started with given prefix. For example, to run all ACPI test cases: ut dm acpi* Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-04-06test: Allow tests to run on any boardSimon Glass1-3/+2
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-26dm: test: Avoid destroying uclasses with of-platdata-instSimon Glass1-11/+19
It is not possible to destroy the uclasses when they are created at build time. Skip this step so that SPL test can complete successfully. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-12test: Allow SPL to run any available testSimon Glass1-4/+13
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: Move restoring of driver model state to ut_run_list()Simon Glass1-1/+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 Glass1-0/+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: Run driver-model tests using ut_run_list()Simon Glass1-11/+76
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/+18
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-3/+64
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-3/+23
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 Glass1-0/+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 Glass1-1/+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: Handle driver model reinit in test_pre_run()Simon Glass1-0/+3
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/+2
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 Glass1-1/+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 Glass1-3/+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 Glass1-0/+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 Glass1-0/+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 Glass1-0/+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 Glass1-1/+7
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 Glass1-0/+66
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>