From 752c3769874596d012cd8325099d2ae20123f989 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 9 Feb 2025 09:07:14 -0700 Subject: test/py: Shorten u_boot_console This fixture name is quite long and results in lots of verbose code. We know this is U-Boot so the 'u_boot_' part is not necessary. But it is also a bit of a misnomer, since it provides access to all the information available to tests. It is not just the console. It would be too confusing to use con as it would be confused with config and it is probably too short. So shorten it to 'ubman'. Signed-off-by: Simon Glass Link: https://lore.kernel.org/u-boot/CAFLszTgPa4aT_J9h9pqeTtLCVn4x2JvLWRcWRD8NaN3uoSAtyA@mail.gmail.com/ --- test/py/tests/test_fit.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/py/tests/test_fit.py') diff --git a/test/py/tests/test_fit.py b/test/py/tests/test_fit.py index 8f9c4b26411..459be5af39d 100755 --- a/test/py/tests/test_fit.py +++ b/test/py/tests/test_fit.py @@ -118,7 +118,7 @@ host save hostfs 0 %(loadables2_addr)x %(loadables2_out)s %(loadables2_size)x @pytest.mark.boardspec('sandbox') @pytest.mark.buildconfigspec('fit_signature') @pytest.mark.requiredtool('dtc') -def test_fit(u_boot_console): +def test_fit(ubman): def make_fname(leaf): """Make a temporary filename @@ -397,7 +397,7 @@ def test_fit(u_boot_console): check_equal(ramdisk + '.gz', ramdisk_out, 'Ramdist not loaded') - cons = u_boot_console + cons = ubman # We need to use our own device tree file. Remember to restore it # afterwards. old_dtb = cons.config.dtb -- cgit v1.2.3 From d9ed4b75add4b4ccc37cf32b54cd9c77f48e3396 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 9 Feb 2025 09:07:15 -0700 Subject: test/py: Drop u_boot_ prefix on test files We know this is U-Boot so the prefix serves no purpose other than to make things longer and harder to read. Drop it and rename the files. Signed-off-by: Simon Glass Reviewed-by: Mattijs Korpershoek # test_android / test_dfu --- test/py/tests/test_fit.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test/py/tests/test_fit.py') diff --git a/test/py/tests/test_fit.py b/test/py/tests/test_fit.py index 459be5af39d..0f2d0940562 100755 --- a/test/py/tests/test_fit.py +++ b/test/py/tests/test_fit.py @@ -6,7 +6,7 @@ import os import pytest import struct -import u_boot_utils as util +import utils as util import fit_util # Define a base ITS which we can adjust using % and a dictionary -- cgit v1.2.3 From dd693ecb60384049dd8c3f6a36331c1a70b6558f Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 9 Feb 2025 09:07:16 -0700 Subject: test/py: Drop importing utils as util Now that we have a shorter name, we don't need this sort of thing. Drop it. Signed-off-by: Simon Glass Reviewed-by: Mattijs Korpershoek # test_android --- test/py/tests/test_fit.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test/py/tests/test_fit.py') diff --git a/test/py/tests/test_fit.py b/test/py/tests/test_fit.py index 0f2d0940562..bfc20c4b1ed 100755 --- a/test/py/tests/test_fit.py +++ b/test/py/tests/test_fit.py @@ -6,7 +6,7 @@ import os import pytest import struct -import utils as util +import utils import fit_util # Define a base ITS which we can adjust using % and a dictionary @@ -165,7 +165,7 @@ def test_fit(ubman): return fname def make_compressed(filename): - util.run_and_log(cons, ['gzip', '-f', '-k', filename]) + utils.run_and_log(cons, ['gzip', '-f', '-k', filename]) return filename + '.gz' def find_matching(text, match): -- cgit v1.2.3 From d08653d3699c1aafada3418c9f74b887bfb21a65 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Sun, 9 Feb 2025 09:07:17 -0700 Subject: test/py: Drop assigning ubman to cons Now that we have a shorter name, we don't need this sort of thing. Just use ubman instead. Signed-off-by: Simon Glass --- test/py/tests/test_fit.py | 63 +++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 32 deletions(-) (limited to 'test/py/tests/test_fit.py') diff --git a/test/py/tests/test_fit.py b/test/py/tests/test_fit.py index bfc20c4b1ed..619f73153a0 100755 --- a/test/py/tests/test_fit.py +++ b/test/py/tests/test_fit.py @@ -127,7 +127,7 @@ def test_fit(ubman): Return: Temporary filename """ - return os.path.join(cons.config.build_dir, leaf) + return os.path.join(ubman.config.build_dir, leaf) def filesize(fname): """Get the size of a file @@ -165,7 +165,7 @@ def test_fit(ubman): return fname def make_compressed(filename): - utils.run_and_log(cons, ['gzip', '-f', '-k', filename]) + utils.run_and_log(ubman, ['gzip', '-f', '-k', filename]) return filename + '.gz' def find_matching(text, match): @@ -260,10 +260,10 @@ def test_fit(ubman): - run code coverage to make sure we are testing all the code """ # Set up invariant files - control_dtb = fit_util.make_dtb(cons, base_fdt, 'u-boot') - kernel = fit_util.make_kernel(cons, 'test-kernel.bin', 'kernel') + control_dtb = fit_util.make_dtb(ubman, base_fdt, 'u-boot') + kernel = fit_util.make_kernel(ubman, 'test-kernel.bin', 'kernel') ramdisk = make_ramdisk('test-ramdisk.bin', 'ramdisk') - loadables1 = fit_util.make_kernel(cons, 'test-loadables1.bin', 'lenrek') + loadables1 = fit_util.make_kernel(ubman, 'test-loadables1.bin', 'lenrek') loadables2 = make_ramdisk('test-loadables2.bin', 'ksidmar') kernel_out = make_fname('kernel-out.bin') fdt = make_fname('u-boot.dtb') @@ -311,16 +311,16 @@ def test_fit(ubman): } # Make a basic FIT and a script to load it - fit = fit_util.make_fit(cons, mkimage, base_its, params) + fit = fit_util.make_fit(ubman, mkimage, base_its, params) params['fit'] = fit cmd = base_script % params # First check that we can load a kernel # We could perhaps reduce duplication with some loss of readability - cons.config.dtb = control_dtb - cons.restart_uboot() - with cons.log.section('Kernel load'): - output = cons.run_command_list(cmd.splitlines()) + ubman.config.dtb = control_dtb + ubman.restart_uboot() + with ubman.log.section('Kernel load'): + output = ubman.run_command_list(cmd.splitlines()) check_equal(kernel, kernel_out, 'Kernel not loaded') check_not_equal(control_dtb, fdt_out, 'FDT loaded but should be ignored') @@ -340,7 +340,7 @@ def test_fit(ubman): (fit_offset, real_fit_offset)) # Check if bootargs strings substitution works - output = cons.run_command_list([ + output = ubman.run_command_list([ 'env set bootargs \\\"\'my_boot_var=${foo}\'\\\"', 'env set foo bar', 'bootm prep', @@ -348,63 +348,62 @@ def test_fit(ubman): assert 'bootargs="my_boot_var=bar"' in output, "Bootargs strings not substituted" # Now a kernel and an FDT - with cons.log.section('Kernel + FDT load'): + with ubman.log.section('Kernel + FDT load'): params['fdt_load'] = 'load = <%#x>;' % params['fdt_addr'] - fit = fit_util.make_fit(cons, mkimage, base_its, params) - cons.restart_uboot() - output = cons.run_command_list(cmd.splitlines()) + fit = fit_util.make_fit(ubman, mkimage, base_its, params) + ubman.restart_uboot() + output = ubman.run_command_list(cmd.splitlines()) check_equal(kernel, kernel_out, 'Kernel not loaded') check_equal(control_dtb, fdt_out, 'FDT not loaded') check_not_equal(ramdisk, ramdisk_out, 'Ramdisk loaded but should not be') # Try a ramdisk - with cons.log.section('Kernel + FDT + Ramdisk load'): + with ubman.log.section('Kernel + FDT + Ramdisk load'): params['ramdisk_config'] = 'ramdisk = "ramdisk-1";' params['ramdisk_load'] = 'load = <%#x>;' % params['ramdisk_addr'] - fit = fit_util.make_fit(cons, mkimage, base_its, params) - cons.restart_uboot() - output = cons.run_command_list(cmd.splitlines()) + fit = fit_util.make_fit(ubman, mkimage, base_its, params) + ubman.restart_uboot() + output = ubman.run_command_list(cmd.splitlines()) check_equal(ramdisk, ramdisk_out, 'Ramdisk not loaded') # Configuration with some Loadables - with cons.log.section('Kernel + FDT + Ramdisk load + Loadables'): + with ubman.log.section('Kernel + FDT + Ramdisk load + Loadables'): params['loadables_config'] = 'loadables = "kernel-2", "ramdisk-2";' params['loadables1_load'] = ('load = <%#x>;' % params['loadables1_addr']) params['loadables2_load'] = ('load = <%#x>;' % params['loadables2_addr']) - fit = fit_util.make_fit(cons, mkimage, base_its, params) - cons.restart_uboot() - output = cons.run_command_list(cmd.splitlines()) + fit = fit_util.make_fit(ubman, mkimage, base_its, params) + ubman.restart_uboot() + output = ubman.run_command_list(cmd.splitlines()) check_equal(loadables1, loadables1_out, 'Loadables1 (kernel) not loaded') check_equal(loadables2, loadables2_out, 'Loadables2 (ramdisk) not loaded') # Kernel, FDT and Ramdisk all compressed - with cons.log.section('(Kernel + FDT + Ramdisk) compressed'): + with ubman.log.section('(Kernel + FDT + Ramdisk) compressed'): params['compression'] = 'gzip' params['kernel'] = make_compressed(kernel) params['fdt'] = make_compressed(fdt) params['ramdisk'] = make_compressed(ramdisk) - fit = fit_util.make_fit(cons, mkimage, base_its, params) - cons.restart_uboot() - output = cons.run_command_list(cmd.splitlines()) + fit = fit_util.make_fit(ubman, mkimage, base_its, params) + ubman.restart_uboot() + output = ubman.run_command_list(cmd.splitlines()) check_equal(kernel, kernel_out, 'Kernel not loaded') check_equal(control_dtb, fdt_out, 'FDT not loaded') check_not_equal(ramdisk, ramdisk_out, 'Ramdisk got decompressed?') check_equal(ramdisk + '.gz', ramdisk_out, 'Ramdist not loaded') - cons = ubman # We need to use our own device tree file. Remember to restore it # afterwards. - old_dtb = cons.config.dtb + old_dtb = ubman.config.dtb try: - mkimage = cons.config.build_dir + '/tools/mkimage' + mkimage = ubman.config.build_dir + '/tools/mkimage' run_fit_test(mkimage) finally: # Go back to the original U-Boot with the correct dtb. - cons.config.dtb = old_dtb - cons.restart_uboot() + ubman.config.dtb = old_dtb + ubman.restart_uboot() -- cgit v1.2.3