History log of /u-boot/test/dm/test-dm.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# d678a59d 18-May-2024 Tom Rini <trini@konsulko.com>

Revert "Merge patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet""

When bringing in the series 'arm: dts: am62-beagleplay: Fix Beagleplay
Ethernet"' I failed to notice that b4 noticed it was based on next and
so took that as the base commit and merged that part of next to master.

This reverts commit c8ffd1356d42223cbb8c86280a083cc3c93e6426, reversing
changes made to 2ee6f3a5f7550de3599faef9704e166e5dcace35.

Reported-by: Jonas Karlman <jonas@kwiboo.se>
Signed-off-by: Tom Rini <trini@konsulko.com>

# 752ed086 27-Apr-2024 Tom Rini <trini@konsulko.com>

test: Remove <common.h> and add needed includes

Remove <common.h> from all "test/" files and when needed add
missing include files directly.

Signed-off-by: Tom Rini <trini@konsulko.com>

# fa1e420a 29-Oct-2022 Simon Glass <sjg@chromium.org>

dm: test: Drop the special function for running DM tests

This is not needed since the flag takes care of all differences. Make use
of the common function.

Signed-off-by: Simon Glass <sjg@chromium.org>

# cbd71fad 20-Oct-2022 Simon Glass <sjg@chromium.org>

test: Support tests which can only be run manually

At present we normally write tests either in Python or in C. But most
Python tests end up doing a lot of checks which would be better done in C.
Checks done in C are orders of magnitude faster and it is possible to get
full access to U-Boot's internal workings, rather than just relying on
the command line.

The model is to have a Python test set up some things and then use C code
(in a unit test) to check that they were done correctly. But we don't want
those checks to happen as part of normal test running, since each C unit
tests is dependent on the associate Python tests, so cannot run without
it.

To acheive this, add a new UT_TESTF_MANUAL flag to use with the C 'check'
tests, so that they can be skipped by default when the 'ut' command is
used. Require that tests have a name ending with '_norun', so that pytest
knows to skip them.

Signed-off-by: Simon Glass <sjg@chromium.org>

# ea94d053 01-Aug-2022 Simon Glass <sjg@chromium.org>

test: Allow running tests multiple times

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>

# 185f812c 19-Jan-2022 Heinrich Schuchardt <xypron.glpk@gmx.de>

doc: replace @return by Return:

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>

# 8482356f 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# a7a98755 07-Mar-2021 Simon Glass <sjg@chromium.org>

test: Add a macros for finding tests in linker_lists

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>

# 664277f1 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 1fc9c122 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 45d191af 07-Mar-2021 Simon Glass <sjg@chromium.org>

test: Use return values in dm_test_run()

Update this function to use the return value of ut_run_list() to check for
success/failure, so that they are in sync. Also return a command success
code so that the caller gets what it expects.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f97f85e6 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# fe806861 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# d2281bb0 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# c169d542 07-Mar-2021 Simon Glass <sjg@chromium.org>

test: Drop dm_do_test()

In an effort to make use of a common test runner, use ut_run_test()
directly to run driver model tests.

Signed-off-by: Simon Glass <sjg@chromium.org>

# ca44ca05 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# e77615d3 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# c79705ea 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 4a467c6d 07-Mar-2021 Simon Glass <sjg@chromium.org>

test: Drop struct dm_test_state

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>

# 72b524cf 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 47ec3ede 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 74524712 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 19fb3dba 07-Mar-2021 Simon Glass <sjg@chromium.org>

test: Drop mallinfo() work-around

This is not needed now. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5a986f3f 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 4b8b27e3 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# d8ed234b 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 30a0d206 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 409f4a2a 07-Mar-2021 Simon Glass <sjg@chromium.org>

test: Rename test-main.c to test-dm.c

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>

# 752ed086 27-Apr-2024 Tom Rini <trini@konsulko.com>

test: Remove <common.h> and add needed includes

Remove <common.h> from all "test/" files and when needed add
missing include files directly.

Signed-off-by: Tom Rini <trini@konsulko.com>

# fa1e420a 29-Oct-2022 Simon Glass <sjg@chromium.org>

dm: test: Drop the special function for running DM tests

This is not needed since the flag takes care of all differences. Make use
of the common function.

Signed-off-by: Simon Glass <sjg@chromium.org>

# cbd71fad 20-Oct-2022 Simon Glass <sjg@chromium.org>

test: Support tests which can only be run manually

At present we normally write tests either in Python or in C. But most
Python tests end up doing a lot of checks which would be better done in C.
Checks done in C are orders of magnitude faster and it is possible to get
full access to U-Boot's internal workings, rather than just relying on
the command line.

The model is to have a Python test set up some things and then use C code
(in a unit test) to check that they were done correctly. But we don't want
those checks to happen as part of normal test running, since each C unit
tests is dependent on the associate Python tests, so cannot run without
it.

To acheive this, add a new UT_TESTF_MANUAL flag to use with the C 'check'
tests, so that they can be skipped by default when the 'ut' command is
used. Require that tests have a name ending with '_norun', so that pytest
knows to skip them.

Signed-off-by: Simon Glass <sjg@chromium.org>

# ea94d053 01-Aug-2022 Simon Glass <sjg@chromium.org>

test: Allow running tests multiple times

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>

# 185f812c 19-Jan-2022 Heinrich Schuchardt <xypron.glpk@gmx.de>

doc: replace @return by Return:

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>

# 8482356f 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# a7a98755 07-Mar-2021 Simon Glass <sjg@chromium.org>

test: Add a macros for finding tests in linker_lists

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>

# 664277f1 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 1fc9c122 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 45d191af 07-Mar-2021 Simon Glass <sjg@chromium.org>

test: Use return values in dm_test_run()

Update this function to use the return value of ut_run_list() to check for
success/failure, so that they are in sync. Also return a command success
code so that the caller gets what it expects.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f97f85e6 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# fe806861 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# d2281bb0 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# c169d542 07-Mar-2021 Simon Glass <sjg@chromium.org>

test: Drop dm_do_test()

In an effort to make use of a common test runner, use ut_run_test()
directly to run driver model tests.

Signed-off-by: Simon Glass <sjg@chromium.org>

# ca44ca05 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# e77615d3 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# c79705ea 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 4a467c6d 07-Mar-2021 Simon Glass <sjg@chromium.org>

test: Drop struct dm_test_state

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>

# 72b524cf 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 47ec3ede 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 74524712 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 19fb3dba 07-Mar-2021 Simon Glass <sjg@chromium.org>

test: Drop mallinfo() work-around

This is not needed now. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5a986f3f 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 4b8b27e3 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# d8ed234b 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 30a0d206 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 409f4a2a 07-Mar-2021 Simon Glass <sjg@chromium.org>

test: Rename test-main.c to test-dm.c

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>

# fa1e420a 29-Oct-2022 Simon Glass <sjg@chromium.org>

dm: test: Drop the special function for running DM tests

This is not needed since the flag takes care of all differences. Make use
of the common function.

Signed-off-by: Simon Glass <sjg@chromium.org>

# cbd71fad 20-Oct-2022 Simon Glass <sjg@chromium.org>

test: Support tests which can only be run manually

At present we normally write tests either in Python or in C. But most
Python tests end up doing a lot of checks which would be better done in C.
Checks done in C are orders of magnitude faster and it is possible to get
full access to U-Boot's internal workings, rather than just relying on
the command line.

The model is to have a Python test set up some things and then use C code
(in a unit test) to check that they were done correctly. But we don't want
those checks to happen as part of normal test running, since each C unit
tests is dependent on the associate Python tests, so cannot run without
it.

To acheive this, add a new UT_TESTF_MANUAL flag to use with the C 'check'
tests, so that they can be skipped by default when the 'ut' command is
used. Require that tests have a name ending with '_norun', so that pytest
knows to skip them.

Signed-off-by: Simon Glass <sjg@chromium.org>

# ea94d053 01-Aug-2022 Simon Glass <sjg@chromium.org>

test: Allow running tests multiple times

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>

# 185f812c 19-Jan-2022 Heinrich Schuchardt <xypron.glpk@gmx.de>

doc: replace @return by Return:

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>

# 8482356f 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# a7a98755 07-Mar-2021 Simon Glass <sjg@chromium.org>

test: Add a macros for finding tests in linker_lists

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>

# 664277f1 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 1fc9c122 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 45d191af 07-Mar-2021 Simon Glass <sjg@chromium.org>

test: Use return values in dm_test_run()

Update this function to use the return value of ut_run_list() to check for
success/failure, so that they are in sync. Also return a command success
code so that the caller gets what it expects.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f97f85e6 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# fe806861 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# d2281bb0 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# c169d542 07-Mar-2021 Simon Glass <sjg@chromium.org>

test: Drop dm_do_test()

In an effort to make use of a common test runner, use ut_run_test()
directly to run driver model tests.

Signed-off-by: Simon Glass <sjg@chromium.org>

# ca44ca05 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# e77615d3 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# c79705ea 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 4a467c6d 07-Mar-2021 Simon Glass <sjg@chromium.org>

test: Drop struct dm_test_state

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>

# 72b524cf 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 47ec3ede 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 74524712 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 19fb3dba 07-Mar-2021 Simon Glass <sjg@chromium.org>

test: Drop mallinfo() work-around

This is not needed now. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5a986f3f 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 4b8b27e3 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# d8ed234b 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 30a0d206 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 409f4a2a 07-Mar-2021 Simon Glass <sjg@chromium.org>

test: Rename test-main.c to test-dm.c

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>

# cbd71fad 20-Oct-2022 Simon Glass <sjg@chromium.org>

test: Support tests which can only be run manually

At present we normally write tests either in Python or in C. But most
Python tests end up doing a lot of checks which would be better done in C.
Checks done in C are orders of magnitude faster and it is possible to get
full access to U-Boot's internal workings, rather than just relying on
the command line.

The model is to have a Python test set up some things and then use C code
(in a unit test) to check that they were done correctly. But we don't want
those checks to happen as part of normal test running, since each C unit
tests is dependent on the associate Python tests, so cannot run without
it.

To acheive this, add a new UT_TESTF_MANUAL flag to use with the C 'check'
tests, so that they can be skipped by default when the 'ut' command is
used. Require that tests have a name ending with '_norun', so that pytest
knows to skip them.

Signed-off-by: Simon Glass <sjg@chromium.org>

# ea94d053 01-Aug-2022 Simon Glass <sjg@chromium.org>

test: Allow running tests multiple times

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>

# 185f812c 19-Jan-2022 Heinrich Schuchardt <xypron.glpk@gmx.de>

doc: replace @return by Return:

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>

# 8482356f 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# a7a98755 07-Mar-2021 Simon Glass <sjg@chromium.org>

test: Add a macros for finding tests in linker_lists

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>

# 664277f1 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 1fc9c122 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 45d191af 07-Mar-2021 Simon Glass <sjg@chromium.org>

test: Use return values in dm_test_run()

Update this function to use the return value of ut_run_list() to check for
success/failure, so that they are in sync. Also return a command success
code so that the caller gets what it expects.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f97f85e6 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# fe806861 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# d2281bb0 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# c169d542 07-Mar-2021 Simon Glass <sjg@chromium.org>

test: Drop dm_do_test()

In an effort to make use of a common test runner, use ut_run_test()
directly to run driver model tests.

Signed-off-by: Simon Glass <sjg@chromium.org>

# ca44ca05 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# e77615d3 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# c79705ea 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 4a467c6d 07-Mar-2021 Simon Glass <sjg@chromium.org>

test: Drop struct dm_test_state

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>

# 72b524cf 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 47ec3ede 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 74524712 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 19fb3dba 07-Mar-2021 Simon Glass <sjg@chromium.org>

test: Drop mallinfo() work-around

This is not needed now. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5a986f3f 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 4b8b27e3 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# d8ed234b 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 30a0d206 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 409f4a2a 07-Mar-2021 Simon Glass <sjg@chromium.org>

test: Rename test-main.c to test-dm.c

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>

# ea94d053 01-Aug-2022 Simon Glass <sjg@chromium.org>

test: Allow running tests multiple times

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>

# 185f812c 19-Jan-2022 Heinrich Schuchardt <xypron.glpk@gmx.de>

doc: replace @return by Return:

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>

# 8482356f 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# a7a98755 07-Mar-2021 Simon Glass <sjg@chromium.org>

test: Add a macros for finding tests in linker_lists

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>

# 664277f1 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 1fc9c122 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 45d191af 07-Mar-2021 Simon Glass <sjg@chromium.org>

test: Use return values in dm_test_run()

Update this function to use the return value of ut_run_list() to check for
success/failure, so that they are in sync. Also return a command success
code so that the caller gets what it expects.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f97f85e6 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# fe806861 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# d2281bb0 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# c169d542 07-Mar-2021 Simon Glass <sjg@chromium.org>

test: Drop dm_do_test()

In an effort to make use of a common test runner, use ut_run_test()
directly to run driver model tests.

Signed-off-by: Simon Glass <sjg@chromium.org>

# ca44ca05 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# e77615d3 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# c79705ea 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 4a467c6d 07-Mar-2021 Simon Glass <sjg@chromium.org>

test: Drop struct dm_test_state

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>

# 72b524cf 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 47ec3ede 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 74524712 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 19fb3dba 07-Mar-2021 Simon Glass <sjg@chromium.org>

test: Drop mallinfo() work-around

This is not needed now. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5a986f3f 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 4b8b27e3 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# d8ed234b 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 30a0d206 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 409f4a2a 07-Mar-2021 Simon Glass <sjg@chromium.org>

test: Rename test-main.c to test-dm.c

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>

# 185f812c 19-Jan-2022 Heinrich Schuchardt <xypron.glpk@gmx.de>

doc: replace @return by Return:

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>

# 8482356f 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# a7a98755 07-Mar-2021 Simon Glass <sjg@chromium.org>

test: Add a macros for finding tests in linker_lists

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>

# 664277f1 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 1fc9c122 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 45d191af 07-Mar-2021 Simon Glass <sjg@chromium.org>

test: Use return values in dm_test_run()

Update this function to use the return value of ut_run_list() to check for
success/failure, so that they are in sync. Also return a command success
code so that the caller gets what it expects.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f97f85e6 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# fe806861 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# d2281bb0 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# c169d542 07-Mar-2021 Simon Glass <sjg@chromium.org>

test: Drop dm_do_test()

In an effort to make use of a common test runner, use ut_run_test()
directly to run driver model tests.

Signed-off-by: Simon Glass <sjg@chromium.org>

# ca44ca05 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# e77615d3 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# c79705ea 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 4a467c6d 07-Mar-2021 Simon Glass <sjg@chromium.org>

test: Drop struct dm_test_state

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>

# 72b524cf 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 47ec3ede 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 74524712 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 19fb3dba 07-Mar-2021 Simon Glass <sjg@chromium.org>

test: Drop mallinfo() work-around

This is not needed now. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5a986f3f 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 4b8b27e3 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# d8ed234b 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 30a0d206 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 409f4a2a 07-Mar-2021 Simon Glass <sjg@chromium.org>

test: Rename test-main.c to test-dm.c

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>

# 8482356f 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# a7a98755 07-Mar-2021 Simon Glass <sjg@chromium.org>

test: Add a macros for finding tests in linker_lists

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>

# 664277f1 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 1fc9c122 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 45d191af 07-Mar-2021 Simon Glass <sjg@chromium.org>

test: Use return values in dm_test_run()

Update this function to use the return value of ut_run_list() to check for
success/failure, so that they are in sync. Also return a command success
code so that the caller gets what it expects.

Signed-off-by: Simon Glass <sjg@chromium.org>

# f97f85e6 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# fe806861 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# d2281bb0 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# c169d542 07-Mar-2021 Simon Glass <sjg@chromium.org>

test: Drop dm_do_test()

In an effort to make use of a common test runner, use ut_run_test()
directly to run driver model tests.

Signed-off-by: Simon Glass <sjg@chromium.org>

# ca44ca05 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# e77615d3 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# c79705ea 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 4a467c6d 07-Mar-2021 Simon Glass <sjg@chromium.org>

test: Drop struct dm_test_state

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>

# 72b524cf 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 47ec3ede 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 74524712 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 19fb3dba 07-Mar-2021 Simon Glass <sjg@chromium.org>

test: Drop mallinfo() work-around

This is not needed now. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>

# 5a986f3f 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 4b8b27e3 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# d8ed234b 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 30a0d206 07-Mar-2021 Simon Glass <sjg@chromium.org>

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>

# 409f4a2a 07-Mar-2021 Simon Glass <sjg@chromium.org>

test: Rename test-main.c to test-dm.c

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>