From c756e326eff383886cba7fab4efad7baf5431c7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dirk=20M=C3=BCller?= Date: Thu, 28 Nov 2024 14:46:25 +0100 Subject: [PATCH] Test SUSE KMP building with the kernel-module devel --- tests/test_kernel_module.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/test_kernel_module.py b/tests/test_kernel_module.py index 18178b65..8a6963c6 100644 --- a/tests/test_kernel_module.py +++ b/tests/test_kernel_module.py @@ -48,6 +48,34 @@ def create_kernel_test(containerfile: str) -> ParameterSet: ) +# the commit hash and the download link for the sources need to be updated together +# there is no significance to the chosen hash, it is simple the tip of tree with the +# corresponding sources to fetch. +KMP_CONTAINER = create_kernel_test( + r"""WORKDIR /src +RUN set -euxo pipefail; \ + curl -sf https://src.opensuse.org/pool/vhba-kmp/archive/f7b947967abfd854991eed3a50a333f2efa4c47932e3d7d2fc1d07c6afdb79bd.tar.gz | tar -xzf - ; \ + cp -a vhba-kmp/* /usr/src/packages/SOURCES; cd /usr/src/packages/SOURCES ; \ + curl -LO https://downloads.sf.net/cdemu/vhba-module-20240202.tar.xz ; \ + rpmbuild -bb vhba-kmp.spec ; \ + openssl req -new -x509 -newkey rsa:2048 -sha256 -keyout key.asc -out cert.der \ + -outform der -nodes -days 4745 -addext "extendedKeyUsage=codeSigning" \ + -subj "/CN=Donut Eat/" ; \ + modsign-repackage -c ./cert.der -k ./key.asc /usr/src/packages/RPMS/$(uname -m)/vhba-kmp-default-*.rpm ; \ + rpm -i --nodeps RPMS/$(uname -m)/vhba-kmp-default-*.rpm +""", +) + + +@pytest.mark.parametrize("container", [KMP_CONTAINER], indirect=True) +def test_kmp_builds(container: ContainerData) -> None: + """Test that we can build a SUSE Kernel Module Package with signed modules.""" + + assert "Donut Eat" in container.connection.check_output( + "modinfo /lib/modules/*-default/*/vhba.ko" + ) + + @pytest.mark.skipif( OS_VERSION in ("16.0",), reason="can't install additional packages yet on 16",