[PATCH 1/4] ci: pytest: mount virtfs with signed FIT image into VMs
Ahmad Fatoum
a.fatoum at barebox.org
Thu Jun 12 01:56:00 PDT 2025
This is in preparation for adding a FIT boot pytest.
We intentionally don't use scripts/make_fit.py as its compression is
broken and we want to sign the FIT image, so we can test that in future
too.
Signed-off-by: Ahmad Fatoum <a.fatoum at barebox.org>
---
.github/testfs/multi_v7_defconfig-gzipped.its | 57 +++++++++++++++++++
.github/testfs/multi_v8_defconfig-gzipped.its | 57 +++++++++++++++++++
.github/workflows/test-labgrid-pytest.yml | 20 ++++++-
scripts/generate_testfs.sh | 26 +++++++++
4 files changed, 159 insertions(+), 1 deletion(-)
create mode 100644 .github/testfs/multi_v7_defconfig-gzipped.its
create mode 100644 .github/testfs/multi_v8_defconfig-gzipped.its
create mode 100755 scripts/generate_testfs.sh
diff --git a/.github/testfs/multi_v7_defconfig-gzipped.its b/.github/testfs/multi_v7_defconfig-gzipped.its
new file mode 100644
index 000000000000..11595c39baa1
--- /dev/null
+++ b/.github/testfs/multi_v7_defconfig-gzipped.its
@@ -0,0 +1,57 @@
+/dts-v1/;
+
+/ {
+ description = "fitImage for testing";
+ #address-cells = <1>;
+ images {
+ kernel-1 {
+ description = "barebox image";
+ data = /incbin/("barebox-dt-2nd.img.gz");
+ type = "kernel";
+ arch = "arm";
+ os = "linux";
+ compression = "gzip";
+ hash-1 {
+ algo = "sha256";
+ };
+ };
+ fdt-qemu-virt32.dtb {
+ description = "Flattened Device Tree blob";
+ data = /incbin/("arch/arm/dts/qemu-virt32.dtb");
+ type = "flat_dt";
+ arch = "arm";
+ compression = "none";
+ hash-1 {
+ algo = "sha256";
+ };
+ };
+ ramdisk-1 {
+ description = "initramfs";
+ data = /incbin/("ramdisk.cpio.gz");
+ type = "ramdisk";
+ arch = "arm";
+ os = "linux";
+ compression = "none";
+ hash-1 {
+ algo = "sha256";
+ };
+ };
+ };
+
+ configurations {
+ default = "conf-qemu-virt32.dtb";
+ conf-qemu-virt32.dtb {
+ description = "Qemu Virt32";
+ kernel = "kernel-1";
+ fdt = "fdt-qemu-virt32.dtb";
+ ramdisk = "ramdisk-1";
+ compatible = "linux,dummy-virt";
+ signature-1 {
+ algo = "sha256,rsa2048";
+ sign-images = "kernel", "fdt", "ramdisk";
+ signer-name = "None";
+ signer-version = "None";
+ };
+ };
+ };
+};
diff --git a/.github/testfs/multi_v8_defconfig-gzipped.its b/.github/testfs/multi_v8_defconfig-gzipped.its
new file mode 100644
index 000000000000..5ce678eec9a8
--- /dev/null
+++ b/.github/testfs/multi_v8_defconfig-gzipped.its
@@ -0,0 +1,57 @@
+/dts-v1/;
+
+/ {
+ description = "fitImage for testing";
+ #address-cells = <1>;
+ images {
+ kernel-1 {
+ description = "barebox image";
+ data = /incbin/("barebox-dt-2nd.img.gz");
+ type = "kernel";
+ arch = "arm64";
+ os = "linux";
+ compression = "gzip";
+ hash-1 {
+ algo = "sha256";
+ };
+ };
+ fdt-qemu-virt64.dtb {
+ description = "Flattened Device Tree blob";
+ data = /incbin/("arch/arm/dts/qemu-virt64.dtb");
+ type = "flat_dt";
+ arch = "arm64";
+ compression = "none";
+ hash-1 {
+ algo = "sha256";
+ };
+ };
+ ramdisk-1 {
+ description = "initramfs";
+ data = /incbin/("ramdisk.cpio.gz");
+ type = "ramdisk";
+ arch = "arm64";
+ os = "linux";
+ compression = "none";
+ hash-1 {
+ algo = "sha256";
+ };
+ };
+ };
+
+ configurations {
+ default = "conf-qemu-virt64.dtb";
+ conf-qemu-virt64.dtb {
+ description = "Qemu Virt64";
+ kernel = "kernel-1";
+ fdt = "fdt-qemu-virt64.dtb";
+ ramdisk = "ramdisk-1";
+ compatible = "linux,dummy-virt";
+ signature-1 {
+ algo = "sha256,rsa2048";
+ sign-images = "kernel", "fdt", "ramdisk";
+ signer-name = "None";
+ signer-version = "None";
+ };
+ };
+ };
+};
diff --git a/.github/workflows/test-labgrid-pytest.yml b/.github/workflows/test-labgrid-pytest.yml
index d4043de961b2..64618582a940 100644
--- a/.github/workflows/test-labgrid-pytest.yml
+++ b/.github/workflows/test-labgrid-pytest.yml
@@ -80,6 +80,20 @@ jobs:
if [ ${{matrix.arch}} = "riscv" ]; then
cp /usr/share/qemu/opensbi-riscv32-generic-fw_dynamic.bin ${KBUILD_OUTPUT}/
fi
+
+ - name: Populate testfs
+ run: |
+ export KBUILD_OUTPUT=build-${{matrix.arch}}-${{matrix.defconfig}}
+ export KBUILD_DEFCONFIG=${{matrix.defconfig}}
+
+ for i in ${{matrix.lgenv}}; do
+ grep -wq 'testfs' "$i" || continue
+
+ # Just use already built dtc
+ export PATH="$PATH:${KBUILD_OUTPUT}/scripts/dtc/"
+ exec scripts/generate_testfs.sh
+ done
+
- name: labgrid-pytest
run: |
export KBUILD_OUTPUT=build-${{matrix.arch}}-${{matrix.defconfig}}
@@ -87,10 +101,14 @@ jobs:
for i in ${{matrix.lgenv}}; do
grep -wq '\(QEMUDriver\|ExternalConsoleDriver\):' "$i" || continue
+ if grep -wq 'testfs' "$i"; then
+ extraargs="--fs testfs=${KBUILD_OUTPUT}/testfs"
+ fi
+
cfg=$(basename $i .yaml)
echo "Testing $cfg"
labgrid-pytest --lg-env $i test/py --verbosity=1 \
- --junitxml=$cfg.tests.xml --lg-log=log/$cfg
+ --junitxml=$cfg.tests.xml --lg-log=log/$cfg $extraargs
done
- name: Publish Test Results
diff --git a/scripts/generate_testfs.sh b/scripts/generate_testfs.sh
new file mode 100755
index 000000000000..c5d24f7e1af8
--- /dev/null
+++ b/scripts/generate_testfs.sh
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+MKIMAGE=${MKIMAGE:-mkimage}
+KGZIP=${KGZIP:-gzip}
+
+set -e
+
+if [ -z "${KBUILD_OUTPUT}" ] || [ -z "${KBUILD_DEFCONFIG}" ] ; then
+ 2>&1 echo "KBUILD_OUTPUT and KBUILD_DEFCONFIG must be set"
+ exit 1
+fi
+
+rm -rf "${KBUILD_OUTPUT}/testfs/"
+mkdir -p ${KBUILD_OUTPUT}/testfs
+
+cat ${KBUILD_OUTPUT}/images/barebox-dt-2nd.img | \
+ ${KGZIP} -n -f -9 >${KBUILD_OUTPUT}/barebox-dt-2nd.img.gz
+
+cp .github/testfs/${KBUILD_DEFCONFIG}-gzipped.its ${KBUILD_OUTPUT}/
+
+find COPYING LICENSES/ | cpio -o -H newc | ${KGZIP} \
+ > ${KBUILD_OUTPUT}/ramdisk.cpio.gz
+
+${MKIMAGE} -G $PWD/test/self/development_rsa2048.pem -r \
+ -f ${KBUILD_OUTPUT}/${KBUILD_DEFCONFIG}-gzipped.its \
+ ${KBUILD_OUTPUT}/testfs/barebox-gzipped.fit
--
2.39.5
More information about the barebox
mailing list