summaryrefslogtreecommitdiff
path: root/test/py
AgeCommit message (Collapse)AuthorFilesLines
2022-10-31test: Support tests which can only be run manuallySimon Glass1-1/+7
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>
2022-10-29event: Drop the path when checking event-list filenamesSimon Glass1-3/+3
This path does not seem to be present in clang-14 for some reason. Relax the regular expression so that the test works, at least for non-LTO. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-10-26test: Move to a working version of setuptoolsSimon Glass1-0/+1
The version used on Ubuntu 2022.04 produces a number of warnings: /usr/lib/python3/dist-packages/pkg_resources/__init__.py:116: PkgResourcesDeprecationWarning: 1.16.0-unknown is an invalid version and will not be supported in a future release Same with: 0.1.43ubuntu1 11.4.1ubuntu1 2.22.1ubuntu1 1.1build1 According to [1] this is a bug in setuptools. Employ the workaround for now. [1] https://askubuntu.com/questions/1406952/what-is-the-meaning-of-this- pkgresourcesdeprecationwarning-warning-from-pipenv Signed-off-by: Simon Glass <sjg@chromium.org>
2022-10-18vbe: Add a test for VBE device tree fixupsSimon Glass2-1/+127
When a FIT includes some OS requests, U-Boot should process these and add the requested info to corresponding subnodes of the /chosen node. Add a pytest for this, which sets up the FIT, runs bootm and then uses a C unit test to check that everything looks OK. The test needs to run on sandbox_flattree since we don't support device tree fixups on sandbox (live tree) yet. So enable BOOTMETH_VBE and disable bootflow_system(), since EFI is not supported on sandbox_flattree. Add a link to the initial documentation. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-10-18vbe: Add fixups for a basic set of OS requestsSimon Glass1-0/+1
As a starting point, add support for providing random data, if requested by the OS. Also add ASLR, as a placeholder for now. Signed-off-by: Simon Glass <sjg@chromium.org> (fixed up to use uclass_first_device_err() instead)
2022-10-18test: Move common FIT code into a separate fit_util fileSimon Glass2-70/+99
To avoid duplicating code, create a new fit_util module which provides various utility functions for FIT. Move this code out from the existing test_fit.py and refactor it with addition parameters. Fix up pylint warnings in the conversion. This involves no functional change. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-10-11cmd: xxd: add new commandRoger Knecht2-0/+58
Add xxd command to print file content as hexdump to standard out Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Roger Knecht <rknecht@pm.me>
2022-10-11cmd: cat: add new commandRoger Knecht2-0/+55
Add cat command to print file content to standard out Reviewed-by: Simon Glass <sjg@chromium.org> Signed-off-by: Roger Knecht <rknecht@pm.me>
2022-10-06test: fix some pylint errors in test_efi_secbootHeinrich Schuchardt1-9/+3
* Remove unused import * Provide module docstring Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2022-09-25sandbox: Add a test for SCSISimon Glass1-0/+9
Add a simple uclass test for SCSI. It reads the partition table from a disk image and checks that it looks correct. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-14test: unit test for eficonfigMasahisa Kojima2-0/+394
Provide a unit test for the eficonfig command. Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2022-09-13test/py: Support --build when running tests in parallelSimon Glass2-4/+27
At present when -n is used, all workers try to build U-Boot at once. Add a lock to ensure that only one of them builds, with the others using the build that is produced. The lock file is removed on startup. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-13test/py: Move U-Boot building into a functionSimon Glass1-24/+36
This is a lot of code in a function that is too long. Split out the building code. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-13test: Make test_gpio_read() independentSimon Glass1-0/+1
This assumes that the GPIO starts as 0 but it does not if test_gpio_input() ran first and test_gpio_exit_statuses() was skipped. This can happen when running tests in parallel. Fix it. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-13test: Mark test_gpt tests as slowSimon Glass1-0/+3
Mark all the tests in this file as slow, since they take a while. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-13test: Mark all but the first vboot test as slowSimon Glass1-1/+5
When doing a quick check we don't need to run all the vboot tests. Just run the first one, which is enough to catch most problems. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-13test: Make test_efi_bootmgr() single-threadedSimon Glass1-0/+1
This test seems to fail when run in parallel. Mark it single-threaded to avoid any problems. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-13test: Make test_sqfs_ls() single-threadedSimon Glass1-0/+1
This test seems to interfere with the other test in this file. Mark it single-threaded to avoid any problems. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-13test: Update FIT tests to run in parallelSimon Glass2-2/+7
Use a different temporary dir for each test, to allow them to run in parallel. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-13test: Make test_bind_unbind_with_uclass() single-threadedSimon Glass1-0/+1
This test seems to rely on the other test in this file. Mark it single-threaded to avoid any problems. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-13test/py: Allow tests to be marked single-threaded onlySimon Glass2-0/+18
Add a new 'singlethread' marker to allow tests to be skipped when running in parallel. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-09-13test: Fix test_pinmux to run in parallelSimon Glass1-0/+1
At present test_pinmux_status() assumes that test_pinmux_dev() has run beforehand. Drop this assumption so we can run the tests in parallel. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-08-22CI: Move to Ubuntu 2022.04 "Jammy" for CI baseTom Rini1-2/+2
- We now have a new enough sbsigntools in the distro, stop building. - Use the 20220801 tag for Jammy. - Move to pygit2 1.9.2 (current version) as the old one doesn't build on "Jammy". - Add the working directory to the list of safe directories for git. - Move to pytest 6.2.5 to address other issues. - This move exposed a number of minor issues in the existing scripts we used within CI to perform the jobs themselves. The most notable changes here involve using 'set +e / set -e' to enforce when we should or should not make non-zero buildman status be a fatal error. Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-08-12vbe: Support VBE simpleSimon Glass1-1/+1
Add support for VBE simple, which permits firmware update of a single image stored in MMC or another block device. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-08-12event: Add an event for device tree fixupsSimon Glass1-0/+1
At present there is a confusing array of functions that handle the device tree fix-ups needed for booting an OS. We should be able to switch to using events to clean this up. As a first step, create a new event type and call it from the standard place. Note that this event uses the ofnode interface only, since this can support live tree which is more efficient when making lots of updates. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-08-10test: Add some tests for kconfig.hSimon Glass1-0/+39
The macros in this file are a little confusing and we currently have no tests to check that they work as expected. Add some tests which check the macros in C code. Add a few tests which check that the build errors are generated correctly too, using buildman's -a option. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-07-26test/py: Run simple dm commands without checkingMichal Simek1-0/+8
Just to make sure that dm commands can operate. This was the problem on Microblaze in past without fixing manual relocation. Signed-off-by: Michal Simek <michal.simek@xilinx.com> Signed-off-by: Michal Simek <michal.simek@amd.com> Reviewed-by: Simon Glass <sjg@chromium.org> Link: https://lore.kernel.org/r/e6c4b8b44445c16cee84436627642ccc9886f507.1657191580.git.michal.simek@amd.com
2022-07-26py: tests: Bind should run only on sandboxMichal Simek1-1/+2
Disable test to run on any other platform than sandbox. Signed-off-by: Michal Simek <michal.simek@xilinx.com> Signed-off-by: Michal Simek <michal.simek@amd.com> Reviewed-by: Simon Glass <sjg@chromium.org> Link: https://lore.kernel.org/r/786bfdfda7dee4494e39c3fff699970ecd623116.1657191142.git.michal.simek@amd.com
2022-07-18efi: test/py: repair authenticated capsules testsVincent Stehlé2-0/+5
The UEFI console initialisation has been modified by commit 68edbed454b8 ("efi_loader: initialize console size late"). A corresponding workaround is now necessary for the automated tests, as added to some of the tests already by commit e05bd68ed5fc ("test: work around for EFI terminal size probing"). Add the same workaround to the UEFI authenticated capsules tests to repair them. This can be tested with sandbox_defconfig, sandbox64_defconfig or sandbox_flattree_defconfig, plus CONFIG_EFI_CAPSULE_AUTHENTICATE=y. Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com> Cc: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-07-11Merge branch 'next'Tom Rini2-170/+176
2022-07-08requirements: Move to atomicwrites==1.4.1Tom Rini1-1/+1
As explained upstream: https://github.com/untitaker/python-atomicwrites/issues/61 there is no longer a 1.3.0 version but the API is unchanged. Move to 1.4.1. Signed-off-by: Tom Rini <trini@konsulko.com>
2022-07-08requirements: Move to atomicwrites==1.4.1Tom Rini1-1/+1
As explained upstream: https://github.com/untitaker/python-atomicwrites/issues/61 there is no longer a 1.3.0 version but the API is unchanged. Move to 1.4.1. Signed-off-by: Tom Rini <trini@konsulko.com>
2022-07-05test/py: efi_secboot: add a test for a forged signed imageAKASHI Takahiro3-0/+43
In this test case, a image binary, helloworld.efi.signed, is willfully modified to print a corrupted message while the signature itself is unchanged. This binary must be rejected under secure boot mode. Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
2022-06-28test: fix some pylint errors in test_bind.pyHeinrich Schuchardt1-170/+175
* Use spaces not tabs * Limit lines to 100 spaces * Remove an unused import * Sort imports correctly * Add a module description Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-06-23test/py: test_stackprotector: Disable for ASANAndrew Scull1-0/+1
The stack protector test intentionally overflows a buffer in order to corrupt the stack canary so that it can test that the corruption is detected as expected. However, this is incompatible with ASAN, which detects the buffer overflow and interrupts the test, so disable the test for such configurations. Signed-off-by: Andrew Scull <ascull@google.com>
2022-06-19test: work around for EFI terminal size probingHeinrich Schuchardt2-0/+3
When the UEFI sub-system is initialized it sends an escape sequence to the serial console to determine the terminal size. This stops the run_command_list() function of the console emulation from recognizing the U-Boot command line prompt. Add a 'print -e' command as first command in the command list to work around this issue. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-06-04efi: test/py: authenticate fit capsulesVincent Stehlé3-6/+280
Add support for the authentication of UEFI capsules containing FIT images. The authentication code is moved out of the function handling raw images into a new function efi_firmware_capsule_authenticate(). The special case for the FMP header coming from edk2 tools is preserved. There is no functional change for capsules containing raw images. The python test for signed capsules with raw images is renamed with no functional change and a new test is added for signed capsules containing FIT images. This can be tested with sandbox64_defconfig or sandbox_flattree_defconfig, plus CONFIG_EFI_CAPSULE_AUTHENTICATE=y. Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com> Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
2022-06-04test/py: efi_capsule: repair image authentication testVincent Stehlé2-5/+5
Repair the python tests for authenticated EFI capsules, which can be run with sandbox_defconfig plus CONFIG_EFI_CAPSULE_AUTHENTICATE=y. - Account for the reset changes done by commit 3e6f81000672 ("efi_loader: test/py: Reset system after capsule update on disk"). - Fix the capsule GUID typo introduced by commit 2e9c3c6965ba ("test: capsule: Modify the capsule tests to use GUID values for sandbox"). Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com> Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
2022-05-28test: don't change console timeout in EFI selftest.Heinrich Schuchardt1-2/+0
Changing the console timeout to 500 ms without restoring the original value leads to failures in other tests. As the console timeout change is not necessary for the text input protocol tests remove it. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-05-28test: fix pylint warnings in test_efi_selftest.pyHeinrich Schuchardt1-61/+28
* change format of parameter documentation * avoid superfluous assignments Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-05-28test: restore timeout after bootmenu unit testHeinrich Schuchardt1-33/+33
In the bootmenu unit test the console timeout is set to 500 ms. Other tests rely on the original timeout. Ensure that the original value is restored. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-05-26test: fix parsing the mksquashfs version numberHeinrich Schuchardt1-5/+4
Testing with mksquasshfs 4.5.1 results in an error ValueError: could not convert string to float: '4.5.1' Version 4.10 would be considered to be lower than 4.4. Fixes: 04c9813e951f ("test/py: rewrite common tools for SquashFS tests") Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2022-05-26test/py: test_part: Correct the test case nameBin Meng1-1/+1
Use test_part_types as the name instead of dm_compact. Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
2022-05-26test/py: test_fs: Correct the test case nameBin Meng1-1/+1
Use test_fstypes as the name instead of test_dm_compact. Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
2022-05-26test/py: Reset the console timeout valueBin Meng1-0/+4
Reset the console timeout value as some tests may change its default value during the execution. This fixes the random case timeout issue seen in the U-Boot CI. Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
2022-05-08Merge tag 'efi-2022-07-rc3-2' of ↵Tom Rini2-0/+57
https://source.denx.de/u-boot/custodians/u-boot-efi Pull request for efi-2022-07-rc3-2 UEFI: * Fix build errors due to - using sed with non-standard extension for regular expression - target architecture not recognized for CROSS_COMPILE=armv7a-* - CONFIG_EVENT not selected * add sha384/512 on certificate revocation Others: * factor out the user input handling in bootmenu command
2022-05-08test/py: Add more test cases for rejecting an EFI imageIlias Apalodimas2-0/+57
The previous patch adds support for rejecting images when the sha384/512 of an x.509 certificate is present in dbx. Update the sandbox selftests Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2022-05-06test: py: tests: test_gpt.py: add a simple test for the command gpt repairPhilippe Reynes1-0/+10
Adds a simple test for the command gpt repair. Signed-off-by: Philippe Reynes <philippe.reynes@softathome.com>
2022-05-05sandbox: Avoid binman error when run without device treeSimon Glass1-0/+12
With sandbox, U-Boot can be run without a device tree (i.e. no -d or -T parameter). In this case an empty device tree is created for convenience. With a recent change this causes an error due to the missing '/binman' node. Add this node to avoid the problem, as well as a test that U-Boot can be run without a device tree. Fixes: 059df5624b ("arch: Kconfig: imply BINMAN for SANDBOX") Fixes: https://source.denx.de/u-boot/u-boot/-/issues/11 Signed-off-by: Simon Glass <sjg@chromium.org>
2022-05-05test/py: Add a way to start sandbox without a device treeSimon Glass1-7/+8
This is useful sometimes when running a specific test. Add support for it in the existing restart_uboot_with_flags() function. Signed-off-by: Simon Glass <sjg@chromium.org>