diff options
| author | Martin Schwan <[email protected]> | 2026-02-18 14:35:07 +0100 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2026-03-06 12:09:17 -0600 |
| commit | 36add050eea439f0b2a15e4ea0d3a8e21216f159 (patch) | |
| tree | 28fef3ed892a88ce361cdc037432a758de27a72a /test/py | |
| parent | fe6484b402759dba6024cf2f8c212b27f769a0d7 (diff) | |
test: boot: Add test for bootmeth_rauc
Add a simple unit test for testing the RAUC bootmethod. Provide only the
very basic tests for now, running a scan and list, to verify correct
detection of the RAUC bootmethod. More advanced boot tests of this
bootmethod can be added in a separate patch.
This requires another mmc image (mmc10) to contain the following
partitions:
1. boot A: contains a dummy boot.scr
2. root A: contains an empty root filesystem
3. boot B: contains a dummy boot.scr
4. root B: contains an empty root filesystem
The bootmeth_rauc scans all four partitions for existence and expects a
boot script in each boot partition.
Also add BOOTMETH_RAUC as a dependency on sandbox so that we can test
this with:
$ ./test/py/test.py -B sandbox --build -k test_ut # build the mmc10.img
$ ./test/py/test.py -B sandbox --build -k bootflow_rauc
Signed-off-by: Martin Schwan <[email protected]>
Reviewed-by: Simon Glass <[email protected]>
[trini: mmc9 is now in use, switch to mmc10]
Signed-off-by: Tom Rini <[email protected]>
Diffstat (limited to 'test/py')
| -rw-r--r-- | test/py/tests/test_ut.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/test/py/tests/test_ut.py b/test/py/tests/test_ut.py index b7166d59943..98641a46c1d 100644 --- a/test/py/tests/test_ut.py +++ b/test/py/tests/test_ut.py @@ -554,6 +554,52 @@ def setup_efi_image(ubman): utils.run_and_log(ubman, f'rm -rf {mnt}') utils.run_and_log(ubman, f'rm -f {fsfile}') +def setup_rauc_image(ubman): + """Create a 40MB disk image with an A/B RAUC system on it""" + mmc_dev = 10 + fname = os.path.join(ubman.config.source_dir, f'mmc{mmc_dev}.img') + mnt = ubman.config.persistent_data_dir + + spec = 'type=c, size=8M, start=1M, bootable\n' \ + 'type=83, size=10M\n' \ + 'type=c, size=8M, bootable\n' \ + 'type=83, size=10M' + + utils.run_and_log(ubman, f'qemu-img create {fname} 40M') + utils.run_and_log(ubman, ['sh', '-c', f'printf "{spec}" | sfdisk {fname}']) + + # Generate boot script + script = '# dummy boot script' + bootdir = os.path.join(mnt, 'boot') + utils.run_and_log(ubman, f'mkdir -p {bootdir}') + cmd_fname = os.path.join(bootdir, 'boot.cmd') + scr_fname = os.path.join(bootdir, 'boot.scr') + with open(cmd_fname, 'w', encoding='ascii') as outf: + print(script, file=outf) + + mkimage = os.path.join(ubman.config.build_dir, 'tools/mkimage') + utils.run_and_log( + ubman, f'{mkimage} -C none -A arm -T script -d {cmd_fname} {scr_fname}') + utils.run_and_log(ubman, f'rm -f {cmd_fname}') + + # Generate empty rootfs + rootdir = os.path.join(mnt, 'root') + utils.run_and_log(ubman, f'mkdir -p {rootdir}') + + # Create boot filesystem image with boot script in it and copy to disk image + fsfile = f'rauc_boot.fat32.img' + fs_helper.mk_fs(ubman.config, 'fat32', 0x800000, fsfile.split('.')[0], bootdir) + utils.run_and_log(ubman, f'dd if={mnt}/{fsfile} of=mmc{mmc_dev}.img bs=1M seek=1 conv=notrunc') + utils.run_and_log(ubman, f'dd if={mnt}/{fsfile} of=mmc{mmc_dev}.img bs=1M seek=19 conv=notrunc') + utils.run_and_log(ubman, f'rm -f {scr_fname}') + + # Create empty root filesystem image and copy to disk image + fsfile = f'rauc_root.ext4.img' + fs_helper.mk_fs(ubman.config, 'ext4', 0xa00000, fsfile.split('.')[0], rootdir) + utils.run_and_log(ubman, f'dd if={mnt}/{fsfile} of=mmc{mmc_dev}.img bs=1M seek=9 conv=notrunc') + utils.run_and_log(ubman, f'dd if={mnt}/{fsfile} of=mmc{mmc_dev}.img bs=1M seek=27 conv=notrunc') + utils.run_and_log(ubman, f'rm -f {fsfile}') + @pytest.mark.buildconfigspec('cmd_bootflow') @pytest.mark.buildconfigspec('sandbox') def test_ut_dm_init_bootstd(ubman): @@ -565,6 +611,7 @@ def test_ut_dm_init_bootstd(ubman): setup_cros_image(ubman) setup_android_image(ubman) setup_efi_image(ubman) + setup_rauc_image(ubman) # Restart so that the new mmc1.img is picked up ubman.restart_uboot() |
