Commit Graph

913 Commits

Author SHA1 Message Date
Simon Glass
12af37117f bootstd: Remove prepared images
These are no-longer used. Drop them.

Signed-off-by: Simon Glass <sjg@chromium.org>
(cherry picked from commit bda30f83f9)
2025-12-24 05:16:56 -07:00
Simon Glass
60788f5431 ext4l: Add ls command support
Implement directory listing (ls) for the ext4l filesystem driver. This
includes path resolution with symlink following (limited to 8 levels to
prevent loops).

Add ext4l_ls() which uses ext4_lookup() for path resolution and
ext4_readdir() for directory enumeration. The dir_context actor callback
formats and prints each directory entry.

Export ext4_lookup() from namei.c and add declarations to ext4.h.

Add test_ls to the Python test suite, which creates a test file using
debugfs and verifies it appears in the directory listing with the
correct size.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>

Cover-letter:
ext4l: Add support for listing directoties (Part H)
This series adds directory-listing support to the ext4l filesystem
driver. It exports a few required functions from the Linux ext4 code,
fixes the dir_emit() stub to properly call the actor callback, and
implements ext4l_ls() with path resolution and symlink following.
END

Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-22 16:49:47 -07:00
Simon Glass
65ce554ee6 test: fs: Add ext4l filesystem tests
Add initial tests for the ext4l filesystem driver:

- fs_test_ext4l_probe_norun: verifies the driver can probe and mount
  an ext4 filesystem
- fs_test_ext4l_msgs_norun: verifies the ext4l_msgs env var causes
  mount messages to be printed

The C tests use UTF_MANUAL flag and accept fs_image argument,
following the pattern established by fs_basic.c. The Python wrapper
creates an ext4 image and calls the C tests.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-22 16:49:47 -07:00
Heinrich Schuchardt
472fd4aa09 test: fix test_extension.py
extension_bootdev_hunt may have already run.
Without reboot we cannot make any assumption here.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
(cherry picked from commit d01720a8305a1e12b61bb40ff76c3a8a0d52d2f6)
[Resolved conflict: used ubman instead of u_boot_console per ci/master rename]
2025-12-20 08:25:37 -07:00
Simon Glass
5ef532deaa test/py: Simplify test_distro_arm_app_efi
The GRUB menu editing approach is fragile because:
1. GRUB can auto-boot before the test interacts with the menu
2. The command line content varies (e.g. '$vt_handoff' vs 'quiet splash')
3. Character-by-character navigation depends on exact screen layout

Simplify to just verify that EFI boot through GRUB reaches Linux
userspace, without trying to edit the kernel command line.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-19 21:49:06 -07:00
Simon Glass
652e93b301 test/py: Use longer timeout for lab-mode restart
When restarting U-Boot in lab mode, ensure_spawned() sets the timeout
to TIMEOUT_MS (30 seconds) before calling _wait_for_boot_prompt(). In
lab mode, _wait_for_banner() is skipped, so TIMEOUT_PREPARE_MS is never
restored.

This causes tests that boot into Linux and then restart U-Boot (like
test_distro_script) to fail with a timeout if the board takes more than
30 seconds to reset and boot.

Fix this by setting the timeout to TIMEOUT_PREPARE_MS (3 minutes) at
the start of _wait_for_boot_prompt() when in lab mode.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-19 21:48:59 -07:00
Simon Glass
32c67c43fb test: fs: Update Python tests to call C implementations
Update test_basic.py to call the new C-based filesystem tests via the
'ut' command. This allows tests to run more directly, calling the actual
FS layer, without having to go through the command interface and
worrying about which filesystem command to use.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-14 09:52:56 -07:00
Simon Glass
6e5c5a0993 test: vbe: Fix the ut-flag order in vbe_test_fixup_norun()
Move the -f flag before the suite name since ut parses flags
before the suite argument.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-14 07:15:34 -07:00
Simon Glass
caa5edc39c test: Add mmc13 and mmc14 devices for TKey and pre-derived
Add two new MMC test devices:

- mmc13: LUKS2 encrypted with TKey-derived key, for testing TKey-based
  disk encryption unlock
- mmc14: LUKS2 encrypted with a known master key, for testing the
  pre-derived master key unlock path

The test setup generates keys matching the TKey emulator's deterministic
output. An override.bin file can be used to test with a physical TKey.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-08 05:22:18 -07:00
Simon Glass
daa53f61a9 test: fs_helper: Support LUKS keyfile and master key
Add encrypt_keyfile and master_keyfile parameters to FsHelper and the
image setup functions. This allows creating encrypted test images using:

- A key file instead of a passphrase (encrypt_keyfile)
- A specific master key for pre-derived unlock testing (master_keyfile)

The keyfile takes precedence over passphrase when both are provided.
Also reduce Argon2 memory parameters to values suitable for U-Boot
testing.

These new features will allow use of a real TKey for trying out this
feature locally, as well as the emulated TKey for automated testing.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-08 05:22:18 -07:00
Simon Glass
819ef32f87 fit: Move values one column to the right
Line up the values witht the FIT Description and Created items at the
top. This looks a little nicer.

Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-19 19:51:46 -07:00
Simon Glass
ff60648e0b test: fit: Add pytest for mkimage output
Add a new pytest to check the output of 'mkimage -l' on the test FIT.

Only check the first 80 chars as the signature lines can be very long.

The timestamps are quite annoying, since we need the test to pass on
whatever CI machine is used. Obtain the first timestamp and use that to
check the rest, after some sanity checks.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-19 19:40:54 -07:00
Simon Glass
90dc46ddfd test: fit: Add test for missing FIT description
Add a test to verify that fit_print_contents() correctly handles a FIT
image with a missing description property.

To handle this a new FIT created with the description removed after
mkimage has processed it, since mkimage will fail if the description is
missing.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-19 19:39:10 -07:00
Simon Glass
1214d7760d test: fit: Test the remaining features and edge cases
Add support for testing the loadables, fpga, compatible properties and
unavailable/error conditions in FIT configurations.

With this, most of the FIT-printing code is covered by tests.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-19 19:39:10 -07:00
Simon Glass
be2786c1f0 test: fit: Test printing a FIT with multiple FDTs
Update the FDT fdt to include two separate FDT images, referenced by the
two configurations.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-19 19:39:10 -07:00
Simon Glass
b1595b0f55 test: Add signature-testing to the FIT-printing test
Add a signature node to the FIT configuration in the ITS template, using
a fixed RSA-2048 private key for reproducible signatures. Use the default
'pkcs-1.5' padding.

Use mkimage to sign it.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-19 19:39:10 -07:00
Simon Glass
4bbf198c46 test: Add a test for FIT image printing
The code for printing FITs is quite messy, with lots of separate
printf() calls, an indentation string, etc.

It also has no tests.

In preparation for refactoring this code, add a test. Use Python code
to create the test image and C code to test it.

The test covers FIT description, image details (type, architecture, OS,
addresses), and configuration details.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-19 19:39:09 -07:00
Simon Glass
6359810bbc test/py: Avoid pulling in Labgrid with tests
When Labgrid is installed as an editable package (pip install -e),
pytest automatically loads it as a plugin. This can interfere with
U-Boot's test suite.

Disable automatic loading of the Labgrid pytest plugin to prevent
conflicts.

Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-17 06:59:47 -07:00
Simon Glass
b2e53c814d test: Switch mmc12 over to use argon2id
Use the more common argon2id algorithm for this disk so that we can test
the implementation.

Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-11 04:16:42 -07:00
Simon Glass
b614f6b2a7 test: Add a way to create a LUKS2 partition with XTS
For LUKS version 2, argon is normally used in preference to pbkdf2. Add
an argument to specify this when creating a filesystem.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-11 04:16:23 -07:00
Simon Glass
1dcfa2ecbb test: Shorten the encrypt_passphrase parameter for FsHelper
This is very long and the 'encrypt' part is implied by the passphrase.
Shorten it to just 'passphrase'.

Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-11 04:15:03 -07:00
Simon Glass
eb2ae89f55 luks: Create a disk image with LUKS2 encryption
Add a new mmc12 image which has a LUKS2-encrypted ext4 partition.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-24 21:02:11 +01:00
Simon Glass
838f9ce777 luks: Encrypt the mmc11 test image
Encrypt the ext4 partition in this image so that we can use it for
tests.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-24 20:12:40 +01:00
Simon Glass
444dd0a4fd luks: Add a way to create an encrypted partition
If requested, use cryptsetup to encrypt a partition with the provided
passphrase.

This requires use of sudo since there doesn't seem to be any other way
to write files into a filesystem on an encrypted disk.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-24 20:12:25 +01:00
Simon Glass
8863215954 test/py: Set up an Ubuntu image with space for FDE
Update one of the Ubuntu images to provide space for using full-disk
encryption.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-24 08:47:38 +01:00
Simon Glass
31fd3d283e test/py: Support FDE with the extlinux image
Add a parameter to indicate the size of the root partition so that it
can have space for the LUTS metadata.

Move the import of gzip to the top of the file while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-24 08:47:38 +01:00
Simon Glass
79cabfeb63 test/py: Support creating space after a filesystem
At present the partition size is always the same as the filesystem
within it. Add a way to specify a larger size, to make space for LUTS
tables needed for full-disk encryption.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-24 08:47:38 +01:00
Simon Glass
d6e71fafcd boot: test: Add another Ubuntu image on mmc11
Bring in a test image which has a different version of Ubuntu.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-18 09:38:25 +01:00
Simon Glass
648cc3c926 test/py: Mark a few more tests as slow
These are the top five slowest test as reported from 'make qcheck':

   42.2s  test_dep_esl
   29.7s  test_dep_hwids
   17.3s  test_dep_dtbo
    6.4s  test_bind_unbind_with_node
    5.2s  test_fit_auto_signed

Mark them as slow so that they are skipped with 'make qcheck'.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-18 09:07:43 +01:00
Simon Glass
c2ad688206 test/py: Make test_bind_unbind_with_uclass() independent
Unbind the test node at the start of this test, so that it can be run
independently from test_bind_unbind_with_node()

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-18 09:07:40 +01:00
Simon Glass
2f4e1b291f test: Allow creating disks with a different Ubuntu version
Add a way to specify the (fake) Ubuntu release being used, so that we
can (later) add more tests for this case.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-25 09:43:54 -06:00
Simon Glass
c3646ef52e test: Deal with the silent menu in grub
The distro test for EFI in the EFI ARM app is currently flaky.

If the test does not send an 'escape' character, then the board may boot
straight into Ubuntu. If it does, but didn't need to, then grub sits at
the command prompt.

Handle this by pressing escape twice (which should always go to the grub
command line), then using the 'normal' command to start the menu.

Series-to: concept
Series-cc: heinrich

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-23 13:45:23 -06:00
Simon Glass
16a1847b06 efi: test: Update distro EFI-app tests for new naming
The EFI-media devices names were recently changed to make it easier to
tell them apart. Update the tests as well, since this change caused them
to fail.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: dea4ea00a7 ("efi: Set the efi_media device name when binding")
2025-09-23 12:25:40 -06:00
Simon Glass
ad59fee0e8 test: Add newlines at the end of the img functions
The functions which create images lack a newline at the end of the file.
Add one, for consistency.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-14 17:32:24 -06:00
Simon Glass
3f24d8b2e2 test: ulib: Add a test for the rust example
Provide a test which is similar to the ulib example, to make sure that
the Rust programs can be built correctly.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-11 15:19:22 -06:00
Simon Glass
fe981e965f test: Tighten up the code in test_make_dep.py
This makes a few changes to improve code readability:

- Avoid skipping tests
- Put all tests at bottom
- Shorten messages
- Avoid searching for files; just use those known to be there

Series-to: concept
Series-cc: heinrich

Signed-off-by: Simon Glass <sjg@chromium.org>
Series-links: 1:30
2025-09-10 11:37:29 -06:00
Simon Glass
ccd038bdcf test/py: Add ESL dependency tracking test
Add test for ESL (EFI Signature List) dependency chain that verifies proper
dependency tracking when FORCE is removed. Tests the transformation chain:
certificate -> ESL file -> DTSI file

The test ensures that:
- Certificate changes trigger ESL file rebuild
- ESL file changes trigger DTSI file rebuild
- Template changes rebuild DTSI but not ESL file
- No unnecessary rebuilds occur when dependencies are unchanged

Series-to: concept
Cover-letter:
Makefile: Reduce unnecessary rebuilds
In a few cases, U-Boot always rebuilds files even if nothing has
changed. This series fixes these and adds some tests which attempt to
show that these changes cause no problems.

The affected build rules are:

- converting htids to dtsi
- building devicetree overlays
- converting a certificate to an ESL file and a dtsi
END

Co-developed-by: Claude <noreply@anthropic.com>
Co-developed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-09 22:58:34 +00:00
Simon Glass
6247067f46 test/py: Add test for dtbo dependency tracking
Add a comprehensive test to verify that the $(obj)/%.dtbo rule properly
tracks dependencies and rebuilds when the corresponding .dtso source
file is modified. This ensures that removing FORCE from the dtbo rule
still maintains correct dependency tracking behavior.

The test creates a sample device tree overlay (.dtso) file and verifies:
- Initial build creates the .dtbo file
- Subsequent builds don't rebuild when nothing changed
- Changes to the .dtso source file trigger a rebuild

Co-developed-by: Claude <noreply@anthropic.com>
Co-developed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-09 22:58:34 +00:00
Simon Glass
2699626960 test/py: Add test for Makefile dependency tracking
Add a comprehensive test to verify that Makefile dependency tracking
works correctly when FORCE is removed from build rules. The test
ensures that targets are rebuilt when dependencies change but not
when they remain unchanged.

Co-developed-by: Claude <noreply@anthropic.com>
Co-developed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-09 22:58:34 +00:00
Simon Glass
f457b31524 test/py: Add a test for ulib functionality
Provide a test that checks that ulib operates as expected.

Add a .gitignore file for the executables thus created

There is a strange interaction with PLATFORM_LIBS which can cause the
examples to fail to build via 'make qcheck':

- CI runs 'make qcheck'
- the main Makefile sets PLATFORM_LIBS
- test/run calls test.py
- at some point test_ulib_demos() starts, with PLATFORM_LIBS set
- the test calls 'make' on examples/ulib/Makefile
- PLATFORM_LIBS is left alone, since it already has a value
- lSDL ends up not being in the link line

Thank you to Claude for helping to debug this and figure out the
PLATFORM_LIBS interaction.

Series-to: concept
Series-cc: heinrich
Cover-letter:
ulib: Complete initial U-Boot library

This series completes support for building U-Boot as a shared or static
library, enabling reuse of U-Boot functionality in external programs and
test suites.

The U-Boot library (ulib) allows developers to:
- Link against U-Boot functionality without a full U-Boot image
- Use U-Boot's OS abstraction layer, drivers, and utility functions
- Build test programs that can exercise U-Boot code in isolation
- Create applications that benefit from U-Boot's hardware support

Key features:
- Builds both shared (libu-boot.so) and static (libu-boot.a) libraries
- Preserves U-Boot linker lists for proper driver/subsystem init
- Configurable symbol renaming to avoid conflicts with system libraries
- Generated API headers with renamed function declarations
- Documentation and working examples
- Currently only supports sandbox architecture

The series includes:
- More build-infrastructure and Makefile integration
- Python-based mechanism for symbol renaming and API generation
- Test programs demonstrating basic library usage
- A simple example program showing real-world usage patterns

Symbol renaming ensures that U-Boot functions don't conflict with system
libraries. For example, printf() remains the standard library function
while ub_printf() provides access to U-Boot's printf implementation.
This is handled automatically during the build process.

The library excludes main() to allow external programs to provide their own
entry points while still accessing U-Boot functionality through ulib_init()
and ulib_uninit().

For example:

    #include <u-boot-lib.h>
    #include <u-boot-api.h>

    int main(int argc, char *argv[])
    {
        if (ulib_init(argv[0]) < 0)
            return 1;

        ub_printf("Hello from U-Boot library!\n");

        ulib_uninit();

        return 0;
    }

License implications are documented - the GPL-2.0+ license applies to
any programs linked with the library, requiring source code distribution
for compliant usage.

Future work will look at expanding support to other architectures.
END

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-09 09:14:05 -06:00
Simon Glass
e2d8843922 test/py: Allow setting the cwd with run_and_log()
Sometimes it is useful to run a command in a particular subdirectory.
Add support for this to the run_and_log() functions.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-08 12:16:38 -06:00
Simon Glass
0d11fbb0e2 test: Move the non-LTO test to sandbox_flattree
The sandbox build is about to be used for ulib, so will not support LTO.
Use the sandbox_flatree build to check disabling LTO.

There is limited value in this, since sandbox will already check
building without LTO. But it seems reasonable to keep the test working,
making sure that the same board can build with and without LTO.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-08 12:16:38 -06:00
Simon Glass
8ee598e20c test: Add more SMBIOS data to sandbox
Some common smbios settings are not included with sandbox. Add these to
test.dts so the data is more meaningful.

Update smbios tests to match the new devicetree values.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-04 07:08:24 -06:00
Simon Glass
149fe34151 test/py: Disable terminal detection with sandbox tests
Detecting the terminal size results in unwanted output in tests. Use the
-A option to disable this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-26 14:36:07 -06:00
Simon Glass
03fde8e2bf test/py: Disable the pager when running sandbox tests
The pager gets in the way of most tests, since it kicks in (by default)
when a command results in more than 25 lines of output. Use the -P flag
to bypass it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-26 14:36:07 -06:00
Simon Glass
b60fd4dae9 efi: Change env print -e to show only names by default
Change the default behavior of 'printenv -e' to show only EFI variable
names. The previous verbose output is now available with the -v flag.
This makes the command more user-friendly for quick variable listing.

Update documentation to reflect the new behavior and provide examples
of all three output modes: default (names only), -n (details without
hex dump), and -v (full verbose output).

It might be nicer to use -d to enable the dump, rather than have it on
by default.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-22 08:23:17 -06:00
Simon Glass
96d39714e4 test: efi: Add a test for the app booting Ubuntu via EFI
Now that the EFI app supports booting Ubuntu via the EFI bootmeth, add
a test for this, for ARM. This uses the sjg lab.

Series-to: concept
Series-cc: heinrich
Cover-letter:
efi: app: Support booting an OS
This series completes the work to get the EFI app booting an EFI
application (e.g. Ubuntu):

- efidebug dh now works, and is slightly enhanced
- device paths which refer to the underlying EFI layer can now be
  requested by the app
- a test is provided, for EFI on ARM booting into Ubuntu using the sjg
  lab
END

Signed-off-by: Simon Glass <sjg@chromium.org>
Series-links: 1:12
2025-08-20 10:07:17 -06:00
Simon Glass
a7117cda66 test/py: Support a timing report when max_count is 0
If only a single test runs, it does not set the max_count variable, so
it remains as zero. Handle this situation as a special case.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 10:07:17 -06:00
Simon Glass
165aed7671 test: Update test_fdt_add_pubkey() to use a separate dir
This test uses the same directory as the vboot tests, which means that
they conflict when tests are run in parallel.

Add a 'pk-' prefix to avoid this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-20 07:41:19 -06:00
Simon Glass
b351843588 test: Move localboot image-creation to its own file
Move setup_localboot_image() to a new module

Series-to: concept
Cover-letter:
test: Split up the image-creation code
This series moves the image-creation code into separate files so it is
easier to find and maintain.
END

Signed-off-by: Simon Glass <sjg@chromium.org>
Co-authored-by: Claude <noreply@anthropic.com>
2025-08-17 15:32:25 -06:00