Commit Graph

24 Commits

Author SHA1 Message Date
Andy Shevchenko 494a5e126b test: Use positive conditional in test_matches()
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-29 03:23:39 -07:00
Andy Shevchenko ff232a7296 test: Allow simple glob pattern in the test name
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-29 03:23:39 -07:00
Simon Glass d4a1592a99 test: Allow tests to run on any board
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: c79705ea93 ("test: Move dm_test_init() into test-main.c")
Tested-by: Sean Anderson <seanga2@gmail.com>
2021-04-06 16:33:19 +12:00
Simon Glass e8c023c3f9 dm: test: Avoid destroying uclasses with of-platdata-inst
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-26 17:03:08 +13:00
Simon Glass 8482356f48 test: Allow SPL to run any available test
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-12 09:57:31 -05:00
Simon Glass 664277f106 test: Move restoring of driver model state to ut_run_list()
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-12 09:57:30 -05:00
Simon Glass 1fc9c12210 test: Move the devicetree check into ut_run_list()
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-12 09:57:30 -05:00
Simon Glass f97f85e661 test: Run driver-model tests using ut_run_list()
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-12 09:57:30 -05:00
Simon Glass fe806861a9 test: Use a local variable for test state
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-12 09:57:30 -05:00
Simon Glass d2281bb09b test: Add ut_run_test_live_flat() to run tests twice
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-12 09:57:30 -05:00
Simon Glass ca44ca0556 test: Use ut_run_test() to run driver model tests
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-12 09:57:30 -05:00
Simon Glass 99a88fe1bd test: Move test running into a separate function
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-12 09:57:30 -05:00
Simon Glass e77615d3a7 test: Move dm_test_destroy() into test-main.c
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-12 09:57:30 -05:00
Simon Glass c79705ea93 test: Move dm_test_init() into test-main.c
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-12 09:57:30 -05:00
Simon Glass 72b524cf42 test: Handle driver model reinit in test_pre_run()
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-12 09:57:30 -05:00
Simon Glass 47ec3ede4e test: Move delay skipping to test_pre_run()
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-12 09:57:30 -05:00
Simon Glass 7452471287 test: Move console silencing to test_pre_run()
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-12 09:57:30 -05:00
Simon Glass 19fb3dba8e test: Drop mallinfo() work-around
This is not needed now. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-12 09:57:30 -05:00
Simon Glass 5a986f3fee test: Move dm_scan_plat() to test_pre_run()
Move this step over to the pre-run function.

Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-12 09:57:29 -05:00
Simon Glass 4b8b27e3d2 test: Move do_autoprobe() to test_pre_run()
Move this step over to the pre-run function.

Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-12 09:57:29 -05:00
Simon Glass d8ed234b29 test: Move dm_extended_scan() to test_pre_run()
Move this step over to the pre-run function.

Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-12 09:57:29 -05:00
Simon Glass 30a0d2064d test: Call test_pre/post_run() from driver model tests
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-12 09:57:29 -05:00
Simon Glass d002a27644 test: Create pre/post-run functions
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-12 09:57:29 -05:00
Simon Glass 1c7217511c test: Add an overall test runner
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-12 09:57:29 -05:00