Commit graph

110 commits

Author SHA1 Message Date
Simon Glass
404cdf0cda test: Update documentation
Update documentation for how to write tests and the 'ut' command.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-11 20:12:36 -06:00
Simon Glass
540bf7881a test: Do flag-processing in the correct place
At present the 'ut' command handles its flags in a strange way, in that
they must come after the subcommand.

So, we must use 'ut bloblist -r2' to run the bloblist tests twice. This
is an artefact of the way tests were run, through subcommands.

It is now possible to correct this, by doing flag-processing before
running the suite.

Update the code to handle this, so that 'ut -r2 bloblist' works. Update
the 'test_suite' test to check the new arguments.

Add a sanity-check for -I while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-11 20:12:36 -06:00
Simon Glass
d45fc8b2cd test: Move code out of cmd_ut_category()
Move the logic from this function into run_suite(), on the way to having
flag parsing in the top-level 'ut' command instead of its children.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-11 20:12:36 -06:00
Simon Glass
fa0b68d22a test: Allow running a selection of suites
Enhance the ut command to accept a comma-separated list of test suites
to run. Report the summary information for these at the end.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-11 20:12:36 -06:00
Simon Glass
32aba887e3 test: Drop suites.h
This file is empty now. Remove it and its uses.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-11 20:12:36 -06:00
Simon Glass
854225191a test: Make cmd_ut_category() static
This function is not used outside the cmd_ut file anymore, so make it
static.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-11 20:10:59 -06:00
Simon Glass
59713c412a test: Drop support for test commands
Now that everything is using the new test-suite features, drop support
for running commands.

Fix a missing closing-bracket while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-11 20:10:59 -06:00
Simon Glass
daf583a317 test: Drop the function for running optee tests
Use the new suite-runner to run these tests instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-11 20:10:59 -06:00
Simon Glass
7e1c6bd077 test: Drop the function for running bootstd tests
Use the new suite-runner to run these tests instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-11 20:10:59 -06:00
Simon Glass
ba1112839a test: Drop the function for running fdt_overlay tests
Use the new suite-runner to run these tests instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-11 20:10:59 -06:00
Simon Glass
ea29bad9cf test: Tweak FDT-overlay tests
Use fdt_overlay consistently in the identifiers and file/dir names.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-11 20:10:58 -06:00
Simon Glass
63adc40d4c test: Leave out the prefix when printing test names
When tests are all in the same suite it is annoying to have to read all
the common text after each name. Skip this to help the user.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-11 20:10:58 -06:00
Simon Glass
b85df267e1 test: Show the average time per test
Show the average duration of a test, so we can keep track of how it is
trending. Report the suite with the longest average test to encourage
people to improve it.

Add a function to update the stats based on the results from a single
suite and another to show the summary information.

Make this optional, since sandbox's SPL tests do not have a timer driver
and people may want to print results without times.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-11 20:10:58 -06:00
Simon Glass
5c47e432fd test: Add up the number of tests manually
All tests should belong to a suite, but if there is a suite we don't
know about (e.g. not added to cmd_ut.c) then the totals will not add up.
Add a check for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-11 20:10:58 -06:00
Simon Glass
fc7968c118 test: Move help into the suite declaration
Rather than having the help in the longhelp, put it in the suite info
so 'ut info -s' can show it. This is tidier, particular due to the
removal of #ifdefs

This means that the help text is present in the image (although not
displayed with 'ut info -s') so the image-size increases. But with
UNIT_TEST enabled, we expect large images so this doesn't seem
important.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 14:34:41 -06:00
Simon Glass
18aa9913a1 test: Sort the test suites
Put the suites in order by name, for easier code-maintenance. This also
helps find test results for a particular swuit in the 'ut all' output.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 14:34:41 -06:00
Simon Glass
6d97c98095 test: Record and show the totals for all test runs
With 'ut all' multiple test suites are run. Add a way to collect totals
and show them at the end.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 14:34:41 -06:00
Simon Glass
bbff0b165c test: Pass the test state to cmd_ut_category()
Update this function to access a unit-test state, so that the caller can
collect results from running multiple suites.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 14:34:41 -06:00
Simon Glass
374203bd2e test: Drop conditional compilation for suites
This is not needed anymore. If a test suite is not built, then it will
have no linker-list entries. So we can just check for that and know that
the suite is not present.

This allows removal of the #ifdefs and the need to keep them in sync
with the associated Makefile rules, which has actually failed, since the
help does not match what commands are actually present.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 14:34:41 -06:00
Simon Glass
81c5434f49 test: Drop the info test from the list
The 'info' test is not a real test. With the new suite array we can drop
this and the associated special-case code.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 14:34:41 -06:00
Simon Glass
0af17462b9 test: Drop the function for running upl tests
Use the new suite-runner to run these tests instead.

It is not clear that these actually work, since they are not enabled on
sandbox for some reason.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 14:34:40 -06:00
Simon Glass
b073d8a272 test: Drop the function for running seama tests
Use the new suite-runner to run these tests instead.

It is not clear that these actually work, since they are not enabled on
sandbox for some reason.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
2025-01-24 14:34:40 -06:00
Simon Glass
a2cf88d807 test: Drop the function for running pci_mps tests
Use the new suite-runner to run these tests instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 14:34:40 -06:00
Simon Glass
822cb558e1 test: Drop the function for running loadm tests
Use the new suite-runner to run these tests instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 14:34:40 -06:00
Simon Glass
d5e5cb48e6 test: Drop the function for running hush tests
Use the new suite-runner to run these tests instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 14:34:40 -06:00
Simon Glass
e6959512b6 test: Drop the function for running addrmap tests
Use the new suite-runner to run these tests instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 14:34:40 -06:00
Simon Glass
1ca67c3f04 test: Drop the function for running bootm tests
Use the new suite-runner to run these tests instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 14:34:40 -06:00
Simon Glass
28b32858aa test: Drop the function for running bloblist tests
Use the new suite-runner to run these tests instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 14:34:40 -06:00
Simon Glass
446e6f9cd3 test: Drop the function for running measurement tests
Use the new suite-runner to run these tests instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 14:34:40 -06:00
Simon Glass
cebdc5376f test: Drop the function for running setexpr tests
Use the new suite-runner to run these tests instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 14:34:40 -06:00
Simon Glass
bda212bad5 test: Drop the function for running mem tests
Use the new suite-runner to run these tests instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 14:34:40 -06:00
Simon Glass
1ade3afa2d test: Drop the function for running mbr tests
Use the new suite-runner to run these tests instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 14:34:40 -06:00
Simon Glass
87cf479fdb test: Drop the function for running log tests
Use the new suite-runner to run these tests instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 14:34:40 -06:00
Simon Glass
d824e20fc2 test: Drop the function for running lib tests
Use the new suite-runner to run these tests instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 14:34:40 -06:00
Simon Glass
a9976e52be test: Drop the function for running font tests
Use the new suite-runner to run these tests instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 14:34:40 -06:00
Simon Glass
45dfbdde37 test: Drop the function for running fdt tests
Use the new suite-runner to run these tests instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 14:34:40 -06:00
Simon Glass
ca917e491f test: Drop the function for running exit tests
Use the new suite-runner to run these tests instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 14:34:40 -06:00
Simon Glass
3e5e638e62 test: Drop the function for running env tests
Use the new suite-runner to run these tests instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 14:34:40 -06:00
Simon Glass
7c012db106 test: Drop the function for running dm tests
Use the new suite-runner to run these tests instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 14:34:40 -06:00
Simon Glass
cfc0f46cd0 test: Drop the function for running common tests
Use the new suite-runner to run these tests instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 14:34:40 -06:00
Simon Glass
6054e8463c test: Drop the function for running cmd tests
Use the new suite-runner to run these tests instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 14:34:40 -06:00
Simon Glass
9e93c249f7 test: Drop the function for running bdinfo tests
Use the new suite-runner to run these tests instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 14:34:40 -06:00
Simon Glass
7bbf2f7983 test: Introduce a better array of test suites
The current cmd_ut_sub[] array was fine when there were only a few test
suites. But is quite unwieldy now:

- it requires a separate do_ut_xxx for each suite, even though the code
  for most is almost identical
- running more than one suite requires running multiple commands, and
  there is no record of which suites passed or failed
- 'ut all' runs all suites but reports their results individually
- we need lots of #ifdefs in the array, mirroring those in the makefile
  but maintained in a separate place

In fact the tests are all in the same linker list. The suites are
grouped, so it is possible to access the information without a command.

Introduce a 'suite' array, which holds the cmd_ut_...() function to
call, but can also support running a suite without that function. This
means that the array of struct cmd_tbl is transformed into an array of
'struct suite'.

This will allow removal of many of the functions, particularly those
without test-specific init.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 14:34:40 -06:00
Simon Glass
c16b388ea8 test/py: Add a test which runs all unit tests
Add a Python test which runs 'ut all' and then checks that the expected
suites are present and all tests in each suite are run.

This can help to check that nothing is missing.

Update 'ut info' to ignore the 'all' suite when counting the number of
suites, since that is really just a combination of all the other suites.

Adjust the message for skipped tests so that appears even if no
particular test was selected. This helps the new 'test_suite' test see
what is going on.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 14:34:40 -06:00
Simon Glass
67f84dba6b test: Update ut info to show suites
It is helpful to see a list of available suites. At present this is
handled by the longhelp for the 'ut' command, but this is not in a
format which can be easily parsed by python tests.

Add a -s option to show this. At present it is not possible to show the
number of tests in each suite, but future work will address this. For
now, show a ?

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 14:34:40 -06:00
Simon Glass
94b5284398 test: Pass the test-state into ut_run_list()
Pass this into the function so that callers can inspect the state
afterwards.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-01-24 14:34:39 -06:00
Evgeny Bachinin
90856d695f test: sandbox: fix link error with do_ut_bootm if BLOBLIST=n
Having CONFIG_OF_EMBED=y && CONFIG_BLOBLIST=n leads to the link
error:
```
ld: /tmp/ccwtRVty.ltrans28.ltrans.o:(.data.rel+0x4e8): undefined \
                                            reference to `do_ut_bootm'
```

Fixes: fe158657a5 ("test: inconsistent bootm tests")
Signed-off-by: Evgeny Bachinin <EABachinin@salutedevices.com>
2024-12-18 15:19:16 -06:00
Evgeny Bachinin
6970eeb788 test: sandbox: fix link error with do_ut_bloblist if BLOBLIST=n
Having CONFIG_OF_EMBED=y && CONFIG_BLOBLIST=n leads to the link
error:
```
ld: /tmp/ccwtRVty.ltrans28.ltrans.o:(.data.rel+0x4b0): undefined \
                                         reference to `do_ut_bloblist'
```

Fixes: 6ea5df39e8 ("test: Only enable bloblist test when supported")
Signed-off-by: Evgeny Bachinin <EABachinin@salutedevices.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2024-12-18 15:19:16 -06:00
Simon Glass
dd0057dacb test: Move time tests into the lib suite
There is no particular need for the time tests to have their own test
command. Move them into the lib suite instead.

Update the test functions to match the normal unit-test signature.

Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Tom Rini <trini@konsulko.com> # rpi_3, rpi_4, rpi_arm64, am64x_evm_a53, am64-sk
2024-11-13 11:56:02 -06:00
Simon Glass
5912a9ea1a test: Move unicode tests into the lib suite
There is no particular need for the unicode tests to have their own test
suite. Move them into the lib suite instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Tested-by: Tom Rini <trini@konsulko.com> # rpi_3, rpi_4, rpi_arm64, am64x_evm_a53, am64-sk
2024-11-13 11:56:02 -06:00