All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [git commit] support/testing/tests/fs/test_cpio.py: new runtime test
@ 2022-08-18 20:49 Yann E. MORIN
  0 siblings, 0 replies; only message in thread
From: Yann E. MORIN @ 2022-08-18 20:49 UTC (permalink / raw)
  To: buildroot

commit: https://git.buildroot.net/buildroot/commit/?id=bd0b2db23154f700fbb94aa3a0a0752a52b5ea7b
branch: https://git.buildroot.net/buildroot/commit/?id=refs/heads/master

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>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
---
 support/testing/tests/fs/test_cpio.py | 125 ++++++++++++++++++++++++++++++++++
 1 file changed, 125 insertions(+)

diff --git a/support/testing/tests/fs/test_cpio.py b/support/testing/tests/fs/test_cpio.py
new file mode 100644
index 0000000000..3f661e370c
--- /dev/null
+++ b/support/testing/tests/fs/test_cpio.py
@@ -0,0 +1,125 @@
+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_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()
+
+
+class TestCpioDracutUclibcMergedUsr(TestCpioDracutBase):
+    config = TestCpioDracutBase.config + \
+        """
+        BR2_ROOTFS_MERGED_USR=y
+        BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_ARMV5_EABI_UCLIBC_STABLE=y
+        """
+
+    def test_run(self):
+        self.check_dracut()
+
+
+class TestCpioDracutGlibcMergedUsr(TestCpioDracutBase):
+    config = TestCpioDracutBase.config + \
+        """
+        BR2_ROOTFS_MERGED_USR=y
+        BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_ARMV5_EABI_GLIBC_STABLE=y
+        """
+
+    def test_run(self):
+        self.check_dracut()
+
+
+class TestCpioDracutMuslMergedUsr(TestCpioDracutBase):
+    config = TestCpioDracutBase.config + \
+        """
+        BR2_ROOTFS_MERGED_USR=y
+        BR2_TOOLCHAIN_EXTERNAL_BOOTLIN_ARMV5_EABI_MUSL_STABLE=y
+        """
+
+    def test_run(self):
+        self.check_dracut()
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-09-11  8:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-18 20:49 [Buildroot] [git commit] support/testing/tests/fs/test_cpio.py: new runtime test Yann E. MORIN

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.