From e22cadb856a5c9c8dd4b7d8a2c23be7e575ca88d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20Hor=C3=A1k?= Date: Fri, 1 Aug 2025 10:36:13 +0200 Subject: [PATCH] tests: add check for presence of zkey related kernel modules and tools in initrd --- tests/zkey-initrd/main.fmf | 17 +++++++++++ tests/zkey-initrd/runtest.sh | 59 ++++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 tests/zkey-initrd/main.fmf create mode 100755 tests/zkey-initrd/runtest.sh diff --git a/tests/zkey-initrd/main.fmf b/tests/zkey-initrd/main.fmf new file mode 100644 index 0000000..1d562c2 --- /dev/null +++ b/tests/zkey-initrd/main.fmf @@ -0,0 +1,17 @@ +summary: zkey-initrd +description: | + Check for zkey related kernel modules and tools in initrd +link: https://issues.redhat.com/browse/RHEL-96131 +contact: Daniel Horák +component: + - s390utils-base +test: ./runtest.sh +framework: beakerlib +require: + - s390utils-base +duration: 5m +enabled: true +adjust: + - when: arch != s390x + enabled: false + because: This test applies only to s390x systems. diff --git a/tests/zkey-initrd/runtest.sh b/tests/zkey-initrd/runtest.sh new file mode 100755 index 0000000..b9e2978 --- /dev/null +++ b/tests/zkey-initrd/runtest.sh @@ -0,0 +1,59 @@ +#!/bin/bash +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Description: Check for required kernel modules and tools in initrd +# Reference: https://issues.redhat.com/browse/RHEL-96131 +# Author: Dan Horák +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2025 Red Hat, Inc. +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 2 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be +# useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR +# PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Include Beaker environment +. /usr/share/beakerlib/beakerlib.sh || exit 1 + +PACKAGE="s390utils-base" +INITRD=initrd.img +LISTING=$INITRD.lst + +rlJournalStart + rlPhaseStartSetup + rlAssertRpm $PACKAGE + rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory" + rlRun "pushd $TmpDir" + rlPhaseEnd + + rlPhaseStartTest "Create initrd and check its content for required kernel modules and tools" + rlRun "dracut $INITRD" + rlRun "lsinitrd $INITRD > $LISTING" + for module in pkey pkey-pckmo pkey-ep11 pkey-cca zcrypt zcrypt_cex4; do + rlAssertGrep "kernel/drivers/s390/crypto/${module}\.ko\.xz" $LISTING + done + for module in paes_s390; do + rlAssertGrep "kernel/arch/s390/crypto/${module}\.ko\.xz" $LISTING + done + for tool in chzcrypt lszcrypt zkey zkey-cryptsetup; do + rlAssertGrep "usr/(bin|sbin)/${tool}\$" $LISTING -E + done + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "popd" + rlRun "rm -r $TmpDir" 0 "Removing tmp directory" + rlPhaseEnd +rlJournalEnd