d4a4eb
From 4e10601254bb20891dc2919416d7151583678c3d Mon Sep 17 00:00:00 2001
d4a4eb
From: Lubomir Rintel <lkundrak@v3.sk>
d4a4eb
Date: Mon, 10 Jun 2019 16:04:18 +0200
d4a4eb
Subject: [PATCH] test: copy BONDBRIDGETEAMVLAN to IFCFG
d4a4eb
d4a4eb
The IFCFG test will make sure the network-legacy plugin keeps writing
d4a4eb
out correct ifcfg files.
d4a4eb
d4a4eb
This is a separate commit so that actual changes are visible in the
d4a4eb
following one.
d4a4eb
d4a4eb
(cherry picked from commit 70787ab61957741a05e4046bad49758c4e9bc1cc)
d4a4eb
---
d4a4eb
 test/TEST-60-IFCFG/99-idesymlinks.rules |   8 +
d4a4eb
 test/TEST-60-IFCFG/Makefile             |  10 +
d4a4eb
 test/TEST-60-IFCFG/client-init.sh       |  22 +++
d4a4eb
 test/TEST-60-IFCFG/dhcpd.conf           |  27 +++
d4a4eb
 test/TEST-60-IFCFG/exports              |   1 +
d4a4eb
 test/TEST-60-IFCFG/finished-false.sh    |   2 +
d4a4eb
 test/TEST-60-IFCFG/hard-off.sh          |   3 +
d4a4eb
 test/TEST-60-IFCFG/hosts                |   5 +
d4a4eb
 test/TEST-60-IFCFG/server-init.sh       | 120 ++++++++++++
d4a4eb
 test/TEST-60-IFCFG/test.sh              | 336 ++++++++++++++++++++++++++++++++
d4a4eb
 10 files changed, 534 insertions(+)
d4a4eb
d4a4eb
diff --git a/test/TEST-60-IFCFG/99-idesymlinks.rules b/test/TEST-60-IFCFG/99-idesymlinks.rules
d4a4eb
new file mode 100644
d4a4eb
index 00000000..d557790a
d4a4eb
--- /dev/null
d4a4eb
+++ b/test/TEST-60-IFCFG/99-idesymlinks.rules
d4a4eb
@@ -0,0 +1,8 @@
d4a4eb
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hda", SYMLINK+="sda"
d4a4eb
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hda*", SYMLINK+="sda$env{MINOR}"
d4a4eb
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hdb", SYMLINK+="sdb"
d4a4eb
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hdb*", SYMLINK+="sdb$env{MINOR}"
d4a4eb
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hdc", SYMLINK+="sdc"
d4a4eb
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hdc*", SYMLINK+="sdc$env{MINOR}"
d4a4eb
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hdd", SYMLINK+="sdd"
d4a4eb
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hdd*", SYMLINK+="sdd$env{MINOR}"
d4a4eb
diff --git a/test/TEST-60-IFCFG/Makefile b/test/TEST-60-IFCFG/Makefile
d4a4eb
new file mode 100644
d4a4eb
index 00000000..aad27059
d4a4eb
--- /dev/null
d4a4eb
+++ b/test/TEST-60-IFCFG/Makefile
d4a4eb
@@ -0,0 +1,10 @@
d4a4eb
+all:
d4a4eb
+	@$(MAKE) -s --no-print-directory -C ../.. all
d4a4eb
+	@V=$(V) basedir=../.. testdir=../ ./test.sh --all
d4a4eb
+setup:
d4a4eb
+	@$(MAKE) --no-print-directory -C ../.. all
d4a4eb
+	@basedir=../.. testdir=../ ./test.sh --setup
d4a4eb
+clean:
d4a4eb
+	@basedir=../.. testdir=../ ./test.sh --clean
d4a4eb
+run:
d4a4eb
+	@basedir=../.. testdir=../ ./test.sh --run
d4a4eb
diff --git a/test/TEST-60-IFCFG/client-init.sh b/test/TEST-60-IFCFG/client-init.sh
d4a4eb
new file mode 100755
d4a4eb
index 00000000..8c33ff0f
d4a4eb
--- /dev/null
d4a4eb
+++ b/test/TEST-60-IFCFG/client-init.sh
d4a4eb
@@ -0,0 +1,22 @@
d4a4eb
+#!/bin/sh
d4a4eb
+exec >/dev/console 2>&1
d4a4eb
+export PATH=/sbin:/bin:/usr/sbin:/usr/bin
d4a4eb
+strstr() { [ "${1#*$2*}" != "$1" ]; }
d4a4eb
+CMDLINE=$(while read line; do echo $line;done < /proc/cmdline)
d4a4eb
+export TERM=linux
d4a4eb
+export PS1='initramfs-test:\w\$ '
d4a4eb
+stty sane
d4a4eb
+echo "made it to the rootfs! Powering down."
d4a4eb
+
d4a4eb
+(
d4a4eb
+    echo OK
d4a4eb
+    ip -o -4 address show scope global | while read n if rest; do echo $if;done | sort
d4a4eb
+    for i in /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-*; do
d4a4eb
+	echo $i
d4a4eb
+	grep -v 'UUID=' $i
d4a4eb
+    done
d4a4eb
+    echo EOF
d4a4eb
+) > /dev/sda
d4a4eb
+
d4a4eb
+strstr "$CMDLINE" "rd.shell" && sh -i
d4a4eb
+poweroff -f
d4a4eb
diff --git a/test/TEST-60-IFCFG/dhcpd.conf b/test/TEST-60-IFCFG/dhcpd.conf
d4a4eb
new file mode 100644
d4a4eb
index 00000000..e26bd60b
d4a4eb
--- /dev/null
d4a4eb
+++ b/test/TEST-60-IFCFG/dhcpd.conf
d4a4eb
@@ -0,0 +1,27 @@
d4a4eb
+ddns-update-style none;
d4a4eb
+
d4a4eb
+use-host-decl-names true;
d4a4eb
+
d4a4eb
+subnet 192.168.50.0 netmask 255.255.255.0 {
d4a4eb
+	option subnet-mask      255.255.255.0;
d4a4eb
+	option routers          192.168.50.1;
d4a4eb
+	next-server             192.168.50.1;
d4a4eb
+	server-identifier       192.168.50.1;
d4a4eb
+	option domain-name-servers 192.168.50.1;
d4a4eb
+	option domain-search "example.com";
d4a4eb
+	option domain-name "other.com";
d4a4eb
+	option root-path "nfs:192.168.50.1:/nfs/client";
d4a4eb
+	range 192.168.50.10 192.168.50.100;
d4a4eb
+}
d4a4eb
+
d4a4eb
+subnet 192.168.51.0 netmask 255.255.255.0 {
d4a4eb
+	option subnet-mask      255.255.255.0;
d4a4eb
+	option routers          192.168.51.1;
d4a4eb
+	next-server             192.168.51.1;
d4a4eb
+	server-identifier       192.168.51.1;
d4a4eb
+	option domain-name-servers 192.168.51.1;
d4a4eb
+	option domain-search "example.com";
d4a4eb
+	option domain-name "other.com";
d4a4eb
+	option root-path "nfs:192.168.51.1:/nfs/client";
d4a4eb
+	range 192.168.51.10 192.168.51.100;
d4a4eb
+}
d4a4eb
diff --git a/test/TEST-60-IFCFG/exports b/test/TEST-60-IFCFG/exports
d4a4eb
new file mode 100644
d4a4eb
index 00000000..ff5f29b1
d4a4eb
--- /dev/null
d4a4eb
+++ b/test/TEST-60-IFCFG/exports
d4a4eb
@@ -0,0 +1 @@
d4a4eb
+/nfs/client	192.168.50.0/24(rw,insecure,no_subtree_check,no_root_squash)
d4a4eb
diff --git a/test/TEST-60-IFCFG/finished-false.sh b/test/TEST-60-IFCFG/finished-false.sh
d4a4eb
new file mode 100755
d4a4eb
index 00000000..ecdbef95
d4a4eb
--- /dev/null
d4a4eb
+++ b/test/TEST-60-IFCFG/finished-false.sh
d4a4eb
@@ -0,0 +1,2 @@
d4a4eb
+#!/bin/sh
d4a4eb
+exit 1
d4a4eb
diff --git a/test/TEST-60-IFCFG/hard-off.sh b/test/TEST-60-IFCFG/hard-off.sh
d4a4eb
new file mode 100755
d4a4eb
index 00000000..12c3d5ac
d4a4eb
--- /dev/null
d4a4eb
+++ b/test/TEST-60-IFCFG/hard-off.sh
d4a4eb
@@ -0,0 +1,3 @@
d4a4eb
+#!/bin/sh
d4a4eb
+getarg rd.shell || poweroff -f
d4a4eb
+getarg failme && poweroff -f
d4a4eb
diff --git a/test/TEST-60-IFCFG/hosts b/test/TEST-60-IFCFG/hosts
d4a4eb
new file mode 100644
d4a4eb
index 00000000..d02a4e9b
d4a4eb
--- /dev/null
d4a4eb
+++ b/test/TEST-60-IFCFG/hosts
d4a4eb
@@ -0,0 +1,5 @@
d4a4eb
+127.0.0.1	localhost
d4a4eb
+192.168.50.1	server
d4a4eb
+192.168.50.100	client-if1
d4a4eb
+192.168.50.101	client-if2
d4a4eb
+192.168.50.102	client-if3
d4a4eb
diff --git a/test/TEST-60-IFCFG/server-init.sh b/test/TEST-60-IFCFG/server-init.sh
d4a4eb
new file mode 100755
d4a4eb
index 00000000..b9f01c9b
d4a4eb
--- /dev/null
d4a4eb
+++ b/test/TEST-60-IFCFG/server-init.sh
d4a4eb
@@ -0,0 +1,120 @@
d4a4eb
+#!/bin/sh
d4a4eb
+exec </dev/console >/dev/console 2>&1
d4a4eb
+set -x
d4a4eb
+export PATH=/sbin:/bin:/usr/sbin:/usr/bin
d4a4eb
+export TERM=linux
d4a4eb
+export PS1='nfstest-server:\w\$ '
d4a4eb
+stty sane
d4a4eb
+echo "made it to the rootfs!"
d4a4eb
+echo server > /proc/sys/kernel/hostname
d4a4eb
+
d4a4eb
+wait_for_if_link() {
d4a4eb
+    local cnt=0
d4a4eb
+    local li
d4a4eb
+    while [ $cnt -lt 600 ]; do
d4a4eb
+        li=$(ip -o link show dev $1 2>/dev/null)
d4a4eb
+        [ -n "$li" ] && return 0
d4a4eb
+        sleep 0.1
d4a4eb
+        cnt=$(($cnt+1))
d4a4eb
+    done
d4a4eb
+    return 1
d4a4eb
+}
d4a4eb
+
d4a4eb
+wait_for_if_up() {
d4a4eb
+    local cnt=0
d4a4eb
+    local li
d4a4eb
+    while [ $cnt -lt 200 ]; do
d4a4eb
+        li=$(ip -o link show up dev $1)
d4a4eb
+        [ -n "$li" ] && return 0
d4a4eb
+        sleep 0.1
d4a4eb
+        cnt=$(($cnt+1))
d4a4eb
+    done
d4a4eb
+    return 1
d4a4eb
+}
d4a4eb
+
d4a4eb
+wait_for_route_ok() {
d4a4eb
+    local cnt=0
d4a4eb
+    while [ $cnt -lt 200 ]; do
d4a4eb
+        li=$(ip route show)
d4a4eb
+        [ -n "$li" ] && [ -z "${li##*$1*}" ] && return 0
d4a4eb
+        sleep 0.1
d4a4eb
+        cnt=$(($cnt+1))
d4a4eb
+    done
d4a4eb
+    return 1
d4a4eb
+}
d4a4eb
+
d4a4eb
+linkup() {
d4a4eb
+    wait_for_if_link $1 2>/dev/null\
d4a4eb
+     && ip link set $1 up 2>/dev/null\
d4a4eb
+     && wait_for_if_up $1 2>/dev/null
d4a4eb
+}
d4a4eb
+
d4a4eb
+modprobe --all -b -q 8021q ipvlan macvlan
d4a4eb
+>/dev/watchdog
d4a4eb
+ip addr add 127.0.0.1/8 dev lo
d4a4eb
+linkup lo
d4a4eb
+ip link set dev eth0 name ens3
d4a4eb
+ip addr add 192.168.50.1/24 dev ens3
d4a4eb
+linkup ens3
d4a4eb
+>/dev/watchdog
d4a4eb
+ip link set dev eth1 name ens4
d4a4eb
+ip link add dev ens4.1 link ens4 type vlan id 1
d4a4eb
+ip link add dev ens4.2 link ens4 type vlan id 2
d4a4eb
+ip link add dev ens4.3 link ens4 type vlan id 3
d4a4eb
+ip link add dev ens4.4 link ens4 type vlan id 4
d4a4eb
+ip addr add 192.168.54.1/24 dev ens4.1
d4a4eb
+ip addr add 192.168.55.1/24 dev ens4.2
d4a4eb
+ip addr add 192.168.56.1/24 dev ens4.3
d4a4eb
+ip addr add 192.168.57.1/24 dev ens4.4
d4a4eb
+linkup ens4
d4a4eb
+ip link set dev ens4.1 up
d4a4eb
+ip link set dev ens4.2 up
d4a4eb
+ip link set dev ens4.3 up
d4a4eb
+ip link set dev ens4.4 up
d4a4eb
+ip link set dev eth2 name ens5
d4a4eb
+ip addr add 192.168.51.1/24 dev ens5
d4a4eb
+linkup ens5
d4a4eb
+ip link set dev eth3 name ens6
d4a4eb
+linkup ens6
d4a4eb
+>/dev/watchdog
d4a4eb
+modprobe af_packet
d4a4eb
+> /dev/watchdog
d4a4eb
+modprobe sunrpc
d4a4eb
+>/dev/watchdog
d4a4eb
+mount -t rpc_pipefs sunrpc /var/lib/nfs/rpc_pipefs
d4a4eb
+>/dev/watchdog
d4a4eb
+[ -x /sbin/portmap ] && portmap
d4a4eb
+>/dev/watchdog
d4a4eb
+mkdir -p /run/rpcbind
d4a4eb
+[ -x /sbin/rpcbind ] && rpcbind
d4a4eb
+>/dev/watchdog
d4a4eb
+modprobe nfsd
d4a4eb
+>/dev/watchdog
d4a4eb
+mount -t nfsd nfsd /proc/fs/nfsd
d4a4eb
+>/dev/watchdog
d4a4eb
+exportfs -r
d4a4eb
+>/dev/watchdog
d4a4eb
+rpc.nfsd
d4a4eb
+>/dev/watchdog
d4a4eb
+rpc.mountd
d4a4eb
+>/dev/watchdog
d4a4eb
+rpc.idmapd
d4a4eb
+>/dev/watchdog
d4a4eb
+exportfs -r
d4a4eb
+>/dev/watchdog
d4a4eb
+>/var/lib/dhcpd/dhcpd.leases
d4a4eb
+>/dev/watchdog
d4a4eb
+chmod 777 /var/lib/dhcpd/dhcpd.leases
d4a4eb
+>/dev/watchdog
d4a4eb
+dhcpd -cf /etc/dhcpd.conf -lf /var/lib/dhcpd/dhcpd.leases ens3 ens5
d4a4eb
+#echo -n 'V' > /dev/watchdog
d4a4eb
+#sh -i
d4a4eb
+#tcpdump -i ens3
d4a4eb
+# Wait forever for the VM to die
d4a4eb
+echo "Serving NFS mounts"
d4a4eb
+while :; do
d4a4eb
+	sleep 10
d4a4eb
+	>/dev/watchdog
d4a4eb
+done
d4a4eb
+mount -n -o remount,ro /
d4a4eb
+poweroff -f
d4a4eb
diff --git a/test/TEST-60-IFCFG/test.sh b/test/TEST-60-IFCFG/test.sh
d4a4eb
new file mode 100755
d4a4eb
index 00000000..8c11a7d3
d4a4eb
--- /dev/null
d4a4eb
+++ b/test/TEST-60-IFCFG/test.sh
d4a4eb
@@ -0,0 +1,336 @@
d4a4eb
+#!/bin/bash
d4a4eb
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
d4a4eb
+# ex: ts=8 sw=4 sts=4 et filetype=sh
d4a4eb
+TEST_DESCRIPTION="root filesystem on NFS with bridging/bonding/vlan"
d4a4eb
+KVERSION=${KVERSION-$(uname -r)}
d4a4eb
+
d4a4eb
+# Uncomment this to debug failures
d4a4eb
+#DEBUGFAIL="rd.shell rd.break"
d4a4eb
+#DEBUGFAIL="rd.shell rd.break rd.debug"
d4a4eb
+#SERIAL="tcp:127.0.0.1:9999"
d4a4eb
+
d4a4eb
+run_server() {
d4a4eb
+    # Start server first
d4a4eb
+    echo "MULTINIC TEST SETUP: Starting DHCP/NFS server"
d4a4eb
+
d4a4eb
+    fsck -a "$TESTDIR"/server.ext3 || return 1
d4a4eb
+
d4a4eb
+    $testdir/run-qemu \
d4a4eb
+        -hda "$TESTDIR"/server.ext3 \
d4a4eb
+        -m 512M -smp 2 \
d4a4eb
+        -display none \
d4a4eb
+        -netdev socket,id=n0,listen=127.0.0.1:12370 \
d4a4eb
+        -netdev socket,id=n1,listen=127.0.0.1:12371 \
d4a4eb
+        -netdev socket,id=n2,listen=127.0.0.1:12372 \
d4a4eb
+        -netdev socket,id=n3,listen=127.0.0.1:12373 \
d4a4eb
+        -device e1000,netdev=n0,mac=52:54:01:12:34:56 \
d4a4eb
+        -device e1000,netdev=n1,mac=52:54:01:12:34:57 \
d4a4eb
+        -device e1000,netdev=n2,mac=52:54:01:12:34:58 \
d4a4eb
+        -device e1000,netdev=n3,mac=52:54:01:12:34:59 \
d4a4eb
+        ${SERIAL:+-serial "$SERIAL"} \
d4a4eb
+        ${SERIAL:--serial file:"$TESTDIR"/server.log} \
d4a4eb
+        -watchdog i6300esb -watchdog-action poweroff \
d4a4eb
+        -no-reboot \
d4a4eb
+        -append "panic=1 loglevel=7 root=/dev/sda rootfstype=ext3 rw console=ttyS0,115200n81 selinux=0 rd.debug" \
d4a4eb
+        -initrd "$TESTDIR"/initramfs.server \
d4a4eb
+        -pidfile "$TESTDIR"/server.pid -daemonize || return 1
d4a4eb
+    chmod 644 -- "$TESTDIR"/server.pid || return 1
d4a4eb
+
d4a4eb
+    # Cleanup the terminal if we have one
d4a4eb
+    tty -s && stty sane
d4a4eb
+
d4a4eb
+    echo Sleeping 10 seconds to give the server a head start
d4a4eb
+    sleep 10
d4a4eb
+}
d4a4eb
+
d4a4eb
+client_test() {
d4a4eb
+    local test_name="$1"
d4a4eb
+    local do_vlan13="$2"
d4a4eb
+    local cmdline="$3"
d4a4eb
+    local check="$4"
d4a4eb
+    local CONF
d4a4eb
+
d4a4eb
+    echo "CLIENT TEST START: $test_name"
d4a4eb
+
d4a4eb
+    [ "$do_vlan13" != "yes" ] && unset do_vlan13
d4a4eb
+
d4a4eb
+    # Need this so kvm-qemu will boot (needs non-/dev/zero local disk)
d4a4eb
+    if ! dd if=/dev/zero of="$TESTDIR"/client.img bs=1M count=1; then
d4a4eb
+        echo "Unable to make client sda image" 1>&2
d4a4eb
+        return 1
d4a4eb
+    fi
d4a4eb
+    if [[ $do_vlan13 ]]; then
d4a4eb
+        nic1=" -netdev socket,connect=127.0.0.1:12371,id=n1"
d4a4eb
+        nic3=" -netdev socket,connect=127.0.0.1:12373,id=n3"
d4a4eb
+    else
d4a4eb
+        nic1=" -netdev hubport,id=n1,hubid=2"
d4a4eb
+        nic3=" -netdev hubport,id=n3,hubid=3"
d4a4eb
+    fi
d4a4eb
+
d4a4eb
+    if $testdir/run-qemu --help | grep -qF -m1 'netdev hubport,id=str,hubid=n[,netdev=nd]' && echo OK; then
d4a4eb
+        $testdir/run-qemu \
d4a4eb
+            -hda "$TESTDIR"/client.img -m 512M -smp 2 -nographic \
d4a4eb
+            -netdev socket,connect=127.0.0.1:12370,id=s1 \
d4a4eb
+            -netdev hubport,hubid=1,id=h1,netdev=s1 \
d4a4eb
+            -netdev hubport,hubid=1,id=h2 -device e1000,mac=52:54:00:12:34:01,netdev=h2 \
d4a4eb
+            -netdev hubport,hubid=1,id=h3 -device e1000,mac=52:54:00:12:34:02,netdev=h3 \
d4a4eb
+            $nic1 -device e1000,mac=52:54:00:12:34:03,netdev=n1  \
d4a4eb
+            -netdev socket,connect=127.0.0.1:12372,id=n2 -device e1000,mac=52:54:00:12:34:04,netdev=n2 \
d4a4eb
+            $nic3 -device e1000,mac=52:54:00:12:34:05,netdev=n3 \
d4a4eb
+            -watchdog i6300esb -watchdog-action poweroff \
d4a4eb
+            -no-reboot \
d4a4eb
+            -append "panic=1 $cmdline rd.debug $DEBUGFAIL rd.retry=5 rw console=ttyS0,115200n81 selinux=0 init=/sbin/init" \
d4a4eb
+            -initrd "$TESTDIR"/initramfs.testing
d4a4eb
+    else
d4a4eb
+        $testdir/run-qemu \
d4a4eb
+            -hda "$TESTDIR"/client.img -m 512M -smp 2 -nographic \
d4a4eb
+            -net socket,vlan=0,connect=127.0.0.1:12370 \
d4a4eb
+            ${do_vlan13:+-net socket,vlan=1,connect=127.0.0.1:12371} \
d4a4eb
+            -net socket,vlan=2,connect=127.0.0.1:12372 \
d4a4eb
+            ${do_vlan13:+-net socket,vlan=3,connect=127.0.0.1:12373} \
d4a4eb
+            -net nic,vlan=0,macaddr=52:54:00:12:34:01,model=e1000 \
d4a4eb
+            -net nic,vlan=0,macaddr=52:54:00:12:34:02,model=e1000 \
d4a4eb
+            -net nic,vlan=1,macaddr=52:54:00:12:34:03,model=e1000 \
d4a4eb
+            -net nic,vlan=2,macaddr=52:54:00:12:34:04,model=e1000 \
d4a4eb
+            -net nic,vlan=3,macaddr=52:54:00:12:34:05,model=e1000 \
d4a4eb
+            -watchdog i6300esb -watchdog-action poweroff \
d4a4eb
+            -no-reboot \
d4a4eb
+            -append "panic=1 $cmdline rd.debug $DEBUGFAIL rd.retry=5 rw console=ttyS0,115200n81 selinux=0 init=/sbin/init" \
d4a4eb
+            -initrd "$TESTDIR"/initramfs.testing
d4a4eb
+    fi
d4a4eb
+
d4a4eb
+    { 
d4a4eb
+        read OK
d4a4eb
+        if [[ "$OK" != "OK" ]]; then
d4a4eb
+            echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]"
d4a4eb
+            return 1
d4a4eb
+        fi
d4a4eb
+
d4a4eb
+        while read line; do
d4a4eb
+            [[ $line == END ]] && break
d4a4eb
+            CONF+="$line "
d4a4eb
+        done
d4a4eb
+    } < "$TESTDIR"/client.img || return 1
d4a4eb
+
d4a4eb
+    if [[ "$check" != "$CONF" ]]; then
d4a4eb
+        echo "Expected: '$check'"
d4a4eb
+        echo
d4a4eb
+        echo
d4a4eb
+        echo "Got:      '$CONF'"
d4a4eb
+        echo "CLIENT TEST END: $test_name [FAILED - BAD CONF]"
d4a4eb
+        return 1
d4a4eb
+    fi
d4a4eb
+
d4a4eb
+    echo "CLIENT TEST END: $test_name [OK]"
d4a4eb
+    return 0
d4a4eb
+}
d4a4eb
+
d4a4eb
+
d4a4eb
+test_run() {
d4a4eb
+    if ! run_server; then
d4a4eb
+        echo "Failed to start server" 1>&2
d4a4eb
+        return 1
d4a4eb
+    fi
d4a4eb
+    test_client || { kill_server; return 1; }
d4a4eb
+}
d4a4eb
+
d4a4eb
+test_client() {
d4a4eb
+    client_test "Multiple VLAN" \
d4a4eb
+        "yes" \
d4a4eb
+        "
d4a4eb
+vlan=vlan0001:ens5
d4a4eb
+vlan=vlan2:ens5
d4a4eb
+vlan=ens5.3:ens5
d4a4eb
+vlan=ens5.0004:ens5
d4a4eb
+ip=ens3:dhcp
d4a4eb
+ip=192.168.54.101::192.168.54.1:24:test:vlan0001:none
d4a4eb
+ip=192.168.55.102::192.168.55.1:24:test:vlan2:none
d4a4eb
+ip=192.168.56.103::192.168.56.1:24:test:ens5.3:none
d4a4eb
+ip=192.168.57.104::192.168.57.1:24:test:ens5.0004:none
d4a4eb
+rd.neednet=1
d4a4eb
+root=nfs:192.168.50.1:/nfs/client bootdev=ens3
d4a4eb
+" \
d4a4eb
+    'ens3 ens5.0004 ens5.3 vlan0001 vlan2 /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens3 # Generated by dracut initrd NAME="ens3" DEVICE="ens3" ONBOOT=yes NETBOOT=yes IPV6INIT=yes BOOTPROTO=dhcp TYPE=Ethernet /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens5.0004 # Generated by dracut initrd NAME="ens5.0004" ONBOOT=yes NETBOOT=yes BOOTPROTO=none IPADDR="192.168.57.104" PREFIX="24" GATEWAY="192.168.57.1" TYPE=Vlan DEVICE="ens5.0004" VLAN=yes PHYSDEV="ens5" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens5.3 # Generated by dracut initrd NAME="ens5.3" ONBOOT=yes NETBOOT=yes BOOTPROTO=none IPADDR="192.168.56.103" PREFIX="24" GATEWAY="192.168.56.1" TYPE=Vlan DEVICE="ens5.3" VLAN=yes PHYSDEV="ens5" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-vlan0001 # Generated by dracut initrd NAME="vlan0001" ONBOOT=yes NETBOOT=yes BOOTPROTO=none IPADDR="192.168.54.101" PREFIX="24" GATEWAY="192.168.54.1" TYPE=Vlan DEVICE="vlan0001" VLAN=yes PHYSDEV="ens5" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-vlan2 # Generated by dracut initrd NAME="vlan2" ONBOOT=yes NETBOOT=yes BOOTPROTO=none IPADDR="192.168.55.102" PREFIX="24" GATEWAY="192.168.55.1" TYPE=Vlan DEVICE="vlan2" VLAN=yes PHYSDEV="ens5" EOF ' \
d4a4eb
+    || return 1
d4a4eb
+
d4a4eb
+    client_test "Multiple Bonds" \
d4a4eb
+        "yes" \
d4a4eb
+        "
d4a4eb
+bond=bond0:ens4,ens5
d4a4eb
+bond=bond1:ens6,ens7
d4a4eb
+ip=bond0:dhcp
d4a4eb
+ip=bond1:dhcp
d4a4eb
+rd.neednet=1
d4a4eb
+root=nfs:192.168.50.1:/nfs/client bootdev=bond0
d4a4eb
+" \
d4a4eb
+    'bond0 bond1 /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-bond0 # Generated by dracut initrd NAME="bond0" DEVICE="bond0" ONBOOT=yes NETBOOT=yes IPV6INIT=yes BOOTPROTO=dhcp BONDING_OPTS="" NAME="bond0" TYPE=Bond /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-bond1 # Generated by dracut initrd NAME="bond1" DEVICE="bond1" ONBOOT=yes NETBOOT=yes IPV6INIT=yes BOOTPROTO=dhcp BONDING_OPTS="" NAME="bond1" TYPE=Bond /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens4 # Generated by dracut initrd NAME="ens4" TYPE=Ethernet ONBOOT=yes NETBOOT=yes SLAVE=yes MASTER="bond0" DEVICE="ens4" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens5 # Generated by dracut initrd NAME="ens5" TYPE=Ethernet ONBOOT=yes NETBOOT=yes SLAVE=yes MASTER="bond0" DEVICE="ens5" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens6 # Generated by dracut initrd NAME="ens6" TYPE=Ethernet ONBOOT=yes NETBOOT=yes SLAVE=yes MASTER="bond1" DEVICE="ens6" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens7 # Generated by dracut initrd NAME="ens7" TYPE=Ethernet ONBOOT=yes NETBOOT=yes SLAVE=yes MASTER="bond1" DEVICE="ens7" EOF ' \
d4a4eb
+    || return 1
d4a4eb
+
d4a4eb
+    client_test "Multiple Bridges" \
d4a4eb
+        "no" \
d4a4eb
+        "
d4a4eb
+bridge=br0:ens4,ens5
d4a4eb
+bridge=br1:ens6,ens7
d4a4eb
+ip=br0:dhcp
d4a4eb
+ip=br1:dhcp
d4a4eb
+rd.neednet=1
d4a4eb
+root=nfs:192.168.50.1:/nfs/client bootdev=br0
d4a4eb
+" \
d4a4eb
+    'br0 br1 /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-br0 # Generated by dracut initrd NAME="br0" DEVICE="br0" ONBOOT=yes NETBOOT=yes IPV6INIT=yes BOOTPROTO=dhcp TYPE=Bridge NAME="br0" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-br1 # Generated by dracut initrd NAME="br1" DEVICE="br1" ONBOOT=yes NETBOOT=yes IPV6INIT=yes BOOTPROTO=dhcp TYPE=Bridge NAME="br1" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens4 # Generated by dracut initrd NAME="ens4" TYPE=Ethernet ONBOOT=yes NETBOOT=yes BRIDGE="br0" DEVICE="ens4" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens5 # Generated by dracut initrd NAME="ens5" TYPE=Ethernet ONBOOT=yes NETBOOT=yes BRIDGE="br0" DEVICE="ens5" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens6 # Generated by dracut initrd NAME="ens6" TYPE=Ethernet ONBOOT=yes NETBOOT=yes BRIDGE="br1" DEVICE="ens6" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens7 # Generated by dracut initrd NAME="ens7" TYPE=Ethernet ONBOOT=yes NETBOOT=yes BRIDGE="br1" DEVICE="ens7" EOF ' \
d4a4eb
+    || return 1
d4a4eb
+
d4a4eb
+    kill_server
d4a4eb
+    return 0
d4a4eb
+}
d4a4eb
+
d4a4eb
+test_setup() {
d4a4eb
+     # Make server root
d4a4eb
+    dd if=/dev/null of="$TESTDIR"/server.ext3 bs=1M seek=120
d4a4eb
+    mke2fs -j -F -- "$TESTDIR"/server.ext3
d4a4eb
+    mkdir -- "$TESTDIR"/mnt
d4a4eb
+    mount -o loop -- "$TESTDIR"/server.ext3 "$TESTDIR"/mnt
d4a4eb
+    kernel=$KVERSION
d4a4eb
+    (
d4a4eb
+        export initdir="$TESTDIR"/mnt
d4a4eb
+        . "$basedir"/dracut-init.sh
d4a4eb
+
d4a4eb
+        (
d4a4eb
+            cd "$initdir";
d4a4eb
+            mkdir -p -- dev sys proc run etc var/run tmp var/lib/{dhcpd,rpcbind}
d4a4eb
+            mkdir -p -- var/lib/nfs/{v4recovery,rpc_pipefs}
d4a4eb
+            chmod 777 -- var/lib/rpcbind var/lib/nfs
d4a4eb
+        )
d4a4eb
+
d4a4eb
+        for _f in modules.builtin.bin modules.builtin; do
d4a4eb
+            [[ $srcmods/$_f ]] && break
d4a4eb
+        done || {
d4a4eb
+            dfatal "No modules.builtin.bin and modules.builtin found!"
d4a4eb
+            return 1
d4a4eb
+        }
d4a4eb
+
d4a4eb
+        for _f in modules.builtin.bin modules.builtin modules.order; do
d4a4eb
+            [[ $srcmods/$_f ]] && inst_simple "$srcmods/$_f" "/lib/modules/$kernel/$_f"
d4a4eb
+        done
d4a4eb
+
d4a4eb
+        inst_multiple sh ls shutdown poweroff stty cat ps ln ip \
d4a4eb
+            dmesg mkdir cp ping exportfs \
d4a4eb
+            modprobe rpc.nfsd rpc.mountd showmount tcpdump \
d4a4eb
+            /etc/services sleep mount chmod
d4a4eb
+        for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
d4a4eb
+            [ -f "${_terminfodir}"/l/linux ] && break
d4a4eb
+        done
d4a4eb
+        inst_multiple -o "${_terminfodir}"/l/linux
d4a4eb
+        type -P portmap >/dev/null && inst_multiple portmap
d4a4eb
+        type -P rpcbind >/dev/null && inst_multiple rpcbind
d4a4eb
+        [ -f /etc/netconfig ] && inst_multiple /etc/netconfig
d4a4eb
+        type -P dhcpd >/dev/null && inst_multiple dhcpd
d4a4eb
+        [ -x /usr/sbin/dhcpd3 ] && inst /usr/sbin/dhcpd3 /usr/sbin/dhcpd
d4a4eb
+        instmods nfsd sunrpc ipv6 lockd af_packet 8021q ipvlan macvlan
d4a4eb
+        inst_simple /etc/os-release
d4a4eb
+        inst ./server-init.sh /sbin/init
d4a4eb
+        inst ./hosts /etc/hosts
d4a4eb
+        inst ./exports /etc/exports
d4a4eb
+        inst ./dhcpd.conf /etc/dhcpd.conf
d4a4eb
+        inst_multiple /etc/nsswitch.conf /etc/rpc /etc/protocols
d4a4eb
+
d4a4eb
+        inst_multiple rpc.idmapd /etc/idmapd.conf
d4a4eb
+
d4a4eb
+        inst_libdir_file 'libnfsidmap_nsswitch.so*'
d4a4eb
+        inst_libdir_file 'libnfsidmap/*.so*'
d4a4eb
+        inst_libdir_file 'libnfsidmap*.so*'
d4a4eb
+
d4a4eb
+        _nsslibs=$(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' /etc/nsswitch.conf \
d4a4eb
+            |  tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
d4a4eb
+        _nsslibs=${_nsslibs#|}
d4a4eb
+        _nsslibs=${_nsslibs%|}
d4a4eb
+
d4a4eb
+        inst_libdir_file -n "$_nsslibs" 'libnss_*.so*'
d4a4eb
+
d4a4eb
+        inst /etc/nsswitch.conf /etc/nsswitch.conf
d4a4eb
+        inst /etc/passwd /etc/passwd
d4a4eb
+        inst /etc/group /etc/group
d4a4eb
+
d4a4eb
+        cp -a -- /etc/ld.so.conf* "$initdir"/etc
d4a4eb
+        ldconfig -r "$initdir"
d4a4eb
+        dracut_kernel_post
d4a4eb
+    )
d4a4eb
+
d4a4eb
+    # Make client root inside server root
d4a4eb
+    (
d4a4eb
+        export initdir="$TESTDIR"/mnt/nfs/client
d4a4eb
+        . "$basedir"/dracut-init.sh
d4a4eb
+        inst_multiple sh shutdown poweroff stty cat ps ln ip \
d4a4eb
+            mount dmesg mkdir cp ping grep ls sort
d4a4eb
+        for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
d4a4eb
+            [[ -f ${_terminfodir}/l/linux ]] && break
d4a4eb
+        done
d4a4eb
+        inst_multiple -o "${_terminfodir}"/l/linux
d4a4eb
+        inst_simple /etc/os-release
d4a4eb
+        inst ./client-init.sh /sbin/init
d4a4eb
+        (
d4a4eb
+            cd "$initdir"
d4a4eb
+            mkdir -p -- dev sys proc etc run
d4a4eb
+            mkdir -p -- var/lib/nfs/rpc_pipefs
d4a4eb
+        )
d4a4eb
+        inst /etc/nsswitch.conf /etc/nsswitch.conf
d4a4eb
+        inst /etc/passwd /etc/passwd
d4a4eb
+        inst /etc/group /etc/group
d4a4eb
+
d4a4eb
+        inst_multiple rpc.idmapd /etc/idmapd.conf
d4a4eb
+        inst_libdir_file 'libnfsidmap_nsswitch.so*'
d4a4eb
+        inst_libdir_file 'libnfsidmap/*.so*'
d4a4eb
+        inst_libdir_file 'libnfsidmap*.so*'
d4a4eb
+
d4a4eb
+        _nsslibs=$(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' -- /etc/nsswitch.conf \
d4a4eb
+            |  tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
d4a4eb
+        _nsslibs=${_nsslibs#|}
d4a4eb
+        _nsslibs=${_nsslibs%|}
d4a4eb
+
d4a4eb
+        inst_libdir_file -n "$_nsslibs" 'libnss_*.so*'
d4a4eb
+
d4a4eb
+        cp -a -- /etc/ld.so.conf* "$initdir"/etc
d4a4eb
+        ldconfig -r "$initdir"
d4a4eb
+    )
d4a4eb
+
d4a4eb
+    umount "$TESTDIR"/mnt
d4a4eb
+    rm -fr -- "$TESTDIR"/mnt
d4a4eb
+
d4a4eb
+    # Make an overlay with needed tools for the test harness
d4a4eb
+    (
d4a4eb
+        export initdir="$TESTDIR"/overlay
d4a4eb
+        . "$basedir"/dracut-init.sh
d4a4eb
+        inst_multiple poweroff shutdown
d4a4eb
+        inst_hook emergency 000 ./hard-off.sh
d4a4eb
+        inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
d4a4eb
+    )
d4a4eb
+
d4a4eb
+    # Make server's dracut image
d4a4eb
+    $basedir/dracut.sh -l -i "$TESTDIR"/overlay / \
d4a4eb
+        --no-early-microcode \
d4a4eb
+        -m "udev-rules base rootfs-block fs-lib debug kernel-modules watchdog" \
d4a4eb
+        -d "ipvlan macvlan af_packet piix ide-gd_mod ata_piix ext3 sd_mod nfsv2 nfsv3 nfsv4 nfs_acl nfs_layout_nfsv41_files nfsd e1000 i6300esb ib700wdt" \
d4a4eb
+        --no-hostonly-cmdline -N \
d4a4eb
+        -f "$TESTDIR"/initramfs.server "$KVERSION" || return 1
d4a4eb
+
d4a4eb
+    # Make client's dracut image
d4a4eb
+    $basedir/dracut.sh -l -i "$TESTDIR"/overlay / \
d4a4eb
+        --no-early-microcode \
d4a4eb
+        -o "plymouth" \
d4a4eb
+        -a "debug" \
d4a4eb
+        -d "ipvlan macvlan 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" \
d4a4eb
+        --no-hostonly-cmdline -N \
d4a4eb
+        -f "$TESTDIR"/initramfs.testing "$KVERSION" || return 1
d4a4eb
+}
d4a4eb
+
d4a4eb
+kill_server() {
d4a4eb
+    if [[ -s "$TESTDIR"/server.pid ]]; then
d4a4eb
+        kill -TERM -- $(cat "$TESTDIR"/server.pid)
d4a4eb
+        rm -f -- "$TESTDIR"/server.pid
d4a4eb
+    fi
d4a4eb
+}
d4a4eb
+
d4a4eb
+test_cleanup() {
d4a4eb
+    kill_server
d4a4eb
+}
d4a4eb
+
d4a4eb
+. "$testdir"/test-functions
d4a4eb