aboutsummaryrefslogtreecommitdiff
path: root/test
AgeCommit message (Collapse)AuthorFilesLines
2021-07-23lib: wrap crypt API to hide errno usageSteffen Jaeckel1-2/+22
In order to prevent using the global errno, replace it with a static version and create a wrapper function which returns the error value. Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Heiko Schocher <hs@denx.de>
2021-07-23lib: add crypt subsystemSteffen Jaeckel3-0/+55
Add the basic functionality required to support the standard crypt format. The files crypt-sha256.c and crypt-sha512.c originate from libxcrypt and their formatting is therefor retained. The integration is done via a crypt_compare() function in crypt.c. ``` libxcrypt $ git describe --long --always --all tags/v4.4.17-0-g6b110bc ``` Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Heiko Schocher <hs@denx.de>
2021-07-23reboot-mode: read the boot mode from RTC memoryNandor Han1-0/+29
RTC devices could provide battery-backed memory that can be used for storing the reboot mode magic value. Add a new reboot-mode back-end that uses RTC to store the reboot-mode magic value. The driver also supports both endianness modes. Signed-off-by: Nandor Han <nandor.han@vaisala.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-07-23reboot-mode: read the boot mode from GPIOs statusNandor Han2-0/+43
A use case for controlling the boot mode is when the user wants to control the device boot by pushing a button without needing to go in user-space. Add a new backed for reboot mode where GPIOs are used to control the reboot-mode. The driver is able to scan a predefined list of GPIOs and return the magic value. Having the modes associated with the magic value generated based on the GPIO values, allows the reboot mode uclass to select the proper mode. Signed-off-by: Nandor Han <nandor.han@vaisala.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-07-23cmd: pinmux: support pin name in status commandPatrick Delaunay2-0/+37
Allow pin name parameter for pimux staus command, as gpio command to get status of one pin. The possible usage of the command is: > pinmux dev pinctrl > pinmux status > pinmux status -a > pinmux status <pin-name> Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-07-23cmd: pinmux: update result of do_statusPatrick Delaunay1-2/+2
Update the result of do_status and always returns a CMD_RET_ value (-ENOSYS was a possible result of show_pinmux). This patch also adds pincontrol name in error messages (dev->name) and treats correctly the status sub command when pin-controller device is not selected. Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-07-21log: Allow padding of the function nameSimon Glass1-7/+9
At present when function names are logged, the output is a little hard to read since every function is a different length. Add a way to pad the names so that the log messages line up vertically. This doesn't work if the function name is very long, but it makes a big difference in most cases. Use 20 characters as a default since this covers the vast majority of functions. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-07-21blk: Support iterationSimon Glass1-0/+55
It is useful to be able to iterate over block devices. Typically there are fixed and removable devices. For security reasons it is sometimes useful to ignore removable devices since they are under user control. Add iterators which support selecting the block-device type. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-07-21bloblist: Correct condition in bloblist_addrec()Simon Glass1-0/+23
It is possible to add a blob that ends at the end of the bloblist, but at present this is not supported. Fix it and add a regression test for this case. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-07-21bloblist: Support resizing a blobSimon Glass1-0/+192
Sometimes a blob needs to expand, e.g. because it needs to hold more log data. Add support for this. Note that the bloblist must have sufficient spare space for this to work. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-07-21sandbox: Support executables for more phasesSimon Glass1-1/+5
The SPL header has a function for obtaining the phase in capital letters, e.g. 'SPL'. Add one for lower-case also, as used by sandbox. Use this to generalise the sandbox logic for determining the filename of the next sandbox executable. This can provide support for VPL. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-07-21test: Avoid a build error with SPLSimon Glass1-1/+1
At present this fails to build chromeos_sandbox due to a rebase error in dm_test_pre_run(). Fix it. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-07-21test: Add DM_DMA to be disabledSimon Glass1-0/+2
At present if DM_DMA is disabled on a sandbox build, the build fails. Make the test conditional. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-07-21test: Allow CONFIG_SPL_LOAD_FIT to be disabledSimon Glass1-0/+2
At present if this is not enabled on a sandbox build, the build fails. Add a condition to avoid this. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-07-19Merge tag 'ti-v2021.10-rc1' of ↵Tom Rini1-10/+67
https://source.denx.de/u-boot/custodians/u-boot-ti - Enabled distro boot for all TI platforms. - Cleanup for AM335x Guardian Board - PRUSS rproc on AM65 platform. - Add PMIC support for J7200 - Misc fixes for Nokia RX-51 # Conflicts: # arch/arm/mach-omap2/am33xx/Kconfig
2021-07-15test: Rename final check in setexpr_test_backref()Simon Glass1-2/+0
The bug in setexpr is fixed now, so this test can be enabled. Reported-by: Coverity (CID: 316346) Signed-off-by: Simon Glass <sjg@chromium.org>
2021-07-15Nokia RX-51: Add check for /lib/ld-linux.so.2 in test scriptPali Rohár1-0/+1
Unfortunately for testing is required qflasher which works only in 32-bit x86 mode. Apparently 64-bit x86 Azure CI has no problems as it has preinstalled 32-bit libraries and can execute also 32-bit x86 executables. This change just show human readable output why nokia_rx51_test.sh test script fails. Signed-off-by: Pali Rohár <pali@kernel.org> Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com> Link: https://lore.kernel.org/r/20210618133108.32497-1-pali@kernel.org
2021-07-15Nokia RX-51: Add support for booting kernel in zImage formatPali Rohár1-10/+66
Enable U-Boot bootz command and update env scripts to try loading also zImage file and to try booting via bootz command. Update also lowlevel_init.S code for checking validity of zImage magic to correctly relocate kernel in zImage format. This change allows U-Boot to directly boot Linux kernel without need for converting kernel image into U-Boot uImage format. Signed-off-by: Pali Rohár <pali@kernel.org> Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com> Link: https://lore.kernel.org/r/20210618132704.32066-1-pali@kernel.org
2021-07-06sandbox: cros-ec: Add tests for the Chromium OS EC PWM driverAlper Nebi Yasak5-5/+96
This patch adds a limited pulse-width modulator to sandbox's Chromium OS Embedded Controller emulation. The emulated PWM device supports multiple channels but can only set a duty cycle for each, as the actual EC doesn't expose any functionality or information other than that. Though the EC supports specifying the PWM channel by its type (e.g. display backlight, keyboard backlight), this is not implemented in the emulation as nothing in U-Boot uses this type specification. This emulated PWM device is then used to test the Chromium OS PWM driver in sandbox. Adding the required device node to the sandbox test device-tree unfortunately makes it the first PWM device, so this also touches some other tests to make sure they still use the sandbox PWM. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-07-05Docker/CI: Update to "focal" and latest buildTom Rini1-1/+1
Move us up to being based on Ubuntu 20.04 "focal" and the latest tag from Ubuntu for this release. For this, we make sure that "python" is now python3 but still include python2.7 for the rx51 qemu build as that is very old and does not support python3. Signed-off-by: Tom Rini <trini@konsulko.com>
2021-07-05test/py: rewrite sqfsls command test suiteJoao Marcos Costa1-19/+121
Add more details to test cases by comparing each expected line with the command's output. Add new test cases: - sqfsls at an empty directory - sqfsls at a sub-directory Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Simon Glass <sjg@chromium.org> [on sandbox] Signed-off-by: Joao Marcos Costa <jmcosta944@gmail.com>
2021-07-05test/py: rewrite sqfsload command test suiteJoao Marcos Costa1-30/+138
The previous strategy to know if a file was correctly loaded was to check for how many bytes were read and compare it against the file's original size. Since this is not a good solution, replace it by comparing the checksum of the loaded bytes against the original file's checksum. Add more test cases: files at a sub-directory and non-existent file. Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Simon Glass <sjg@chromium.org> [on sandbox] Signed-off-by: Joao Marcos Costa <jmcosta944@gmail.com>
2021-07-05test/py: rewrite common tools for SquashFS testsJoao Marcos Costa1-64/+193
Remove the previous OOP approach, which was confusing and incomplete. Add more test cases by making SquashFS images with various options, concerning file fragmentation and its compression. Add comments to properly document the code. Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Simon Glass <sjg@chromium.org> [on sandbox] Signed-off-by: Joao Marcos Costa <jmcosta944@gmail.com>
2021-07-05test/py: Wait for guestmount worker to exit after running guestunmountAlper Nebi Yasak2-1/+48
Some filesystem tests are failing when their image is prepared with guestmount, but succeeding if loop mounts are used instead. The reason seems to be a race condition the guestmount(1) manual page explains: When guestunmount(1)/fusermount(1) exits, guestmount may still be running and cleaning up the mountpoint. The disk image will not be fully finalized. This means that scripts like the following have a nasty race condition: guestmount -a disk.img -i /mnt # copy things into /mnt guestunmount /mnt # immediately try to use 'disk.img' ** UNSAFE ** The solution is to use the --pid-file option to write the guestmount PID to a file, then after guestunmount spin waiting for this PID to exit. The Python standard library has an os.waitpid() function for waiting a child to terminate, but it cannot wait on non-child processes. Implement a utility function that can do this by polling the process repeatedly for a given duration, optionally killing the process if it won't terminate on its own. Apply the suggested solution with this utility function, which makes the failing tests succeed again. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-07-05test/py: Use loop mounts if guestmount fails in filesystem testsAlper Nebi Yasak1-16/+15
If guestmount isn't available on the system, filesystem test setup falls back to using loop mounts to prepare its disk images. If guestmount is available but fails to work, the tests are immediately skipped. Instead of giving up on a guestmount failure, try using loop mounts as an attempt to keep tests running. Also stop checking if guestmount is in PATH, as trying to run a missing guestmount can now follow the same failure codepath and fall back to loop mounts anyway. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
2021-06-28Merge tag 'v2021.07-rc5' into nextTom Rini3-2/+6
Prepare v2021.07-rc5 # gpg: Signature made Mon 28 Jun 2021 03:39:36 PM EDT # gpg: using RSA key 1A3C7F70E08FAB1707809BBF147C39FF9634B72C # gpg: Good signature from "Thomas Rini <trini@konsulko.com>" [ultimate] # Conflicts: # configs/am64x_evm_r5_defconfig
2021-06-24dm: core: add ofnode_get_path()Marek Behún1-0/+21
Add function for retrieving full node path of a given ofnode. This uses np->full_name if OF is live, otherwise a call to fdt_get_path() is made. Signed-off-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com> Tested-by: Patrice Chotard <patrice.chotard@foss.st.com> Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
2021-06-24dm: core: add non-translating version of ofnode_get_addr_size_index()Marek Behún1-0/+5
Add functions ofnode_get_addr_size_index_notrans(), which is a non-translating version of ofnode_get_addr_size_index(). Some addresses are not meant to be translated, for example those of MTD fixed-partitions. Signed-off-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com> Tested-by: Patrice Chotard <patrice.chotard@foss.st.com> Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
2021-06-23test: Include /sbin to the PATH when creating file systemAndy Shevchenko1-0/+4
On some distributions the mkfs is under /sbin and /sbin is not set for mere users. Include /sbin to the PATH when creating file system, so that users won't get a scary traceback from Python. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
2021-06-18net: use the same alias stem for ethernet as linuxMichael Walle2-2/+2
Linux uses the prefix "ethernet" whereas u-boot uses "eth". This is from the linux tree: $ grep "eth[0-9].*=.*&" arch/**/*dts{,i}|wc -l 0 $ grep "ethernet[0-9].*=.*&" arch/**/*dts{,i}|wc -l 633 In u-boot device trees both prefixes are used. Until recently the only user of the ethernet alias was the sandbox test device tree. This changed with commit fc054d563bfb ("net: Introduce DSA class for Ethernet switches"). There, the MAC addresses are inherited based on the devices sequence IDs which is in turn given by the device tree. Before there are more users in u-boot and both worlds will differ even more, rename the alias prefix to "ethernet" to match the linux ones. Also adapt the test cases and rename any old aliases in the u-boot device trees. Cc: David Wu <david.wu@rock-chips.com> Signed-off-by: Michael Walle <michael@walle.cc> Reviewed-by: Fabio Estevam <festevam@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-06-08log: Convert log values to printf() if not enabledWIP/2021-06-08-display-and-logging-updatesSimon Glass3-0/+43
At present if logging not enabled, log_info() becomes a nop. But we want log output at the 'info' level to be akin to printf(). Update the macro to pass the output straight to printf() in this case. This mimics the behaviour for the log_...() macros like log_debug() and log_info(), so we can drop the special case for these. Add new tests to cover this case. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-06-08sandbox: log: Avoid build error with !CONFIG_LOGSimon Glass1-0/+1
The pr_cont_test.c test requires CONFIG_LOG since it directly accesses fields in global_data that require it. Move the test into the CONFIG_LOG condition to avoid build errors. Enable CONFIG_LOG on sandbox (not sandbox_spl, etc.) so that we still run this test. This requires resyncing of the configs. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-06-08log: Add support for logging a bufferSimon Glass1-0/+27
The print_buffer() function is very useful for debugging. Add a version of this in the log system also. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-06-08display_options: Split print_buffer() into two functionsSimon Glass1-0/+26
At present print_buffer() outputs a hex dump but it is not possible to place this dump in a string. Refactor it into a top-level function which does the printing and a utility function that dumps a line into a string. This makes the code more generally useful. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-06-08hexdump: Support any rowsizeSimon Glass1-3/+20
At present print_hex_dump() only supports either 16- or 32-byte lines. With U-Boot we want to support any line length up to a maximum of 64. Update the function to support this, with 0 defaulting to 16, as with print_buffer(). Signed-off-by: Simon Glass <sjg@chromium.org>
2021-06-08hexdump: Add support for sandboxSimon Glass1-0/+58
The current implementation outputs an address as a pointer. Update the code to use an address instead, respecting the 32/64 nature of the CPU. Add some initial tests copied from print_test_display_buffer(), just the ones that can pass with the current implementation. Note that for this case print_hex_dump() and print_bufffer() produce the same result. For now the tests are duplicated sine we have separate functions. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-06-08display_options: Drop two spaces before the ASCII columnSimon Glass4-33/+33
At present with print_buffer() U-Boot shows four spaces between the hex and ASCII data. Two seems enough and matches print_hex_dump(). Change it. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-06-08test: Add a test for print_buffer()Simon Glass1-0/+82
Add a test for this function, to cover the various features. Expand the expect_str length to take acount of the ~300-bytes lines generated in one case. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-06-08test: Convert print tests to use ut frameworkSimon Glass2-51/+56
This test predates the test framework in U-Boot. It uses #define DEBUG and assert() to check the result. Update it to use the framework so it can report failure constitent with other tests. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-06-08test: Detect when expect_str is too smallSimon Glass1-2/+14
If a line of more than 256 bytes is generated, the test will fail but the reason is not clear. Add a check for this condition and print a helpful message. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-06-08console: Report an error when output buffer is exhaustedSimon Glass1-5/+32
If the console output buffer is exhausted, characters are silently dropped from the end. Detect this condition and report an error when reading back the characters. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-06-07test: lmb: add test for lmb_reserve_flagsPatrick Delaunay1-0/+89
Add a test to check the management of reserved region with flags. Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-06-05test: add dm_test_read_resourcePatrick Delaunay1-0/+33
Add a test of dev_read_resource with translation or without translation Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-05-26test: Fix filesystem tests always being skippedAlper Nebi Yasak1-12/+36
Commit 1ba21bb06b08 ("test: Don't unmount not (yet) mounted system") fixes an issue in the filesystem tests where the test setup may fail to mount an image and still attempt to unmount it. However, the commit unintentionally breaks the test setups in two ways. The newly created unmounted filesystem images are being immediately deleted due to some cleanup steps being misplaced into finally blocks, which makes them always run instead of only on failures. The mount calls always fail since the images never exist, causing the tests to be always skipped. This patch moves these cleanup calls into the except blocks to fix this and makes the tests run again. There are also unmount calls misplaced into finally blocks, making them run after the tests instead of before the tests. These unmount calls make the filesystem image file consistent with the changes made to it as part of the test setup, and this misplacement is making a number of tests fail unexpectedly. The unmount calls must be run before the tests use the image, meaning before the yield call and not in the finally block. They must also be run as a cleanup step when the filesystem setup fails, so they can't be placed as the final call in the try blocks since they would be skipped on such failures. For these reasons, this patch places the unmount calls both in the except blocks and the else blocks of the final setup step. This makes the unexpectedly failing tests to succeed again. Furthermore, this isolates the mount calls to their own try-except statement to avoid reintroducing the original issue of unmounting a not-mounted image while fixing the unmount misplacement. After these fixes, running "make tests" with guestmount available results in two test failures not related to the mentioned commit. If the guestmount executables are unavailable, the mounts fallback to using sudo and result in no failures. Fixes: 1ba21bb06b08 ("test: Don't unmount not (yet) mounted system") Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
2021-05-26part: Add check for NULL dev_part_strSean Anderson1-7/+30
Some callers (e.g. cmd/fs.c) of fs_set_blk_dev may use a NULL dev_part_str. While blk_get_device_part_str handles this fine, part_get_info_by_dev_and_name does not. This fixes commands crashing when implicitly using bootdevice. The unit test has also been updated to set bootdevice to a known value and to restore it after we are done. Fixes: 7194527b6a ("cmd: fs: Use part_get_info_by_dev_and_name_or_num to parse partitions") Reported-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-05-24test/py: improve regular expression for ut subtest symbol matcherMarek Behún1-1/+1
Improve the regular expression that matches unittest symbols in u-boot.sym. Currently we do not enforce no prefix in symbol string, but with the soon to come change in linker lists declaring lists and entries with the __ADDRESSABLE macro (because of LTO), the symbol file will contain for every symbol of the form _u_boot_list_2_ut_X_2_Y also symbol __UNIQUE_ID___addressable__u_boot_list_2_ut_X_2_YN, (where N at the end is some number). In order to avoid matching these additional symbols, ensure that the character before "_u_boot_list_2_ut" is not a symbol name character. Signed-off-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-05-24test: Avoid random numbers in dm_test_devm_regmap()Simon Glass1-2/+1
There is no good reason to use a sequence from rand() here. We may as well invent our own sequence. This should molify Coverity which does not use rand() being used. Signed-off-by: Simon Glass <sjg@chromium.org> Reported-by: Coverity (CID: 312949)
2021-05-13pytest: add sandbox test for "extension" commandKory Maincent1-0/+53
This commit extends the sandbox to implement a dummy extension_board_scan() function and enables the extension command in the sandbox configuration. It then adds a test that checks the proper functionality of the extension command by applying two Device Tree overlays to the sandbox Device Tree. Signed-off-by: Kory Maincent <kory.maincent@bootlin.com> [trini: Limit to running on sandbox] Signed-off-by: Tom Rini <trini@konsulko.com>
2021-05-12Revert "fdt: translate address if #size-cells = <0>"Dario Binacchi1-68/+0
This reverts commit d64b9cdcd475eb7f07b49741ded87e24dae4a5fc. As pointed by [1] and [2], the reverted patch made every DT 'reg' property translatable. What the patch was trying to fix was fixed in a different way from previously submitted patches which instead of correcting the generic address translation function fixed the issue with appropriate platform code. [1] https://patchwork.ozlabs.org/project/uboot/patch/1614324949-61314-1-git-send-email-bmeng.cn@gmail.com/ [2] https://lore.kernel.org/linux-clk/20210402192054.7934-1-dariobin@libero.it/T/ Signed-off-by: Dario Binacchi <dariobin@libero.it> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2021-05-04sandbox: add test of CONFIG_ENV_IMPORT_FDTRasmus Villemoes2-0/+21
Check that a variable defined in /config/environment is found in the run-time environment, and that clearing fdt_env_path from within that node works. Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk> Acked-by: Joe Hershberger <joe.hershberger@ni.com> [trini: Conditionalize the test being linked in] Signed-off-by: Tom Rini <trini@konsulko.com>