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