All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: U-Boot Mailing List <u-boot@lists.denx.de>
Cc: Simon Glass <sjg@chromium.org>,
	Francis Laniel <francis.laniel@amarulasolutions.com>,
	Guillaume La Roque <glaroque@baylibre.com>,
	Julien Masson <jmasson@baylibre.com>,
	Mattijs Korpershoek <mkorpershoek@baylibre.com>,
	Richard Weinberger <richard@nod.at>,
	Stephen Warren <swarren@nvidia.com>,
	Stephen Warren <swarren@wwwdotorg.org>,
	Tom Rini <trini@konsulko.com>
Subject: [PATCH 1/5] test/py: Refactor extlinux-image creation into a function
Date: Thu, 19 Dec 2024 21:01:16 -0700	[thread overview]
Message-ID: <20241220040120.3245610-2-sjg@chromium.org> (raw)
In-Reply-To: <20241220040120.3245610-1-sjg@chromium.org>

We would like to make another image which is very similar, so create a
function to produce an extlinux image.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 test/py/tests/test_ut.py | 67 +++++++++++++++++++++++-----------------
 1 file changed, 38 insertions(+), 29 deletions(-)

diff --git a/test/py/tests/test_ut.py b/test/py/tests/test_ut.py
index cacf11f7c0a..e3b988efe23 100644
--- a/test/py/tests/test_ut.py
+++ b/test/py/tests/test_ut.py
@@ -57,6 +57,43 @@ def setup_image(cons, devnum, part_type, img_size=20, second_part=False,
                              stdin=spec.encode('utf-8'))
     return fname, mnt
 
+def setup_extlinux_image(cons, mmc_dev, vmlinux, initrd, dtbdir, script):
+    """Create a 20MB disk image with a single FAT partition"""
+    fname, mnt = setup_image(cons, mmc_dev, 0xc, second_part=True)
+
+    ext = os.path.join(mnt, 'extlinux')
+    mkdir_cond(ext)
+
+    conf = os.path.join(ext, 'extlinux.conf')
+    with open(conf, 'w', encoding='ascii') as fd:
+        print(script, file=fd)
+
+    inf = os.path.join(cons.config.persistent_data_dir, 'inf')
+    with open(inf, 'wb') as fd:
+        fd.write(gzip.compress(b'vmlinux'))
+    mkimage = cons.config.build_dir + '/tools/mkimage'
+    u_boot_utils.run_and_log(
+        cons, f'{mkimage} -f auto -d {inf} {os.path.join(mnt, vmlinux)}')
+
+    with open(os.path.join(mnt, initrd), 'w', encoding='ascii') as fd:
+        print('initrd', file=fd)
+
+    if dtbdir:
+        mkdir_cond(os.path.join(mnt, dtbdir))
+
+        dtb_file = os.path.join(mnt, f'{dtbdir}/sandbox.dtb')
+        u_boot_utils.run_and_log(
+            cons, f'dtc -o {dtb_file}', stdin=b'/dts-v1/; / {};')
+
+    fsfile = 'vfat18M.img'
+    u_boot_utils.run_and_log(cons, f'fallocate -l 18M {fsfile}')
+    u_boot_utils.run_and_log(cons, f'mkfs.vfat {fsfile}')
+    u_boot_utils.run_and_log(cons, ['sh', '-c', f'mcopy -i {fsfile} {mnt}/* ::/'])
+    u_boot_utils.run_and_log(cons, f'dd if={fsfile} of={fname} bs=1M seek=1')
+    u_boot_utils.run_and_log(cons, f'rm -rf {mnt}')
+    u_boot_utils.run_and_log(cons, f'rm -f {fsfile}')
+
+
 def setup_bootmenu_image(cons):
     """Create a 20MB disk image with a single ext4 partition
 
@@ -197,36 +234,8 @@ label Fedora-Workstation-armhfp-31-1.9 (5.3.7-301.fc31.armv7hl)
         append ro root=UUID=9732b35b-4cd5-458b-9b91-80f7047e0b8a rhgb quiet LANG=en_US.UTF-8 cma=192MB cma=256MB
         fdtdir /%s/
         initrd /%s''' % (vmlinux, dtbdir, initrd)
-    ext = os.path.join(mnt, 'extlinux')
-    mkdir_cond(ext)
 
-    conf = os.path.join(ext, 'extlinux.conf')
-    with open(conf, 'w', encoding='ascii') as fd:
-        print(script, file=fd)
-
-    inf = os.path.join(cons.config.persistent_data_dir, 'inf')
-    with open(inf, 'wb') as fd:
-        fd.write(gzip.compress(b'vmlinux'))
-    mkimage = cons.config.build_dir + '/tools/mkimage'
-    u_boot_utils.run_and_log(
-        cons, f'{mkimage} -f auto -d {inf} {os.path.join(mnt, vmlinux)}')
-
-    with open(os.path.join(mnt, initrd), 'w', encoding='ascii') as fd:
-        print('initrd', file=fd)
-
-    mkdir_cond(os.path.join(mnt, dtbdir))
-
-    dtb_file = os.path.join(mnt, f'{dtbdir}/sandbox.dtb')
-    u_boot_utils.run_and_log(
-        cons, f'dtc -o {dtb_file}', stdin=b'/dts-v1/; / {};')
-
-    fsfile = 'vfat18M.img'
-    u_boot_utils.run_and_log(cons, f'fallocate -l 18M {fsfile}')
-    u_boot_utils.run_and_log(cons, f'mkfs.vfat {fsfile}')
-    u_boot_utils.run_and_log(cons, ['sh', '-c', f'mcopy -i {fsfile} {mnt}/* ::/'])
-    u_boot_utils.run_and_log(cons, f'dd if={fsfile} of={fname} bs=1M seek=1')
-    u_boot_utils.run_and_log(cons, f'rm -rf {mnt}')
-    u_boot_utils.run_and_log(cons, f'rm -f {fsfile}')
+    setup_extlinux_image(cons, mmc_dev, vmlinux, initrd, dtbdir, script)
 
 def setup_cros_image(cons):
     """Create a 20MB disk image with ChromiumOS partitions"""
-- 
2.34.1


  reply	other threads:[~2024-12-20  4:01 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-20  4:01 [PATCH 0/5] pxe: Support an automatic localboot Simon Glass
2024-12-20  4:01 ` Simon Glass [this message]
2024-12-20  4:01 ` [PATCH 2/5] test: bootflow: Avoid a confusing error condition Simon Glass
2024-12-20  4:01 ` [PATCH 3/5] pxe_utils: Allow the FDT to be missing Simon Glass
2024-12-20 14:45   ` Tom Rini
2025-01-14 15:13   ` Quentin Schulz
2025-01-15  1:16     ` Simon Glass
2025-01-15 11:59       ` Quentin Schulz
2025-01-15 13:19         ` Simon Glass
2024-12-20  4:01 ` [PATCH 4/5] pxe_utils: Support a backup for localboot Simon Glass
2024-12-20 14:56   ` Tom Rini
2024-12-20 17:18     ` Simon Glass
2024-12-20 17:23       ` Tom Rini
2024-12-20 17:37         ` Simon Glass
2024-12-20 20:48           ` Tom Rini
2025-01-08 17:04             ` Simon Glass
2025-01-08 17:31               ` Tom Rini
2025-01-09 12:31                 ` Simon Glass
2024-12-20  4:01 ` [PATCH 5/5] pxe_utils: Support the SAY command Simon Glass
2024-12-20 14:44   ` Tom Rini
2024-12-20 17:36     ` Simon Glass
2024-12-20 18:30       ` Tom Rini
2024-12-20 19:34         ` Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241220040120.3245610-2-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=francis.laniel@amarulasolutions.com \
    --cc=glaroque@baylibre.com \
    --cc=jmasson@baylibre.com \
    --cc=mkorpershoek@baylibre.com \
    --cc=richard@nod.at \
    --cc=swarren@nvidia.com \
    --cc=swarren@wwwdotorg.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.