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/fit_util.py | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'test/py/tests/fit_util.py') diff --git a/test/py/tests/fit_util.py b/test/py/tests/fit_util.py index 79718d431a0..22b971131b8 100644 --- a/test/py/tests/fit_util.py +++ b/test/py/tests/fit_util.py @@ -5,25 +5,25 @@ import os -import u_boot_utils as util +import utils as util -def make_fname(cons, basename): +def make_fname(ubman, basename): """Make a temporary filename Args: - cons (ConsoleBase): u_boot_console to use + ubman (ConsoleBase): ubman to use basename (str): Base name of file to create (within temporary directory) Return: Temporary filename """ - return os.path.join(cons.config.build_dir, basename) + return os.path.join(ubman.config.build_dir, basename) -def make_its(cons, base_its, params, basename='test.its'): +def make_its(ubman, base_its, params, basename='test.its'): """Make a sample .its file with parameters embedded Args: - cons (ConsoleBase): u_boot_console to use + ubman (ConsoleBase): ubman to use base_its (str): Template text for the .its file, typically containing %() references params (dict of str): Parameters to embed in the %() strings @@ -31,19 +31,19 @@ def make_its(cons, base_its, params, basename='test.its'): Returns: str: Filename of .its file created """ - its = make_fname(cons, basename) + its = make_fname(ubman, basename) with open(its, 'w', encoding='utf-8') as outf: print(base_its % params, file=outf) return its -def make_fit(cons, mkimage, base_its, params, basename='test.fit', base_fdt=None): +def make_fit(ubman, mkimage, base_its, params, basename='test.fit', base_fdt=None): """Make a sample .fit file ready for loading This creates a .its script with the selected parameters and uses mkimage to turn this into a .fit image. Args: - cons (ConsoleBase): u_boot_console to use + ubman (ConsoleBase): ubman to use mkimage (str): Filename of 'mkimage' utility base_its (str): Template text for the .its file, typically containing %() references @@ -52,25 +52,25 @@ def make_fit(cons, mkimage, base_its, params, basename='test.fit', base_fdt=None Return: Filename of .fit file created """ - fit = make_fname(cons, basename) - its = make_its(cons, base_its, params) - util.run_and_log(cons, [mkimage, '-f', its, fit]) + fit = make_fname(ubman, basename) + its = make_its(ubman, base_its, params) + util.run_and_log(ubman, [mkimage, '-f', its, fit]) if base_fdt: - with open(make_fname(cons, 'u-boot.dts'), 'w') as fd: + with open(make_fname(ubman, 'u-boot.dts'), 'w') as fd: fd.write(base_fdt) return fit -def make_kernel(cons, basename, text): +def make_kernel(ubman, basename, text): """Make a sample kernel with test data Args: - cons (ConsoleBase): u_boot_console to use + ubman (ConsoleBase): ubman to use basename (str): base name to write to (will be placed in the temp dir) text (str): Contents of the kernel file (will be repeated 100 times) Returns: str: Full path and filename of the kernel it created """ - fname = make_fname(cons, basename) + fname = make_fname(ubman, basename) data = '' for i in range(100): data += f'this {text} {i} is unlikely to boot\n' @@ -78,16 +78,16 @@ def make_kernel(cons, basename, text): print(data, file=outf) return fname -def make_dtb(cons, base_fdt, basename): +def make_dtb(ubman, base_fdt, basename): """Make a sample .dts file and compile it to a .dtb Returns: - cons (ConsoleBase): u_boot_console to use + ubman (ConsoleBase): ubman to use Filename of .dtb file created """ - src = make_fname(cons, f'{basename}.dts') - dtb = make_fname(cons, f'{basename}.dtb') + src = make_fname(ubman, f'{basename}.dts') + dtb = make_fname(ubman, f'{basename}.dtb') with open(src, 'w', encoding='utf-8') as outf: outf.write(base_fdt) - util.run_and_log(cons, ['dtc', src, '-O', 'dtb', '-o', dtb]) + util.run_and_log(ubman, ['dtc', src, '-O', 'dtb', '-o', dtb]) return dtb -- 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/fit_util.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'test/py/tests/fit_util.py') diff --git a/test/py/tests/fit_util.py b/test/py/tests/fit_util.py index 22b971131b8..f322b50a319 100644 --- a/test/py/tests/fit_util.py +++ b/test/py/tests/fit_util.py @@ -5,7 +5,7 @@ import os -import utils as util +import utils def make_fname(ubman, basename): """Make a temporary filename @@ -54,7 +54,7 @@ def make_fit(ubman, mkimage, base_its, params, basename='test.fit', base_fdt=Non """ fit = make_fname(ubman, basename) its = make_its(ubman, base_its, params) - util.run_and_log(ubman, [mkimage, '-f', its, fit]) + utils.run_and_log(ubman, [mkimage, '-f', its, fit]) if base_fdt: with open(make_fname(ubman, 'u-boot.dts'), 'w') as fd: fd.write(base_fdt) @@ -89,5 +89,5 @@ def make_dtb(ubman, base_fdt, basename): dtb = make_fname(ubman, f'{basename}.dtb') with open(src, 'w', encoding='utf-8') as outf: outf.write(base_fdt) - util.run_and_log(ubman, ['dtc', src, '-O', 'dtb', '-o', dtb]) + utils.run_and_log(ubman, ['dtc', src, '-O', 'dtb', '-o', dtb]) return dtb -- cgit v1.2.3