From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 13/16] test: py: add test for initrd concatenation
Date: Thu, 12 Mar 2026 15:44:56 +0100 [thread overview]
Message-ID: <20260312144505.2159816-13-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20260312144505.2159816-1-a.fatoum@pengutronix.de>
Now that the FIT code supports processing multiple entries in the
ramdisk property, add a test to ensure this doesn't regress.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
test/py/test_fit.py | 38 +++++++++++++-------
test/py/testfs.py | 23 ++++++++++++
test/testdata/multi_v7_defconfig-gzipped.its | 28 +++++++++++++--
test/testdata/multi_v8_defconfig-gzipped.its | 28 +++++++++++++--
4 files changed, 98 insertions(+), 19 deletions(-)
create mode 100644 test/py/testfs.py
diff --git a/test/py/test_fit.py b/test/py/test_fit.py
index 8bcee6a75f23..0fd5a3c5dcc5 100644
--- a/test/py/test_fit.py
+++ b/test/py/test_fit.py
@@ -7,6 +7,7 @@ import shutil
import subprocess
from pathlib import Path
from .helper import of_get_property, filter_errors
+from .testfs import mkcpio
def generate_bootscript(barebox, image, name="test"):
@@ -37,16 +38,9 @@ def fit_testdata(barebox_config, testfs):
input=(builddir / "images" / "barebox-dt-2nd.img").read_bytes(),
stdout=open(builddir / "barebox-dt-2nd.img.gz", "wb"))
- find = subprocess.Popen(["find", "COPYING", "LICENSES/"],
- stdout=subprocess.PIPE)
- cpio = subprocess.Popen(["cpio", "-o", "-H", "newc"],
- stdin=find.stdout, stdout=subprocess.PIPE)
- gzip = subprocess.Popen(["gzip"], stdin=cpio.stdout,
- stdout=open(builddir / "ramdisk.cpio.gz", "wb"))
-
- find.wait()
- cpio.wait()
- gzip.wait()
+ mkcpio("COPYING", outdir / "ramdisk1.cpio.gz")
+ mkcpio("LICENSES/exceptions/", outdir / "ramdisk2.cpio")
+ mkcpio("LICENSES/preferred/", outdir / "ramdisk3.cpio.gz")
run(["mkimage", "-G", "test/self/development_rsa2048.pem", "-r", "-f",
str(builddir / its_name), str(outfile)])
@@ -105,6 +99,15 @@ def test_fit(barebox, strategy, fitimage):
barebox.run_check("global linux.bootargs.testarg=barebox.chainloaded")
+ barebox.run_check("cat -o /tmp/ramdisks.cpio /mnt/9p/testfs/ramdisk*.cpio*")
+ [hashsum1] = barebox.run_check("md5sum /tmp/ramdisks.cpio")
+
+ hashsum1 = re.split("/tmp/ramdisks.cpio", hashsum1, maxsplit=1)[0]
+ # Get the actual size of the concatenated ramdisks file
+ [fileinfo] = barebox.run_check("ls -l /tmp/ramdisks.cpio")
+ # Parse the size from ls -l output (format: permissions links user group size ...)
+ actual_size = int(fileinfo.split()[1])
+
boottarget = generate_bootscript(barebox, fitimage)
with strategy.boot_barebox(boottarget) as barebox:
@@ -118,7 +121,16 @@ def test_fit(barebox, strategy, fitimage):
bootargs = of_get_property(barebox, "/chosen/bootargs")
assert "barebox.chainloaded" in bootargs
- initrd_start = of_get_property(barebox, "/chosen/linux,initrd-start", 0)
- initrd_end = of_get_property(barebox, "/chosen/linux,initrd-end", 0)
+ initrd_start = of_get_property(barebox, "/chosen/linux,initrd-start", ncells=0)
+ initrd_end = of_get_property(barebox, "/chosen/linux,initrd-end", ncells=0)
+ initrd_size = initrd_end - initrd_start
- assert initrd_start < initrd_end
+ # Verify the DT-reported size matches the actual file size
+ assert initrd_size == actual_size, \
+ f"Initrd size mismatch: DT says {initrd_size}, file is {actual_size}"
+
+ [hashsum2] = barebox.run_check(f"md5sum {initrd_start}+{initrd_size}")
+
+ hashsum2 = re.split("/dev/mem", hashsum2, maxsplit=1)[0]
+
+ assert hashsum1 == hashsum2
diff --git a/test/py/testfs.py b/test/py/testfs.py
new file mode 100644
index 000000000000..3ead67c0621b
--- /dev/null
+++ b/test/py/testfs.py
@@ -0,0 +1,23 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+import subprocess
+
+
+def mkcpio(inpath, outname):
+ compress = outname.suffix == ".gz"
+
+ find = subprocess.Popen(["find", inpath], stdout=subprocess.PIPE)
+
+ with open(outname, "wb") as outfile:
+ cpio = subprocess.Popen(["cpio", "-o", "-H", "newc"], stdin=find.stdout,
+ stdout=(subprocess.PIPE if compress else outfile))
+
+ find.stdout.close()
+
+ if compress:
+ gzip = subprocess.Popen(["gzip"], stdin=cpio.stdout, stdout=outfile)
+ cpio.stdout.close()
+ gzip.wait()
+
+ cpio.wait()
+ find.wait()
diff --git a/test/testdata/multi_v7_defconfig-gzipped.its b/test/testdata/multi_v7_defconfig-gzipped.its
index 11595c39baa1..1cb84fd41564 100644
--- a/test/testdata/multi_v7_defconfig-gzipped.its
+++ b/test/testdata/multi_v7_defconfig-gzipped.its
@@ -26,8 +26,30 @@
};
};
ramdisk-1 {
- description = "initramfs";
- data = /incbin/("ramdisk.cpio.gz");
+ description = "initramfs 1 (compressed)";
+ data = /incbin/("testfs/ramdisk1.cpio.gz");
+ type = "ramdisk";
+ arch = "arm";
+ os = "linux";
+ compression = "none";
+ hash-1 {
+ algo = "sha256";
+ };
+ };
+ ramdisk-2 {
+ description = "initramfs 2 (uncompressed)";
+ data = /incbin/("testfs/ramdisk2.cpio");
+ type = "ramdisk";
+ arch = "arm";
+ os = "linux";
+ compression = "none";
+ hash-1 {
+ algo = "sha256";
+ };
+ };
+ ramdisk-3 {
+ description = "initramfs 3 (compressed)";
+ data = /incbin/("testfs/ramdisk3.cpio.gz");
type = "ramdisk";
arch = "arm";
os = "linux";
@@ -44,7 +66,7 @@
description = "Qemu Virt32";
kernel = "kernel-1";
fdt = "fdt-qemu-virt32.dtb";
- ramdisk = "ramdisk-1";
+ ramdisk = "ramdisk-1", "ramdisk-2", "ramdisk-3";
compatible = "linux,dummy-virt";
signature-1 {
algo = "sha256,rsa2048";
diff --git a/test/testdata/multi_v8_defconfig-gzipped.its b/test/testdata/multi_v8_defconfig-gzipped.its
index 5ce678eec9a8..3786d0f12187 100644
--- a/test/testdata/multi_v8_defconfig-gzipped.its
+++ b/test/testdata/multi_v8_defconfig-gzipped.its
@@ -26,8 +26,30 @@
};
};
ramdisk-1 {
- description = "initramfs";
- data = /incbin/("ramdisk.cpio.gz");
+ description = "initramfs 1 (compressed)";
+ data = /incbin/("testfs/ramdisk1.cpio.gz");
+ type = "ramdisk";
+ arch = "arm64";
+ os = "linux";
+ compression = "none";
+ hash-1 {
+ algo = "sha256";
+ };
+ };
+ ramdisk-2 {
+ description = "initramfs 2 (uncompressed)";
+ data = /incbin/("testfs/ramdisk2.cpio");
+ type = "ramdisk";
+ arch = "arm64";
+ os = "linux";
+ compression = "none";
+ hash-1 {
+ algo = "sha256";
+ };
+ };
+ ramdisk-3 {
+ description = "initramfs 3 (compressed)";
+ data = /incbin/("testfs/ramdisk3.cpio.gz");
type = "ramdisk";
arch = "arm64";
os = "linux";
@@ -44,7 +66,7 @@
description = "Qemu Virt64";
kernel = "kernel-1";
fdt = "fdt-qemu-virt64.dtb";
- ramdisk = "ramdisk-1";
+ ramdisk = "ramdisk-1", "ramdisk-2", "ramdisk-3";
compatible = "linux,dummy-virt";
signature-1 {
algo = "sha256,rsa2048";
--
2.47.3
next prev parent reply other threads:[~2026-03-12 15:03 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-12 14:44 [PATCH 01/16] lib: add lazy loadable infrastructure for deferred boot component loading Ahmad Fatoum
2026-03-12 14:44 ` [PATCH 02/16] bootm: split preparatory step from handler invocation Ahmad Fatoum
2026-03-12 14:44 ` [PATCH 03/16] boot: add bootm_boot wrapper that takes struct bootentry Ahmad Fatoum
2026-03-12 14:44 ` [PATCH 04/16] bootchooser: pass along " Ahmad Fatoum
2026-03-12 14:44 ` [PATCH 05/16] bootm: switch plain file names case to loadable API Ahmad Fatoum
2026-03-12 14:44 ` [PATCH 06/16] uimage: add offset parameter to uimage_load Ahmad Fatoum
2026-03-12 14:44 ` [PATCH 07/16] bootm: uimage: switch to loadable API Ahmad Fatoum
2026-03-12 14:44 ` [PATCH 08/16] bootm: fit: switch to new " Ahmad Fatoum
2026-03-12 14:44 ` [PATCH 09/16] bootm: stash initial OS address/entry in image_data Ahmad Fatoum
2026-03-12 14:44 ` [PATCH 10/16] bootm: support multiple entries for bootm.initrd Ahmad Fatoum
2026-03-12 14:44 ` [PATCH 11/16] bootm: implement plain and FIT bootm.image override Ahmad Fatoum
2026-03-18 9:01 ` Sascha Hauer
2026-03-18 9:17 ` Ahmad Fatoum
2026-03-12 14:44 ` [PATCH 12/16] bootm: overrides: add support for overlays Ahmad Fatoum
2026-03-12 14:44 ` Ahmad Fatoum [this message]
2026-03-12 14:44 ` [PATCH 14/16] defaultenv: base: add new devboot script Ahmad Fatoum
2026-03-18 9:50 ` Sascha Hauer
2026-03-18 10:50 ` Ahmad Fatoum
2026-03-18 14:49 ` Sascha Hauer
2026-03-12 14:44 ` [PATCH 15/16] Documentation: user: devboot: add section on forwarding build dirs Ahmad Fatoum
2026-03-12 14:44 ` [PATCH 16/16] libfile: remove file_to_sdram Ahmad Fatoum
2026-03-18 10:06 ` [PATCH 01/16] lib: add lazy loadable infrastructure for deferred boot component loading Sascha Hauer
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=20260312144505.2159816-13-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox