diff options
Diffstat (limited to 'test/py/tests')
-rw-r--r-- | test/py/tests/bootstd/flash1.img.xz | bin | 0 -> 4924 bytes | |||
-rw-r--r-- | test/py/tests/test_spi.py | 20 | ||||
-rw-r--r-- | test/py/tests/test_ut.py | 53 |
3 files changed, 57 insertions, 16 deletions
diff --git a/test/py/tests/bootstd/flash1.img.xz b/test/py/tests/bootstd/flash1.img.xz Binary files differnew file mode 100644 index 00000000000..29b78c62a9b --- /dev/null +++ b/test/py/tests/bootstd/flash1.img.xz diff --git a/test/py/tests/test_spi.py b/test/py/tests/test_spi.py index caca9303271..0abdfa78b76 100644 --- a/test/py/tests/test_spi.py +++ b/test/py/tests/test_spi.py @@ -75,7 +75,7 @@ def get_params_spi(u_boot_console): ''' Get SPI device test parameters from boardenv file ''' f = u_boot_console.config.env.get('env__spi_device_test', None) if not f: - pytest.skip('No env file to read for SPI family device test') + pytest.skip('No SPI test device configured') bus = f.get('bus', 0) cs = f.get('chip_select', 0) @@ -84,7 +84,7 @@ def get_params_spi(u_boot_console): timeout = f.get('timeout', None) if not part_name: - pytest.skip('No env file to read SPI family flash part name') + pytest.skip('No SPI test device configured') return bus, cs, mode, part_name, timeout @@ -92,7 +92,7 @@ def spi_find_freq_range(u_boot_console): '''Find out minimum and maximum frequnecies that SPI device can operate''' f = u_boot_console.config.env.get('env__spi_device_test', None) if not f: - pytest.skip('No env file to read for SPI family device test') + pytest.skip('No SPI test device configured') min_f = f.get('min_freq', None) max_f = f.get('max_freq', None) @@ -116,21 +116,21 @@ def spi_pre_commands(u_boot_console, freq): pytest.fail('No SPI device available') if not part_name in output: - pytest.fail('SPI flash part name not recognized') + pytest.fail('Not recognized the SPI flash part name') m = re.search('page size (.+?) Bytes', output) if m: try: page_size = int(m.group(1)) except ValueError: - pytest.fail('SPI page size not recognized') + pytest.fail('Not recognized the SPI page size') m = re.search('erase size (.+?) KiB', output) if m: try: erase_size = int(m.group(1)) except ValueError: - pytest.fail('SPI erase size not recognized') + pytest.fail('Not recognized the SPI erase size') erase_size *= 1024 @@ -139,7 +139,7 @@ def spi_pre_commands(u_boot_console, freq): try: total_size = int(m.group(1)) except ValueError: - pytest.fail('SPI total size not recognized') + pytest.fail('Not recognized the SPI total size') total_size *= 1024 * 1024 @@ -149,7 +149,7 @@ def spi_pre_commands(u_boot_console, freq): flash_part = m.group(1) assert flash_part == part_name except ValueError: - pytest.fail('SPI flash part not recognized') + pytest.fail('Not recognized the SPI flash part') global SPI_DATA SPI_DATA = { @@ -574,7 +574,7 @@ def test_spi_lock_unlock(u_boot_console): min_f, max_f, loop = spi_find_freq_range(u_boot_console) flashes = u_boot_console.config.env.get('env__spi_lock_unlock', False) if not flashes: - pytest.skip('No supported flash list for lock/unlock provided') + pytest.skip('No SPI test device configured for lock/unlock') i = 0 while i < loop: @@ -695,7 +695,7 @@ def test_spi_negative(u_boot_console): # Read to relocation address output = u_boot_console.run_command('bdinfo') - m = re.search('relocaddr\s*= (.+)', output) + m = re.search(r'relocaddr\s*= (.+)', output) res_area = int(m.group(1), 16) start = 0 diff --git a/test/py/tests/test_ut.py b/test/py/tests/test_ut.py index 9166c8f6b6e..6d44191976b 100644 --- a/test/py/tests/test_ut.py +++ b/test/py/tests/test_ut.py @@ -28,21 +28,22 @@ def mkdir_cond(dirname): if not os.path.exists(dirname): os.mkdir(dirname) -def setup_image(cons, mmc_dev, part_type, second_part=False): +def setup_image(cons, devnum, part_type, second_part=False, basename='mmc'): """Create a 20MB disk image with a single partition Args: cons (ConsoleBase): Console to use - mmc_dev (int): MMC device number to use, e.g. 1 + devnum (int): Device number to use, e.g. 1 part_type (int): Partition type, e.g. 0xc for FAT32 second_part (bool): True to contain a small second partition + basename (str): Base name to use in the filename, e.g. 'mmc' Returns: tuple: str: Filename of MMC image str: Directory name of 'mnt' directory """ - fname = os.path.join(cons.config.source_dir, f'mmc{mmc_dev}.img') + fname = os.path.join(cons.config.source_dir, f'{basename}{devnum}.img') mnt = os.path.join(cons.config.persistent_data_dir, 'mnt') mkdir_cond(mnt) @@ -78,16 +79,17 @@ def mount_image(cons, fname, mnt, fstype): u_boot_utils.run_and_log(cons, f'sudo chown {getpass.getuser()} {mnt}') return loop -def copy_prepared_image(cons, mmc_dev, fname): +def copy_prepared_image(cons, devnum, fname, basename='mmc'): """Use a prepared image since we cannot create one Args: cons (ConsoleBase): Console touse - mmc_dev (int): MMC device number + devnum (int): device number fname (str): Filename of MMC image + basename (str): Base name to use in the filename, e.g. 'mmc' """ infname = os.path.join(cons.config.source_dir, - f'test/py/tests/bootstd/mmc{mmc_dev}.img.xz') + f'test/py/tests/bootstd/{basename}{devnum}.img.xz') u_boot_utils.run_and_log(cons, ['sh', '-c', f'xz -dc {infname} >{fname}']) def setup_bootmenu_image(cons): @@ -547,6 +549,44 @@ def test_ut_dm_init(u_boot_console): with open(fn, 'wb') as fh: fh.write(data) + +def setup_efi_image(cons): + """Create a 20MB disk image with an EFI app on it""" + devnum = 1 + basename = 'flash' + fname, mnt = setup_image(cons, devnum, 0xc, second_part=True, + basename=basename) + + loop = None + mounted = False + complete = False + try: + loop = mount_image(cons, fname, mnt, 'ext4') + mounted = True + efi_dir = os.path.join(mnt, 'EFI') + mkdir_cond(efi_dir) + bootdir = os.path.join(efi_dir, 'BOOT') + mkdir_cond(bootdir) + efi_src = os.path.join(cons.config.build_dir, + f'lib/efi_loader/testapp.efi') + efi_dst = os.path.join(bootdir, 'BOOTSBOX.EFI') + with open(efi_src, 'rb') as inf: + with open(efi_dst, 'wb') as outf: + outf.write(inf.read()) + complete = True + except ValueError as exc: + print(f'Falled to create image, failing back to prepared copy: {exc}') + + finally: + if mounted: + u_boot_utils.run_and_log(cons, 'sudo umount --lazy %s' % mnt) + if loop: + u_boot_utils.run_and_log(cons, 'sudo losetup -d %s' % loop) + + if not complete: + copy_prepared_image(cons, devnum, fname, basename) + + @pytest.mark.buildconfigspec('cmd_bootflow') @pytest.mark.buildconfigspec('sandbox') def test_ut_dm_init_bootstd(u_boot_console): @@ -557,6 +597,7 @@ def test_ut_dm_init_bootstd(u_boot_console): setup_cedit_file(u_boot_console) setup_cros_image(u_boot_console) setup_android_image(u_boot_console) + setup_efi_image(u_boot_console) # Restart so that the new mmc1.img is picked up u_boot_console.restart_uboot() |