3277 Commits

Author SHA1 Message Date
Evgeny Bachinin
54f6f7134d test: sandbox: fix invalid_use_of_IF_ENABLED_INT if BLOBLIST=n
Having CONFIG_OF_EMBED=y && CONFIG_BLOBLIST=n leads to the link
error:
```
ld: /tmp/ccRVty.ltrans40.ltrans.o: in function `lib_test_is_enabled':
test/lib/kconfig.c:24: undefined reference to \
                                       `invalid_use_of_IF_ENABLED_INT'
ld: test/lib/kconfig.c:26: undefined reference to \
                                `invalid_use_of_CONFIG_IF_ENABLED_INT'
```

Fixes: 29784d62ed ("test: Add some tests for kconfig.h")
Signed-off-by: Evgeny Bachinin <EABachinin@salutedevices.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
(cherry picked from commit 844f87366e)
2025-12-24 05:17:02 -07:00
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
Sam Protsenko
23525e545d lmb: Return -EEXIST in lmb_add_region_flags() if region already added
An attempt to add the already added LMB region using
lmb_add_region_flags() ends up in lmb_addrs_overlap() check, which
eventually leads to either returning 0 if 'flags' is LMB_NONE, or -1
otherwise. It makes it impossible for the user of this function to catch
the case when the region is already added and differentiate it from
regular errors. That in turn may lead to incorrect error handling in the
caller code, like reporting misleading errors or interrupting the normal
code path where it could be treated as the normal case. An example is
boot_fdt_reserve_region() function, which might be called twice (e.g.
during board startup in initr_lmb(), and then during 'booti' command
booting the OS), thus trying to reserve exactly the same memory regions
described in the device tree twice, which produces an error message on
second call.

Return -EEXIST error code in case when the added region exists and it's
not LMB_NONE; for LMB_NONE return 0, to conform to unit tests
(specifically test_alloc_addr() in test/lib/lmb.c) and the preferred
behavior described in commit 1d9aa4a283 ("lmb: Fix the allocation of
overlapping memory areas with !LMB_NONE"). The change of
lmb_add_region_flags() return values is described in the table below:

    Return case                        Pre-1d9   1d9    New
    -----------------------------------------------------------
    Added successfully                    0      0      0
    Failed to add                         -1     -1     -1
    Already added, flags == LMB_NONE      0      0      0
    Already added, flags != LMB_NONE      0      -1     -EEXIST

Rework all affected functions and their documentation. Also fix the
corresponding unit test which checks reserving the same region with the
same flags to account for the changed return value.

No functional change is intended (by this patch itself).

Fixes: 1d9aa4a283 ("lmb: Fix the allocation of overlapping memory areas with !LMB_NONE")
Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Tested-by: Michal Simek <michal.simek@amd.com>
(cherry picked from commit 8b8b35a4f5)
2025-12-17 14:02:26 -07:00
Ilias Apalodimas
38a2583258 lmb: Fix the allocation of overlapping memory areas with !LMB_NONE
At the moment the LMB allocator will return 'success' immediately on two
consecutive allocations if the second one is smaller and the flags match
without resizing the reserved area.

This is problematic for two reasons, first of all the new updated
allocation won't update the size and we end up holding more memory than
needed, but most importantly it breaks the EFI SCT tests since EFI
now allocates via LMB.

More specifically when EFI requests a specific address twice with the
EFI_ALLOCATE_ADDRESS flag set, the first allocation will succeed and
update the EFI memory map. Due to the LMB behavior the second allocation
will also succeed but the address ranges are already in the EFI memory
map due the first allocation. EFI will then fail to update the memory map,
returning EFI_OUT_OF_RESOURCES instead of EFI_NOT_FOUND which break EFI
conformance.

So let's remove the fast check with is problematic anyway and leave LMB
resize and calculate address properly. LMB will now
- try to resize the reservations for LMB_NONE
- return -1 if the memory is not LMB_NONE and already reserved

The LMB code needs some cleanup in that part, but since we are close to
2025.01 do the easy fix and plan to refactor it later.
Also update the dm tests with the new behavior.

Fixes: commit 22f2c9ed9f ("efi: memory: use the lmb API's for allocating and freeing memory")
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
(cherry picked from commit 1d9aa4a283)
2025-12-16 20:38:21 -07:00
Jerome Forissier
8647480ac9 test/cmd/wget.c: move net_test_wget() to the cmd test suite
Since net_test_wget() is testing a command and is in test/cmd it should
be in the 'cmd' test suite, not 'lib'.

Saving and restoring the values of the environment variables that the
test manipulates is necessary to avoid a regression when running the
whole ut test suite. A minimal reproducer is:

 $ ./u-boot -T -c "ut cmd net_test_wget; ut dm dm_test_eth_act" | \
     grep -E "(Test:|Failures:)"

Reported-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
(cherry picked from commit 20f641987f)
2025-12-16 11:12:15 -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
72aeb4a2e2 test: fs: add C-based filesystem tests
Add C implementations of filesystem tests that can be called via
the 'ut fs' command. These tests use UTF_MANUAL flag since they require
external setup, i.e. creation of filesystem images.

This covers the existing TestFsBasic tests.

The tests use typed arguments (fs_type, fs_image, md5 values) passed
via the command line.

Add a few helpers to make the code easier to read.

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
2ac3226758 test: Add tests for unit-test arguments
Add a set of tests to check the behaviour of test arguments and the ut
command. This includes failure cases, where the wrong type or a
non-existent argument is requested.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-14 09:17:31 -07:00
Simon Glass
688e830a22 test: Allow preserving console recording on failure
Update the 'ut' command to have a -R command option to prevent ut_fail()
and ut_failf() from clearing GD_FLG_RECORD. This is useful when testing
the test framework itself, where error messages need to be captured.

Refactor ut_fail() and ut_failf() to call ut_unsilence_console() instead
of duplicating the flag-clearing logic.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-14 09:17:14 -07:00
Simon Glass
a9d6c0322e test: Add type-checked argument accessor functions
Add ut_get_str(), ut_get_int(), and ut_get_bool() functions with
corresponding ut_str(), ut_int(), and ut_bool() macros for accessing
test arguments with type checking.

These functions check that the argument index is within bounds and the
type matches what was requested.

The first failure for a test is reported via ut_failf() which should
make it fairly easy to debug the test.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-14 09:14:52 -07:00
Simon Glass
64850634f0 test: Enhance the ut command to pass test arguments
Update the ut command to permit passing arguments to tests.

Usage: ut -f fs test_name key1=value1 key2=value2

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-14 09:14:41 -07:00
Simon Glass
a3b60a2094 test: Add support for passing arguments to C tests
Add support for passing key=value arguments to unit tests. The test
framework parses arguments based on definitions provided by each test
and makes them available via uts->args[]

For now the 'ut' command does not support this new feature.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-14 09:14:34 -07:00
Simon Glass
1fbf894923 test: Add a helper to check the next line against a regex
Add a new ut_assert_nextline_regex() macro and ut_check_console_line_regex()
helper to check console output against a regex pattern. This is useful when
the exact output varies (e.g., file paths or line numbers in error messages).

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-14 09:12:44 -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
2ddc96ae88 vsprintf: Add support for the %pV format-specifier
Add support for the %pV format-specifier which allows printing a
struct va_format. This is used by the Linux kernel for recursive
printf() formatting and is needed by the ext4l filesystem driver.

Add the struct to include/linux/printk.h to match the kernel location.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-13 16:28:53 -07:00
Simon Glass
754a755e4a malloc: Record caller backtrace for each allocation
When CONFIG_MCHECK_HEAP_PROTECTION is enabled, use backtrace_str() to
capture the caller information for each malloc/calloc/realloc/memalign
call. This information is stored in the mcheck header and can be viewed
with 'malloc dump'.

Add a flag to disable the backtrace when the stack is corrupted, since
the backtrace code tries to walks the invalid stack frames and will
crash.

Note: A few allocations made during libbacktrace initialisation may
not have caller info since they occur during the first backtrace call.

Example output showing caller info:
    18a1d010   90  used  log_init:453 <-board_init_r:774
    18a1d0a0 6060  used  membuf_new:420 <-console_record
    18a3b840   90  used  of_alias_scan:911 <-board_init_

Fix up the backtrace test to avoid recursion.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-10 05:53:03 -07:00
Simon Glass
ee8e9bf104 malloc: Add malloc dump command to walk the heap
Add a new 'malloc dump' command that walks the dlmalloc heap from start
to end, printing each chunk's address, size (in hex), and status
(used/free/top). This is useful for debugging memory allocation issues.

When CONFIG_MCHECK_HEAP_PROTECTION is enabled, the caller string is
also shown if available.

Example output:
    Heap dump: 18a1d000 - 1ea1f000
         Address        Size  Status
    ----------------------------------
        18a1d000          10  (chunk header)
        18a1d010          90  used
        18adfc30          60  <free>
        18adff90     5f3f030  top
        1ea1f000              end
    ----------------------------------
    Used: c2ef0 bytes in 931 chunks
    Free: 5f3f0c0 bytes in 2 chunks + top

Expand the console-record size to handle this command.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-10 05:53:03 -07:00
Simon Glass
d8b19014d7 malloc: Add call counters for malloc, free, realloc
Add counters to track the number of calls to malloc(), free(), and
realloc(). These are displayed by the 'malloc info' command and
accessible via malloc_get_info().

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-10 05:53:03 -07:00
Simon Glass
cfbee94582 malloc: Add 'malloc' command with 'info' subcommand
Add a command to display malloc heap statistics, showing total heap
size and memory currently in use.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-10 05:53:03 -07:00
Simon Glass
0cf38dc8c8 backtrace: Add backtrace_str() for condensed backtrace output
Add a new function backtrace_str() that returns a condensed backtrace
string containing function names and line numbers separated by " <-".

For example: "func_a:123 <-func_b:456 <-func_c:789"

This is useful for logging and debugging where a compact representation
of the call stack is needed. The depth is controlled by the new
CONFIG_BACKTRACE_DEPTH option (default 3).

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-10 05:53:03 -07:00
Simon Glass
e1e95b2887 backtrace: Use a static buffer in backtrace_ctx for symbols
Replace the dynamic allocation in os_backtrace_symbols() with a static
buffer embedded in struct backtrace_ctx. This avoids malloc recursion
when backtrace is called from within dlmalloc (e.g., for the upcoming
mcheck caller-tracking).

The API gets a complete rework as part of this:

- Combine addrs[] and syms[] arrays into struct backtrace_frame with
  addr and sym fields
- Store the strings in a unified buffer, with pointers from an array
- Change os_backtrace_symbols() to take ctx pointer and fill sym_buf
- Remove os_backtrace_symbols_free() as nothing needs freeing
- Rename BACKTRACE_MAX to BACKTRACE_MAX_FRAMES

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-10 05:53:03 -07:00
Simon Glass
95f10a6302 malloc: Make mcheck respect REALLOC_ZERO_BYTES_FREES
The mcheck wrapper for realloc() unconditionally frees memory and
returns NULL when size is 0. This differs from dlmalloc's default
behaviour which returns a minimum-sized allocation unless
REALLOC_ZERO_BYTES_FREES is defined.

Make the mcheck wrapper respect the same REALLOC_ZERO_BYTES_FREES
setting for consistent behavior with or without mcheck enabled.

Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-10 05:53:03 -07:00
Simon Glass
c17d68b0fb test: Show the required size when console-record overflows
When the console-record buffer overflows, show both the current buffer
size and the size needed. This helps the user know what value to set
for CONFIG_CONSOLE_RECORD_OUT_SIZE.

Add a console_out_ovf field to global_data to track the number of bytes
that could not be written due to overflow.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-10 05:53:03 -07:00
Simon Glass
8f8c862a7a test: Add ut_asserteq_regex() for regex pattern matching
Add a new assertion macro ut_asserteq_regex() that checks if a string
matches a regular expression pattern using the SLRE library.

This is useful for tests where exact string-matching is difficult, such
as when output contains line numbers or other variable content.

Use a helper function ut_check_regex() to avoid including slre.h in the
header.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-10 05:53:03 -07:00
Simon Glass
bf72ede55e lib: Add format_size() to format sizes as strings
Refactor print_size() to use a new format_size() helper that formats
a size into a buffer. This allows callers to get the formatted string
without printing it directly.

The format_size() function is only exported in U-Boot proper (controlled
by CONFIG_LIB_FORMAT_SIZE) to avoid code-size impact in SPL/TPL where it
remains static.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-10 05:53:03 -07:00
Simon Glass
69d2f4ab58 video: truetype: Use pre-allocated buffer for glyph rendering
The TrueType console driver calls malloc/free for every character
rendered, which causes significant memory fragmentation and allocation
traffic.

Add CONFIG_CONSOLE_TRUETYPE_GLYPH_BUF to enable a pre-allocated buffer
in the driver's private data. The buffer starts at 4KB and grows via
realloc() as needed. When rendering a glyph, use this buffer to avoid
malloc/free for normal characters.

The buffer is allocated lazily after relocation to avoid consuming
early malloc space before the full heap is available.

Add CONFIG_VIDEO_GLYPH_STATS (default y on sandbox) to track the number
of glyphs rendered. Use 'font info' to view the count.

Series-changes: 2
- Rename the Kconfig to just enable the feature: always allocate

Co-developed-by: Claude Opus 4 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-10 05:53:00 -07:00
Simon Glass
82be61976f test: dm: Fix delta usage in dm_test_devres_free()
This test passes delta values to ut_check_delta() where it expects
absolute values. ut_check_delta(last) computes (current - last), so
'last' must be an absolute reference point from a previous
ut_check_delta(0) call, not a delta.

The bug causes incorrect memory accounting that happens to work with
smaller allocation overhead but fails when mcheck header size increases.

Use ut_check_delta(0) to capture absolute reference points before each
operation.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-09 06:28:04 -07:00
Simon Glass
e0aa4bfae6 test: dm: Fix memory leaks in test drivers
The test_manual_drv driver allocates private data in its probe function
with calloc(), but never frees it in remove(). Add the missing free()
call to test_manual_remove().

Similarly, create_children() allocates platform data with calloc() and
sets it with dev_set_plat(), but doesn't set the DM_FLAG_ALLOC_PDATA
flag. This flag tells the device removal code to free the platform data.
Set this flag so driver model will free the allocated memory on unbind.

These fixes eliminate memory leaks that caused the malloc_dump output
to grow excessively after running DM tests.

Co-developed-by: Claude Opus 4 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-09 05:59:53 -07:00
Simon Glass
4d30a452bc test: bootctl: Add passphrase UI and TKey unlock tests
Add tests for the bootctl passphrase entry UI and TKey-based LUKS
unlock flow:

- check_passphrase(): Tests the passphrase textline widget, verifying
  character input, backspace handling, and passphrase retrieval

- prepare_tkey_test(): Sets up the TKey emulator with a test pubkey
  and configures app mode to test replugging scenarios

- try_tkey_unlock(): Tests the complete TKey unlock flow including
  passphrase entry and LUKS partition decryption

- bootctl_logic_tkey: Full integration test for TKey-based encrypted
  boot with mouse click interactions

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
3313195a6f test: luks: Add test for pre-derived master key unlock
Add a test for the LUKS pre-derived master key unlock path using mmc14.
The test verifies that:

- A LUKS partition can be unlocked with the correct pre-derived key
- Files can be read from the decrypted filesystem
- Unlock fails with an incorrect pre-derived key

This exercises the -p flag path in the luks unlock command.

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
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
81f9a02891 bootctl: Enable the tests
Enable the bootctl tests (only for the sandbox board) so we can keep
this functionality working.

Series-to: concept
Cover-letter:
bootctl: Continue development with TKey functionality
This series integrates the TKey disk-unlock features into the bootctl
UI, as a demonstration of how this might work. The user is prompted for
a passphrase, which is then used as a user-supplied secret (USS) for the
TKey.

This series includes support for using a pre-derived master key, so that
the TKey emulator can be used in tests.

Future work will continue this effort.
END

Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-07 17:18:57 -07:00
Simon Glass
3006b1ad45 bootctl: Fix up the header-inclusion order in the test
The bootctl headers should before the test headers. Fix this.

Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-07 17:18:57 -07:00
Simon Glass
4fb40b79a6 bootctl: Show a lock symbol for locked disks
When an OS is using disk encryption, show a lock symbol next to it.

Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-07 17:18:57 -07:00
Simon Glass
ceab1d8010 bootctl: Allow switching between logos
The bootctl tests are currently disabled due to some image
incompatibilities: the multi UI uses one image and the simple UI uses a
different one.

Update the logic to switch between these logos when the layout changes.
For now, use the U-Boot logo in both cases.

Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-07 17:18:57 -07:00
Simon Glass
b766b80826 video: Add a lock image
Add an image which represents a locked disk.

Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-07 17:18:57 -07:00
Simon Glass
7c6983bc3c test: expo: Add a test for textline rendering in an expo
Add a test that creates a textline in a non-popup expo, renders it,
opens it, sends keypresses to edit text (including cursor movement
with Ctrl+B and character deletion with Ctrl+D), and verifies the
text is saved when the textline is closed.

Series-to: concept
Series-cc: heinrich
Cover-letter:
expo: Expand docs, dump and textlines in non-popup expos
So far textlines are mostly used in cedits as a way to enter textual
information.

For non-popup expos, textlines are not yet fully plumbed in.

This series adds a way to send keypresses to a highlighted textline,
adds a test for this case and fixes various minor issues to make this
all work.

One noteable change is renumbering the BKEY enum. At present the values
conflict with the control keys used by CLI processing, so for example,
expo is unable to distinguish an up-arrow from a backspace.

Tests which use textedits mostly need to run with the console active,
since a silent console suppresses output of the text in the textedit.
In fact, at present cedit_render_lineedit() does not work unless the
previous test ran first. A new UTF_NO_SILENT test flag is added to make
this problem easier to discover/debug.

This series also resolves an issue where the 'cedit dump' is never
enabled due to a typo in the Kconfig item. With that fixed, the dump
format is converted to use hex (U-Boot convention). The expo menu and
cedit implementations are updated to use better names for objects.

This series also includes some documentation updates, since much of the
debugging methods used are not explicitly described. This should make it
easier for others to make improvements.

With all of this complete, it is possible to have a password field in a
menu item and to enter text into it, even with a non-popup expo. It also
becomes easier to debug such issues in future.
END

Co-developed-by: Claude <claude@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-07 12:11:45 -07:00
Simon Glass
8ddf1dbd6e test: cedit: Allow cedit_render_lineedit() to run alone
This test works as part of the bootstd suite but currently fails if run
by itself. The problem is that the console is silenced, so use the new
UTF_NO_SILENT flag to fix this.

Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-07 11:53:55 -07:00
Simon Glass
daafb72443 test: cedit: Use UTF_NO_SILENT
Use the UTF_NO_SILENT flag for cedit_render() instead of manually
calling ut_unsilence_console()/ut_silence_console(). This is makes it
more obvious that the test needs this handling.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-07 11:53:55 -07:00
Simon Glass
4ce003192f expo: Use better names for child objects in expo_build
Use the parent object name as a prefix for child objects, so they
have descriptive names like "cpu-speed.title" instead of generic
"title". This makes debugging easier when multiple objects exist.

Update add_txt_str() and add_txt_str_list() to take separate
property name and object name parameters.

Also set the scene's prompt_id when building from devicetree.

Co-developed-by: Claude <claude@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-07 11:53:55 -07:00
Simon Glass
90ac588dc6 test: Add a flag for test which need console output
Some tests cannot run when the console is silent.

An example is an expo test which checks text entry into a textline
object. The console must be enabled so that the characters actually
reach the putc_xy() in console_truetype, since in
scene_textline_send_key(), the lineedit restores the vidconsole state,
outputs the character and then saves the state again. If the character
is never output, then the state won't be updated and the lineedit will
be inconsistent.

Rather than having individual tests handle this manually, add an
explicit flag, in the hope that this quirk does not trip anyone else up.

Put the flag next to the existing UTF_CONSOLE flag, since they are
related.

Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-07 11:43:29 -07:00
Simon Glass
1966c328b5 expo: Use textline consistently in tests
The word 'lineedit' has crept into one of the tests, but it is not
correct. Use 'textline' instead.

Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-07 11:37:56 -07:00
Simon Glass
13197ab962 test: Add some tests for dlmalloc
We know or assume that dlmalloc itself works correctly, but there is
still the possibility that the U-Boot integration has bugs.

Add a test suite for the malloc() implementation, covering:
- Basic malloc/free operations
- Edge cases (zero size, NULL pointer handling)
- realloc() in various scenarios
- memalign() with different alignments
- Multiple allocations and fragmentation
- malloc_enable_testing() failure simulation
- Large allocations (1MB, 16MB)
- Full pool allocation (CONFIG_SYS_MALLOC_LEN plus environment size)
- Fill pool test with random sizes

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-01 17:00:23 +00:00
Simon Glass
654efb5edd test: Use TOTAL_MALLOC_LEN for abuf and alist tests
Several tests use CONFIG_SYS_MALLOC_LEN to test allocations that should
fail due to exceeding pool size. However, the actual malloc pool size is
TOTAL_MALLOC_LEN, which includes CONFIG_ENV_SIZE for boards that need to
store the environment in RAM. The extra space accommodates:

- the hash table allocated via calloc()
- strdup() calls for each environment variable key
- strdup() calls for each environment variable value

This is an estimate and typically consumes less than CONFIG_ENV_SIZE,
leaving more free space in the malloc pool than was reserved.

On qemu-x86_64, CONFIG_ENV_SIZE is 0x40000, making the actual pool
0x240000 bytes. Tests expecting malloc(CONFIG_SYS_MALLOC_LEN) to fail
might unexpectedly succeed since there's more space available.

Update all tests to use TOTAL_MALLOC_LEN to correctly reflect the actual
malloc pool size.

Co-developed-by: Claude <noreply@anthropic.com>
2025-12-01 15:57:28 +00:00