summaryrefslogtreecommitdiff
path: root/test/py/tests/test_android
diff options
context:
space:
mode:
Diffstat (limited to 'test/py/tests/test_android')
-rw-r--r--test/py/tests/test_android/test_ab.py46
-rw-r--r--test/py/tests/test_android/test_abootimg.py90
-rw-r--r--test/py/tests/test_android/test_avb.py48
3 files changed, 92 insertions, 92 deletions
diff --git a/test/py/tests/test_android/test_ab.py b/test/py/tests/test_android/test_ab.py
index 9bf1a0eb00a..739b7ce695d 100644
--- a/test/py/tests/test_android/test_ab.py
+++ b/test/py/tests/test_android/test_ab.py
@@ -10,11 +10,11 @@ import u_boot_utils
class ABTestDiskImage(object):
"""Disk Image used by the A/B tests."""
- def __init__(self, u_boot_console):
+ def __init__(self, ubman):
"""Initialize a new ABTestDiskImage object.
Args:
- u_boot_console: A U-Boot console.
+ ubman: A U-Boot console.
Returns:
Nothing.
@@ -22,40 +22,40 @@ class ABTestDiskImage(object):
filename = 'test_ab_disk_image.bin'
- persistent = u_boot_console.config.persistent_data_dir + '/' + filename
- self.path = u_boot_console.config.result_dir + '/' + filename
+ persistent = ubman.config.persistent_data_dir + '/' + filename
+ self.path = ubman.config.result_dir + '/' + filename
- with u_boot_utils.persistent_file_helper(u_boot_console.log, persistent):
+ with u_boot_utils.persistent_file_helper(ubman.log, persistent):
if os.path.exists(persistent):
- u_boot_console.log.action('Disk image file ' + persistent +
+ ubman.log.action('Disk image file ' + persistent +
' already exists')
else:
- u_boot_console.log.action('Generating ' + persistent)
+ ubman.log.action('Generating ' + persistent)
fd = os.open(persistent, os.O_RDWR | os.O_CREAT)
os.ftruncate(fd, 524288)
os.close(fd)
cmd = ('sgdisk', persistent)
- u_boot_utils.run_and_log(u_boot_console, cmd)
+ u_boot_utils.run_and_log(ubman, cmd)
cmd = ('sgdisk', '--new=1:64:512', '--change-name=1:misc',
persistent)
- u_boot_utils.run_and_log(u_boot_console, cmd)
+ u_boot_utils.run_and_log(ubman, cmd)
cmd = ('sgdisk', '--load-backup=' + persistent)
- u_boot_utils.run_and_log(u_boot_console, cmd)
+ u_boot_utils.run_and_log(ubman, cmd)
cmd = ('cp', persistent, self.path)
- u_boot_utils.run_and_log(u_boot_console, cmd)
+ u_boot_utils.run_and_log(ubman, cmd)
di = None
@pytest.fixture(scope='function')
-def ab_disk_image(u_boot_console):
+def ab_disk_image(ubman):
global di
if not di:
- di = ABTestDiskImage(u_boot_console)
+ di = ABTestDiskImage(ubman)
return di
-def ab_dump(u_boot_console, slot_num, crc):
- output = u_boot_console.run_command('bcb ab_dump host 0#misc')
+def ab_dump(ubman, slot_num, crc):
+ output = ubman.run_command('bcb ab_dump host 0#misc')
header, slot0, slot1 = output.split('\r\r\n\r\r\n')
slots = [slot0, slot1]
slot_suffixes = ['_a', '_b']
@@ -79,20 +79,20 @@ def ab_dump(u_boot_console, slot_num, crc):
@pytest.mark.buildconfigspec('android_ab')
@pytest.mark.buildconfigspec('cmd_bcb')
@pytest.mark.requiredtool('sgdisk')
-def test_ab(ab_disk_image, u_boot_console):
+def test_ab(ab_disk_image, ubman):
"""Test the 'bcb ab_select' command."""
- u_boot_console.run_command('host bind 0 ' + ab_disk_image.path)
+ ubman.run_command('host bind 0 ' + ab_disk_image.path)
- output = u_boot_console.run_command('bcb ab_select slot_name host 0#misc')
+ output = ubman.run_command('bcb ab_select slot_name host 0#misc')
assert 're-initializing A/B metadata' in output
assert 'Attempting slot a, tries remaining 7' in output
- output = u_boot_console.run_command('printenv slot_name')
+ output = ubman.run_command('printenv slot_name')
assert 'slot_name=a' in output
- ab_dump(u_boot_console, 0, '0xd438d1b9')
+ ab_dump(ubman, 0, '0xd438d1b9')
- output = u_boot_console.run_command('bcb ab_select slot_name host 0:1')
+ output = ubman.run_command('bcb ab_select slot_name host 0:1')
assert 'Attempting slot b, tries remaining 7' in output
- output = u_boot_console.run_command('printenv slot_name')
+ output = ubman.run_command('printenv slot_name')
assert 'slot_name=b' in output
- ab_dump(u_boot_console, 1, '0x011ec016')
+ ab_dump(ubman, 1, '0x011ec016')
diff --git a/test/py/tests/test_android/test_abootimg.py b/test/py/tests/test_android/test_abootimg.py
index 6a8ff34538b..fd3e08fa899 100644
--- a/test/py/tests/test_android/test_abootimg.py
+++ b/test/py/tests/test_android/test_abootimg.py
@@ -105,78 +105,78 @@ dtb2_addr = vloadaddr + dtb2_offset
class AbootimgTestDiskImage(object):
"""Disk image used by abootimg tests."""
- def __init__(self, u_boot_console, image_name, hex_img):
+ def __init__(self, ubman, image_name, hex_img):
"""Initialize a new AbootimgDiskImage object.
Args:
- u_boot_console: A U-Boot console.
+ ubman: A U-Boot console.
Returns:
Nothing.
"""
- gz_hex = u_boot_console.config.persistent_data_dir + '/' + image_name + '.gz.hex'
- gz = u_boot_console.config.persistent_data_dir + '/' + image_name + '.gz'
+ gz_hex = ubman.config.persistent_data_dir + '/' + image_name + '.gz.hex'
+ gz = ubman.config.persistent_data_dir + '/' + image_name + '.gz'
filename = image_name
- persistent = u_boot_console.config.persistent_data_dir + '/' + filename
- self.path = u_boot_console.config.result_dir + '/' + filename
- u_boot_console.log.action('persistent is ' + persistent)
- with u_boot_utils.persistent_file_helper(u_boot_console.log, persistent):
+ persistent = ubman.config.persistent_data_dir + '/' + filename
+ self.path = ubman.config.result_dir + '/' + filename
+ ubman.log.action('persistent is ' + persistent)
+ with u_boot_utils.persistent_file_helper(ubman.log, persistent):
if os.path.exists(persistent):
- u_boot_console.log.action('Disk image file ' + persistent +
+ ubman.log.action('Disk image file ' + persistent +
' already exists')
else:
- u_boot_console.log.action('Generating ' + persistent)
+ ubman.log.action('Generating ' + persistent)
f = open(gz_hex, "w")
f.write(hex_img)
f.close()
cmd = ('xxd', '-r', '-p', gz_hex, gz)
- u_boot_utils.run_and_log(u_boot_console, cmd)
+ u_boot_utils.run_and_log(ubman, cmd)
cmd = ('gunzip', '-9', gz)
- u_boot_utils.run_and_log(u_boot_console, cmd)
+ u_boot_utils.run_and_log(ubman, cmd)
cmd = ('cp', persistent, self.path)
- u_boot_utils.run_and_log(u_boot_console, cmd)
+ u_boot_utils.run_and_log(ubman, cmd)
gtdi1 = None
@pytest.fixture(scope='function')
-def abootimg_disk_image(u_boot_console):
+def abootimg_disk_image(ubman):
"""pytest fixture to provide a AbootimgTestDiskImage object to tests.
- This is function-scoped because it uses u_boot_console, which is also
+ This is function-scoped because it uses ubman, which is also
function-scoped. However, we don't need to actually do any function-scope
work, so this simply returns the same object over and over each time."""
global gtdi1
if not gtdi1:
- gtdi1 = AbootimgTestDiskImage(u_boot_console, 'boot.img', img_hex)
+ gtdi1 = AbootimgTestDiskImage(ubman, 'boot.img', img_hex)
return gtdi1
gtdi2 = None
@pytest.fixture(scope='function')
-def abootimgv4_disk_image_vboot(u_boot_console):
+def abootimgv4_disk_image_vboot(ubman):
"""pytest fixture to provide a AbootimgTestDiskImage object to tests.
- This is function-scoped because it uses u_boot_console, which is also
+ This is function-scoped because it uses ubman, which is also
function-scoped. However, we don't need to actually do any function-scope
work, so this simply returns the same object over and over each time."""
global gtdi2
if not gtdi2:
- gtdi2 = AbootimgTestDiskImage(u_boot_console, 'vendor_boot.img', vboot_img_hex)
+ gtdi2 = AbootimgTestDiskImage(ubman, 'vendor_boot.img', vboot_img_hex)
return gtdi2
gtdi3 = None
@pytest.fixture(scope='function')
-def abootimgv4_disk_image_boot(u_boot_console):
+def abootimgv4_disk_image_boot(ubman):
"""pytest fixture to provide a AbootimgTestDiskImage object to tests.
- This is function-scoped because it uses u_boot_console, which is also
+ This is function-scoped because it uses ubman, which is also
function-scoped. However, we don't need to actually do any function-scope
work, so this simply returns the same object over and over each time."""
global gtdi3
if not gtdi3:
- gtdi3 = AbootimgTestDiskImage(u_boot_console, 'bootv4.img', boot_img_hex)
+ gtdi3 = AbootimgTestDiskImage(ubman, 'bootv4.img', boot_img_hex)
return gtdi3
@pytest.mark.boardspec('sandbox')
@@ -185,42 +185,42 @@ def abootimgv4_disk_image_boot(u_boot_console):
@pytest.mark.buildconfigspec('cmd_fdt')
@pytest.mark.requiredtool('xxd')
@pytest.mark.requiredtool('gunzip')
-def test_abootimg(abootimg_disk_image, u_boot_console):
+def test_abootimg(abootimg_disk_image, ubman):
"""Test the 'abootimg' command."""
- u_boot_console.log.action('Loading disk image to RAM...')
- u_boot_console.run_command('setenv loadaddr 0x%x' % (loadaddr))
- u_boot_console.run_command('host load hostfs - 0x%x %s' % (loadaddr,
+ ubman.log.action('Loading disk image to RAM...')
+ ubman.run_command('setenv loadaddr 0x%x' % (loadaddr))
+ ubman.run_command('host load hostfs - 0x%x %s' % (loadaddr,
abootimg_disk_image.path))
- u_boot_console.log.action('Testing \'abootimg get ver\'...')
- response = u_boot_console.run_command('abootimg get ver')
+ ubman.log.action('Testing \'abootimg get ver\'...')
+ response = ubman.run_command('abootimg get ver')
assert response == "2"
- u_boot_console.run_command('abootimg get ver v')
- response = u_boot_console.run_command('env print v')
+ ubman.run_command('abootimg get ver v')
+ response = ubman.run_command('env print v')
assert response == 'v=2'
- u_boot_console.log.action('Testing \'abootimg get recovery_dtbo\'...')
- response = u_boot_console.run_command('abootimg get recovery_dtbo a')
+ ubman.log.action('Testing \'abootimg get recovery_dtbo\'...')
+ response = ubman.run_command('abootimg get recovery_dtbo a')
assert response == 'Error: recovery_dtbo_size is 0'
- u_boot_console.log.action('Testing \'abootimg dump dtb\'...')
- response = u_boot_console.run_command('abootimg dump dtb').replace('\r', '')
+ ubman.log.action('Testing \'abootimg dump dtb\'...')
+ response = ubman.run_command('abootimg dump dtb').replace('\r', '')
assert response == dtb_dump_resp
- u_boot_console.log.action('Testing \'abootimg get dtb_load_addr\'...')
- u_boot_console.run_command('abootimg get dtb_load_addr a')
- response = u_boot_console.run_command('env print a')
+ ubman.log.action('Testing \'abootimg get dtb_load_addr\'...')
+ ubman.run_command('abootimg get dtb_load_addr a')
+ response = ubman.run_command('env print a')
assert response == 'a=11f00000'
- u_boot_console.log.action('Testing \'abootimg get dtb --index\'...')
- u_boot_console.run_command('abootimg get dtb --index=1 dtb1_start')
- response = u_boot_console.run_command('env print dtb1_start')
+ ubman.log.action('Testing \'abootimg get dtb --index\'...')
+ ubman.run_command('abootimg get dtb --index=1 dtb1_start')
+ response = ubman.run_command('env print dtb1_start')
correct_str = "dtb1_start=%x" % (dtb1_addr)
assert response == correct_str
- u_boot_console.run_command('fdt addr $dtb1_start')
- u_boot_console.run_command('fdt get value v / model')
- response = u_boot_console.run_command('env print v')
+ ubman.run_command('fdt addr $dtb1_start')
+ ubman.run_command('fdt get value v / model')
+ response = ubman.run_command('env print v')
assert response == 'v=x2'
@pytest.mark.boardspec('sandbox')
@@ -229,10 +229,10 @@ def test_abootimg(abootimg_disk_image, u_boot_console):
@pytest.mark.buildconfigspec('cmd_fdt')
@pytest.mark.requiredtool('xxd')
@pytest.mark.requiredtool('gunzip')
-def test_abootimgv4(abootimgv4_disk_image_vboot, abootimgv4_disk_image_boot, u_boot_console):
+def test_abootimgv4(abootimgv4_disk_image_vboot, abootimgv4_disk_image_boot, ubman):
"""Test the 'abootimg' command with boot image header v4."""
- cons = u_boot_console
+ cons = ubman
cons.log.action('Loading disk image to RAM...')
cons.run_command('setenv loadaddr 0x%x' % (loadaddr))
cons.run_command('setenv vloadaddr 0x%x' % (vloadaddr))
diff --git a/test/py/tests/test_android/test_avb.py b/test/py/tests/test_android/test_avb.py
index 865efbca4de..451a476da76 100644
--- a/test/py/tests/test_android/test_avb.py
+++ b/test/py/tests/test_android/test_avb.py
@@ -24,34 +24,34 @@ temp_addr2 = 0x90002000
@pytest.mark.buildconfigspec('cmd_avb')
@pytest.mark.buildconfigspec('cmd_mmc')
-def test_avb_verify(u_boot_console):
+def test_avb_verify(ubman):
"""Run AVB 2.0 boot verification chain with avb subset of commands
"""
success_str = "Verification passed successfully"
- response = u_boot_console.run_command('avb init %s' %str(mmc_dev))
+ response = ubman.run_command('avb init %s' %str(mmc_dev))
assert response == ''
- response = u_boot_console.run_command('avb verify')
+ response = ubman.run_command('avb verify')
assert response.find(success_str)
@pytest.mark.buildconfigspec('cmd_avb')
@pytest.mark.buildconfigspec('cmd_mmc')
@pytest.mark.notbuildconfigspec('sandbox')
-def test_avb_mmc_uuid(u_boot_console):
+def test_avb_mmc_uuid(ubman):
"""Check if 'avb get_uuid' works, compare results with
'part list mmc 1' output
"""
- response = u_boot_console.run_command('avb init %s' % str(mmc_dev))
+ response = ubman.run_command('avb init %s' % str(mmc_dev))
assert response == ''
- response = u_boot_console.run_command('mmc rescan; mmc dev %s' %
+ response = ubman.run_command('mmc rescan; mmc dev %s' %
str(mmc_dev))
assert response.find('is current device')
- part_lines = u_boot_console.run_command('mmc part').splitlines()
+ part_lines = ubman.run_command('mmc part').splitlines()
part_list = {}
cur_partname = ''
@@ -67,72 +67,72 @@ def test_avb_mmc_uuid(u_boot_console):
# lets check all guids with avb get_guid
for part, guid in part_list.items():
- avb_guid_resp = u_boot_console.run_command('avb get_uuid %s' % part)
+ avb_guid_resp = ubman.run_command('avb get_uuid %s' % part)
assert guid == avb_guid_resp.split('UUID: ')[1]
@pytest.mark.buildconfigspec('cmd_avb')
-def test_avb_read_rb(u_boot_console):
+def test_avb_read_rb(ubman):
"""Test reading rollback indexes
"""
- response = u_boot_console.run_command('avb init %s' % str(mmc_dev))
+ response = ubman.run_command('avb init %s' % str(mmc_dev))
assert response == ''
- response = u_boot_console.run_command('avb read_rb 1')
+ response = ubman.run_command('avb read_rb 1')
assert response == 'Rollback index: 0'
@pytest.mark.buildconfigspec('cmd_avb')
-def test_avb_is_unlocked(u_boot_console):
+def test_avb_is_unlocked(ubman):
"""Test if device is in the unlocked state
"""
- response = u_boot_console.run_command('avb init %s' % str(mmc_dev))
+ response = ubman.run_command('avb init %s' % str(mmc_dev))
assert response == ''
- response = u_boot_console.run_command('avb is_unlocked')
+ response = ubman.run_command('avb is_unlocked')
assert response == 'Unlocked = 1'
@pytest.mark.buildconfigspec('cmd_avb')
@pytest.mark.buildconfigspec('cmd_mmc')
@pytest.mark.notbuildconfigspec('sandbox')
-def test_avb_mmc_read(u_boot_console):
+def test_avb_mmc_read(ubman):
"""Test mmc read operation
"""
- response = u_boot_console.run_command('mmc rescan; mmc dev %s 0' %
+ response = ubman.run_command('mmc rescan; mmc dev %s 0' %
str(mmc_dev))
assert response.find('is current device')
- response = u_boot_console.run_command('mmc read 0x%x 0x100 0x1' % temp_addr)
+ response = ubman.run_command('mmc read 0x%x 0x100 0x1' % temp_addr)
assert response.find('read: OK')
- response = u_boot_console.run_command('avb init %s' % str(mmc_dev))
+ response = ubman.run_command('avb init %s' % str(mmc_dev))
assert response == ''
- response = u_boot_console.run_command('avb read_part xloader 0 100 0x%x' %
+ response = ubman.run_command('avb read_part xloader 0 100 0x%x' %
temp_addr2)
assert response.find('Read 512 bytes')
# Now lets compare two buffers
- response = u_boot_console.run_command('cmp 0x%x 0x%x 40' %
+ response = ubman.run_command('cmp 0x%x 0x%x 40' %
(temp_addr, temp_addr2))
assert response.find('64 word')
@pytest.mark.buildconfigspec('cmd_avb')
@pytest.mark.buildconfigspec('optee_ta_avb')
-def test_avb_persistent_values(u_boot_console):
+def test_avb_persistent_values(ubman):
"""Test reading/writing persistent storage to avb
"""
- response = u_boot_console.run_command('avb init %s' % str(mmc_dev))
+ response = ubman.run_command('avb init %s' % str(mmc_dev))
assert response == ''
- response = u_boot_console.run_command('avb write_pvalue test value_value')
+ response = ubman.run_command('avb write_pvalue test value_value')
assert response == 'Wrote 12 bytes'
- response = u_boot_console.run_command('avb read_pvalue test 12')
+ response = ubman.run_command('avb read_pvalue test 12')
assert response == 'Read 12 bytes, value = value_value'