dm: test: Add a way to run SPL tests
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>
This commit is contained in:
@@ -374,6 +374,15 @@ static int sandbox_cmdline_cb_show_of_platdata(struct sandbox_state *state,
|
||||
}
|
||||
SANDBOX_CMDLINE_OPT(show_of_platdata, 0, "Show of-platdata in SPL");
|
||||
|
||||
static int sandbox_cmdline_cb_unittests(struct sandbox_state *state,
|
||||
const char *arg)
|
||||
{
|
||||
state->run_unittests = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
SANDBOX_CMDLINE_OPT_SHORT(unittests, 'u', 0, "Run unit tests");
|
||||
|
||||
static void setup_ram_buf(struct sandbox_state *state)
|
||||
{
|
||||
/* Zero the RAM buffer if we didn't read it, to keep valgrind happy */
|
||||
|
||||
Reference in New Issue
Block a user