[elbe-devel] [PATCH 3/4] tests: add initial validation image
Thomas Weißschuh
thomas.weissschuh at linutronix.de
Thu May 23 09:30:43 CEST 2024
This is an example configuration meant to make use of as many features
of elbe as possible.
The result of the build is validated with the "elbevalidate" package.
The example configuration will be extended over time in lockstep with
the testsuite.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
tests/simple-validation-image-test.py | 80 +++++++++++++++++++++++++++++++++++
tests/simple-validation-image.xml | 57 +++++++++++++++++++++++++
2 files changed, 137 insertions(+)
diff --git a/tests/simple-validation-image-test.py b/tests/simple-validation-image-test.py
new file mode 100755
index 000000000000..718b4645de38
--- /dev/null
+++ b/tests/simple-validation-image-test.py
@@ -0,0 +1,80 @@
+#!/usr/bin/env python3
+
+import sys
+import textwrap
+
+import elbevalidate
+import elbevalidate.pytest
+
+
+def test_build_directory_contents(build_dir):
+ assert sorted([p.name for p in build_dir.iterdir()]) == [
+ 'elbe-report.txt',
+ 'licence-chroot.txt',
+ 'licence-chroot.xml',
+ 'licence-target.txt',
+ 'licence-target.xml',
+ 'log.txt',
+ 'sda.img',
+ 'source.xml',
+ 'validation.txt',
+ ]
+
+
+def _test_rfs_partition(part):
+ assert part.number == 1
+ assert part.start == 1 * 1024 * 1024
+ assert part.size == 799 * 1024 * 1024
+ assert part.type == '83'
+
+ blkid = part.blkid()
+ assert blkid['USAGE'] == 'filesystem'
+ assert blkid['TYPE'] == 'ext4'
+ assert blkid['LABEL'] == 'rfs'
+
+ with part.files() as root:
+ statvfs = elbevalidate.statvfs(root)
+ assert statvfs.f_bfree * statvfs.f_bsize > 350 * 1024 * 1024
+
+ assert root.joinpath('etc', 'hostname').read_text() == 'validation-image'
+ assert root.joinpath('etc', 'mailname').read_text() == 'validation-image.elbe-ci'
+ assert not root.joinpath('etc', 'resolv.conf').exists()
+ assert root.joinpath('etc', 'os-release').read_text().strip() == textwrap.dedent("""
+ PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
+ NAME="Debian GNU/Linux"
+ VERSION_ID="12"
+ VERSION="12 (bookworm)"
+ VERSION_CODENAME=bookworm
+ ID=debian
+ HOME_URL="https://www.debian.org/"
+ SUPPORT_URL="https://www.debian.org/support"
+ BUG_REPORT_URL="https://bugs.debian.org/"
+ """).strip()
+ assert root.joinpath('etc', 'apt', 'sources.list').read_text() == \
+ 'deb [arch=amd64] http://deb.debian.org/debian bookworm main'
+
+ sources_list_d = root.joinpath('etc', 'apt', 'sources.list.d')
+ assert sources_list_d.is_dir()
+ assert len(list(sources_list_d.iterdir())) == 0
+
+ getty_service = root.joinpath('etc', 'systemd', 'system', 'getty.target.wants',
+ 'serial-getty at ttyS0.service')
+ assert getty_service.is_symlink()
+ assert str(getty_service.readlink()) == '/lib/systemd/system/serial-getty at .service'
+
+
+def test_image(build_dir):
+ with elbevalidate.Image.from_file(build_dir / 'sda.img') as img:
+ assert img.size == 800 * 1024 * 1024
+
+ blkid = img.blkid()
+ assert blkid['PTTYPE'] == 'dos'
+
+ partitions = img.partitions
+ assert len(partitions) == 1
+
+ _test_rfs_partition(partitions[0])
+
+
+if __name__ == '__main__':
+ elbevalidate.pytest.run_with_pytest(__file__, sys.argv[1])
diff --git a/tests/simple-validation-image.xml b/tests/simple-validation-image.xml
new file mode 100644
index 000000000000..1c87c3c46896
--- /dev/null
+++ b/tests/simple-validation-image.xml
@@ -0,0 +1,57 @@
+<!--
+SPDX-License-Identifier: GPL-3.0-or-later
+SPDX-FileCopyrightText: Linutronix GmbH
+-->
+<ns0:RootFileSystem xmlns:ns0="https://www.linutronix.de/projects/Elbe"
+ 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>simple-validation-image</name>
+ <version>1.0</version>
+ <suite>bookworm</suite>
+ <buildtype>amd64</buildtype>
+
+ <description>
+ Image used to test ELBE features
+ </description>
+
+ <mirror>
+ <primary_host>deb.debian.org</primary_host>
+ <primary_path>/debian</primary_path>
+ <primary_proto>http</primary_proto>
+ </mirror>
+
+ </project>
+
+ <target>
+ <hostname>validation-image</hostname>
+ <domain>elbe-ci</domain>
+ <passwd>root</passwd>
+ <console>ttyS0,115200</console>
+
+ <images>
+ <msdoshd>
+ <name>sda.img</name>
+ <size>800MiB</size>
+ <partition>
+ <size>remain</size>
+ <label>rfs</label>
+ </partition>
+ </msdoshd>
+ </images>
+
+ <fstab>
+ <bylabel>
+ <label>rfs</label>
+ <mountpoint>/</mountpoint>
+ <fs><type>ext4</type></fs>
+ </bylabel>
+ </fstab>
+
+ <project-finetuning>
+ <set_packer packer="none">sda.img</set_packer>
+ </project-finetuning>
+ </target>
+</ns0:RootFileSystem>
--
2.45.1
More information about the elbe-devel
mailing list