Skip to content

Commit

Permalink
fix: make testsuite pass on OpenSuse and Arch
Browse files Browse the repository at this point in the history
This removes some hard assumptions about the file system layout.

It also hardens the tests with network interface renaming rules and
guards.
  • Loading branch information
haraldh committed May 14, 2021
1 parent 44fd1c1 commit 8b2afb0
Show file tree
Hide file tree
Showing 67 changed files with 470 additions and 349 deletions.
2 changes: 1 addition & 1 deletion test/TEST-01-BASIC/test-init.sh
Expand Up @@ -3,7 +3,7 @@

. /lib/dracut-lib.sh

export PATH=/sbin:/bin:/usr/sbin:/usr/bin
export PATH=/usr/sbin:/usr/bin:/sbin:/bin
command -v plymouth > /dev/null 2>&1 && plymouth --quit
exec > /dev/console 2>&1

Expand Down
3 changes: 0 additions & 3 deletions test/TEST-01-BASIC/test.sh
Expand Up @@ -37,9 +37,6 @@ test_setup() {
cd "$initdir" || exit
mkdir -p -- dev sys proc etc var/run tmp
mkdir -p root usr/bin usr/lib usr/lib64 usr/sbin
for i in bin sbin lib lib64; do
ln -sfnr usr/$i $i
done
)
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
mount dmesg dhclient mkdir cp ping dhclient \
Expand Down
2 changes: 1 addition & 1 deletion test/TEST-02-SYSTEMD/test-init.sh
Expand Up @@ -3,7 +3,7 @@

. /lib/dracut-lib.sh

export PATH=/sbin:/bin:/usr/sbin:/usr/bin
export PATH=/usr/sbin:/usr/bin:/sbin:/bin
command -v plymouth > /dev/null 2>&1 && plymouth --quit
exec > /dev/console 2>&1

Expand Down
3 changes: 0 additions & 3 deletions test/TEST-02-SYSTEMD/test.sh
Expand Up @@ -35,9 +35,6 @@ test_setup() {
cd "$initdir" || exit
mkdir -p -- dev sys proc etc var/run tmp
mkdir -p root usr/bin usr/lib usr/lib64 usr/sbin
for i in bin sbin lib lib64; do
ln -sfnr usr/$i $i
done
mkdir -p -- var/lib/nfs/rpc_pipefs
)
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
Expand Down
2 changes: 1 addition & 1 deletion test/TEST-03-USR-MOUNT/test-init.sh
Expand Up @@ -3,7 +3,7 @@

. /lib/dracut-lib.sh

export PATH=/sbin:/bin:/usr/sbin:/usr/bin
export PATH=/usr/sbin:/usr/bin:/sbin:/bin
command -v plymouth > /dev/null 2>&1 && plymouth --quit
exec > /dev/console 2>&1

Expand Down
3 changes: 0 additions & 3 deletions test/TEST-03-USR-MOUNT/test.sh
Expand Up @@ -57,9 +57,6 @@ test_setup() {
cd "$initdir" || exit
mkdir -p -- dev sys proc etc var/run tmp
mkdir -p root usr/bin usr/lib usr/lib64 usr/sbin
for i in bin sbin lib lib64; do
ln -sfnr usr/$i $i
done
)
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
mount dmesg dhclient mkdir cp ping dhclient \
Expand Down
2 changes: 1 addition & 1 deletion test/TEST-04-FULL-SYSTEMD/test-init.sh
Expand Up @@ -3,7 +3,7 @@

. /lib/dracut-lib.sh

export PATH=/sbin:/bin:/usr/sbin:/usr/bin
export PATH=/usr/sbin:/usr/bin:/sbin:/bin
command -v plymouth > /dev/null 2>&1 && plymouth --quit
exec > /dev/console 2>&1

Expand Down
10 changes: 3 additions & 7 deletions test/TEST-04-FULL-SYSTEMD/test.sh
Expand Up @@ -90,11 +90,7 @@ test_setup() {
return 1
fi
inst /sbin/init
inst /lib/systemd/system/systemd-remount-fs.service
inst /lib/systemd/systemd-remount-fs
inst /lib/systemd/system/systemd-journal-flush.service
inst /lib/systemd/system/slices.target
inst_multiple -o /lib/systemd/system/dracut*
inst_multiple -o {,/usr}/lib/systemd/system/"dracut*"

inst_simple "${basedir}/modules.d/99base/dracut-lib.sh" "/lib/dracut-lib.sh"
inst_binary "${basedir}/dracut-util" "/usr/bin/dracut-util"
Expand All @@ -112,7 +108,7 @@ test_setup() {
/etc/shadow \
/etc/group \
/etc/shells \
/etc/nsswitch.conf \
{,/usr}/etc/nsswitch.conf \
/etc/pam.conf \
/etc/securetty \
/etc/os-release \
Expand Down Expand Up @@ -200,7 +196,7 @@ EOF
ln -fs /proc/self/mounts "$initdir"/etc/mtab

# install any Execs from the service files
grep -Eho '^Exec[^ ]*=[^ ]+' "$initdir"/lib/systemd/system/*.service \
grep -Eho '^Exec[^ ]*=[^ ]+' "$initdir"{,/usr}/lib/systemd/system/*.service \
| while read -r i || [ -n "$i" ]; do
i=${i##Exec*=}
i=${i##-}
Expand Down
2 changes: 1 addition & 1 deletion test/TEST-10-RAID/test-init.sh
Expand Up @@ -3,7 +3,7 @@

. /lib/dracut-lib.sh

export PATH=/sbin:/bin:/usr/sbin:/usr/bin
export PATH=/usr/sbin:/usr/bin:/sbin:/bin
command -v plymouth > /dev/null 2>&1 && plymouth --quit
exec > /dev/console 2>&1

Expand Down
3 changes: 0 additions & 3 deletions test/TEST-10-RAID/test.sh
Expand Up @@ -37,9 +37,6 @@ test_setup() {
cd "$initdir" || exit
mkdir -p -- dev sys proc etc var/run tmp
mkdir -p root usr/bin usr/lib usr/lib64 usr/sbin
for i in bin sbin lib lib64; do
ln -sfnr usr/$i $i
done
)
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
mount dmesg dhclient mkdir cp ping dhclient dd sync
Expand Down
2 changes: 1 addition & 1 deletion test/TEST-11-LVM/test-init.sh
Expand Up @@ -3,7 +3,7 @@

. /lib/dracut-lib.sh

export PATH=/sbin:/bin:/usr/sbin:/usr/bin
export PATH=/usr/sbin:/usr/bin:/sbin:/bin
command -v plymouth > /dev/null 2>&1 && plymouth --quit
exec > /dev/console 2>&1

Expand Down
3 changes: 0 additions & 3 deletions test/TEST-11-LVM/test.sh
Expand Up @@ -38,9 +38,6 @@ test_setup() {
cd "$initdir" || exit
mkdir -p -- dev sys proc etc var/run tmp
mkdir -p root usr/bin usr/lib usr/lib64 usr/sbin
for i in bin sbin lib lib64; do
ln -sfnr usr/$i $i
done
mkdir -p -- var/lib/nfs/rpc_pipefs
)
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
Expand Down
2 changes: 1 addition & 1 deletion test/TEST-12-RAID-DEG/test-init.sh
Expand Up @@ -3,7 +3,7 @@

. /lib/dracut-lib.sh

export PATH=/sbin:/bin:/usr/sbin:/usr/bin
export PATH=/usr/sbin:/usr/bin:/sbin:/bin
command -v plymouth > /dev/null 2>&1 && plymouth --quit
exec > /dev/console 2>&1

Expand Down
3 changes: 0 additions & 3 deletions test/TEST-12-RAID-DEG/test.sh
Expand Up @@ -69,9 +69,6 @@ test_setup() {
cd "$initdir" || exit
mkdir -p -- dev sys proc etc var/run tmp
mkdir -p root usr/bin usr/lib usr/lib64 usr/sbin
for i in bin sbin lib lib64; do
ln -sfnr usr/$i $i
done
)
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
mount dmesg dhclient mkdir cp ping dhclient dd sync
Expand Down
2 changes: 1 addition & 1 deletion test/TEST-13-ENC-RAID-LVM/test-init.sh
Expand Up @@ -3,7 +3,7 @@

. /lib/dracut-lib.sh

export PATH=/sbin:/bin:/usr/sbin:/usr/bin
export PATH=/usr/sbin:/usr/bin:/sbin:/bin
command -v plymouth > /dev/null 2>&1 && plymouth --quit
exec > /dev/console 2>&1

Expand Down
3 changes: 0 additions & 3 deletions test/TEST-13-ENC-RAID-LVM/test.sh
Expand Up @@ -66,9 +66,6 @@ test_setup() {
cd "$initdir" || exit
mkdir -p -- dev sys proc etc var/run tmp
mkdir -p root usr/bin usr/lib usr/lib64 usr/sbin
for i in bin sbin lib lib64; do
ln -sfnr usr/$i $i
done
mkdir -p -- var/lib/nfs/rpc_pipefs
)
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
Expand Down
8 changes: 3 additions & 5 deletions test/TEST-14-IMSM/create-root.sh
Expand Up @@ -27,14 +27,15 @@ sleep 1
udevadm settle

sfdisk -g /dev/mapper/isw*Test0
# save a partition at the beginning for future flagging purposes
sfdisk --no-reread /dev/mapper/isw*Test0 << EOF
,4M
,28M
,28M
,28M
EOF

set -x

udevadm settle
dmraid -a n
udevadm settle
Expand All @@ -49,10 +50,7 @@ done
udevadm settle

mdadm --create /dev/md0 --run --auto=yes --level=5 --raid-devices=3 \
/dev/mapper/isw*p2 \
/dev/mapper/isw*p3 \
/dev/mapper/isw*p4

/dev/mapper/isw*p*[234]
# wait for the array to finish initailizing, otherwise this sometimes fails
# randomly.
mdadm -W /dev/md0
Expand Down
2 changes: 1 addition & 1 deletion test/TEST-14-IMSM/test-init.sh
Expand Up @@ -3,7 +3,7 @@

. /lib/dracut-lib.sh

export PATH=/sbin:/bin:/usr/sbin:/usr/bin
export PATH=/usr/sbin:/usr/bin:/sbin:/bin
command -v plymouth > /dev/null 2>&1 && plymouth --quit
exec > /dev/console 2>&1

Expand Down
3 changes: 0 additions & 3 deletions test/TEST-14-IMSM/test.sh
Expand Up @@ -63,9 +63,6 @@ test_setup() {
cd "$initdir" || exit
mkdir -p -- dev sys proc etc var/run tmp
mkdir -p root usr/bin usr/lib usr/lib64 usr/sbin
for i in bin sbin lib lib64; do
ln -sfnr usr/$i $i
done
)
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
mount dmesg dhclient mkdir cp ping dhclient dd sync
Expand Down
2 changes: 1 addition & 1 deletion test/TEST-15-BTRFSRAID/test-init.sh
Expand Up @@ -3,7 +3,7 @@

. /lib/dracut-lib.sh

export PATH=/sbin:/bin:/usr/sbin:/usr/bin
export PATH=/usr/sbin:/usr/bin:/sbin:/bin
command -v plymouth > /dev/null 2>&1 && plymouth --quit
exec > /dev/console 2>&1

Expand Down
3 changes: 0 additions & 3 deletions test/TEST-15-BTRFSRAID/test.sh
Expand Up @@ -41,9 +41,6 @@ test_setup() {
cd "$initdir" || exit
mkdir -p -- dev sys proc etc var/run tmp
mkdir -p root usr/bin usr/lib usr/lib64 usr/sbin
for i in bin sbin lib lib64; do
ln -sfnr usr/$i $i
done
mkdir -p -- var/lib/nfs/rpc_pipefs
)
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
Expand Down
2 changes: 1 addition & 1 deletion test/TEST-16-DMSQUASH/test-init.sh
Expand Up @@ -3,7 +3,7 @@

. /lib/dracut-lib.sh

export PATH=/sbin:/bin:/usr/sbin:/usr/bin
export PATH=/usr/sbin:/usr/bin:/sbin:/bin
command -v plymouth > /dev/null 2>&1 && plymouth --quit
exec > /dev/console 2>&1

Expand Down
3 changes: 0 additions & 3 deletions test/TEST-16-DMSQUASH/test.sh
Expand Up @@ -76,9 +76,6 @@ test_setup() {
cd "$initdir" || exit
mkdir -p -- dev sys proc etc var/run tmp
mkdir -p root usr/bin usr/lib usr/lib64 usr/sbin
for i in bin sbin lib lib64; do
ln -sfnr usr/$i $i
done
)
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
mount dmesg dhclient mkdir cp ping dhclient \
Expand Down
2 changes: 1 addition & 1 deletion test/TEST-17-LVM-THIN/test-init.sh
Expand Up @@ -3,7 +3,7 @@

. /lib/dracut-lib.sh

export PATH=/sbin:/bin:/usr/sbin:/usr/bin
export PATH=/usr/sbin:/usr/bin:/sbin:/bin
command -v plymouth > /dev/null 2>&1 && plymouth --quit
exec > /dev/console 2>&1

Expand Down
3 changes: 0 additions & 3 deletions test/TEST-17-LVM-THIN/test.sh
Expand Up @@ -36,9 +36,6 @@ test_setup() {
cd "$initdir" || exit
mkdir -p -- dev sys proc etc var/run tmp
mkdir -p root usr/bin usr/lib usr/lib64 usr/sbin
for i in bin sbin lib lib64; do
ln -sfnr usr/$i $i
done
mkdir -p -- var/lib/nfs/rpc_pipefs
)
inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
Expand Down
2 changes: 1 addition & 1 deletion test/TEST-20-NFS/client-init.sh
Expand Up @@ -2,7 +2,7 @@
: > /dev/watchdog
. /lib/dracut-lib.sh

export PATH=/sbin:/bin:/usr/sbin:/usr/bin
export PATH=/usr/sbin:/usr/bin:/sbin:/bin
command -v plymouth > /dev/null 2>&1 && plymouth --quit
exec > /dev/console 2>&1

Expand Down
File renamed without changes.
56 changes: 30 additions & 26 deletions test/TEST-20-NFS/server-init.sh
@@ -1,10 +1,10 @@
#!/bin/sh
exec < /dev/console > /dev/console 2>&1
set -x
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
export PATH=/usr/sbin:/usr/bin:/sbin:/bin
export TERM=linux
export PS1='nfstest-server:\w\$ '
echo > /dev/watchdog
: > /dev/watchdog
stty sane
echo "made it to the rootfs!"
echo server > /proc/sys/kernel/hostname
Expand Down Expand Up @@ -48,57 +48,61 @@ linkup() {
wait_for_if_link "$1" 2> /dev/null && ip link set "$1" up 2> /dev/null && wait_for_if_up "$1" 2> /dev/null
}

wait_for_if_link enp0s1
wait_for_if_link enx525400123456

ip addr add 127.0.0.1/8 dev lo
ip link set lo up
ip addr add 192.168.50.1/24 dev enp0s1
ip addr add 192.168.50.2/24 dev enp0s1
ip addr add 192.168.50.3/24 dev enp0s1
linkup enp0s1
ip addr add 192.168.50.1/24 dev enx525400123456
ip addr add 192.168.50.2/24 dev enx525400123456
ip addr add 192.168.50.3/24 dev enx525400123456
linkup enx525400123456

echo > /dev/watchdog
: > /dev/watchdog
modprobe af_packet
echo > /dev/watchdog
: > /dev/watchdog
mkdir /nfs/nfs3-5
mount --bind /nfs/client /nfs/nfs3-5
echo > /dev/watchdog
: > /dev/watchdog
mkdir -p /nfs/ip/192.168.50.101
mount --bind /nfs/client /nfs/ip/192.168.50.101
echo > /dev/watchdog
: > /dev/watchdog
mkdir -p /nfs/tftpboot/nfs4-5
mount --bind /nfs/client /nfs/tftpboot/nfs4-5
echo > /dev/watchdog
: > /dev/watchdog
modprobe sunrpc
echo > /dev/watchdog
: > /dev/watchdog
mount -t rpc_pipefs sunrpc /var/lib/nfs/rpc_pipefs
echo > /dev/watchdog
: > /dev/watchdog
[ -x /sbin/portmap ] && portmap
echo > /dev/watchdog
: > /dev/watchdog
mkdir -p /run/rpcbind
[ -x /sbin/rpcbind ] && rpcbind
echo > /dev/watchdog
: > /dev/watchdog
modprobe nfsd
echo > /dev/watchdog
: > /dev/watchdog
mount -t nfsd nfsd /proc/fs/nfsd
echo > /dev/watchdog
: > /dev/watchdog
exportfs -r
echo > /dev/watchdog
: > /dev/watchdog
rpc.nfsd
echo > /dev/watchdog
: > /dev/watchdog
rpc.mountd
echo > /dev/watchdog
: > /dev/watchdog
rpc.idmapd
echo > /dev/watchdog
: > /dev/watchdog
exportfs -r
echo > /dev/watchdog
: > /dev/watchdog
mkdir -p /var/lib/dhcpd
: > /var/lib/dhcpd/dhcpd.leases
echo > /dev/watchdog
: > /dev/watchdog
chmod 777 /var/lib/dhcpd/dhcpd.leases
echo > /dev/watchdog
: > /dev/watchdog
rm -f /var/run/dhcpd.pid
dhcpd -d -cf /etc/dhcpd.conf -lf /var/lib/dhcpd/dhcpd.leases &
exportfs -s
echo "Serving NFS mounts"
while :; do
[ -n "$(jobs -rp)" ] && echo > /dev/watchdog
[ -n "$(jobs -rp)" ] && : > /dev/watchdog
sleep 10
done
mount -n -o remount,ro /
Expand Down
File renamed without changes.

0 comments on commit 8b2afb0

Please sign in to comment.