From: Jonas Rebmann <jre@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>,
BAREBOX <barebox@lists.infradead.org>
Cc: Tobias Waldekranz <tobias@waldekranz.com>,
Jonas Rebmann <jre@pengutronix.de>
Subject: [PATCH v2 4/9] test: move fitimage testdata generation to fixture and drop script
Date: Mon, 29 Sep 2025 10:03:55 +0200 [thread overview]
Message-ID: <20250929-tlv-integration-v2-4-55f75da7e670@pengutronix.de> (raw)
In-Reply-To: <20250929-tlv-integration-v2-0-55f75da7e670@pengutronix.de>
Get rid of scripts/generate_testfs.sh and the logic around it. Test data
generation should happen within pytest.
Move test data (its config for fitimages) from .github/testfs to
test/testdata for good measure.
Signed-off-by: Jonas Rebmann <jre@pengutronix.de>
---
.github/workflows/test-labgrid-pytest.yml | 10 -----
scripts/generate_testfs.sh | 33 -----------------
test/py/test_fit.py | 43 +++++++++++++++++++++-
.../testdata}/multi_v7_defconfig-gzipped.its | 0
.../testdata}/multi_v8_defconfig-gzipped.its | 0
5 files changed, 42 insertions(+), 44 deletions(-)
diff --git a/.github/workflows/test-labgrid-pytest.yml b/.github/workflows/test-labgrid-pytest.yml
index 604f1db2fb..4569e475bc 100644
--- a/.github/workflows/test-labgrid-pytest.yml
+++ b/.github/workflows/test-labgrid-pytest.yml
@@ -97,16 +97,6 @@ jobs:
cp /usr/share/qemu/opensbi-riscv32-generic-fw_dynamic.bin ${KBUILD_OUTPUT}/
fi
- - name: Populate testfs
- if: steps.used-features.outputs.testfs == 'true'
- run: |
- export KBUILD_OUTPUT=build-${{matrix.arch}}-${{matrix.defconfig}}
- export KBUILD_DEFCONFIG=${{matrix.defconfig}}
-
- # Just use already built dtc
- export PATH="$PATH:${KBUILD_OUTPUT}/scripts/dtc/"
- exec scripts/generate_testfs.sh
-
- name: labgrid-pytest
if: steps.build.outcome == 'success'
run: |
diff --git a/scripts/generate_testfs.sh b/scripts/generate_testfs.sh
deleted file mode 100755
index d52772e6bf..0000000000
--- a/scripts/generate_testfs.sh
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/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
-
-generate_fit()
-{
- 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
-}
-
-if [ -f .github/testfs/${KBUILD_DEFCONFIG}-gzipped.its ]; then
- generate_fit
-fi
diff --git a/test/py/test_fit.py b/test/py/test_fit.py
index 3b2b8ff871..5620996e9d 100644
--- a/test/py/test_fit.py
+++ b/test/py/test_fit.py
@@ -1,7 +1,11 @@
# SPDX-License-Identifier: GPL-2.0-or-later
import re
+import os
import pytest
+import shutil
+import subprocess
+from pathlib import Path
from .helper import of_get_property
@@ -15,7 +19,44 @@ def generate_bootscript(barebox, image, name="test"):
return name
-def test_fit(barebox, env, target, barebox_config, testfs):
+def run(cmd, **kwargs):
+ subprocess.run(cmd, check=True, **kwargs)
+
+
+@pytest.fixture(scope="module")
+def fit_testdata(barebox_config, testfs):
+ its_name = f"{barebox_config['CONFIG_NAME']}-gzipped.its"
+ its_location = Path("test/testdata")
+ builddir = Path(os.environ['LG_BUILDDIR'])
+ outdir = Path(testfs)
+ outfile = outdir / "barebox-gzipped.fit"
+
+ if not os.path.isfile(its_location / its_name):
+ pytest.skip(f"no fitimage testdata found at {its_location}")
+
+ shutil.copy(its_location / its_name, builddir)
+
+ try:
+ run(["gzip", "-n", "-f", "-9"],
+ 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()
+
+ run([ "mkimage", "-G", "test/self/development_rsa2048.pem", "-r", "-f",
+ str(builddir / its_name), str(outfile) ])
+ except FileNotFoundError as e:
+ pytest.skip(f"Skip dm tests due to missing dependency: {e}")
+
+ yield
+
+ os.remove(outfile)
+
+def test_fit(barebox, target, testfs, fit_testdata):
_, _, returncode = barebox.run(f"ls {fit_name('gzipped')}")
if returncode != 0:
pytest.xfail("skipping test due to missing FIT image")
diff --git a/.github/testfs/multi_v7_defconfig-gzipped.its b/test/testdata/multi_v7_defconfig-gzipped.its
similarity index 100%
rename from .github/testfs/multi_v7_defconfig-gzipped.its
rename to test/testdata/multi_v7_defconfig-gzipped.its
diff --git a/.github/testfs/multi_v8_defconfig-gzipped.its b/test/testdata/multi_v8_defconfig-gzipped.its
similarity index 100%
rename from .github/testfs/multi_v8_defconfig-gzipped.its
rename to test/testdata/multi_v8_defconfig-gzipped.its
--
2.51.0.297.gca2559c1d6
next prev parent reply other threads:[~2025-09-29 8:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-29 8:03 [PATCH v2 0/9] TLV integration tests and test/py cleanup Jonas Rebmann
2025-09-29 8:03 ` [PATCH v2 1/9] test: when testfs feature is available, always enable it Jonas Rebmann
2025-09-29 8:03 ` [PATCH v2 2/9] test: provide testfs via fixture Jonas Rebmann
2025-09-29 8:03 ` [PATCH v2 3/9] test: move dm-verity testdata generation to fixture Jonas Rebmann
2025-09-29 8:03 ` Jonas Rebmann [this message]
2025-09-29 8:03 ` [PATCH v2 5/9] test: py: test_bootchooser: remove dead code Jonas Rebmann
2025-09-29 8:03 ` [PATCH v2 6/9] commands: tlv: clarify error opening tlv Jonas Rebmann
2025-09-29 8:03 ` [PATCH v2 7/9] ci: container: install crcmod and cryptography Jonas Rebmann
2025-09-29 8:03 ` [PATCH v2 8/9] configs: enable tlv command for multi_v7 and multi_v8 Jonas Rebmann
2025-09-29 8:04 ` [PATCH v2 9/9] test: py: add TLV integration tests Jonas Rebmann
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=20250929-tlv-integration-v2-4-55f75da7e670@pengutronix.de \
--to=jre@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=s.hauer@pengutronix.de \
--cc=tobias@waldekranz.com \
/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