[elbe-devel] [PATCH 1/2] tests: validate the output of preprocessing

Thomas Weißschuh thomas.weissschuh at linutronix.de
Mon Apr 8 15:08:15 CEST 2024


Instead of testing only the preprocessing does not fail also validate
its output.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
 elbepack/tests/test_preproc.py | 26 +++++++++++---
 tests/preproc-01.out.xml       | 80 ++++++++++++++++++++++++++++++++++++++++++
 tests/preproc-02.out.xml       | 59 +++++++++++++++++++++++++++++++
 tests/xinclude/simple.xml      |  3 +-
 4 files changed, 163 insertions(+), 5 deletions(-)

diff --git a/elbepack/tests/test_preproc.py b/elbepack/tests/test_preproc.py
index 2e657548757a..6454a007494d 100644
--- a/elbepack/tests/test_preproc.py
+++ b/elbepack/tests/test_preproc.py
@@ -2,10 +2,28 @@
 # SPDX-License-Identifier: GPL-3.0-or-later
 # SPDX-FileCopyrightText: 2020-2021 Linutronix GmbH
 
+import pathlib
+
+import pytest
+
 from elbepack.directories import run_elbe
-from elbepack.tests import parametrize_xml_test_files
 
 
- at parametrize_xml_test_files('f', 'preproc')
-def test_preproc(f):
-    run_elbe(['preprocess', f], check=True)
+def _test_file_path(name):
+    return pathlib.Path(__file__).parents[2].joinpath('tests', name)
+
+
+ at pytest.mark.parametrize(('inp', 'out'), [
+    ('preproc-01.xml', 'preproc-01.out.xml'),
+    ('preproc-02.xml', 'preproc-02.out.xml'),
+])
+def test_preproc(inp, out, tmp_path):
+    actual = tmp_path / (inp + '.out')
+    run_elbe([
+        'preprocess',
+        '-z', '0',
+        '-o', actual,
+        _test_file_path(inp),
+    ], check=True)
+    with open(_test_file_path(out)) as expected, actual.open() as a:
+        assert a.read() == expected.read()
diff --git a/tests/preproc-01.out.xml b/tests/preproc-01.out.xml
new file mode 100644
index 000000000000..09d2e1b6ea12
--- /dev/null
+++ b/tests/preproc-01.out.xml
@@ -0,0 +1,80 @@
+<!--
+SPDX-License-Identifier: GPL-3.0-or-later
+SPDX-FileCopyrightText: Linutronix GmbH
+-->
+<ns0:RootFileSystem xmlns:ns0="https://www.linutronix.de/projects/Elbe" xmlns:xi="http://www.w3.org/2003/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" created="2009-05-20T08:50:56" revision="6" xsi:schemaLocation="https://www.linutronix.de/projects/Elbe dbsfed.xsd">
+
+	<project xml:base="xinclude/simple.xml">
+		<name>simple-armhf-with-grub-tighten</name>
+		<version>1.0</version>
+		<suite>buster</suite>
+		<buildtype>armhf</buildtype>
+
+		<description>
+			Testing armhf
+		</description>
+
+		<mirror>
+			<primary_host>deb.debian.org</primary_host>
+			<primary_path>/debian</primary_path>
+			<primary_proto>http</primary_proto>
+		</mirror>
+	</project><target xml:base="xinclude/simple.xml">
+		<hostname>armhf-buster</hostname>
+		<domain>elbe-ci</domain>
+		<!-- <passwd>root</passwd> -->
+		<passwd_hashed>$6$9Qq25BkNNlhJir0v$4OHpMS5BqY2fLY2g2wzp8TIjKNmmSHNSFjAM84gIU0rZesJY45bg1uoyq08KI8ZIg/BXTCUPOwuWSNDtSCE7X/</passwd_hashed>
+		<console>ttyS0,115200</console>
+
+		<images>
+			<msdoshd>
+				<name>sda.img</name>
+				<size>2000MiB</size>
+				<grub-install/>
+				<partition>
+					<size>1000MiB</size>
+					<label>rfs</label>
+				</partition>
+				<partition>
+					<size>64kB</size>
+					<label>bindata</label>
+					<binary>/etc/hosts</binary>
+				</partition>
+			</msdoshd>
+		</images>
+
+		<fstab>
+			<bylabel>
+				<label>rfs</label>
+				<mountpoint>/</mountpoint>
+				<fs><type>ext4</type></fs>
+			</bylabel>
+		</fstab>
+
+		<pkg-list>
+			<pkg>linux-image-armmp</pkg>
+		</pkg-list>
+
+		<install-recommends/>
+
+		<finetuning>
+			<file dst="/etc/hosts" append="true" encoding="plain">
+				192.168.0.165  mydomain  mydomain-host
+			</file>
+			<cp path="/etc/bash.bashrc">/root/.bashrc</cp>
+			<artifact>/boot/vmlinuz-4.19.0-14-armmp</artifact>
+			<artifact>/boot/initrd.img-4.19.0-14-armmp</artifact>
+			<artifact>/usr/lib/linux-image-4.19.0-14-armmp/vexpress-v2p-ca15-tc1.dtb</artifact>
+		</finetuning>
+
+		<project-finetuning>
+		</project-finetuning>
+	</target><check-image-list xml:base="xinclude/simple.xml">
+		<check>
+			<img>sda.img.tar.gz</img>
+			<interpreter>qemu-system-arm</interpreter>
+			<interpreter-opts>-m 2G -M vexpress-a15 -drive format=raw,file=$ELBE_IMG -nographic -kernel vmlinuz-4.19.0-14-armmp -initrd initrd.img-4.19.0-14-armmp -dtb vexpress-v2p-ca15-tc1.dtb</interpreter-opts>
+			<action> <login/> </action>
+		</check>
+	</check-image-list>
+</ns0:RootFileSystem>
diff --git a/tests/preproc-02.out.xml b/tests/preproc-02.out.xml
new file mode 100644
index 000000000000..d3771664d581
--- /dev/null
+++ b/tests/preproc-02.out.xml
@@ -0,0 +1,59 @@
+<!--
+SPDX-License-Identifier: GPL-3.0-or-later
+SPDX-FileCopyrightText: Linutronix GmbH
+-->
+<ns0:RootFileSystem xmlns:ns0="https://www.linutronix.de/projects/Elbe" xmlns:xi="http://www.w3.org/2003/XInclude" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" created="2009-05-20T08:50:56" revision="6" xsi:schemaLocation="https://www.linutronix.de/projects/Elbe dbsfed.xsd">
+
+	<project>
+		<name xml:base="xinclude/simple.xml">simple-armhf-with-grub-tighten</name><version xml:base="xinclude/simple.xml">1.0</version><suite xml:base="xinclude/simple.xml">buster</suite><buildtype xml:base="xinclude/simple.xml">armhf</buildtype><description xml:base="xinclude/simple.xml">
+			Testing armhf
+		</description><mirror xml:base="xinclude/simple.xml">
+			<primary_host>deb.debian.org</primary_host>
+			<primary_path>/debian</primary_path>
+			<primary_proto>http</primary_proto>
+		</mirror>
+	</project>
+	<target>
+		<hostname xml:base="xinclude/simple.xml">armhf-buster</hostname><domain xml:base="xinclude/simple.xml">elbe-ci</domain><passwd_hashed xml:base="xinclude/simple.xml">$6$9Qq25BkNNlhJir0v$4OHpMS5BqY2fLY2g2wzp8TIjKNmmSHNSFjAM84gIU0rZesJY45bg1uoyq08KI8ZIg/BXTCUPOwuWSNDtSCE7X/</passwd_hashed><console xml:base="xinclude/simple.xml">ttyS0,115200</console><images xml:base="xinclude/simple.xml">
+			<msdoshd>
+				<name>sda.img</name>
+				<size>2000MiB</size>
+				<grub-install/>
+				<partition>
+					<size>1000MiB</size>
+					<label>rfs</label>
+				</partition>
+				<partition>
+					<size>64kB</size>
+					<label>bindata</label>
+					<binary>/etc/hosts</binary>
+				</partition>
+			</msdoshd>
+		</images><fstab xml:base="xinclude/simple.xml">
+			<bylabel>
+				<label>rfs</label>
+				<mountpoint>/</mountpoint>
+				<fs><type>ext4</type></fs>
+			</bylabel>
+		</fstab><pkg-list xml:base="xinclude/simple.xml">
+			<pkg>linux-image-armmp</pkg>
+		</pkg-list><install-recommends xml:base="xinclude/simple.xml"/><finetuning xml:base="xinclude/simple.xml">
+			<file dst="/etc/hosts" append="true" encoding="plain">
+				192.168.0.165  mydomain  mydomain-host
+			</file>
+			<cp path="/etc/bash.bashrc">/root/.bashrc</cp>
+			<artifact>/boot/vmlinuz-4.19.0-14-armmp</artifact>
+			<artifact>/boot/initrd.img-4.19.0-14-armmp</artifact>
+			<artifact>/usr/lib/linux-image-4.19.0-14-armmp/vexpress-v2p-ca15-tc1.dtb</artifact>
+		</finetuning><project-finetuning xml:base="xinclude/simple.xml">
+		</project-finetuning>
+	</target>
+	<check-image-list>
+		<check xml:base="xinclude/simple.xml">
+			<img>sda.img.tar.gz</img>
+			<interpreter>qemu-system-arm</interpreter>
+			<interpreter-opts>-m 2G -M vexpress-a15 -drive format=raw,file=$ELBE_IMG -nographic -kernel vmlinuz-4.19.0-14-armmp -initrd initrd.img-4.19.0-14-armmp -dtb vexpress-v2p-ca15-tc1.dtb</interpreter-opts>
+			<action> <login/> </action>
+		</check>
+	</check-image-list>
+</ns0:RootFileSystem>
diff --git a/tests/xinclude/simple.xml b/tests/xinclude/simple.xml
index 3c23bdc44a73..02794be8ef8e 100644
--- a/tests/xinclude/simple.xml
+++ b/tests/xinclude/simple.xml
@@ -27,7 +27,8 @@ SPDX-FileCopyrightText: Linutronix GmbH
 	<target>
 		<hostname>armhf-buster</hostname>
 		<domain>elbe-ci</domain>
-		<passwd>root</passwd>
+		<!-- <passwd>root</passwd> -->
+		<passwd_hashed>$6$9Qq25BkNNlhJir0v$4OHpMS5BqY2fLY2g2wzp8TIjKNmmSHNSFjAM84gIU0rZesJY45bg1uoyq08KI8ZIg/BXTCUPOwuWSNDtSCE7X/</passwd_hashed>
 		<console>ttyS0,115200</console>
 
 		<images>

-- 
2.44.0



More information about the elbe-devel mailing list