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: "Michal Simek" <michal.simek@xilinx.com>,
	"Heinrich Schuchardt" <xypron.glpk@gmx.de>,
	"Tom Rini" <trini@konsulko.com>,
	"Ilias Apalodimas" <ilias.apalodimas@linaro.org>,
	"Daniel Schwierzeck" <daniel.schwierzeck@gmail.com>,
	"Steffen Jaeckel" <jaeckel-floss@eyet-services.de>,
	"Marek Behún" <marek.behun@nic.cz>,
	"Lukas Auer" <lukas.auer@aisec.fraunhofer.de>,
	"Dennis Gilmore" <dennis@ausil.us>,
	"Simon Glass" <sjg@chromium.org>
Subject: [PATCH v2 39/41] bootstd: Add setup for the bootflow tests
Date: Sat, 23 Oct 2021 17:26:33 -0600	[thread overview]
Message-ID: <20211023232635.9195-28-sjg@chromium.org> (raw)
In-Reply-To: <20211023232635.9195-1-sjg@chromium.org>

We need to create a disk image with a partition table and a DOS-format
filesystem containing a few files. Provide a fallback binary for CI since
it does not seem able to detect the loopback partitions.

Add this to a dm_init test so that it happens when needed.

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

(no changes since v1)

 test/py/tests/bootstd/mmc1.img.xz | Bin 0 -> 4448 bytes
 test/py/tests/test_ut.py          | 103 ++++++++++++++++++++++++++++++
 2 files changed, 103 insertions(+)
 create mode 100644 test/py/tests/bootstd/mmc1.img.xz

diff --git a/test/py/tests/bootstd/mmc1.img.xz b/test/py/tests/bootstd/mmc1.img.xz
new file mode 100644
index 0000000000000000000000000000000000000000..4e7f39b830eb4bddcb9ff6df39e89f130b5706b9
GIT binary patch
literal 4448
zcmeI0c{JOJ7RP@`Y(-R5?X`}rGNKxz9<j8IUF{-@c9c=1cC|-CYOSqGnW?SD*rkjm
zwrEML9ZRXDs3;}Y(T7+w@167BKku)3b7tQA$KUsld(Y?I^ZkC$J<$wzbOHd-@<hW;
zRzR9X2mpYfua`=g%tdzeZ2)+1a%`NFk@nORl#0;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d_}d}Uo+;vP2meZmVEF3+S&?&e02uw_ZaxU
zc6A2q_a>e*VE<)AJOg$H?0@1nXBu{<VSjS)`j13&c42?u!f>3A05H(`mV)`mrvw0O
h4`jqrLheQZEG;rP9FCigsLUjGdmgd=vj{>v{RVxmraJ%t

literal 0
HcmV?d00001

diff --git a/test/py/tests/test_ut.py b/test/py/tests/test_ut.py
index 01c2b3ffa12..dd1a6696da1 100644
--- a/test/py/tests/test_ut.py
+++ b/test/py/tests/test_ut.py
@@ -1,9 +1,102 @@
 # SPDX-License-Identifier: GPL-2.0
 # Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
 
+import gzip
+import os
 import os.path
 import pytest
 
+import u_boot_utils
+
+def mkdir_cond(dirname):
+    """Create a directory if it doesn't already exist
+
+    Args:
+        dirname: Name of directory to create
+    """
+    if not os.path.exists(dirname):
+        os.mkdir(dirname)
+
+def setup_bootflow_image(u_boot_console):
+    """Create a 20MB disk image with a single FAT partition"""
+    cons = u_boot_console
+    fname = os.path.join(cons.config.source_dir, 'mmc1.img')
+    mnt = os.path.join(cons.config.persistent_data_dir, 'mnt')
+    mkdir_cond(mnt)
+
+    u_boot_utils.run_and_log(cons, 'qemu-img create %s 20M' % fname)
+    u_boot_utils.run_and_log(cons, 'sudo sfdisk %s' % fname,
+                             stdin=b'type=c')
+
+    loop = None
+    mounted = False
+    complete = False
+    try:
+        out = u_boot_utils.run_and_log(cons,
+                                       'sudo losetup --show -f -P %s' % fname)
+        loop = out.strip()
+        fatpart = '%sp1' % loop
+        u_boot_utils.run_and_log(cons, 'sudo mkfs.vfat %s' % fatpart)
+        u_boot_utils.run_and_log(
+            cons, 'sudo mount -o loop %s %s -o uid=%d,gid=%d' %
+            (fatpart, mnt, os.getuid(), os.getgid()))
+        mounted = True
+
+        vmlinux = 'vmlinuz-5.3.7-301.fc31.armv7hl'
+        initrd = 'initramfs-5.3.7-301.fc31.armv7hl.img'
+        dtbdir = 'dtb-5.3.7-301.fc31.armv7hl'
+        script = '''# extlinux.conf generated by appliance-creator
+ui menu.c32
+menu autoboot Welcome to Fedora-Workstation-armhfp-31-1.9. Automatic boot in # second{,s}. Press a key for options.
+menu title Fedora-Workstation-armhfp-31-1.9 Boot Options.
+menu hidden
+timeout 20
+totaltimeout 600
+
+label Fedora-Workstation-armhfp-31-1.9 (5.3.7-301.fc31.armv7hl)
+        kernel /%s
+        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)
+
+        with open(os.path.join(ext, 'extlinux.conf'), 'w') 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'))
+        u_boot_utils.run_and_log(cons, 'mkimage -f auto -d %s %s' %
+                                 (inf, os.path.join(mnt, vmlinux)))
+
+        with open(os.path.join(mnt, initrd), 'w') as fd:
+            print('initrd', file=fd)
+
+        mkdir_cond(os.path.join(mnt, dtbdir))
+
+        dtb_file = os.path.join(mnt, '%s/sandbox.dtb' % dtbdir)
+        u_boot_utils.run_and_log(
+            cons, 'dtc -o %s' % dtb_file, stdin=b'/dts-v1/; / {};')
+        complete = True
+    except ValueError as exc:
+        print('Falled to create image, failing back to prepared copy: %s',
+              str(exc))
+    finally:
+        if mounted:
+            u_boot_utils.run_and_log(cons, 'sudo umount %s' % mnt)
+        if loop:
+            u_boot_utils.run_and_log(cons, 'sudo losetup -d %s' % loop)
+
+    if not complete:
+        # Use a prepared image since we cannot create one
+        infname = os.path.join(cons.config.source_dir,
+                               'test/py/tests/bootstd/mmc1.img.xz')
+        u_boot_utils.run_and_log(
+            cons,
+            ['sh', '-c', 'xz -dc %s >%s' % (infname, fname)])
+
+
 @pytest.mark.buildconfigspec('ut_dm')
 def test_ut_dm_init(u_boot_console):
     """Initialize data for ut dm tests."""
@@ -21,6 +114,16 @@ def test_ut_dm_init(u_boot_console):
         with open(fn, 'wb') as fh:
             fh.write(data)
 
+@pytest.mark.buildconfigspec('cmd_bootstd')
+def test_ut_dm_init_bootstd(u_boot_console):
+    """Initialise data for bootflow tests"""
+
+    setup_bootflow_image(u_boot_console)
+
+    # Restart so that the new mmc1.img is picked up
+    u_boot_console.restart_uboot()
+
+
 def test_ut(u_boot_console, ut_subtest):
     """Execute a "ut" subtest.
 
-- 
2.33.0.1079.g6e70778dc9-goog


  parent reply	other threads:[~2021-10-23 23:33 UTC|newest]

Thread overview: 116+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAPnjgZ2TFOQGoQ1+Vt6LRMk+nULj9joS0C7fMMiXfg7JNien7g@mail.gmail.com>
2021-10-23 23:25 ` [PATCH v2 00/41] Initial implementation of standard boot Simon Glass
2021-10-23 23:25   ` [PATCH v2 01/41] lib: Add a way to find the postiion of a trailing number Simon Glass
2021-10-27 12:13     ` Heinrich Schuchardt
2021-10-23 23:25   ` [PATCH v2 02/41] Makefile: Allow LTO to be disabled for a build Simon Glass
2021-10-27  8:50     ` Ilias Apalodimas
2021-10-27 12:21       ` Heinrich Schuchardt
2021-10-27 13:13         ` Tom Rini
2021-10-31 23:46           ` Simon Glass
2021-11-01 21:58             ` Tom Rini
2021-11-04  2:49               ` Simon Glass
2021-11-04 14:55                 ` Tom Rini
2021-11-04 15:12                   ` Simon Glass
2021-11-04 16:44                     ` Tom Rini
2021-10-31 23:45         ` Simon Glass
2021-10-23 23:25   ` [PATCH v2 03/41] test/py: Allow passing input to a program Simon Glass
2021-10-23 23:25   ` [PATCH v2 04/41] sandbox: Support unmapping a file Simon Glass
2021-10-23 23:25   ` [PATCH v2 05/41] sandbox: mmc: Support a backing file Simon Glass
2021-10-23 23:26   ` [PATCH v2 06/41] mmc: Allow for children other than the block device Simon Glass
2021-10-23 23:26   ` [PATCH v2 07/41] mbr: Correct verification check Simon Glass
2021-10-27  7:41     ` Ilias Apalodimas
2021-11-24 22:22     ` Simon Glass
2021-10-23 23:26   ` [PATCH v2 08/41] disk: part_dos: Fix a NULL pointer error Simon Glass
2021-10-23 23:26   ` [PATCH v2 09/41] common: Allow a smaller console-recording pre-reloc Simon Glass
2021-10-23 23:26   ` [PATCH v2 10/41] dm: core: Add tests for stringlist functions Simon Glass
2021-10-23 23:26   ` [PATCH v2 11/41] dm: core: Fix handling of uclass pre_unbind method Simon Glass
2021-10-23 23:26   ` [PATCH v2 12/41] dm: core: Fix up string-function documentation Simon Glass
2021-10-23 23:26   ` [PATCH v2 13/41] dm: core: Add a way to obtain a string list Simon Glass
2021-10-26 19:20     ` Ilias Apalodimas
2021-11-24 22:22       ` Simon Glass
2021-11-24 22:23       ` Simon Glass
2021-10-23 23:26   ` [PATCH v2 14/41] dm: core: Allow finding children / uclasses by partial name Simon Glass
2021-10-23 23:26   ` [PATCH v2 15/41] dm: core: Add a way to count the devices in a uclass Simon Glass
2021-10-23 23:26   ` [PATCH v2 16/41] sandbox: Enable HEXDUMP for sandbox_flattree Simon Glass
2021-10-23 23:26   ` [PATCH v2 17/41] test/py: Relax the naming rules for unit tests Simon Glass
2021-10-23 23:26   ` [PATCH v2 18/41] test/py: Raise a ValueError if a command fails Simon Glass
2021-10-23 23:26   ` [PATCH v2 19/41] bootstd: Add the concept of a bootflow Simon Glass
2021-10-23 23:26   ` [PATCH v2 20/41] bootstd: Add the bootstd uclass and core implementation Simon Glass
2021-10-23 23:26   ` [PATCH v2 21/41] bootstd: Add the bootdev uclass Simon Glass
2021-10-23 23:26   ` [PATCH v2 22/41] bootstd: Add the bootmeth uclass and helpers Simon Glass
2021-10-23 23:26   ` [PATCH v2 23/41] bootstd: Add support for bootflows Simon Glass
2021-10-27  7:37     ` Ilias Apalodimas
2022-03-12  2:24       ` Simon Glass
2021-10-23 23:26   ` [PATCH v2 24/41] bootstd: Add a bootdev command Simon Glass
2021-10-23 23:26   ` [PATCH v2 25/41] bootstd: Add a bootflow ommand Simon Glass
2021-10-23 23:26   ` [PATCH v2 26/41] bootstd: Add a bootmeth command Simon Glass
2021-10-23 23:26   ` [PATCH v2 27/41] bootstd: Add an implementation of distro boot Simon Glass
2021-10-23 23:26   ` [PATCH v2 28/41] bootstd: mmc: Add a bootdev driver Simon Glass
2021-10-23 23:26   ` [PATCH v2 29/41] bootstd: ethernet: " Simon Glass
2021-10-23 23:26   ` [PATCH v2 30/41] bootstd: Add an implementation of distro PXE boot Simon Glass
2021-10-23 23:26   ` [PATCH v2 31/41] bootstd: Add an implementation of EFI boot Simon Glass
2021-10-27  8:35     ` Ilias Apalodimas
2021-10-27 14:09       ` Simon Glass
2021-10-27 14:47         ` Ilias Apalodimas
2021-10-27 18:34           ` Simon Glass
2021-10-29  5:45             ` Ilias Apalodimas
2021-10-29 12:39               ` Tom Rini
2021-10-29 13:42                 ` Ilias Apalodimas
2021-10-29 14:03                   ` AKASHI Takahiro
2021-10-29 14:39                     ` Ilias Apalodimas
2021-10-29 16:37                   ` Mark Kettenis
2021-10-29 17:08                     ` Ilias Apalodimas
2021-10-27 11:57     ` Heinrich Schuchardt
2021-10-27 14:08       ` Simon Glass
2021-10-23 23:26   ` [PATCH v2 32/41] bootstd: Add a system bootdev for strange boot methods Simon Glass
2021-10-23 23:26   ` [PATCH v2 33/41] bootstd: Add an implementation of EFI bootmgr Simon Glass
2021-10-23 23:26   ` [PATCH v2 34/41] bootstd: Add a sandbox bootmeth driver Simon Glass
2021-10-23 23:26   ` [PATCH v2 35/41] bootstd: usb: Add a bootdev driver Simon Glass
2021-10-23 23:26   ` [PATCH v2 36/41] test: fastboot: Avoid using mmc1 Simon Glass
2021-10-23 23:26   ` [PATCH v2 37/41] test: dm: Restart USB before assuming it is stopped Simon Glass
2021-10-23 23:26   ` [PATCH v2 38/41] bootstd: Add tests for bootstd including all uclasses Simon Glass
2021-10-23 23:26   ` Simon Glass [this message]
2021-10-23 23:26   ` [PATCH v2 40/41] bootstd: doc: Add documentation Simon Glass
2021-10-23 23:26   ` [PATCH v2 41/41] RFC: Switch rpi over to use bootstd Simon Glass
2021-10-28 15:13     ` Tom Rini
2021-10-28 16:43     ` Tom Rini
2021-10-28 17:16       ` Simon Glass
2021-10-28 17:29         ` Tom Rini
2021-10-23 23:27   ` [PATCH v2 00/41] Initial implementation of standard boot Simon Glass
2021-10-27 11:38   ` Heinrich Schuchardt
2021-10-27 14:11     ` Simon Glass
2021-10-28 17:37       ` Peter Robinson
2021-10-28 17:47         ` Tom Rini
2021-10-28 17:50           ` Peter Robinson
2021-10-28 17:59             ` Tom Rini
2021-10-28 18:09               ` Heinrich Schuchardt
2021-10-28 18:13                 ` Tom Rini
2021-10-28 18:17               ` François Ozog
2021-10-28 18:27                 ` Tom Rini
2021-10-28 18:28                   ` François Ozog
2021-10-28 21:40           ` Mark Kettenis
2021-10-27 15:20     ` François Ozog
2021-10-27 18:33     ` Simon Glass
2021-10-28 16:27   ` Tom Rini
2021-10-28 17:29     ` Simon Glass
2021-10-28 17:52       ` Tom Rini
2021-10-28 18:13         ` Simon Glass
2021-10-28 18:36           ` Tom Rini
2021-10-28 18:48             ` Simon Glass
2021-10-28 19:19               ` Tom Rini
2021-10-28 22:22                 ` Simon Glass
2021-10-28 22:50                   ` Tom Rini
2021-10-29  1:13                     ` Simon Glass
2021-11-24 22:22   ` [PATCH v2 17/41] test/py: Relax the naming rules for unit tests Simon Glass
2021-11-24 22:22   ` [PATCH v2 18/41] test/py: Raise a ValueError if a command fails Simon Glass
2021-11-24 22:22   ` [PATCH v2 16/41] sandbox: Enable HEXDUMP for sandbox_flattree Simon Glass
2021-11-24 22:22   ` [PATCH v2 15/41] dm: core: Add a way to count the devices in a uclass Simon Glass
2021-11-24 22:22   ` [PATCH v2 14/41] dm: core: Allow finding children / uclasses by partial name Simon Glass
2021-11-24 22:22   ` [PATCH v2 11/41] dm: core: Fix handling of uclass pre_unbind method Simon Glass
2021-11-24 22:22   ` [PATCH v2 12/41] dm: core: Fix up string-function documentation Simon Glass
2021-11-24 22:22   ` [PATCH v2 08/41] disk: part_dos: Fix a NULL pointer error Simon Glass
2021-11-24 22:22   ` [PATCH v2 09/41] common: Allow a smaller console-recording pre-reloc Simon Glass
2021-11-24 22:22   ` [PATCH v2 10/41] dm: core: Add tests for stringlist functions Simon Glass
2021-11-24 22:22   ` [PATCH v2 06/41] mmc: Allow for children other than the block device Simon Glass
2021-11-24 22:22   ` [PATCH v2 05/41] sandbox: mmc: Support a backing file Simon Glass
2021-11-24 22:22   ` [PATCH v2 04/41] sandbox: Support unmapping a file Simon Glass
2021-11-24 22:22   ` [PATCH v2 03/41] test/py: Allow passing input to a program 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=20211023232635.9195-28-sjg@chromium.org \
    --to=sjg@chromium.org \
    --cc=daniel.schwierzeck@gmail.com \
    --cc=dennis@ausil.us \
    --cc=ilias.apalodimas@linaro.org \
    --cc=jaeckel-floss@eyet-services.de \
    --cc=lukas.auer@aisec.fraunhofer.de \
    --cc=marek.behun@nic.cz \
    --cc=michal.simek@xilinx.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.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.