diff options
Diffstat (limited to 'test/py/tests')
-rw-r--r-- | test/py/tests/test_spi.py | 20 | ||||
-rw-r--r-- | test/py/tests/test_ut.py | 49 |
2 files changed, 59 insertions, 10 deletions
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 9b6b6b20c85..10ec7e582e0 100644 --- a/test/py/tests/test_ut.py +++ b/test/py/tests/test_ut.py @@ -442,6 +442,55 @@ def setup_android_image(cons): print(f'wrote to {fname}') + mmc_dev = 8 + fname = os.path.join(cons.config.source_dir, f'mmc{mmc_dev}.img') + u_boot_utils.run_and_log(cons, f'qemu-img create {fname} 20M') + u_boot_utils.run_and_log(cons, f'cgpt create {fname}') + + ptr = 40 + + # Number of sectors in 1MB + sect_size = 512 + sect_1mb = (1 << 20) // sect_size + + required_parts = [ + {'num': 1, 'label':'misc', 'size': '1M'}, + {'num': 2, 'label':'boot_a', 'size': '4M'}, + {'num': 3, 'label':'boot_b', 'size': '4M'}, + ] + + for part in required_parts: + size_str = part['size'] + if 'M' in size_str: + size = int(size_str[:-1]) * sect_1mb + else: + size = int(size_str) + u_boot_utils.run_and_log( + cons, + f"cgpt add -i {part['num']} -b {ptr} -s {size} -l {part['label']} -t basicdata {fname}") + ptr += size + + u_boot_utils.run_and_log(cons, f'cgpt boot -p {fname}') + out = u_boot_utils.run_and_log(cons, f'cgpt show -q {fname}') + + # Create a dict (indexed by partition number) containing the above info + for line in out.splitlines(): + start, size, num, name = line.split(maxsplit=3) + parts[int(num)] = Partition(int(start), int(size), name) + + with open(fname, 'rb') as inf: + disk_data = inf.read() + + test_abootimg.AbootimgTestDiskImage(cons, 'boot.img', test_abootimg.img_hex) + boot_img = os.path.join(cons.config.result_dir, 'boot.img') + with open(boot_img, 'rb') as inf: + set_part_data(2, inf.read()) + + with open(fname, 'wb') as outf: + outf.write(disk_data) + + print(f'wrote to {fname}') + return fname def setup_cedit_file(cons): |