summaryrefslogtreecommitdiff
path: root/test
AgeCommit message (Collapse)Author
2025-03-17lmb: check if a region can be reserved by lmb_reserve()Sughosh Ganu
The logic used in lmb_alloc() takes into consideration the existing reserved regions, and ensures that the allocated region does not overlap with any existing allocated regions. The lmb_reserve() function is not doing any such checks -- the requested region might overlap with an existing region. This also shows up with lmb_alloc_addr() as this function ends up calling lmb_reserve(). Add a function which checks if the region requested is overlapping with an existing reserved region, and allow for the reservation to happen only if both the regions have LMB_NONE flag, which allows re-requesting of the region. In any other scenario of an overlap, have lmb_reserve() return -EEXIST, implying that the requested region is already reserved. Add corresponding test cases which check for overlapping reservation requests made through lmb_reserve() and lmb_alloc_addr(). And while here, fix some of the comments in the test function being touched. Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2025-02-24Merge tag 'v2025.04-rc3' into nextTom Rini
Prepare v2025.04-rc3
2025-02-21test/py: Have test_usb.py raise an Exception with unsupported filesystemsTom Rini
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-21test/py: Rework how test_ums.py handles (not) having write enabledTom Rini
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-21test/py: Rework test_spi.py to assert we found outputTom Rini
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-20efi_driver: create a parent device for all EFI block devicesHeinrich Schuchardt
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-14Merge patch series "Rework requirements.txt files"Tom Rini
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-14python: Recreate test/py and tools/buildman requirements.txt filesTom Rini
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-12test: unit tests for strstr() and strnstr()Heinrich Schuchardt
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-11test: Update documentationSimon Glass
Update documentation for how to write tests and the 'ut' command. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-11test: Do flag-processing in the correct placeSimon Glass
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-11test: Move code out of cmd_ut_category()Simon Glass
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-11test: Allow running a selection of suitesSimon Glass
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-11test: Drop suites.hSimon Glass
This file is empty now. Remove it and its uses. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-11test: Make cmd_ut_category() staticSimon Glass
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-11test: Drop support for test commandsSimon Glass
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-11test: Rename optee test-fileSimon Glass
This has nothing to do with commands anymore, so rename the file. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-11test: Drop the function for running optee testsSimon Glass
Use the new suite-runner to run these tests instead. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-11test: Split optee tests into three functionsSimon Glass
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-11test: Update optee to do init and uninit from testsSimon Glass
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-11test: Drop the function for running bootstd testsSimon Glass
Use the new suite-runner to run these tests instead. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-11test: Update bootstd to do init from testsSimon Glass
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-11test: Drop the function for running fdt_overlay testsSimon Glass
Use the new suite-runner to run these tests instead. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-11test: Update fdt_overlay to do init from testsSimon Glass
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-11test: Update fdt_overlay test to use fdtdec functionsSimon Glass
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-11test: Move fdt_overlay init into a functionSimon Glass
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-11test: Make all tests depend on UNIT_TESTSimon Glass
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-11test: Move fdt-overlay-test rule into test/Simon Glass
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-11test: Move optee-test rule into test/Simon Glass
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-11test: Move env-test rule into test/Simon Glass
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-11test: Tweak FDT-overlay testsSimon Glass
Use fdt_overlay consistently in the identifiers and file/dir names. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-11test: Support an init/uninit functions for test suitesSimon Glass
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-11test: Leave out the prefix when printing test namesSimon Glass
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-11test: Show the average time per testSimon Glass
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-11test: Keep track of suite durationSimon Glass
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-11test: Add up the number of tests manuallySimon Glass
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-11test: Fix a stray asterisk in ut_run_list()Simon Glass
Drop the unwanted asterisk in the comment. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-11test: Drop sandbox_set_enable_memio() from mux-cmd testSimon Glass
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-10test/py: usb: Fix format string for fstype commandAndrew Goodbody
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: a730947974e3 ("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-07Merge patch series "cmd/setexpr: support concatenation of direct strings"Tom Rini
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-07cmd/setexpr: support concatenation of direct stringsHeinrich Schuchardt
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-07test: remove available memory check in setexpr_test_str_oper()Heinrich Schuchardt
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-07test: remove available memory check in setexpr_test_str()Heinrich Schuchardt
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-07test: clean up setexpr_test_str()Heinrich Schuchardt
Assign variable buf in the sub-test where it is used. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2025-02-07Merge patch series "led: add function naming option from linux"Tom Rini
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-07led: add function naming option from linuxHeiko Schocher
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-01-30test/py: Add a report show test durationsSimon Glass
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-28bloblist: add api to get blob with sizeRaymond Mao
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-27test/cmd/wget.c: Fix loadaddr rewriteMarek Vasut
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: 20f641987f83 ("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-26test/log: test function filtersHeinrich Schuchardt
Add unit tests for function filters. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>