mirror of
https://xff.cz/git/u-boot/
synced 2025-09-06 03:02:18 +02:00
test: test_efi_fit: fix pylint warnings
Fix warnings issued by pylint: * naming of variables * usage of commas and semicolons * indentation * placement of module description Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
This commit is contained in:
@@ -9,10 +9,6 @@
|
|||||||
#
|
#
|
||||||
# Test launching UEFI binaries from FIT images.
|
# Test launching UEFI binaries from FIT images.
|
||||||
|
|
||||||
import os.path
|
|
||||||
import pytest
|
|
||||||
import u_boot_utils as util
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Note: This test relies on boardenv_* containing configuration values to define
|
Note: This test relies on boardenv_* containing configuration values to define
|
||||||
which network environment is available for testing. Without this, the parts
|
which network environment is available for testing. Without this, the parts
|
||||||
@@ -57,8 +53,12 @@ env__efi_fit_tftp_file = {
|
|||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import os.path
|
||||||
|
import pytest
|
||||||
|
import u_boot_utils as util
|
||||||
|
|
||||||
# Define the parametrized ITS data to be used for FIT images generation.
|
# Define the parametrized ITS data to be used for FIT images generation.
|
||||||
its_data = '''
|
ITS_DATA = '''
|
||||||
/dts-v1/;
|
/dts-v1/;
|
||||||
|
|
||||||
/ {
|
/ {
|
||||||
@@ -101,7 +101,7 @@ its_data = '''
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
# Define the parametrized FDT data to be used for DTB images generation.
|
# Define the parametrized FDT data to be used for DTB images generation.
|
||||||
fdt_data = '''
|
FDT_DATA = '''
|
||||||
/dts-v1/;
|
/dts-v1/;
|
||||||
|
|
||||||
/ {
|
/ {
|
||||||
@@ -199,16 +199,16 @@ def test_efi_fit_launch(u_boot_console):
|
|||||||
cons.run_command('setenv %s %s' % (var, val))
|
cons.run_command('setenv %s %s' % (var, val))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def make_fpath(fname):
|
def make_fpath(file_name):
|
||||||
"""Compute the path of a given (temporary) file.
|
"""Compute the path of a given (temporary) file.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
fname: The name of a file within U-Boot build dir.
|
file_name: The name of a file within U-Boot build dir.
|
||||||
Return:
|
Return:
|
||||||
The computed file path.
|
The computed file path.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
return os.path.join(cons.config.build_dir, fname)
|
return os.path.join(cons.config.build_dir, file_name)
|
||||||
|
|
||||||
def make_efi(fname, comp):
|
def make_efi(fname, comp):
|
||||||
"""Create an UEFI binary.
|
"""Create an UEFI binary.
|
||||||
@@ -225,7 +225,8 @@ def test_efi_fit_launch(u_boot_console):
|
|||||||
|
|
||||||
bin_path = make_fpath(fname)
|
bin_path = make_fpath(fname)
|
||||||
util.run_and_log(cons,
|
util.run_and_log(cons,
|
||||||
['cp', make_fpath('lib/efi_loader/helloworld.efi'), bin_path])
|
['cp', make_fpath('lib/efi_loader/helloworld.efi'),
|
||||||
|
bin_path])
|
||||||
if comp:
|
if comp:
|
||||||
util.run_and_log(cons, ['gzip', '-f', bin_path])
|
util.run_and_log(cons, ['gzip', '-f', bin_path])
|
||||||
bin_path += '.gz'
|
bin_path += '.gz'
|
||||||
@@ -251,8 +252,8 @@ def test_efi_fit_launch(u_boot_console):
|
|||||||
|
|
||||||
# Generate a test FDT file.
|
# Generate a test FDT file.
|
||||||
dts = make_fpath('test-efi-fit-%s.dts' % fdt_type)
|
dts = make_fpath('test-efi-fit-%s.dts' % fdt_type)
|
||||||
with open(dts, 'w') as fd:
|
with open(dts, 'w') as file:
|
||||||
fd.write(fdt_data % fdt_params)
|
file.write(FDT_DATA % fdt_params)
|
||||||
|
|
||||||
# Build the test FDT.
|
# Build the test FDT.
|
||||||
dtb = make_fpath('test-efi-fit-%s.dtb' % fdt_type)
|
dtb = make_fpath('test-efi-fit-%s.dtb' % fdt_type)
|
||||||
@@ -284,8 +285,8 @@ def test_efi_fit_launch(u_boot_console):
|
|||||||
|
|
||||||
# Generate a test ITS file.
|
# Generate a test ITS file.
|
||||||
its_path = make_fpath('test-efi-fit-helloworld.its')
|
its_path = make_fpath('test-efi-fit-helloworld.its')
|
||||||
with open(its_path, 'w') as fd:
|
with open(its_path, 'w') as file:
|
||||||
fd.write(its_data % its_params)
|
file.write(ITS_DATA % its_params)
|
||||||
|
|
||||||
# Build the test ITS.
|
# Build the test ITS.
|
||||||
fit_path = make_fpath('test-efi-fit-helloworld.fit')
|
fit_path = make_fpath('test-efi-fit-helloworld.fit')
|
||||||
@@ -293,56 +294,56 @@ def test_efi_fit_launch(u_boot_console):
|
|||||||
cons, [make_fpath('tools/mkimage'), '-f', its_path, fit_path])
|
cons, [make_fpath('tools/mkimage'), '-f', its_path, fit_path])
|
||||||
return fit_path
|
return fit_path
|
||||||
|
|
||||||
def load_fit_from_host(f):
|
def load_fit_from_host(fit):
|
||||||
"""Load the FIT image using the 'host load' command and return its address.
|
"""Load the FIT image using the 'host load' command and return its address.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
f: Dictionary describing the FIT image to load, see env__efi_fit_test_file
|
fit: Dictionary describing the FIT image to load, see env__efi_fit_test_file
|
||||||
in the comment at the beginning of this file.
|
in the comment at the beginning of this file.
|
||||||
Return:
|
Return:
|
||||||
The address where the file has been loaded.
|
The address where the file has been loaded.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
addr = f.get('addr', None)
|
addr = fit.get('addr', None)
|
||||||
if not addr:
|
if not addr:
|
||||||
addr = util.find_ram_base(cons)
|
addr = util.find_ram_base(cons)
|
||||||
|
|
||||||
output = cons.run_command(
|
output = cons.run_command(
|
||||||
'host load hostfs - %x %s/%s' % (addr, f['dn'], f['fn']))
|
'host load hostfs - %x %s/%s' % (addr, fit['dn'], fit['fn']))
|
||||||
expected_text = ' bytes read'
|
expected_text = ' bytes read'
|
||||||
sz = f.get('size', None)
|
size = fit.get('size', None)
|
||||||
if sz:
|
if size:
|
||||||
expected_text = '%d' % sz + expected_text
|
expected_text = '%d' % size + expected_text
|
||||||
assert(expected_text in output)
|
assert expected_text in output
|
||||||
|
|
||||||
return addr
|
return addr
|
||||||
|
|
||||||
def load_fit_from_tftp(f):
|
def load_fit_from_tftp(fit):
|
||||||
"""Load the FIT image using the tftpboot command and return its address.
|
"""Load the FIT image using the tftpboot command and return its address.
|
||||||
|
|
||||||
The file is downloaded from the TFTP server, its size and optionally its
|
The file is downloaded from the TFTP server, its size and optionally its
|
||||||
CRC32 are validated.
|
CRC32 are validated.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
f: Dictionary describing the FIT image to load, see env__efi_fit_tftp_file
|
fit: Dictionary describing the FIT image to load, see env__efi_fit_tftp_file
|
||||||
in the comment at the beginning of this file.
|
in the comment at the beginning of this file.
|
||||||
Return:
|
Return:
|
||||||
The address where the file has been loaded.
|
The address where the file has been loaded.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
addr = f.get('addr', None)
|
addr = fit.get('addr', None)
|
||||||
if not addr:
|
if not addr:
|
||||||
addr = util.find_ram_base(cons)
|
addr = util.find_ram_base(cons)
|
||||||
|
|
||||||
fn = f['fn']
|
file_name = fit['fn']
|
||||||
output = cons.run_command('tftpboot %x %s' % (addr, fn))
|
output = cons.run_command('tftpboot %x %s' % (addr, file_name))
|
||||||
expected_text = 'Bytes transferred = '
|
expected_text = 'Bytes transferred = '
|
||||||
sz = f.get('size', None)
|
size = fit.get('size', None)
|
||||||
if sz:
|
if size:
|
||||||
expected_text += '%d' % sz
|
expected_text += '%d' % size
|
||||||
assert expected_text in output
|
assert expected_text in output
|
||||||
|
|
||||||
expected_crc = f.get('crc32', None)
|
expected_crc = fit.get('crc32', None)
|
||||||
if not expected_crc:
|
if not expected_crc:
|
||||||
return addr
|
return addr
|
||||||
|
|
||||||
@@ -398,8 +399,8 @@ def test_efi_fit_launch(u_boot_console):
|
|||||||
if not fit:
|
if not fit:
|
||||||
pytest.skip('No env__efi_fit_tftp_file binary specified in environment')
|
pytest.skip('No env__efi_fit_tftp_file binary specified in environment')
|
||||||
|
|
||||||
sz = fit.get('size', None)
|
size = fit.get('size', None)
|
||||||
if not sz:
|
if not size:
|
||||||
if not fit.get('dn', None):
|
if not fit.get('dn', None):
|
||||||
pytest.skip('Neither "size", nor "dn" info provided in env__efi_fit_tftp_file')
|
pytest.skip('Neither "size", nor "dn" info provided in env__efi_fit_tftp_file')
|
||||||
|
|
||||||
@@ -425,7 +426,7 @@ def test_efi_fit_launch(u_boot_console):
|
|||||||
cons.wait_for('Booting using the fdt blob')
|
cons.wait_for('Booting using the fdt blob')
|
||||||
cons.wait_for('Hello, world')
|
cons.wait_for('Hello, world')
|
||||||
cons.wait_for('## Application terminated, r = 0')
|
cons.wait_for('## Application terminated, r = 0')
|
||||||
cons.restart_uboot();
|
cons.restart_uboot()
|
||||||
|
|
||||||
cons = u_boot_console
|
cons = u_boot_console
|
||||||
# Array slice removes leading/trailing quotes.
|
# Array slice removes leading/trailing quotes.
|
||||||
|
Reference in New Issue
Block a user