diff options
Diffstat (limited to 'test/py')
-rw-r--r-- | test/py/tests/test_efi_selftest.py | 1 | ||||
-rw-r--r-- | test/py/tests/test_fit_mkimage_validate.py | 58 | ||||
-rw-r--r-- | test/py/tests/test_gpt.py | 27 | ||||
-rw-r--r-- | test/py/tests/test_mmc.py | 30 |
4 files changed, 101 insertions, 15 deletions
diff --git a/test/py/tests/test_efi_selftest.py b/test/py/tests/test_efi_selftest.py index 12cbe5caa9b..58dac72fd40 100644 --- a/test/py/tests/test_efi_selftest.py +++ b/test/py/tests/test_efi_selftest.py @@ -179,6 +179,7 @@ def test_efi_selftest_text_input_ex(ubman): @pytest.mark.buildconfigspec('cmd_bootefi_selftest') @pytest.mark.buildconfigspec('efi_tcg2_protocol') +@pytest.mark.notbuildconfigspec('sandbox') def test_efi_selftest_tcg2(ubman): """Test the EFI_TCG2 PROTOCOL diff --git a/test/py/tests/test_fit_mkimage_validate.py b/test/py/tests/test_fit_mkimage_validate.py new file mode 100644 index 00000000000..af56f08ca10 --- /dev/null +++ b/test/py/tests/test_fit_mkimage_validate.py @@ -0,0 +1,58 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright (c) 2025 +# +# Test that mkimage validates image references in configurations + +import os +import subprocess +import pytest +import fit_util + +@pytest.mark.boardspec('sandbox') +@pytest.mark.requiredtool('dtc') +def test_fit_invalid_image_reference(ubman): + """Test that mkimage fails when configuration references a missing image""" + + its_fname = fit_util.make_fname(ubman, "invalid.its") + itb_fname = fit_util.make_fname(ubman, "invalid.itb") + kernel = fit_util.make_kernel(ubman, 'kernel.bin', 'kernel') + + # Write ITS with an invalid reference to a nonexistent image + its_text = ''' +/dts-v1/; + +/ { + images { + kernel@1 { + description = "Test Kernel"; + data = /incbin/("kernel.bin"); + type = "kernel"; + arch = "sandbox"; + os = "linux"; + compression = "none"; + load = <0x40000>; + entry = <0x40000>; + }; + }; + + configurations { + default = "conf@1"; + conf@1 { + kernel = "kernel@1"; + fdt = "notexist"; + }; + }; +}; +''' + + with open(its_fname, 'w') as f: + f.write(its_text) + + mkimage = os.path.join(ubman.config.build_dir, 'tools/mkimage') + cmd = [mkimage, '-f', its_fname, itb_fname] + + result = subprocess.run(cmd, capture_output=True, text=True) + + assert result.returncode != 0, "mkimage should fail due to missing image reference" + assert "references undefined image 'notexist'" in result.stderr + diff --git a/test/py/tests/test_gpt.py b/test/py/tests/test_gpt.py index cfc8f1319a9..e6d8792ac1f 100644 --- a/test/py/tests/test_gpt.py +++ b/test/py/tests/test_gpt.py @@ -330,6 +330,33 @@ def test_gpt_write(state_disk_image, ubman): output = ubman.run_command('gpt guid host 0') assert '375a56f7-d6c9-4e81-b5f0-09d41ca89efe' in output +@pytest.mark.boardspec('sandbox') +@pytest.mark.buildconfigspec('cmd_gpt') +@pytest.mark.buildconfigspec('cmd_part') +@pytest.mark.buildconfigspec('partition_type_guid') +@pytest.mark.requiredtool('sgdisk') +def test_gpt_write_part_type(state_disk_image, ubman): + """Test the gpt command with part type uuid.""" + + output = ubman.run_command('gpt write host 0 "name=part1,type=data,size=1M;name=part2,size=512K,type=system;name=part3,size=65536,type=u-boot-env;name=part4,size=65536,type=375a56f7-d6c9-4e81-b5f0-09d41ca89efe;name=part5,size=-,type=linux"') + assert 'Writing GPT: success!' in output + output = ubman.run_command('part list host 0') + assert '1\t0x00000022\t0x00000821\t"part1"' in output + assert 'ebd0a0a2-b9e5-4433-87c0-68b6b72699c7' in output + assert '(data)' in output + assert '2\t0x00000822\t0x00000c21\t"part2"' in output + assert 'c12a7328-f81f-11d2-ba4b-00a0c93ec93b' in output + assert '(EFI System Partition)' in output + assert '3\t0x00000c22\t0x00000ca1\t"part3"' in output + assert '3de21764-95bd-54bd-a5c3-4abe786f38a8' in output + assert '(u-boot-env)' in output + assert '4\t0x00000ca2\t0x00000d21\t"part4"' in output + assert 'ebd0a0a2-b9e5-4433-87c0-68b6b72699c7' in output + assert '(375a56f7-d6c9-4e81-b5f0-09d41ca89efe)' in output + assert '5\t0x00000d22\t0x00001fde\t"part5"' in output + assert '0fc63daf-8483-4772-8e79-3d69d8477de4' in output + assert '(linux)' in output + @pytest.mark.buildconfigspec('cmd_gpt') @pytest.mark.buildconfigspec('cmd_gpt_rename') @pytest.mark.buildconfigspec('cmd_part') diff --git a/test/py/tests/test_mmc.py b/test/py/tests/test_mmc.py index e751a3bd36a..1f738ef3dcb 100644 --- a/test/py/tests/test_mmc.py +++ b/test/py/tests/test_mmc.py @@ -99,7 +99,7 @@ def test_mmc_dev(ubman): devices[x]['detected'] = 'yes' for y in mmc_modes: - output = ubman.run_command('mmc dev %d 0 %d' % x, y) + output = ubman.run_command('mmc dev %d 0 %d' % (x, y)) if 'Card did not respond to voltage select' in output: fail = 1 @@ -122,7 +122,7 @@ def test_mmcinfo(ubman): for x in range(0, controllers): if devices[x]['detected'] == 'yes': for y in mmc_modes: - ubman.run_command('mmc dev %d 0 %d' % x, y) + ubman.run_command('mmc dev %d 0 %d' % (x, y)) output = ubman.run_command('mmcinfo') if 'busy timeout' in output: pytest.skip('No SD/MMC/eMMC device present') @@ -146,7 +146,7 @@ def test_mmc_info(ubman): for x in range(0, controllers): if devices[x]['detected'] == 'yes': for y in mmc_modes: - ubman.run_command('mmc dev %d 0 %d' % x, y) + ubman.run_command('mmc dev %d 0 %d' % (x, y)) output = ubman.run_command('mmc info') assert mmc_modes_name[mmc_modes.index(y)] in output @@ -172,7 +172,7 @@ def test_mmc_rescan(ubman): for x in range(0, controllers): if devices[x]['detected'] == 'yes': for y in mmc_modes: - ubman.run_command('mmc dev %d 0 %d' % x, y) + ubman.run_command('mmc dev %d 0 %d' % (x, y)) output = ubman.run_command('mmc rescan') if output: pytest.fail('mmc rescan has something to check') @@ -210,7 +210,7 @@ def test_mmc_part(ubman): elif part_type == '83': print('ext(2/4) detected') output = ubman.run_command( - 'fstype mmc %d:%d' % x, part_id + 'fstype mmc %d:%d' % (x, part_id) ) if 'ext2' in output: part_ext2.append(part_id) @@ -246,7 +246,7 @@ def test_mmc_fatls_fatinfo(ubman): for part in partitions: for y in mmc_modes: - ubman.run_command('mmc dev %d %d %d' % x, part, y) + ubman.run_command('mmc dev %d %d %d' % (x, part, y)) output = ubman.run_command( 'fatls mmc %d:%s' % (x, part)) if 'Unrecognized filesystem type' in output: @@ -288,7 +288,7 @@ def test_mmc_fatload_fatwrite(ubman): for part in partitions: for y in mmc_modes: - ubman.run_command('mmc dev %d %d %d' % x, part, y) + ubman.run_command('mmc dev %d %d %d' % (x, part, y)) part_detect = 1 addr = utils.find_ram_base(ubman) devices[x]['addr_%d' % part] = addr @@ -357,7 +357,7 @@ def test_mmc_ext4ls(ubman): for part in partitions: for y in mmc_modes: - ubman.run_command('mmc dev %d %d %d' % x, part, y) + ubman.run_command('mmc dev %d %d %d' % (x, part, y)) output = ubman.run_command( '%sls mmc %d:%s' % (fs, x, part) ) @@ -392,7 +392,7 @@ def test_mmc_ext4load_ext4write(ubman): for part in partitions: for y in mmc_modes: - ubman.run_command('mmc dev %d %d %d' % x, part, y) + ubman.run_command('mmc dev %d %d %d' % (x, part, y)) part_detect = 1 addr = utils.find_ram_base(ubman) devices[x]['addr_%d' % part] = addr @@ -454,7 +454,7 @@ def test_mmc_ext2ls(ubman): for part in partitions: for y in mmc_modes: - ubman.run_command('mmc dev %d %d %d' % x, part, y) + ubman.run_command('mmc dev %d %d %d' % (x, part, y)) part_detect = 1 output = ubman.run_command( '%sls mmc %d:%s' % (fs, x, part) @@ -491,7 +491,7 @@ def test_mmc_ext2load(ubman): for part in partitions: for y in mmc_modes: - ubman.run_command('mmc dev %d %d %d' % x, part, y) + ubman.run_command('mmc dev %d %d %d' % (x, part, y)) part_detect = 1 addr = devices[x]['addr_%d' % part] size = devices[x]['size_%d' % part] @@ -534,7 +534,7 @@ def test_mmc_ls(ubman): for part in partitions: for y in mmc_modes: - ubman.run_command('mmc dev %d %d %d' % x, part, y) + ubman.run_command('mmc dev %d %d %d' % (x, part, y)) part_detect = 1 output = ubman.run_command('ls mmc %d:%s' % (x, part)) if re.search(r'No \w+ table on this device', output): @@ -566,7 +566,7 @@ def test_mmc_load(ubman): for part in partitions: for y in mmc_modes: - ubman.run_command('mmc dev %d %d %d' % x, part, y) + ubman.run_command('mmc dev %d %d %d' % (x, part, y)) part_detect = 1 addr = devices[x]['addr_%d' % part] size = devices[x]['size_%d' % part] @@ -609,7 +609,7 @@ def test_mmc_save(ubman): for part in partitions: for y in mmc_modes: - ubman.run_command('mmc dev %d %d %d' % x, part, y) + ubman.run_command('mmc dev %d %d %d' % (x, part, y)) part_detect = 1 addr = devices[x]['addr_%d' % part] size = 0 @@ -656,7 +656,7 @@ def test_mmc_fat_read_write_files(ubman): for part in partitions: for y in mmc_modes: - ubman.run_command('mmc dev %d %d %d' % x, part, y) + ubman.run_command('mmc dev %d %d %d' % (x, part, y)) part_detect = 1 addr = utils.find_ram_base(ubman) count_f = 0 |