Commit graph

2674 commits

Author SHA1 Message Date
Gabriel Dalimonte
06159a1465 fs: fat: add rename
The implementation roughly follows the POSIX specification for
rename() [1]. The ordering of operations attempting to minimize the chance
for data loss in unexpected circumstances.

The 'mv' command was implemented as a front end for the rename operation
as that is what most users are likely familiar with in terms of behavior.

The 'FAT_RENAME' Kconfig option was added to prevent code size increase on
size-oriented builds like SPL.

[1] https://pubs.opengroup.org/onlinepubs/9799919799/functions/rename.html

Signed-off-by: Gabriel Dalimonte <gabriel.dalimonte@gmail.com>
2025-03-07 11:50:22 -06:00
Tom Rini
3ecda19009 Prepare v2025.04-rc3
-----BEGIN PGP SIGNATURE-----
 
 iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAme8+MQACgkQFHw5/5Y0
 tywiiQv+IQhGDnt1knghs1f3N/ImsAof4EG44MuuaYFFIb25NC4WO55rG2J5Jmd/
 zrUEKnwMWjDUmKqt9BneQ+NfsOTKfnUWiSdTv2KOsI/FJGOj0KhU8TDA6qdiR6Ev
 thfN5QKLtSrIgg3ua19LUT1+AComjD6w86GRwpQ2iSy6WuPlqlU3VDB1JndXMDh1
 VIz1wuGp8CFgZWb1h8yznajObqK6PBnGwX3MVkPrV7oUSJgVq7dNid/1NFDl+EsV
 SDKEjUJbnAoWiXbW3q+lBfpyxZ7jnTNl6d5nssnmjTlpOradaEOsaj7Y3MRliSQs
 1Fe6rRd4rEr7jI8jBvyveXEJ8ahocTP0haC5MRhin8R6ZO0faQbm1UVVKINuvVIn
 nNU62IInPJXTVPUBFTnZGnwtowmzSdOyBaLcjzFCGD4M9MOikWNwzymIMN7tinyO
 yAy3eJIwqLJ/AtuqYGIbs5wkRcwZnLz0QM9ebBl8lYzmezsx21Z3LpUqAjhUb9Nr
 nJJrzI2/
 =ExnJ
 -----END PGP SIGNATURE-----

Merge tag 'v2025.04-rc3' into next

Prepare v2025.04-rc3
2025-02-24 17:15:14 -06:00
Tom Rini
ea9131d904 test/py: Have test_usb.py raise an Exception with unsupported filesystems
With a newer pylint we get a warning about how offset could be used
before assigned. This is because when the underlying filesystem wasn't
one that is supported we would have runtime test failures. Address this
by raise'ing an Exception if fs is not supported.

Signed-off-by: Tom Rini <trini@konsulko.com>
2025-02-21 08:24:05 -06:00
Tom Rini
203d3a9fc7 test/py: Rework how test_ums.py handles (not) having write enabled
With a newer pylint version we get a warning about how mounted_test_fn
could be used before assignment. Evaluating the code, this can't happen
because we check for "not have_writable_fs_partition" and return before
moving to the part of the tests which use mounted_test_fn. However, we
should instead have this written so that we only try this part of the
test if have_writable_fs_partition is set, and this also fixes the
warning. As part of this we also move test_f and mounted_test_fn to the
section of code that already only does this if
have_writable_fs_partition is set.

Signed-off-by: Tom Rini <trini@konsulko.com>
2025-02-21 08:24:02 -06:00
Tom Rini
3e335ddca6 test/py: Rework test_spi.py to assert we found output
When running a newer version of pylint it will complain that page_size
may be used before being assignment. Looking deeper what is going on is
that we could run in to the case where the regex we run for any of the
flash information fails but since we don't have a result, we don't check
it either. In the case of the rest of the numerical values we then have
some assignment (multiplying by some value) and so pylint doesn't
complain. Rework things to assert that each regex has a result and so
failure will stop the test and we won't have any use before assignment.

Signed-off-by: Tom Rini <trini@konsulko.com>
2025-02-21 08:23:59 -06:00
Heinrich Schuchardt
bd8bc53162 efi_driver: create a parent device for all EFI block devices
Up to now root has been the parent device for all block devices created via
calling ConnectController(). This does not work well together with the
implementation of bootstd.

Add a dummy parent device for all EFI block devices.

With this change EFI block devices are also accessible via commands like
'cat', 'load', and 'ls'.

    => dm tree
     Class     Seq    Probed  Driver                Name
    -----------------------------------------------------------
     efi           0  [ + ]   EFI block driver      `-- efi
     blk           3  [ + ]   efi_blk                   `-- efi.efiblk#0
     partition     0  [ + ]   blk_partition                 `-- efi.efiblk#0:1

    => ls efiloader 0:1
           13   hello.txt
            7   u-boot.txt
    2 file(s), 0 dir(s)

    => cat efiloader 0:1 hello.txt
    Hello world!

    => efidebug dh
    0000000018df1700 (efi.efiblk#0:1)
      /VenHw(dbca4c98-6cb0-694d-0872-819c650cb7b8)/HD(1,MBR,0xd1535d21,0x1,0x7f)
      Block IO
      Simple File System

Adjust the event dump unit test to consider the new event spy.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2025-02-20 11:07:44 +01:00
Tom Rini
8fe2c68c32 Merge patch series "Rework requirements.txt files"
Tom Rini <trini@konsulko.com> says:

A challenge we've run in to is making it easier for more people to use
various python tools that we include in the tree. Part of the problem is
that when we have a requirements.txt file, aside from the doc one we
share with the kernel, I created it using "pip freeze". And while this
might have been a best (or at least OK) practice at the time, that's no
longer the case and is why our files have so many things in them. What
this series does is create multiple files, one per project/tool and then
has CI install them as needed. There's a few places here where this
means that we update the requirements as well, but we keep a few big
things where they are currently. This is because updating them
introduces problems of their own and delaing with that would best be a
follow up series. I've put this through GitLab and Azure to make sure
everything is still going fine on both platforms.

Link: https://lore.kernel.org/r/20250205000743.949790-1-trini@konsulko.com
2025-02-14 17:11:37 -06:00
Tom Rini
859621b47f python: Recreate test/py and tools/buildman requirements.txt files
Use the "pipreqs" tool to re-create these files, with a few manual
corrections. We still need to include pytest-xdist which the tool does
not detect. We also for now don't upgrade most of the required tools as
that creates problems with various tests, which should be resolved
independently.

Signed-off-by: Tom Rini <trini@konsulko.com>
2025-02-14 17:11:35 -06:00
Heinrich Schuchardt
4fee75276d test: unit tests for strstr() and strnstr()
Add unit tests for the library functions.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
[jf: drop unwanted change to lib/string.c]
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
2025-02-12 12:37:17 -06:00
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
7c9f4625a5 test: Rename optee test-file
This has nothing to do with commands anymore, so rename the file.

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
ba2feaf414 test: Split optee tests into three functions
These tests run three different checks on the nodes, but the logic is
currently all in one tests.

Split the code out into three different tests, which do different setup
and then run the same checks.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-11 20:10:59 -06:00
Simon Glass
1c05e2c0eb test: Update optee to do init and uninit from tests
Rather than having an init function and then running the tests, create a
test-init function to do it. This will allow us to get rid of the
command function.

Fix the comment abotu 'environment' while we are here.

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
c7326f9691 test: Update bootstd to do init from tests
Rather than having an init function and then running the tests, create a
test-init function to do it. This will allow us to get rid of the
command function.

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
a7290bc4b7 test: Update fdt_overlay to do init from tests
Rather than having an init function and then running the tests, create a
test-init function to do it. This will allow us to get rid of the
command function.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-11 20:10:59 -06:00
Simon Glass
648e4a79bb test: Update fdt_overlay test to use fdtdec functions
Use the helpers provided for this purpose, rather than different ones in
this particular test.

Leave fdt_getprop_str() alone as it seems to have more value.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-11 20:10:59 -06:00
Simon Glass
af4c94709c test: Move fdt_overlay init into a function
Move the init code into a separate function since it is quite large.
Adjust it to use unit-test functions which have become available since
the test was written.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-11 20:10:59 -06:00
Simon Glass
9aaa4a3565 test: Make all tests depend on UNIT_TEST
Rather than having this condition defined separately for each suite,
bracket all options with 'if UNIT_TEST'.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-11 20:10:59 -06:00
Simon Glass
d87ffdaa3c test: Move fdt-overlay-test rule into test/
The Makefile rules for tests should be within test/Makefile so move the
'fdt-overlay' rule over.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-11 20:10:59 -06:00
Simon Glass
5a07d87b80 test: Move optee-test rule into test/
The Makefile rules for tests should be within test/Makefile so move the
'optee' rule over.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-11 20:10:59 -06:00
Simon Glass
81f4605c09 test: Move env-test rule into test/
The Makefile rules for tests should be within test/Makefile so move the
'env' rule over.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-11 20:10:58 -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
c908ecb7b5 test: Support an init/uninit functions for test suites
Some suites need things to be set up before they can run. Add a way to
declare an init function using the UNIT_TEST_INIT() macro. The init
function is just like any other test, but is always placed first so that
it runs before all the other test functions in the suite.

Add an uninit function as well, to clean up after the test.

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
5f6a59e03e test: Keep track of suite duration
Show the time taken by each test suite with 'ut all' and the total time
for all suites.

Take care to remove any sandbox time-offset from the values.

Fix the comment-format on timer_test_add_offset() while we are here.

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
a040c1c187 test: Fix a stray asterisk in ut_run_list()
Drop the unwanted asterisk in the comment.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-11 20:10:58 -06:00
Simon Glass
98eba15ab8 test: Drop sandbox_set_enable_memio() from mux-cmd test
This test does not appear to use sandbox's memory-mapped I/O so there is
no need to enable it.

Even if there were a need, it should be disabled at the end of the test,
so as not to affect other tests.

Drop these lines from the test.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-11 20:10:58 -06:00
Andrew Goodbody
eaa51d0fda test/py: usb: Fix format string for fstype command
USB tests on ext partitions can fail with the following output

test/py/tests/test_usb.py:245: in test_usb_part
    'fstype usb %d:%d' % i, part_id
E   TypeError: not enough arguments for format string

So add brackets around the format string arguments to prevent the
error.

Fixes: a730947974 ("test/py: usb: Distinguish b/w ext2/ext4 partitions")
Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
Reviewed-by: Marek Vasut <marex@denx.de>
Reviewed-by: Love Kumar <love.kumar@amd.com>
2025-02-10 10:27:44 -06:00
Tom Rini
ac3dcb0c27 Merge patch series "cmd/setexpr: support concatenation of direct strings"
Heinrich Schuchardt <heinrich.schuchardt@canonical.com> says:

The setexpr.s command allows to concatenate two strings.

According to the description in doc/usage/cmd/setexpr.rst the parameters
value1 and value2 can be either direct values or pointers to a
memory location holding the values.

Unfortunately `setexpr.s <value1> + <value2>` fails if any of the values
is a direct value. $? is set to false.

* Add support for direct values in setexpr.s.
* Correct the unit test for "setexpr.s fred 0".
* Add a new unit test for "setexpr.s fred '1' + '3'" giving '13'.
* Remove invalid memory leak tests

Link: https://lore.kernel.org/r/20250203151029.60265-1-heinrich.schuchardt@canonical.com
2025-02-07 13:35:32 -06:00
Heinrich Schuchardt
af7eca24a7 cmd/setexpr: support concatenation of direct strings
The setexpr.s command allows to concatenate two strings.

According to the description in doc/usage/cmd/setexpr.rst the parameters
value1 and value2 can be either direct values or pointers to a
memory location holding the values.

Unfortunately `setexpr.s <value1> + <value2>` fails if any of the values
is a direct value. $? is set to false.

* Add support for direct values in setexpr.s.
* Correct the unit test for "setexpr.s fred 0".
* Add a new unit test for "setexpr.s fred '1' + '3'" giving '13'.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2025-02-07 13:35:23 -06:00
Heinrich Schuchardt
d4265cdcd5 test: remove available memory check in setexpr_test_str_oper()
env_set() frees the previous value after allocating the new value.
As the free() may merge memory chunks the available memory is not
expected to stay constant.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2025-02-07 13:35:23 -06:00
Heinrich Schuchardt
b071642636 test: remove available memory check in setexpr_test_str()
env_set() frees the previous value after allocating the new value.
As the free() may merge memory chunks the available memory is not
expected to stay constant.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2025-02-07 13:35:23 -06:00
Heinrich Schuchardt
0395d75d6b test: clean up setexpr_test_str()
Assign variable buf in the sub-test where it is used.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2025-02-07 13:35:23 -06:00
Tom Rini
7a20c89bd0 Merge patch series "led: add function naming option from linux"
Heiko Schocher <hs@denx.de> says:

In linux we have the option to create the name of a led
optionally through the following properties:

- function
- color
- function-enumerator

This series adds support for parsing this properties if there
is no label property.

Link: https://lore.kernel.org/r/20250128135246.74838-1-hs@denx.de
[trini: Document name parameter in led.h]
2025-02-07 11:39:24 -06:00
Heiko Schocher
592b6f394a led: add function naming option from linux
in linux we have the option to create the name of a led
optionally through the following properties:

- function
- color
- function-enumerator

This patch adds support for parsing this properties if there
is no label property.

The led name is created in led_post_bind() and we need some
storage place for it. Currently this patch prevents to use
malloc() instead it stores the name in new member :

        char name[LED_MAX_NAME_SIZE];

of struct led_uc_plat. While at it append led tests for the
new feature.

Signed-off-by: Heiko Schocher <hs@denx.de>
Reviewed-by: Tom Rini <trini@konsulko.com>
2025-02-07 10:53:39 -06:00
Simon Glass
5e46a06950 test/py: Add a report show test durations
Execution time varies widely with the existing tests. Provides a way to
produce a summary of the time taken for each test, along with a
histogram.

This is enabled with the --timing flag.

Enable it for sandbox in CI.

Example:

   Duration : Number of tests
   ======== : ========================================
       <1ms :  1
       <8ms :  1
      <20ms : # 20
      <30ms : ######## 127
      <50ms : ######################################## 582
      <75ms : ####### 102
     <100ms : ## 39
     <200ms : ##### 86
     <300ms : # 29
     <500ms : ## 42
     <750ms : # 16
      <1.0s : # 15
      <2.0s : # 23
      <3.0s :  13
      <5.0s :  9
      <7.5s :  1
     <10.0s :  6
     <20.0s :  12

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
2025-01-30 14:34:51 -06:00
Raymond Mao
bb894c5da5 bloblist: add api to get blob with size
bloblist_find function only returns the pointer of blob data,
which is fine for those self-describing data like FDT.
But as a common scenario, an interface is needed to retrieve both
the pointer and the size of the blob data.

Add a few ut test cases for the new api.

Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2025-01-28 08:59:21 +02:00
Marek Vasut
082b41df8a test/cmd/wget.c: Fix loadaddr rewrite
The $loadaddr variable is a hexadecimal value, not a string, it must be
assigned using env_set_hex(). This may break follow up tests, like the
dm_test_cmd_hash_md5 in CI. To avoid any interference with other tests,
set $wgetaddr variable which is specific to this test and use it in the
test.

Fixes: 20f641987f ("test/cmd/wget.c: move net_test_wget() to the cmd test suite")
Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Fabio Estevam <festevam@gmail.com>
2025-01-27 12:46:44 -06:00
Heinrich Schuchardt
01b35b3e38 test/log: test function filters
Add unit tests for function filters.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2025-01-26 11:06:56 +01:00