All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Arnout Vandecappelle (Essensium/Mind)" <arnout@mind.be>
To: buildroot@buildroot.org
Cc: Thierry Bultel <thierry.bultel@linatsea.fr>,
	Adam Duskett <aduskett@gmail.com>
Subject: [Buildroot] [PATCH next v5 3/3] support/testing/tests/fs/test_cpio.py: new runtime test
Date: Mon, 15 Aug 2022 13:17:10 +0200	[thread overview]
Message-ID: <20220815111710.1459820-3-arnout@mind.be> (raw)
In-Reply-To: <20220815111710.1459820-1-arnout@mind.be>

From: Thierry Bultel <thierry.bultel@linatsea.fr>

It includes a simple test for the full cpio image, and a test of the
dracut image. To validate that the dracut image is a subset of the full
image, 'pv' is added to the image, and the test verifies that pv is not
part of the image. Note that the real rootfs is not mounted at the
moment, so pv is never available in the running image.

Systemd and other init systems are currently untested.

Signed-off-by: Thierry Bultel <thierry.bultel@linatsea.fr>
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
---
Changes v4 -> v5 (Arnout)
  - move runtime test to separate patch;
  - add tests for all libcs;
  - remove tar;
  - add pv and test that it's not included in cpio.
---
 support/testing/tests/fs/test_cpio.py | 93 +++++++++++++++++++++++++++
 1 file changed, 93 insertions(+)
 create mode 100644 support/testing/tests/fs/test_cpio.py

diff --git a/support/testing/tests/fs/test_cpio.py b/support/testing/tests/fs/test_cpio.py
new file mode 100644
index 0000000000..98620ebc06
--- /dev/null
+++ b/support/testing/tests/fs/test_cpio.py
@@ -0,0 +1,93 @@
+import os
+import infra.basetest
+import subprocess
+
+CHECK_FS_CMD = "mount | grep 'rootfs on / type rootfs'"
+
+
+def boot_img(emulator, builddir):
+    img = os.path.join(builddir, "images", "rootfs.cpio")
+    emulator.boot(arch="armv7",
+                  kernel="builtin",
+                  options=["-initrd", "{}".format(img)])
+    emulator.login()
+    _, exit_code = emulator.run(CHECK_FS_CMD)
+    return exit_code
+
+
+class TestCpioFull(infra.basetest.BRTest):
+    config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
+        """
+        BR2_INIT_BUSYBOX=y
+        BR2_TARGET_ROOTFS_CPIO=y
+        BR2_TARGET_ROOTFS_CPIO_FULL=y
+        # BR2_TARGET_ROOTFS_TAR is not set
+        """
+
+    def test_run(self):
+
+        exit_code = boot_img(self.emulator,
+                             self.builddir)
+        self.assertEqual(exit_code, 0)
+
+
+class TestCpioDracutBase(infra.basetest.BRTest):
+    config = \
+        """
+        BR2_arm=y
+        BR2_TOOLCHAIN_EXTERNAL=y
+        BR2_TOOLCHAIN_EXTERNAL_BOOTLIN=y
+        BR2_INIT_BUSYBOX=y
+        BR2_PACKAGE_PV=y
+        BR2_TARGET_ROOTFS_CPIO=y
+        BR2_TARGET_ROOTFS_CPIO_DRACUT=y
+        # BR2_TARGET_ROOTFS_TAR is not set
+        """
+
+    def check_dracut(self):
+        out = subprocess.check_output(["cpio", "--list"],
+                                      stdin=open(os.path.join(self.builddir, "images/rootfs.cpio")),
+                                      stderr=open(os.devnull, "w"),
+                                      cwd=self.builddir,
+                                      env={"LANG": "C"},
+                                      universal_newlines=True)
+        # pv should *not* be included in cpio image
+        self.assertEqual(out.find("bin/pv"), -1)
+
+        exit_code = boot_img(self.emulator,
+                             self.builddir)
+        self.assertEqual(exit_code, 0)
+
+        # No pivot_root is done, so pv shouldn't be there
+        _, exit_code = self.emulator.run("ls -l /usr/bin/pv")
+        self.assertNotEqual(exit_code, 0)
+
+
+class TestCpioDracutUclibc(TestCpioDracutBase):
+    config = TestCpioDracutBase.config + \
+        """
+        BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_ARMV5_EABI_UCLIBC_STABLE=y
+        """
+
+    def test_run(self):
+        self.check_dracut()
+
+
+class TestCpioDracutGlibc(TestCpioDracutBase):
+    config = TestCpioDracutBase.config + \
+        """
+        BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_ARMV5_EABI_GLIBC_STABLE=y
+        """
+
+    def test_run(self):
+        self.check_dracut()
+
+
+class TestCpioDracutMusl(TestCpioDracutBase):
+    config = TestCpioDracutBase.config + \
+        """
+        BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_ARMV5_EABI_MUSL_STABLE=y
+        """
+
+    def test_run(self):
+        self.check_dracut()
-- 
2.37.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

  parent reply	other threads:[~2022-08-15 11:17 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-15 11:17 [Buildroot] [PATCH next v5 1/3] package/dracut: new host package Arnout Vandecappelle (Essensium/Mind)
2022-08-15 11:17 ` [Buildroot] [PATCH next v5 2/3] fs/cpio: new option to use dracut tool Arnout Vandecappelle (Essensium/Mind)
2022-08-15 13:05   ` Yann E. MORIN
2022-08-15 16:37     ` Arnout Vandecappelle
2022-08-18 21:09   ` Yann E. MORIN
2022-08-15 11:17 ` Arnout Vandecappelle (Essensium/Mind) [this message]
2022-08-18 21:10   ` [Buildroot] [PATCH next v5 3/3] support/testing/tests/fs/test_cpio.py: new runtime test Yann E. MORIN
2022-08-15 12:36 ` [Buildroot] [PATCH next v5 1/3] package/dracut: new host package Yann E. MORIN
2022-08-15 16:27   ` Arnout Vandecappelle via buildroot
2022-08-18 21:09 ` Yann E. MORIN

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=20220815111710.1459820-3-arnout@mind.be \
    --to=arnout@mind.be \
    --cc=aduskett@gmail.com \
    --cc=buildroot@buildroot.org \
    --cc=thierry.bultel@linatsea.fr \
    /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.