Browse Source

fix: make testsuite pass on OpenSuse and Arch

This removes some hard assumptions about the file system layout.

It also hardens the tests with network interface renaming rules and
guards.
master
Harald Hoyer 3 years ago committed by Harald Hoyer
parent
commit
8b2afb08ba
  1. 2
      test/TEST-01-BASIC/test-init.sh
  2. 3
      test/TEST-01-BASIC/test.sh
  3. 2
      test/TEST-02-SYSTEMD/test-init.sh
  4. 3
      test/TEST-02-SYSTEMD/test.sh
  5. 2
      test/TEST-03-USR-MOUNT/test-init.sh
  6. 3
      test/TEST-03-USR-MOUNT/test.sh
  7. 2
      test/TEST-04-FULL-SYSTEMD/test-init.sh
  8. 10
      test/TEST-04-FULL-SYSTEMD/test.sh
  9. 2
      test/TEST-10-RAID/test-init.sh
  10. 3
      test/TEST-10-RAID/test.sh
  11. 2
      test/TEST-11-LVM/test-init.sh
  12. 3
      test/TEST-11-LVM/test.sh
  13. 2
      test/TEST-12-RAID-DEG/test-init.sh
  14. 3
      test/TEST-12-RAID-DEG/test.sh
  15. 2
      test/TEST-13-ENC-RAID-LVM/test-init.sh
  16. 3
      test/TEST-13-ENC-RAID-LVM/test.sh
  17. 8
      test/TEST-14-IMSM/create-root.sh
  18. 2
      test/TEST-14-IMSM/test-init.sh
  19. 3
      test/TEST-14-IMSM/test.sh
  20. 2
      test/TEST-15-BTRFSRAID/test-init.sh
  21. 3
      test/TEST-15-BTRFSRAID/test.sh
  22. 2
      test/TEST-16-DMSQUASH/test-init.sh
  23. 3
      test/TEST-16-DMSQUASH/test.sh
  24. 2
      test/TEST-17-LVM-THIN/test-init.sh
  25. 3
      test/TEST-17-LVM-THIN/test.sh
  26. 2
      test/TEST-20-NFS/client-init.sh
  27. 0
      test/TEST-20-NFS/client.link
  28. 56
      test/TEST-20-NFS/server-init.sh
  29. 0
      test/TEST-20-NFS/server.link
  30. 113
      test/TEST-20-NFS/test.sh
  31. 3
      test/TEST-20-NFS/wait-if-server.sh
  32. 2
      test/TEST-30-ISCSI/client-init.sh
  33. 0
      test/TEST-30-ISCSI/client.link
  34. 2
      test/TEST-30-ISCSI/dhcpd.conf
  35. 49
      test/TEST-30-ISCSI/server-init.sh
  36. 6
      test/TEST-30-ISCSI/server.link
  37. 61
      test/TEST-30-ISCSI/test.sh
  38. 4
      test/TEST-30-ISCSI/wait-if-server.sh
  39. 2
      test/TEST-35-ISCSI-MULTI/client-init.sh
  40. 6
      test/TEST-35-ISCSI-MULTI/client.link
  41. 36
      test/TEST-35-ISCSI-MULTI/create-client-root.sh
  42. 2
      test/TEST-35-ISCSI-MULTI/dhcpd.conf
  43. 16
      test/TEST-35-ISCSI-MULTI/server-init.sh
  44. 6
      test/TEST-35-ISCSI-MULTI/server.link
  45. 57
      test/TEST-35-ISCSI-MULTI/test.sh
  46. 4
      test/TEST-35-ISCSI-MULTI/wait-if-server.sh
  47. 2
      test/TEST-40-NBD/client-init.sh
  48. 6
      test/TEST-40-NBD/client.link
  49. 1
      test/TEST-40-NBD/create-encrypted-root.sh
  50. 14
      test/TEST-40-NBD/server-init.sh
  51. 6
      test/TEST-40-NBD/server.link
  52. 64
      test/TEST-40-NBD/test.sh
  53. 3
      test/TEST-40-NBD/wait-if-server.sh
  54. 6
      test/TEST-50-MULTINIC/client-init.sh
  55. 6
      test/TEST-50-MULTINIC/client.link
  56. 6
      test/TEST-50-MULTINIC/create-root.sh
  57. 23
      test/TEST-50-MULTINIC/server-init.sh
  58. 6
      test/TEST-50-MULTINIC/server.link
  59. 127
      test/TEST-50-MULTINIC/test.sh
  60. 3
      test/TEST-50-MULTINIC/wait-if-server.sh
  61. 2
      test/TEST-60-BONDBRIDGEVLANIFCFG/client-init.sh
  62. 6
      test/TEST-60-BONDBRIDGEVLANIFCFG/client.link
  63. 2
      test/TEST-60-BONDBRIDGEVLANIFCFG/server-init.sh
  64. 6
      test/TEST-60-BONDBRIDGEVLANIFCFG/server.link
  65. 24
      test/TEST-60-BONDBRIDGEVLANIFCFG/test.sh
  66. 2
      test/run-qemu
  67. 2
      test/test-functions

2
test/TEST-01-BASIC/test-init.sh

@ -3,7 +3,7 @@ @@ -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


3
test/TEST-01-BASIC/test.sh

@ -37,9 +37,6 @@ test_setup() { @@ -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 \

2
test/TEST-02-SYSTEMD/test-init.sh

@ -3,7 +3,7 @@ @@ -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


3
test/TEST-02-SYSTEMD/test.sh

@ -35,9 +35,6 @@ test_setup() { @@ -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 \

2
test/TEST-03-USR-MOUNT/test-init.sh

@ -3,7 +3,7 @@ @@ -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


3
test/TEST-03-USR-MOUNT/test.sh

@ -57,9 +57,6 @@ test_setup() { @@ -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 \

2
test/TEST-04-FULL-SYSTEMD/test-init.sh

@ -3,7 +3,7 @@ @@ -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


10
test/TEST-04-FULL-SYSTEMD/test.sh

@ -90,11 +90,7 @@ test_setup() { @@ -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"
@ -112,7 +108,7 @@ test_setup() { @@ -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 \
@ -200,7 +196,7 @@ EOF @@ -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##-}

2
test/TEST-10-RAID/test-init.sh

@ -3,7 +3,7 @@ @@ -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


3
test/TEST-10-RAID/test.sh

@ -37,9 +37,6 @@ test_setup() { @@ -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

2
test/TEST-11-LVM/test-init.sh

@ -3,7 +3,7 @@ @@ -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


3
test/TEST-11-LVM/test.sh

@ -38,9 +38,6 @@ test_setup() { @@ -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 \

2
test/TEST-12-RAID-DEG/test-init.sh

@ -3,7 +3,7 @@ @@ -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


3
test/TEST-12-RAID-DEG/test.sh

@ -69,9 +69,6 @@ test_setup() { @@ -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

2
test/TEST-13-ENC-RAID-LVM/test-init.sh

@ -3,7 +3,7 @@ @@ -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


3
test/TEST-13-ENC-RAID-LVM/test.sh

@ -66,9 +66,6 @@ test_setup() { @@ -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 \

8
test/TEST-14-IMSM/create-root.sh

@ -27,7 +27,6 @@ sleep 1 @@ -27,7 +27,6 @@ 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
@ -35,6 +34,8 @@ sfdisk --no-reread /dev/mapper/isw*Test0 << EOF @@ -35,6 +34,8 @@ sfdisk --no-reread /dev/mapper/isw*Test0 << EOF
,28M
EOF

set -x

udevadm settle
dmraid -a n
udevadm settle
@ -49,10 +50,7 @@ done @@ -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

2
test/TEST-14-IMSM/test-init.sh

@ -3,7 +3,7 @@ @@ -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


3
test/TEST-14-IMSM/test.sh

@ -63,9 +63,6 @@ test_setup() { @@ -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

2
test/TEST-15-BTRFSRAID/test-init.sh

@ -3,7 +3,7 @@ @@ -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


3
test/TEST-15-BTRFSRAID/test.sh

@ -41,9 +41,6 @@ test_setup() { @@ -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 \

2
test/TEST-16-DMSQUASH/test-init.sh

@ -3,7 +3,7 @@ @@ -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


3
test/TEST-16-DMSQUASH/test.sh

@ -76,9 +76,6 @@ test_setup() { @@ -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 \

2
test/TEST-17-LVM-THIN/test-init.sh

@ -3,7 +3,7 @@ @@ -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


3
test/TEST-17-LVM-THIN/test.sh

@ -36,9 +36,6 @@ test_setup() { @@ -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 \

2
test/TEST-20-NFS/client-init.sh

@ -2,7 +2,7 @@ @@ -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


0
test/TEST-20-NFS/99-default.link → test/TEST-20-NFS/client.link

56
test/TEST-20-NFS/server-init.sh

@ -1,10 +1,10 @@ @@ -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
@ -48,57 +48,61 @@ linkup() { @@ -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 /

0
test/TEST-60-BONDBRIDGEVLANIFCFG/99-default.link → test/TEST-20-NFS/server.link

113
test/TEST-20-NFS/test.sh

@ -14,10 +14,10 @@ TEST_DESCRIPTION="root filesystem on NFS with $USE_NETWORK" @@ -14,10 +14,10 @@ TEST_DESCRIPTION="root filesystem on NFS with $USE_NETWORK"
KVERSION=${KVERSION-$(uname -r)}

# Uncomment this to debug failures
#DEBUGFAIL="loglevel=1"
DEBUGFAIL="rd.debug loglevel=7"
#DEBUGFAIL="rd.shell rd.break rd.debug loglevel=7 "
#DEBUGFAIL="rd.debug loglevel=7 rd.break=initqueue rd.shell"
#SERVER_DEBUG="rd.debug loglevel=7"
SERVER_DEBUG="rd.debug loglevel=7"
#SERIAL="unix:/tmp/server.sock"

run_server() {
@ -26,7 +26,7 @@ run_server() { @@ -26,7 +26,7 @@ run_server() {
declare -a disk_args=()
# shellcheck disable=SC2034
declare -i disk_index=0
qemu_add_drive_args disk_index disk_args "$TESTDIR"/root.img root 1
qemu_add_drive_args disk_index disk_args "$TESTDIR"/server.img root 1

"$testdir"/run-qemu \
"${disk_args[@]}" \
@ -34,7 +34,7 @@ run_server() { @@ -34,7 +34,7 @@ run_server() {
-net nic,macaddr=52:54:00:12:34:56,model=e1000 \
-serial "${SERIAL:-"file:$TESTDIR/server.log"}" \
-watchdog i6300esb -watchdog-action poweroff \
-append "panic=1 hung_task_panic=1 oops=panic softlockup_panic=1 quiet root=LABEL=dracut rootfstype=ext3 rw console=ttyS0,115200n81 selinux=0 $SERVER_DEBUG" \
-append "panic=1 hung_task_panic=1 oops=panic softlockup_panic=1 root=LABEL=dracut rootfstype=ext3 rw console=ttyS0,115200n81 selinux=0 $SERVER_DEBUG" \
-initrd "$TESTDIR"/initramfs.server \
-pidfile "$TESTDIR"/server.pid -daemonize || return 1
chmod 644 "$TESTDIR"/server.pid || return 1
@ -236,6 +236,7 @@ test_setup() { @@ -236,6 +236,7 @@ test_setup() {
export srcmods="/lib/modules/$kernel/"
# Detect lib paths

rm -rf -- "$TESTDIR"/overlay
(
mkdir -p "$TESTDIR"/server/overlay/source
# shellcheck disable=SC2030
@ -243,25 +244,23 @@ test_setup() { @@ -243,25 +244,23 @@ test_setup() {
# shellcheck disable=SC1090
. "$basedir"/dracut-init.sh

for _f in modules.builtin.bin modules.builtin; do
[[ -f $srcmods/$_f ]] && break
done || {
dfatal "No modules.builtin.bin and modules.builtin found!"
return 1
}

for _f in modules.builtin.bin modules.builtin modules.order; do
[[ -f $srcmods/$_f ]] && inst_simple "$srcmods/$_f" "/lib/modules/$kernel/$_f"
done
(
cd "$initdir" || exit
mkdir -p dev sys proc run etc var/run tmp var/lib/{dhcpd,rpcbind}
mkdir -p var/lib/nfs/{v4recovery,rpc_pipefs}
chmod 777 var/lib/rpcbind var/lib/nfs
)

inst_multiple sh ls shutdown poweroff stty cat ps ln ip \
dmesg mkdir cp ping exportfs \
modprobe rpc.nfsd rpc.mountd showmount tcpdump \
/etc/services sleep mount chmod rm
sleep mount chmod rm
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
if [ -f "${_terminfodir}"/l/linux ]; then
inst_multiple -o "${_terminfodir}"/l/linux
break
fi
done
inst_multiple -o ${_terminfodir}/l/linux
type -P portmap > /dev/null && inst_multiple portmap
type -P rpcbind > /dev/null && inst_multiple rpcbind
[ -f /etc/netconfig ] && inst_multiple /etc/netconfig
@ -273,35 +272,29 @@ test_setup() { @@ -273,35 +272,29 @@ test_setup() {
inst ./hosts /etc/hosts
inst ./exports /etc/exports
inst ./dhcpd.conf /etc/dhcpd.conf
inst_multiple /etc/nsswitch.conf /etc/rpc /etc/protocols
inst_multiple -o {,/usr}/etc/nsswitch.conf {,/usr}/etc/rpc \
{,/usr}/etc/protocols {,/usr}/etc/services
inst_multiple rpc.idmapd /etc/idmapd.conf

inst_libdir_file 'libnfsidmap_nsswitch.so*'
inst_libdir_file 'libnfsidmap/*.so*'
inst_libdir_file 'libnfsidmap*.so*'

_nsslibs=$(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' /etc/nsswitch.conf \
| tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
_nsslibs=$(
cat "$dracutsysrootdir"/{,usr/}etc/nsswitch.conf 2> /dev/null \
| sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' \
| tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|'
)
_nsslibs=${_nsslibs#|}
_nsslibs=${_nsslibs%|}

inst_libdir_file -n "$_nsslibs" 'libnss_*.so*'

(
cd "$initdir" || exit
mkdir -p dev sys proc run etc var/run tmp var/lib/{dhcpd,rpcbind}
mkdir -p var/lib/nfs/{v4recovery,rpc_pipefs}
chmod 777 var/lib/rpcbind var/lib/nfs
)
inst /etc/nsswitch.conf /etc/nsswitch.conf

inst /etc/passwd /etc/passwd
inst /etc/group /etc/group

cp -a /etc/ld.so.conf* "$initdir"/etc
ldconfig -r "$initdir"
dracut_kernel_post

)

# Make client root inside server root
@ -314,20 +307,17 @@ test_setup() { @@ -314,20 +307,17 @@ test_setup() {

(
cd "$initdir" || exit
mkdir -p dev sys proc etc run
mkdir -p var/lib/nfs/rpc_pipefs
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 dev sys proc etc run root usr var/lib/nfs/rpc_pipefs
)

inst_multiple sh shutdown poweroff stty cat ps ln ip dd \
mount dmesg mkdir cp ping grep setsid ls vi less cat sync
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
if [ -f "${_terminfodir}"/l/linux ]; then
inst_multiple -o "${_terminfodir}"/l/linux
break
fi
done
inst_multiple -o ${_terminfodir}/l/linux

inst_simple "${basedir}/modules.d/99base/dracut-lib.sh" "/lib/dracut-lib.sh"
inst_binary "${basedir}/dracut-util" "/usr/bin/dracut-util"
@ -336,7 +326,7 @@ test_setup() { @@ -336,7 +326,7 @@ test_setup() {

inst ./client-init.sh /sbin/init
inst_simple /etc/os-release
inst /etc/nsswitch.conf /etc/nsswitch.conf
inst_multiple -o {,/usr}/etc/nsswitch.conf
inst /etc/passwd /etc/passwd
inst /etc/group /etc/group

@ -344,11 +334,13 @@ test_setup() { @@ -344,11 +334,13 @@ test_setup() {
inst_libdir_file 'libnfsidmap/*.so*'
inst_libdir_file 'libnfsidmap*.so*'

_nsslibs=$(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' /etc/nsswitch.conf \
| tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
_nsslibs=$(
cat "$dracutsysrootdir"/{,usr/}etc/nsswitch.conf 2> /dev/null \
| sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' \
| tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|'
)
_nsslibs=${_nsslibs#|}
_nsslibs=${_nsslibs%|}

inst_libdir_file -n "$_nsslibs" 'libnss_*.so*'

cp -a /etc/ld.so.conf* "$initdir"/etc
@ -378,13 +370,13 @@ test_setup() { @@ -378,13 +370,13 @@ test_setup() {
-f "$TESTDIR"/initramfs.makeroot "$KVERSION" || return 1
rm -rf -- "$TESTDIR"/server

dd if=/dev/zero of="$TESTDIR"/root.img bs=1MiB count=80
dd if=/dev/zero of="$TESTDIR"/server.img bs=1MiB count=80
dd if=/dev/zero of="$TESTDIR"/marker.img bs=1MiB count=1
declare -a disk_args=()
# shellcheck disable=SC2034
declare -i disk_index=0
qemu_add_drive_args disk_index disk_args "$TESTDIR"/marker.img marker
qemu_add_drive_args disk_index disk_args "$TESTDIR"/root.img root
qemu_add_drive_args disk_index disk_args "$TESTDIR"/server.img root

# Invoke KVM and/or QEMU to actually create the target filesystem.
"$testdir"/run-qemu \
@ -396,30 +388,41 @@ test_setup() { @@ -396,30 +388,41 @@ test_setup() {
# Make an overlay with needed tools for the test harness
(
# shellcheck disable=SC2031
export initdir=$TESTDIR/overlay
# shellcheck disable=SC2030
export initdir="$TESTDIR"/overlay
mkdir -p "$TESTDIR"/overlay
# shellcheck disable=SC1090
. "$basedir"/dracut-init.sh
mkdir -p "$TESTDIR"/overlay
inst_multiple poweroff shutdown
inst_hook shutdown-emergency 000 ./hard-off.sh
inst_hook emergency 000 ./hard-off.sh
inst_simple ./99-default.link /etc/systemd/network/99-default.link
inst_simple ./client.link /etc/systemd/network/01-client.link
)

# Make server's dracut image
"$basedir"/dracut.sh -l -i "$TESTDIR"/overlay / \
-m "dash udev-rules base rootfs-block fs-lib debug kernel-modules watchdog qemu" \
-d "af_packet piix ide-gd_mod ata_piix ext3 sd_mod e1000 i6300esb" \
--no-hostonly-cmdline -N \
-f "$TESTDIR"/initramfs.server "$KVERSION" || return 1

# Make client's dracut image
"$basedir"/dracut.sh -l -i "$TESTDIR"/overlay / \
-o "plymouth dash ${OMIT_NETWORK}" \
-a "debug watchdog ${USE_NETWORK}" \
-d "af_packet piix ide-gd_mod ata_piix sd_mod e1000 nfs sunrpc i6300esb" \
--no-hostonly-cmdline -N \
-f "$TESTDIR"/initramfs.testing "$KVERSION" || return 1

(
# shellcheck disable=SC2031
export initdir="$TESTDIR"/overlay
# shellcheck disable=SC1090
. "$basedir"/dracut-init.sh
rm "$initdir"/etc/systemd/network/01-client.link
inst_simple ./server.link /etc/systemd/network/01-server.link
inst_hook pre-mount 99 ./wait-if-server.sh
)
# Make server's dracut image
"$basedir"/dracut.sh -l -i "$TESTDIR"/overlay / \
-m "dash udev-rules base rootfs-block fs-lib debug kernel-modules watchdog qemu network network-legacy" \
-d "af_packet piix ide-gd_mod ata_piix ext3 sd_mod e1000 i6300esb" \
--no-hostonly-cmdline -N \
-f "$TESTDIR"/initramfs.server "$KVERSION" || return 1

rm -rf -- "$TESTDIR"/overlay
}

test_cleanup() {

3
test/TEST-20-NFS/wait-if-server.sh

@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
#!/bin/sh
. /lib/net-lib.sh
wait_for_if_link enx525400123456

2
test/TEST-30-ISCSI/client-init.sh

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
#!/bin/sh
. /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


0
test/TEST-50-MULTINIC/99-default.link → test/TEST-30-ISCSI/client.link

2
test/TEST-30-ISCSI/dhcpd.conf

@ -37,7 +37,7 @@ subnet 192.168.51.0 netmask 255.255.255.0 { @@ -37,7 +37,7 @@ subnet 192.168.51.0 netmask 255.255.255.0 {
# NFSv3: last octect starts at 0x00 and works up

group {
option root-path "iscsi:192.168.51.1:::1:iqn.2009-06.dracut:target1";
#option root-path "iscsi:192.168.51.1:::1:iqn.2009-06.dracut:target1";

host iscsi-2 {
hardware ethernet 52:54:00:12:34:01;

49
test/TEST-30-ISCSI/server-init.sh

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
#!/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='server:\w\$ '
stty sane
@ -20,15 +20,47 @@ wait_for_if_link() { @@ -20,15 +20,47 @@ wait_for_if_link() {
return 1
}

wait_for_if_link enp0s1
wait_for_if_link enp0s2
wait_for_if_up() {
local cnt=0
local li
while [ $cnt -lt 200 ]; do
li=$(ip -o link show up dev "$1")
[ -n "$li" ] && return 0
sleep 0.1
cnt=$((cnt + 1))
done
return 1
}

wait_for_route_ok() {
local cnt=0
while [ $cnt -lt 200 ]; do
li=$(ip route show)
[ -n "$li" ] && [ -z "${li##*$1*}" ] && return 0
sleep 0.1
cnt=$((cnt + 1))
done
return 1
}

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 enx525400123456
wait_for_if_link enx525400123457

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 link set enp0s1 up
ip addr add 192.168.51.1/24 dev enp0s2
ip link set enp0s2 up

ip addr add 192.168.50.1/24 dev enx525400123456
linkup enx525400123456

ip addr add 192.168.51.1/24 dev enx525400123457
linkup enx525400123457

modprobe af_packet

: > /var/lib/dhcpd/dhcpd.leases
chmod 777 /var/lib/dhcpd/dhcpd.leases
dhcpd -d -cf /etc/dhcpd.conf -lf /var/lib/dhcpd/dhcpd.leases &
@ -44,9 +76,8 @@ tgtadm --lld iscsi --mode target --op bind --tid 1 -I 192.168.50.101 @@ -44,9 +76,8 @@ tgtadm --lld iscsi --mode target --op bind --tid 1 -I 192.168.50.101
tgtadm --lld iscsi --mode target --op bind --tid 2 -I 192.168.51.101
tgtadm --lld iscsi --mode target --op bind --tid 3 -I 192.168.50.101

echo "Serving iSCSI"

# Wait forever for the VM to die
echo "Serving iSCSI"
while pidof tgtd > /dev/null; do
: > /dev/watchdog
dmesg -c

6
test/TEST-30-ISCSI/server.link

@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
[Match]
OriginalName=*

[Link]
NamePolicy=mac
MACAddressPolicy=keep

61
test/TEST-30-ISCSI/test.sh

@ -139,14 +139,6 @@ test_setup() { @@ -139,14 +139,6 @@ test_setup() {
return 1
fi

# Create the blank file to use as a root filesystem
rm -f "$TESTDIR"/root.ext3
dd if=/dev/zero of="$TESTDIR"/root.ext3 bs=4096 count=$((200 * 256))
rm -f "$TESTDIR"/iscsidisk2.img
dd if=/dev/zero of="$TESTDIR"/iscsidisk2.img bs=4096 count=$((100 * 256))
rm -f "$TESTDIR"/iscsidisk3.img
dd if=/dev/zero of="$TESTDIR"/iscsidisk3.img bs=4096 count=$((100 * 256))

kernel=$KVERSION
# Create what will eventually be our root filesystem onto an overlay
rm -rf -- "$TESTDIR"/overlay
@ -159,9 +151,6 @@ test_setup() { @@ -159,9 +151,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 shutdown poweroff stty cat ps ln ip \
@ -224,9 +213,6 @@ test_setup() { @@ -224,9 +213,6 @@ test_setup() {
grep -U --binary-files=binary -F -m 1 -q dracut-root-block-created "$TESTDIR"/marker.img || return 1
rm -- "$TESTDIR"/marker.img

# Make server root
dd if=/dev/zero of="$TESTDIR"/server.ext3 bs=1M count=120

# shellcheck disable=SC2031
export kernel=$KVERSION
rm -rf -- "$TESTDIR"/overlay
@ -244,22 +230,32 @@ test_setup() { @@ -244,22 +230,32 @@ test_setup() {
inst /etc/passwd /etc/passwd
inst_multiple sh ls shutdown poweroff stty cat ps ln ip \
dmesg mkdir cp ping modprobe tcpdump setsid \
/etc/services sleep mount chmod pidof
sleep mount chmod pidof
inst_multiple tgtd tgtadm
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
inst_multiple -o ${_terminfodir}/l/linux
instmods iscsi_tcp crc32c ipv6
instmods iscsi_tcp crc32c ipv6 af_packet
[ -f /etc/netconfig ] && inst_multiple /etc/netconfig
type -P dhcpd > /dev/null && inst_multiple dhcpd
[ -x /usr/sbin/dhcpd3 ] && inst /usr/sbin/dhcpd3 /usr/sbin/dhcpd
inst_simple /etc/os-release
inst ./server-init.sh /sbin/init
inst ./hosts /etc/hosts
inst ./dhcpd.conf /etc/dhcpd.conf
inst_multiple /etc/nsswitch.conf /etc/rpc /etc/protocols
inst /etc/group /etc/group
inst_multiple -o {,/usr}/etc/nsswitch.conf {,/usr}/etc/rpc \
{,/usr}/etc/protocols {,/usr}/etc/services \
/etc/group /etc/os-release

_nsslibs=$(
cat "$dracutsysrootdir"/{,usr/}etc/nsswitch.conf 2> /dev/null \
| sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' \
| tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|'
)
_nsslibs=${_nsslibs#|}
_nsslibs=${_nsslibs%|}

inst_libdir_file -n "$_nsslibs" 'libnss_*.so*'

cp -a /etc/ld.so.conf* "$initdir"/etc
ldconfig -r "$initdir"
@ -308,30 +304,39 @@ test_setup() { @@ -308,30 +304,39 @@ test_setup() {
# Make an overlay with needed tools for the test harness
(
# shellcheck disable=SC2031
# shellcheck disable=SC2030
export initdir=$TESTDIR/overlay
# shellcheck disable=SC1090
. "$basedir"/dracut-init.sh
inst_multiple poweroff shutdown
inst_hook shutdown-emergency 000 ./hard-off.sh
inst_hook emergency 000 ./hard-off.sh
inst_simple ./client.link /etc/systemd/network/01-client.link
)
# Make client's dracut image
"$basedir"/dracut.sh -l -i "$TESTDIR"/overlay / \
-o "dash plymouth dmraid nfs ${OMIT_NETWORK}" \
-a "debug ${USE_NETWORK}" \
--no-hostonly-cmdline -N \
-f "$TESTDIR"/initramfs.testing "$KVERSION" || return 1

(
# shellcheck disable=SC2031
export initdir="$TESTDIR"/overlay
# shellcheck disable=SC1090
. "$basedir"/dracut-init.sh
rm "$initdir"/etc/systemd/network/01-client.link
inst_simple ./server.link /etc/systemd/network/01-server.link
inst_hook pre-mount 99 ./wait-if-server.sh
)
# Make server's dracut image
"$basedir"/dracut.sh -l -i "$TESTDIR"/overlay / \
-a "dash udev-rules base rootfs-block fs-lib debug kernel-modules" \
-a "dash udev-rules base rootfs-block fs-lib debug kernel-modules network network-legacy" \
-d "af_packet piix ide-gd_mod ata_piix ext3 sd_mod e1000 drbg" \
--no-hostonly-cmdline -N \
-f "$TESTDIR"/initramfs.server "$KVERSION" || return 1

# Make client dracut image
"$basedir"/dracut.sh -l -i "$TESTDIR"/overlay / \
-o "dash plymouth dmraid nfs ${OMIT_NETWORK}" \
-a "debug ${USE_NETWORK}" \
-d "af_packet piix ide-gd_mod ata_piix ext3 sd_mod" \
--no-hostonly-cmdline -N \
-f "$TESTDIR"/initramfs.testing "$KVERSION" || return 1
rm -rf -- "$TESTDIR"/overlay

}

test_cleanup() {

4
test/TEST-30-ISCSI/wait-if-server.sh

@ -0,0 +1,4 @@ @@ -0,0 +1,4 @@
#!/bin/sh
. /lib/net-lib.sh
wait_for_if_link enx525400123456
wait_for_if_link enx525400123457

2
test/TEST-35-ISCSI-MULTI/client-init.sh

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
#!/bin/sh
. /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


6
test/TEST-35-ISCSI-MULTI/client.link

@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
[Match]
OriginalName=*

[Link]
NamePolicy=keep kernel database onboard slot path
MACAddressPolicy=keep

36
test/TEST-35-ISCSI-MULTI/create-client-root.sh

@ -10,22 +10,24 @@ rm -f -- /etc/lvm/lvm.conf @@ -10,22 +10,24 @@ rm -f -- /etc/lvm/lvm.conf
udevadm control --reload
udevadm settle

mkfs.ext3 -j -L singleroot -F /dev/disk/by-id/ata-disk_singleroot \
&& mkdir -p /sysroot \
&& mount /dev/disk/by-id/ata-disk_singleroot /sysroot \
&& cp -a -t /sysroot /source/* \
&& umount /sysroot \
&& mdadm --create /dev/md0 --run --auto=yes --level=stripe --raid-devices=2 /dev/disk/by-id/ata-disk_raid0-1 /dev/disk/by-id/ata-disk_raid0-2 \
&& mdadm -W /dev/md0 || : \
&& lvm pvcreate -ff -y /dev/md0 \
&& lvm vgcreate dracut /dev/md0 \
&& lvm lvcreate -l 100%FREE -n root dracut \
&& lvm vgchange -ay \
&& mkfs.ext3 -j -L sysroot /dev/dracut/root \
&& mount /dev/dracut/root /sysroot \
&& cp -a -t /sysroot /source/* \
&& umount /sysroot \
&& lvm lvchange -a n /dev/dracut/root \
&& echo "dracut-root-block-created" | dd oflag=direct,dsync of=/dev/disk/by-id/ata-disk_marker
set -ex

mkfs.ext3 -j -L singleroot -F /dev/disk/by-id/ata-disk_singleroot
mkdir -p /sysroot
mount /dev/disk/by-id/ata-disk_singleroot /sysroot
cp -a -t /sysroot /source/*
umount /sysroot
mdadm --create /dev/md0 --run --auto=yes --level=stripe --raid-devices=2 /dev/disk/by-id/ata-disk_raid0-1 /dev/disk/by-id/ata-disk_raid0-2
mdadm -W /dev/md0 || :
lvm pvcreate -ff -y /dev/md0
lvm vgcreate dracut /dev/md0
lvm lvcreate -l 100%FREE -n root dracut
lvm vgchange -ay
mkfs.ext3 -j -L sysroot /dev/dracut/root
mount /dev/dracut/root /sysroot
cp -a -t /sysroot /source/*
umount /sysroot
lvm lvchange -a n /dev/dracut/root
echo "dracut-root-block-created" | dd oflag=direct,dsync of=/dev/disk/by-id/ata-disk_marker
sync
poweroff -f

2
test/TEST-35-ISCSI-MULTI/dhcpd.conf

@ -37,7 +37,7 @@ subnet 192.168.51.0 netmask 255.255.255.0 { @@ -37,7 +37,7 @@ subnet 192.168.51.0 netmask 255.255.255.0 {
# NFSv3: last octect starts at 0x00 and works up

group {
option root-path "iscsi:192.168.51.1:::1:iqn.2009-06.dracut:target1";
#option root-path "iscsi:192.168.51.1:::1:iqn.2009-06.dracut:target1";

host iscsi-2 {
hardware ethernet 52:54:00:12:34:01;

16
test/TEST-35-ISCSI-MULTI/server-init.sh

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
#!/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='server:\w\$ '
stty sane
@ -47,17 +47,19 @@ linkup() { @@ -47,17 +47,19 @@ 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 enp0s2
wait_for_if_link enx525400123456
wait_for_if_link enx525400123457

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
linkup enp0s1
ip addr add 192.168.50.1/24 dev enx525400123456
linkup enx525400123456

ip addr add 192.168.51.1/24 dev enp0s2
linkup enp0s2
ip addr add 192.168.51.1/24 dev enx525400123457
linkup enx525400123457

modprobe af_packet

: > /var/lib/dhcpd/dhcpd.leases
chmod 777 /var/lib/dhcpd/dhcpd.leases

6
test/TEST-35-ISCSI-MULTI/server.link

@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
[Match]
OriginalName=*

[Link]
NamePolicy=mac
MACAddressPolicy=keep

57
test/TEST-35-ISCSI-MULTI/test.sh

@ -163,9 +163,6 @@ test_setup() { @@ -163,9 +163,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 shutdown poweroff stty cat ps ln ip \
@ -228,9 +225,6 @@ test_setup() { @@ -228,9 +225,6 @@ test_setup() {
grep -U --binary-files=binary -F -m 1 -q dracut-root-block-created "$TESTDIR"/marker.img || return 1
rm -- "$TESTDIR"/marker.img

# Make server root
echo "MAKE SERVER ROOT"

# shellcheck disable=SC2031
export kernel=$KVERSION
rm -rf -- "$TESTDIR"/overlay
@ -247,29 +241,39 @@ test_setup() { @@ -247,29 +241,39 @@ test_setup() {
)
inst /etc/passwd /etc/passwd
inst_multiple sh ls shutdown poweroff stty cat ps ln ip \
dmesg mkdir cp ping \
modprobe tcpdump setsid \
/etc/services sleep mount chmod pidof
dmesg mkdir cp ping modprobe tcpdump setsid \
sleep mount chmod pidof
inst_multiple tgtd tgtadm
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
inst_multiple -o ${_terminfodir}/l/linux
instmods iscsi_tcp crc32c ipv6
instmods iscsi_tcp crc32c ipv6 af_packet
[ -f /etc/netconfig ] && inst_multiple /etc/netconfig
type -P dhcpd > /dev/null && inst_multiple dhcpd
[ -x /usr/sbin/dhcpd3 ] && inst /usr/sbin/dhcpd3 /usr/sbin/dhcpd
inst_simple /etc/os-release
inst ./server-init.sh /sbin/init
inst ./hosts /etc/hosts
inst ./dhcpd.conf /etc/dhcpd.conf
inst_multiple /etc/nsswitch.conf /etc/rpc /etc/protocols
inst /etc/group /etc/group
inst_multiple -o {,/usr}/etc/nsswitch.conf {,/usr}/etc/rpc \
{,/usr}/etc/protocols {,/usr}/etc/services \
/etc/group /etc/os-release

_nsslibs=$(
cat "$dracutsysrootdir"/{,usr/}etc/nsswitch.conf 2> /dev/null \
| sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' \
| tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|'
)
_nsslibs=${_nsslibs#|}
_nsslibs=${_nsslibs%|}

inst_libdir_file -n "$_nsslibs" 'libnss_*.so*'

cp -a /etc/ld.so.conf* "$initdir"/etc
ldconfig -r "$initdir"
dracut_kernel_post
)

# second, install the files needed to make the root filesystem
(
# shellcheck disable=SC2031
@ -312,29 +316,38 @@ test_setup() { @@ -312,29 +316,38 @@ test_setup() {
# Make an overlay with needed tools for the test harness
(
# shellcheck disable=SC2031
# shellcheck disable=SC2030
export initdir=$TESTDIR/overlay
# shellcheck disable=SC1090
. "$basedir"/dracut-init.sh
inst_multiple poweroff shutdown
inst_hook shutdown-emergency 000 ./hard-off.sh
inst_hook emergency 000 ./hard-off.sh
inst_simple ./client.link /etc/systemd/network/01-client.link
)

# Make server's dracut image
"$basedir"/dracut.sh -l -i "$TESTDIR"/overlay / \
-a "dash udev-rules base rootfs-block fs-lib debug kernel-modules" \
-d "af_packet piix ide-gd_mod ata_piix ext3 sd_mod e1000 drbg" \
--no-hostonly-cmdline -N \
-f "$TESTDIR"/initramfs.server "$KVERSION" || return 1

# Make client's dracut image
"$basedir"/dracut.sh -l -i "$TESTDIR"/overlay / \
-o "dash plymouth dmraid nfs ${OMIT_NETWORK}" \
-a "debug ${USE_NETWORK}" \
-d "af_packet piix ide-gd_mod ata_piix ext3 sd_mod" \
--no-hostonly-cmdline -N \
-f "$TESTDIR"/initramfs.testing "$KVERSION" || return 1

(
# shellcheck disable=SC2031
export initdir="$TESTDIR"/overlay
# shellcheck disable=SC1090
. "$basedir"/dracut-init.sh
rm "$initdir"/etc/systemd/network/01-client.link
inst_simple ./server.link /etc/systemd/network/01-server.link
inst_hook pre-mount 99 ./wait-if-server.sh
)
# Make server's dracut image
"$basedir"/dracut.sh -l -i "$TESTDIR"/overlay / \
-a "dash udev-rules base rootfs-block fs-lib debug kernel-modules network network-legacy" \
-d "af_packet piix ide-gd_mod ata_piix ext3 sd_mod e1000 drbg" \
--no-hostonly-cmdline -N \
-f "$TESTDIR"/initramfs.server "$KVERSION" || return 1

rm -rf -- "$TESTDIR"/overlay
}


4
test/TEST-35-ISCSI-MULTI/wait-if-server.sh

@ -0,0 +1,4 @@ @@ -0,0 +1,4 @@
#!/bin/sh
. /lib/net-lib.sh
wait_for_if_link enx525400123456
wait_for_if_link enx525400123457

2
test/TEST-40-NBD/client-init.sh

@ -2,7 +2,7 @@ @@ -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


6
test/TEST-40-NBD/client.link

@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
[Match]
OriginalName=*

[Link]
NamePolicy=keep kernel database onboard slot path
MACAddressPolicy=keep

1
test/TEST-40-NBD/create-encrypted-root.sh

@ -20,6 +20,7 @@ lvm pvcreate -ff -y /dev/mapper/dracut_crypt_test @@ -20,6 +20,7 @@ lvm pvcreate -ff -y /dev/mapper/dracut_crypt_test
lvm vgcreate dracut /dev/mapper/dracut_crypt_test
lvm lvcreate -l 100%FREE -n root dracut
lvm vgchange -ay
udevadm settle
mkfs.ext3 -L dracut -j /dev/dracut/root
mkdir -p /sysroot
mount /dev/dracut/root /sysroot

14
test/TEST-40-NBD/server-init.sh

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
#!/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='nbdtest-server:\w\$ '
stty sane
@ -50,9 +50,9 @@ linkup() { @@ -50,9 +50,9 @@ linkup() {
ip addr add 127.0.0.1/8 dev lo
ip link set lo up

wait_for_if_link enp0s1
ip addr add 192.168.50.1/24 dev enp0s1
linkup enp0s1
wait_for_if_link enx525400123456
ip addr add 192.168.50.1/24 dev enx525400123456
linkup enx525400123456

modprobe af_packet
nbd-server
@ -60,9 +60,9 @@ nbd-server @@ -60,9 +60,9 @@ nbd-server
chmod 777 /var/lib/dhcpd/dhcpd.leases
dhcpd -d -cf /etc/dhcpd.conf -lf /var/lib/dhcpd/dhcpd.leases &
echo "Serving NBD disks"
while :; do
[ -n "$(jobs -rp)" ] && echo > /dev/watchdog
sleep 10
while pidof nbd-server && pidof dhcpd; do
echo > /dev/watchdog
sleep 1
done
mount -n -o remount,ro /
poweroff -f

6
test/TEST-40-NBD/server.link

@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
[Match]
OriginalName=*

[Link]
NamePolicy=mac
MACAddressPolicy=keep

64
test/TEST-40-NBD/test.sh

@ -14,11 +14,12 @@ TEST_DESCRIPTION="root filesystem on NBD with $USE_NETWORK" @@ -14,11 +14,12 @@ TEST_DESCRIPTION="root filesystem on NBD with $USE_NETWORK"
KVERSION=${KVERSION-$(uname -r)}

# Uncomment this to debug failures
# DEBUGFAIL="rd.debug systemd.log_target=console loglevel=7"
#DEBUGFAIL="rd.shell rd.break rd.debug systemd.log_target=console loglevel=7 systemd.log_level=debug"
#SERIAL="tcp:127.0.0.1:9999"

test_check() {
if ! type -p nbd-server 2> /dev/null; then
if ! type -p nbd-server &> /dev/null; then
echo "Test needs nbd-server... Skipping"
return 1
fi
@ -208,10 +209,6 @@ make_encrypted_root() { @@ -208,10 +209,6 @@ make_encrypted_root() {
(
cd "$initdir" || exit
mkdir -p dev sys proc etc run 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 \
@ -242,10 +239,7 @@ make_encrypted_root() { @@ -242,10 +239,7 @@ make_encrypted_root() {
. "$basedir"/dracut-init.sh
(
cd "$initdir" || exit
mkdir -p dev sys proc etc tmp var run 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 dev sys proc etc tmp var run root
ln -s ../run var/run
)
inst_multiple mkfs.ext3 poweroff cp umount dd sync
@ -296,10 +290,6 @@ make_client_root() { @@ -296,10 +290,6 @@ make_client_root() {
(
cd "$initdir" || exit
mkdir -p dev sys proc etc run 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 ls shutdown poweroff stty cat ps ln ip \
dmesg mkdir cp ping dd mount sync
@ -315,7 +305,7 @@ make_client_root() { @@ -315,7 +305,7 @@ make_client_root() {

inst ./client-init.sh /sbin/init
inst_simple /etc/os-release
inst /etc/nsswitch.conf /etc/nsswitch.conf
inst_multiple -o {,/usr}/etc/nsswitch.conf
inst /etc/passwd /etc/passwd
inst /etc/group /etc/group
for i in /usr/lib*/libnss_files* /lib*/libnss_files*; do
@ -395,28 +385,34 @@ bs = 4096 @@ -395,28 +385,34 @@ bs = 4096
EOF
inst_multiple sh ls shutdown poweroff stty cat ps ln ip \
dmesg mkdir cp ping grep \
sleep nbd-server chmod modprobe vi
sleep nbd-server chmod modprobe vi pidof
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f ${_terminfodir}/l/linux ] && break
done
inst_multiple -o ${_terminfodir}/l/linux
instmods af_packet
instmods nfsd sunrpc ipv6 lockd af_packet 8021q ipvlan macvlan
type -P dhcpd > /dev/null && inst_multiple dhcpd
[ -x /usr/sbin/dhcpd3 ] && inst /usr/sbin/dhcpd3 /usr/sbin/dhcpd
inst ./server-init.sh /sbin/init
inst_simple /etc/os-release
inst ./hosts /etc/hosts
inst ./dhcpd.conf /etc/dhcpd.conf
inst /etc/nsswitch.conf /etc/nsswitch.conf
inst_multiple -o {,/usr}/etc/nsswitch.conf
inst /etc/passwd /etc/passwd
inst /etc/group /etc/group
for i in /usr/lib*/libnss_files* /lib*/libnss_files*; do
[ -e "$i" ] || continue
inst "$i"
done
_nsslibs=$(
cat "$dracutsysrootdir"/{,usr/}etc/nsswitch.conf 2> /dev/null \
| sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' \
| tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|'
)
_nsslibs=${_nsslibs#|}
_nsslibs=${_nsslibs%|}

inst_libdir_file -n "$_nsslibs" 'libnss_*.so*'

cp -a /etc/ld.so.conf* "$initdir"/etc
ldconfig -r "$initdir"
dracut_kernel_post
)

# second, install the files needed to make the root filesystem
@ -467,6 +463,7 @@ test_setup() { @@ -467,6 +463,7 @@ test_setup() {
# Make the test image
(
# shellcheck disable=SC2031
# shellcheck disable=SC2030
export initdir=$TESTDIR/overlay
# shellcheck disable=SC1090
. "$basedir"/dracut-init.sh
@ -483,20 +480,31 @@ test_setup() { @@ -483,20 +480,31 @@ test_setup() {
mkdir -p "$initdir"/etc
echo "luks-$ID_FS_UUID /dev/nbd0 /etc/key" > "$initdir"/etc/crypttab
echo -n test > "$initdir"/etc/key
inst_simple ./client.link /etc/systemd/network/01-client.link
)

"$basedir"/dracut.sh -l -i "$TESTDIR"/overlay / \
-a "udev-rules base rootfs-block fs-lib debug kernel-modules" \
-d "af_packet piix ide-gd_mod ata_piix ext3 sd_mod e1000 drbg" \
--no-hostonly-cmdline -N \
-f "$TESTDIR"/initramfs.server "$KVERSION" || return 1

"$basedir"/dracut.sh -l -i "$TESTDIR"/overlay / \
-o "plymouth dash iscsi nfs ${OMIT_NETWORK}" \
-a "debug watchdog ${USE_NETWORK}" \
-d "af_packet piix ide-gd_mod ata_piix ext3 ext3 sd_mod e1000 i6300esb ib700wdt" \
--no-hostonly-cmdline -N \
-f "$TESTDIR"/initramfs.testing "$KVERSION" || return 1

(
# shellcheck disable=SC2031
export initdir="$TESTDIR"/overlay
# shellcheck disable=SC1090
. "$basedir"/dracut-init.sh
rm "$initdir"/etc/systemd/network/01-client.link
inst_simple ./server.link /etc/systemd/network/01-server.link
inst_hook pre-mount 99 ./wait-if-server.sh
)
"$basedir"/dracut.sh -l -i "$TESTDIR"/overlay / \
-a "udev-rules base rootfs-block fs-lib debug kernel-modules network network-legacy" \
-d "af_packet piix ide-gd_mod ata_piix ext3 sd_mod e1000 drbg" \
--no-hostonly-cmdline -N \
-f "$TESTDIR"/initramfs.server "$KVERSION" || return 1

rm -rf -- "$TESTDIR"/overlay
}

kill_server() {

3
test/TEST-40-NBD/wait-if-server.sh

@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
#!/bin/sh
. /lib/net-lib.sh
wait_for_if_link enx525400123456

6
test/TEST-50-MULTINIC/client-init.sh

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
#!/bin/sh
. /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

@ -9,6 +9,9 @@ export TERM=linux @@ -9,6 +9,9 @@ export TERM=linux
export PS1='initramfs-test:\w\$ '
stty sane
echo "made it to the rootfs! Powering down."

set -x

for i in /sys/class/net/*; do
# booting with network-manager module
state=/run/NetworkManager/devices/$(cat "$i"/ifindex)
@ -17,6 +20,7 @@ for i in /sys/class/net/*; do @@ -17,6 +20,7 @@ for i in /sys/class/net/*; do
ip link show "$i" | grep -q master && continue
IFACES="${IFACES}${i} "
done

for i in /run/initramfs/net.*.did-setup; do
# booting with network-legacy module
[ -f "$i" ] || continue

6
test/TEST-50-MULTINIC/client.link

@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
[Match]
OriginalName=*

[Link]
NamePolicy=keep kernel database onboard slot path
MACAddressPolicy=keep

6
test/TEST-50-MULTINIC/create-root.sh

@ -8,9 +8,10 @@ for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do @@ -8,9 +8,10 @@ for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
done
rm -f -- /etc/lvm/lvm.conf
udevadm control --reload
set -e

udevadm settle

set -ex

mkfs.ext3 -L dracut /dev/disk/by-id/ata-disk_root
mkdir -p /root
mount /dev/disk/by-id/ata-disk_root /root
@ -18,4 +19,5 @@ cp -a -t /root /source/* @@ -18,4 +19,5 @@ cp -a -t /root /source/*
mkdir -p /root/run
umount /root
echo "dracut-root-block-created" | dd oflag=direct,dsync of=/dev/disk/by-id/ata-disk_marker
sync
poweroff -f

23
test/TEST-50-MULTINIC/server-init.sh

@ -1,10 +1,10 @@ @@ -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
@ -48,14 +48,12 @@ linkup() { @@ -48,14 +48,12 @@ 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 enx525401123456

: > /dev/watchdog
ip addr add 127.0.0.1/8 dev lo
linkup lo

ip addr add 192.168.50.1/24 dev enp0s1
linkup enp0s1
ip link set lo up
ip addr add 192.168.50.1/24 dev enx525401123456
linkup enx525401123456

: > /dev/watchdog
modprobe af_packet
@ -79,20 +77,21 @@ rpc.nfsd @@ -79,20 +77,21 @@ rpc.nfsd
: > /dev/watchdog
rpc.mountd
: > /dev/watchdog
rpc.idmapd -S
rpc.idmapd
: > /dev/watchdog
exportfs -r
: > /dev/watchdog

mkdir -p /var/lib/dhcpd
: > /var/lib/dhcpd/dhcpd.leases

: > /dev/watchdog
chmod 777 /var/lib/dhcpd/dhcpd.leases
: > /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 /

6
test/TEST-50-MULTINIC/server.link

@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
[Match]
OriginalName=*

[Link]
NamePolicy=mac
MACAddressPolicy=keep

127
test/TEST-50-MULTINIC/test.sh

@ -14,7 +14,7 @@ TEST_DESCRIPTION="root filesystem on NFS with multiple nics with $USE_NETWORK" @@ -14,7 +14,7 @@ TEST_DESCRIPTION="root filesystem on NFS with multiple nics with $USE_NETWORK"
KVERSION=${KVERSION-$(uname -r)}

# Uncomment this to debug failures
#DEBUGFAIL="rd.shell rd.break"
#DEBUGFAIL="loglevel=7 rd.shell rd.break"
#SERIAL="tcp:127.0.0.1:9999"

run_server() {
@ -32,7 +32,7 @@ run_server() { @@ -32,7 +32,7 @@ run_server() {
-net nic,macaddr=52:54:01:12:34:56,model=e1000 \
-serial "${SERIAL:-"file:$TESTDIR/server.log"}" \
-watchdog i6300esb -watchdog-action poweroff \
-append "panic=1 hung_task_panic=1 oops=panic softlockup_panic=1 systemd.crash_reboot loglevel=7 root=LABEL=dracut rootfstype=ext3 rw console=ttyS0,115200n81 selinux=0" \
-append "panic=1 hung_task_panic=1 oops=panic softlockup_panic=1 systemd.crash_reboot root=LABEL=dracut rootfstype=ext3 rw console=ttyS0,115200n81 selinux=0" \
-initrd "$TESTDIR"/initramfs.server \
-pidfile "$TESTDIR"/server.pid -daemonize || return 1

@ -70,6 +70,10 @@ client_test() { @@ -70,6 +70,10 @@ client_test() {
declare -i disk_index=0
qemu_add_drive_args disk_index disk_args "$TESTDIR"/marker.img marker

if dhclient --help 2>&1 | grep -q -F -- '--timeout' 2> /dev/null; then
cmdline="$cmdline rd.net.timeout.dhcp=3"
fi

# Invoke KVM and/or QEMU to actually create the target filesystem.
"$testdir"/run-qemu \
"${disk_args[@]}" \
@ -82,7 +86,7 @@ client_test() { @@ -82,7 +86,7 @@ client_test() {
-device e1000,netdev=n1,mac=52:54:00:12:34:98 \
-device e1000,netdev=n2,mac=52:54:00:12:34:99 \
-watchdog i6300esb -watchdog-action poweroff \
-append "quiet rd.net.timeout.dhcp=3 panic=1 hung_task_panic=1 oops=panic softlockup_panic=1 systemd.crash_reboot rd.shell=0 $cmdline $DEBUGFAIL rd.retry=5 ro console=ttyS0,115200n81 selinux=0 init=/sbin/init rd.debug systemd.log_target=console" \
-append "quiet panic=1 hung_task_panic=1 oops=panic softlockup_panic=1 systemd.crash_reboot rd.shell=0 $cmdline $DEBUGFAIL rd.retry=5 ro console=ttyS0,115200n81 selinux=0 init=/sbin/init rd.debug systemd.log_target=console" \
-initrd "$TESTDIR"/initramfs.testing || return 1

{
@ -180,7 +184,9 @@ test_client() { @@ -180,7 +184,9 @@ test_client() {
}

test_setup() {
kernel=$KVERSION
export kernel=$KVERSION
export srcmods="/lib/modules/$kernel/"
rm -rf -- "$TESTDIR"/overlay
(
mkdir -p "$TESTDIR"/overlay/source
# shellcheck disable=SC2030
@ -190,61 +196,53 @@ test_setup() { @@ -190,61 +196,53 @@ test_setup() {

(
cd "$initdir" || exit
mkdir -p -- dev sys proc run var/run etc tmp var/lib/{dhcpd,rpcbind}
mkdir -p -- var/lib/nfs/{v4recovery,rpc_pipefs}
chmod 777 -- var/lib/rpcbind var/lib/nfs
mkdir -p dev sys proc run etc var/run tmp var/lib/{dhcpd,rpcbind}
mkdir -p var/lib/nfs/{v4recovery,rpc_pipefs}
chmod 777 var/lib/rpcbind var/lib/nfs
)

for _f in modules.builtin.bin modules.builtin; do
[[ -f $srcmods/$_f ]] && break
done || {
dfatal "No modules.builtin.bin and modules.builtin found!"
return 1
}

for _f in modules.builtin.bin modules.builtin modules.order; do
[[ -f $srcmods/$_f ]] && inst_simple "$srcmods/$_f" "/lib/modules/$kernel/$_f"
done

inst_multiple sh ls shutdown poweroff stty cat ps ln ip \
dmesg mkdir cp ping exportfs \
modprobe rpc.nfsd rpc.mountd showmount tcpdump \
/etc/services sleep mount chmod
sleep mount chmod rm
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[ -f "${_terminfodir}"/l/linux ] && break
if [ -f "${_terminfodir}"/l/linux ]; then
inst_multiple -o "${_terminfodir}"/l/linux
break
fi
done
inst_multiple -o "${_terminfodir}"/l/linux
type -P portmap > /dev/null && inst_multiple portmap
type -P rpcbind > /dev/null && inst_multiple rpcbind
[ -f /etc/netconfig ] && inst_multiple /etc/netconfig
type -P dhcpd > /dev/null && inst_multiple dhcpd
[ -x /usr/sbin/dhcpd3 ] && inst /usr/sbin/dhcpd3 /usr/sbin/dhcpd
instmods nfsd sunrpc ipv6 lockd af_packet
inst_simple /etc/os-release
inst ./server-init.sh /sbin/init
inst_simple /etc/os-release
inst ./hosts /etc/hosts
inst ./exports /etc/exports
inst ./dhcpd.conf /etc/dhcpd.conf
inst_multiple /etc/nsswitch.conf /etc/rpc /etc/protocols

inst_multiple -o {,/usr}/etc/nsswitch.conf {,/usr}/etc/rpc \
{,/usr}/etc/protocols {,/usr}/etc/services
inst_multiple rpc.idmapd /etc/idmapd.conf

inst_libdir_file 'libnfsidmap_nsswitch.so*'
inst_libdir_file 'libnfsidmap/*.so*'
inst_libdir_file 'libnfsidmap*.so*'

_nsslibs=$(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' /etc/nsswitch.conf \
| tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
_nsslibs=$(
cat "$dracutsysrootdir"/{,usr/}etc/nsswitch.conf 2> /dev/null \
| sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' \
| tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|'
)
_nsslibs=${_nsslibs#|}
_nsslibs=${_nsslibs%|}

inst_libdir_file -n "$_nsslibs" 'libnss_*.so*'

inst /etc/nsswitch.conf /etc/nsswitch.conf
inst /etc/passwd /etc/passwd
inst /etc/group /etc/group

cp -a -- /etc/ld.so.conf* "$initdir"/etc
cp -a /etc/ld.so.conf* "$initdir"/etc
ldconfig -r "$initdir"
dracut_kernel_post
)
@ -256,22 +254,20 @@ test_setup() { @@ -256,22 +254,20 @@ test_setup() {
export initdir=$TESTDIR/overlay/source/nfs/client
# shellcheck disable=SC1090
. "$basedir"/dracut-init.sh

(
cd "$initdir" || exit
mkdir -p dev sys proc etc run
mkdir -p var/lib/nfs/rpc_pipefs
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 dev sys proc etc run root usr var/lib/nfs/rpc_pipefs
)
inst_multiple sh shutdown poweroff stty cat ps ln ip \
mount dmesg mkdir cp ping grep ls dd sync

inst_multiple sh shutdown poweroff stty cat ps ln ip dd \
mount dmesg mkdir cp ping grep setsid ls vi less cat sync
for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
[[ -f ${_terminfodir}/l/linux ]] && break
if [ -f "${_terminfodir}"/l/linux ]; then
inst_multiple -o "${_terminfodir}"/l/linux
break
fi
done
inst_multiple -o "${_terminfodir}"/l/linux
inst_simple /etc/os-release

inst_simple "${basedir}/modules.d/99base/dracut-lib.sh" "/lib/dracut-lib.sh"
inst_binary "${basedir}/dracut-util" "/usr/bin/dracut-util"
@ -279,23 +275,25 @@ test_setup() { @@ -279,23 +275,25 @@ test_setup() {
ln -s dracut-util "${initdir}/usr/bin/dracut-getargs"

inst ./client-init.sh /sbin/init
inst /etc/nsswitch.conf /etc/nsswitch.conf
inst_simple /etc/os-release
inst_multiple -o {,/usr}/etc/nsswitch.conf
inst /etc/passwd /etc/passwd
inst /etc/group /etc/group

inst_multiple rpc.idmapd /etc/idmapd.conf
inst_libdir_file 'libnfsidmap_nsswitch.so*'
inst_libdir_file 'libnfsidmap/*.so*'
inst_libdir_file 'libnfsidmap*.so*'

_nsslibs=$(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' -- /etc/nsswitch.conf \
| tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
_nsslibs=$(
cat "$dracutsysrootdir"/{,usr/}etc/nsswitch.conf 2> /dev/null \
| sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' \
| tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|'
)
_nsslibs=${_nsslibs#|}
_nsslibs=${_nsslibs%|}

inst_libdir_file -n "$_nsslibs" 'libnss_*.so*'

cp -a -- /etc/ld.so.conf* "$initdir"/etc
cp -a /etc/ld.so.conf* "$initdir"/etc
ldconfig -r "$initdir"
)

@ -320,7 +318,7 @@ test_setup() { @@ -320,7 +318,7 @@ test_setup() {
--nomdadmconf \
--no-hostonly-cmdline -N \
-f "$TESTDIR"/initramfs.makeroot "$KVERSION" || return 1
rm -fr "$TESTDIR"/overlay
rm -rf -- "$TESTDIR"/overlay

dd if=/dev/zero of="$TESTDIR"/server.img bs=1MiB count=120
dd if=/dev/zero of="$TESTDIR"/marker.img bs=1MiB count=1
@ -340,31 +338,42 @@ test_setup() { @@ -340,31 +338,42 @@ test_setup() {
# Make an overlay with needed tools for the test harness
(
# shellcheck disable=SC2031
# shellcheck disable=SC2030
export initdir="$TESTDIR"/overlay
mkdir -p "$TESTDIR"/overlay
# shellcheck disable=SC1090
. "$basedir"/dracut-init.sh
inst_multiple poweroff shutdown
inst_hook shutdown-emergency 000 ./hard-off.sh
inst_hook emergency 000 ./hard-off.sh
inst_simple ./99-default.link /etc/systemd/network/99-default.link
inst_simple ./client.link /etc/systemd/network/01-client.link

inst_binary awk
inst_hook pre-pivot 85 "$basedir/modules.d/45ifcfg/write-ifcfg.sh"
)
# Make client's dracut image
"$basedir"/dracut.sh -l -i "$TESTDIR"/overlay / \
-o "ifcfg plymouth dash ${OMIT_NETWORK}" \
-a "debug watchdog ${USE_NETWORK}" \
--no-hostonly-cmdline -N \
-f "$TESTDIR"/initramfs.testing "$KVERSION" || return 1

(
# shellcheck disable=SC2031
export initdir="$TESTDIR"/overlay
# shellcheck disable=SC1090
. "$basedir"/dracut-init.sh
rm "$initdir"/etc/systemd/network/01-client.link
inst_simple ./server.link /etc/systemd/network/01-server.link
inst_hook pre-mount 99 ./wait-if-server.sh
)
# Make server's dracut image
"$basedir"/dracut.sh \
-l -i "$TESTDIR"/overlay / \
-m "dash udev-rules base rootfs-block fs-lib debug kernel-modules watchdog qemu" \
"$basedir"/dracut.sh -l -i "$TESTDIR"/overlay / \
-m "dash udev-rules base rootfs-block fs-lib debug kernel-modules watchdog qemu network network-legacy" \
-d "af_packet piix ide-gd_mod ata_piix ext3 sd_mod nfsv2 nfsv3 nfsv4 nfs_acl nfs_layout_nfsv41_files nfsd e1000 i6300esb ib700wdt" \
--no-hostonly-cmdline -N \
-f "$TESTDIR"/initramfs.server "$KVERSION" || return 1

# Make client's dracut image
"$basedir"/dracut.sh \
-l -i "$TESTDIR"/overlay / \
-o "plymouth ${OMIT_NETWORK}" \
-a "debug ${USE_NETWORK}" \
-d "af_packet piix sd_mod sr_mod ata_piix ide-gd_mod e1000 nfsv2 nfsv3 nfsv4 nfs_acl nfs_layout_nfsv41_files sunrpc i6300esb ib700wdt" \
--no-hostonly-cmdline -N \
-f "$TESTDIR"/initramfs.testing "$KVERSION" || return 1
}

kill_server() {

3
test/TEST-50-MULTINIC/wait-if-server.sh

@ -0,0 +1,3 @@ @@ -0,0 +1,3 @@
#!/bin/sh
. /lib/net-lib.sh
wait_for_if_link enx525401123456

2
test/TEST-60-BONDBRIDGEVLANIFCFG/client-init.sh

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
#!/bin/sh
exec > /dev/console 2>&1
export PATH=/sbin:/bin:/usr/sbin:/usr/bin
export PATH=/usr/sbin:/usr/bin:/sbin:/bin
strstr() { [ "${1#*$2*}" != "$1" ]; }
CMDLINE=$(while read -r line; do echo "$line"; done < /proc/cmdline)
export TERM=linux

6
test/TEST-60-BONDBRIDGEVLANIFCFG/client.link

@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
[Match]
OriginalName=*

[Link]
NamePolicy=keep kernel database onboard slot path
MACAddressPolicy=keep

2
test/TEST-60-BONDBRIDGEVLANIFCFG/server-init.sh

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
#!/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\$ '
stty sane

6
test/TEST-60-BONDBRIDGEVLANIFCFG/server.link

@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
[Match]
OriginalName=*

[Link]
NamePolicy=mac
MACAddressPolicy=keep

24
test/TEST-60-BONDBRIDGEVLANIFCFG/test.sh

@ -211,6 +211,7 @@ test_setup() { @@ -211,6 +211,7 @@ test_setup() {
dd if=/dev/zero of="$TESTDIR"/server.ext3 bs=1M count=120

kernel=$KVERSION
rm -rf -- "$TESTDIR"/overlay
(
mkdir -p "$TESTDIR"/overlay/source
# shellcheck disable=SC2030
@ -255,7 +256,7 @@ test_setup() { @@ -255,7 +256,7 @@ test_setup() {
inst ./hosts /etc/hosts
inst ./exports /etc/exports
inst ./dhcpd.conf /etc/dhcpd.conf
inst_multiple /etc/nsswitch.conf /etc/rpc /etc/protocols
inst_multiple -o {,/usr}/etc/nsswitch.conf {,/usr}/etc/rpc {,/usr}/etc/protocols

inst_multiple rpc.idmapd /etc/idmapd.conf

@ -263,14 +264,16 @@ test_setup() { @@ -263,14 +264,16 @@ test_setup() {
inst_libdir_file 'libnfsidmap/*.so*'
inst_libdir_file 'libnfsidmap*.so*'

_nsslibs=$(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' /etc/nsswitch.conf \
| tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
_nsslibs=$(
cat "$dracutsysrootdir"/{,usr/}etc/nsswitch.conf 2> /dev/null \
| sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' \
| tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|'
)
_nsslibs=${_nsslibs#|}
_nsslibs=${_nsslibs%|}

inst_libdir_file -n "$_nsslibs" 'libnss_*.so*'

inst /etc/nsswitch.conf /etc/nsswitch.conf
inst /etc/passwd /etc/passwd
inst /etc/group /etc/group

@ -299,7 +302,7 @@ test_setup() { @@ -299,7 +302,7 @@ test_setup() {
mkdir -p -- dev sys proc etc run
mkdir -p -- var/lib/nfs/rpc_pipefs
)
inst /etc/nsswitch.conf /etc/nsswitch.conf
inst_multiple -o {,/usr}/etc/nsswitch.conf {,/usr}/etc/rpc {,/usr}/etc/protocols
inst /etc/passwd /etc/passwd
inst /etc/group /etc/group

@ -308,8 +311,11 @@ test_setup() { @@ -308,8 +311,11 @@ test_setup() {
inst_libdir_file 'libnfsidmap/*.so*'
inst_libdir_file 'libnfsidmap*.so*'

_nsslibs=$(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' -- /etc/nsswitch.conf \
| tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
_nsslibs=$(
cat "$dracutsysrootdir"/{,usr/}etc/nsswitch.conf 2> /dev/null \
| sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' \
| tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|'
)
_nsslibs=${_nsslibs#|}
_nsslibs=${_nsslibs%|}

@ -358,13 +364,13 @@ test_setup() { @@ -358,13 +364,13 @@ test_setup() {
. "$basedir"/dracut-init.sh
inst_multiple poweroff shutdown
inst_hook emergency 000 ./hard-off.sh
inst_simple ./client.link /etc/systemd/network/01-client.link
)
# Make client's dracut image
"$basedir"/dracut.sh -l -i "$TESTDIR"/overlay / \
--no-early-microcode \
-o "plymouth ${OMIT_NETWORK}" \
-a "debug ${USE_NETWORK}" \
-d "ipvlan macvlan af_packet piix sd_mod sr_mod ata_piix ide-gd_mod virtio-net nfsv2 nfsv3 nfsv4 nfs_acl nfs_layout_nfsv41_files sunrpc i6300esb ib700wdt" \
--no-hostonly-cmdline -N \
-f "$TESTDIR"/initramfs.testing "$KVERSION" || return 1

@ -373,7 +379,7 @@ test_setup() { @@ -373,7 +379,7 @@ test_setup() {
export initdir="$TESTDIR"/overlay
# shellcheck disable=SC1090
. "$basedir"/dracut-init.sh
inst_simple ./99-default.link /etc/systemd/network/99-default.link
inst_simple ./server.link /etc/systemd/network/01-server.link
inst_hook pre-mount 99 ./wait-if-server.sh
)
# Make server's dracut image

2
test/run-qemu

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
# Check which virtualization technology to use
# We prefer kvm, kqemu, userspace in that order.

export PATH=/sbin:/bin:/usr/sbin:/usr/bin
export PATH=/usr/sbin:/usr/bin:/sbin:/bin

[[ -x /usr/bin/qemu ]] && BIN=/usr/bin/qemu && ARGS=(-cpu max)
(lsmod | grep -q '^kqemu ') && BIN=/usr/bin/qemu && ARGS=(-kernel-kqemu -cpu host)

2
test/test-functions

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
#!/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
PATH=/usr/sbin:/usr/bin:/sbin:/bin
export PATH

# shellcheck disable=SC1090

Loading…
Cancel
Save