tests: add check for presence of zkey related kernel modules and tools in initrd

This commit is contained in:
Dan Horák 2025-08-01 10:36:13 +02:00
parent e18b9ab604
commit e22cadb856
2 changed files with 76 additions and 0 deletions

View File

@ -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 <dhorak@redhat.com>
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.

59
tests/zkey-initrd/runtest.sh Executable file
View File

@ -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 <dhorak@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# 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