18971c
From 323093b621c415cf0d04c48716d77cf9569850d6 Mon Sep 17 00:00:00 2001
18971c
From: Harald Hoyer <harald@redhat.com>
18971c
Date: Wed, 29 Jun 2016 15:51:42 +0200
18971c
Subject: [PATCH] test: add TEST-60-MTUMAC
18971c
18971c
test MTU and MACADDR setting
18971c
---
18971c
 test/TEST-60-MTUMAC/99-idesymlinks.rules |   8 +
18971c
 test/TEST-60-MTUMAC/Makefile             |  10 +
18971c
 test/TEST-60-MTUMAC/client-init.sh       |  22 ++
18971c
 test/TEST-60-MTUMAC/dhcpd.conf           |  15 ++
18971c
 test/TEST-60-MTUMAC/exports              |   1 +
18971c
 test/TEST-60-MTUMAC/finished-false.sh    |   2 +
18971c
 test/TEST-60-MTUMAC/hard-off.sh          |   3 +
18971c
 test/TEST-60-MTUMAC/hosts                |   5 +
18971c
 test/TEST-60-MTUMAC/server-init.sh       |  98 ++++++++
18971c
 test/TEST-60-MTUMAC/test.sh              | 282 +++++++++++++++++++++++
18971c
 10 files changed, 446 insertions(+)
18971c
 create mode 100644 test/TEST-60-MTUMAC/99-idesymlinks.rules
18971c
 create mode 100644 test/TEST-60-MTUMAC/Makefile
18971c
 create mode 100755 test/TEST-60-MTUMAC/client-init.sh
18971c
 create mode 100644 test/TEST-60-MTUMAC/dhcpd.conf
18971c
 create mode 100644 test/TEST-60-MTUMAC/exports
18971c
 create mode 100755 test/TEST-60-MTUMAC/finished-false.sh
18971c
 create mode 100755 test/TEST-60-MTUMAC/hard-off.sh
18971c
 create mode 100644 test/TEST-60-MTUMAC/hosts
18971c
 create mode 100755 test/TEST-60-MTUMAC/server-init.sh
18971c
 create mode 100755 test/TEST-60-MTUMAC/test.sh
18971c
18971c
diff --git a/test/TEST-60-MTUMAC/99-idesymlinks.rules b/test/TEST-60-MTUMAC/99-idesymlinks.rules
18971c
new file mode 100644
18971c
index 00000000..d557790a
18971c
--- /dev/null
18971c
+++ b/test/TEST-60-MTUMAC/99-idesymlinks.rules
18971c
@@ -0,0 +1,8 @@
18971c
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hda", SYMLINK+="sda"
18971c
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hda*", SYMLINK+="sda$env{MINOR}"
18971c
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hdb", SYMLINK+="sdb"
18971c
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hdb*", SYMLINK+="sdb$env{MINOR}"
18971c
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hdc", SYMLINK+="sdc"
18971c
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hdc*", SYMLINK+="sdc$env{MINOR}"
18971c
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hdd", SYMLINK+="sdd"
18971c
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hdd*", SYMLINK+="sdd$env{MINOR}"
18971c
diff --git a/test/TEST-60-MTUMAC/Makefile b/test/TEST-60-MTUMAC/Makefile
18971c
new file mode 100644
18971c
index 00000000..aad27059
18971c
--- /dev/null
18971c
+++ b/test/TEST-60-MTUMAC/Makefile
18971c
@@ -0,0 +1,10 @@
18971c
+all:
18971c
+	@$(MAKE) -s --no-print-directory -C ../.. all
18971c
+	@V=$(V) basedir=../.. testdir=../ ./test.sh --all
18971c
+setup:
18971c
+	@$(MAKE) --no-print-directory -C ../.. all
18971c
+	@basedir=../.. testdir=../ ./test.sh --setup
18971c
+clean:
18971c
+	@basedir=../.. testdir=../ ./test.sh --clean
18971c
+run:
18971c
+	@basedir=../.. testdir=../ ./test.sh --run
18971c
diff --git a/test/TEST-60-MTUMAC/client-init.sh b/test/TEST-60-MTUMAC/client-init.sh
18971c
new file mode 100755
18971c
index 00000000..a45c3123
18971c
--- /dev/null
18971c
+++ b/test/TEST-60-MTUMAC/client-init.sh
18971c
@@ -0,0 +1,22 @@
18971c
+#!/bin/sh
18971c
+exec >/dev/console 2>&1
18971c
+set -x
18971c
+export PATH=/sbin:/bin:/usr/sbin:/usr/bin
18971c
+strstr() { [ "${1#*$2*}" != "$1" ]; }
18971c
+CMDLINE=$(while read line; do echo $line;done < /proc/cmdline)
18971c
+export TERM=linux
18971c
+export PS1='initramfs-test:\w\$ '
18971c
+stty sane
18971c
+echo "made it to the rootfs! Powering down."
18971c
+
18971c
+(
18971c
+    echo OK
18971c
+    cd /sys/class/net
18971c
+    for i in ens*; do
18971c
+	echo "$i" "$(cat $i/mtu)" "$(cat $i/address)"
18971c
+    done
18971c
+    echo END
18971c
+) > /dev/sda
18971c
+
18971c
+strstr "$CMDLINE" "rd.shell" && sh -i
18971c
+poweroff -f
18971c
diff --git a/test/TEST-60-MTUMAC/dhcpd.conf b/test/TEST-60-MTUMAC/dhcpd.conf
18971c
new file mode 100644
18971c
index 00000000..cba28233
18971c
--- /dev/null
18971c
+++ b/test/TEST-60-MTUMAC/dhcpd.conf
18971c
@@ -0,0 +1,15 @@
18971c
+ddns-update-style none;
18971c
+
18971c
+use-host-decl-names true;
18971c
+
18971c
+subnet 192.168.50.0 netmask 255.255.255.0 {
18971c
+	option subnet-mask      255.255.255.0;
18971c
+	option routers          192.168.50.1;
18971c
+	next-server             192.168.50.1;
18971c
+	server-identifier       192.168.50.1;
18971c
+	option domain-name-servers 192.168.50.1;
18971c
+	option domain-search "example.com";
18971c
+	option domain-name "other.com";
18971c
+	option root-path "nfs:192.168.50.1:/nfs/client";
18971c
+	range 192.168.50.10 192.168.50.100;
18971c
+}
18971c
diff --git a/test/TEST-60-MTUMAC/exports b/test/TEST-60-MTUMAC/exports
18971c
new file mode 100644
18971c
index 00000000..ff5f29b1
18971c
--- /dev/null
18971c
+++ b/test/TEST-60-MTUMAC/exports
18971c
@@ -0,0 +1 @@
18971c
+/nfs/client	192.168.50.0/24(rw,insecure,no_subtree_check,no_root_squash)
18971c
diff --git a/test/TEST-60-MTUMAC/finished-false.sh b/test/TEST-60-MTUMAC/finished-false.sh
18971c
new file mode 100755
18971c
index 00000000..ecdbef95
18971c
--- /dev/null
18971c
+++ b/test/TEST-60-MTUMAC/finished-false.sh
18971c
@@ -0,0 +1,2 @@
18971c
+#!/bin/sh
18971c
+exit 1
18971c
diff --git a/test/TEST-60-MTUMAC/hard-off.sh b/test/TEST-60-MTUMAC/hard-off.sh
18971c
new file mode 100755
18971c
index 00000000..12c3d5ac
18971c
--- /dev/null
18971c
+++ b/test/TEST-60-MTUMAC/hard-off.sh
18971c
@@ -0,0 +1,3 @@
18971c
+#!/bin/sh
18971c
+getarg rd.shell || poweroff -f
18971c
+getarg failme && poweroff -f
18971c
diff --git a/test/TEST-60-MTUMAC/hosts b/test/TEST-60-MTUMAC/hosts
18971c
new file mode 100644
18971c
index 00000000..d02a4e9b
18971c
--- /dev/null
18971c
+++ b/test/TEST-60-MTUMAC/hosts
18971c
@@ -0,0 +1,5 @@
18971c
+127.0.0.1	localhost
18971c
+192.168.50.1	server
18971c
+192.168.50.100	client-if1
18971c
+192.168.50.101	client-if2
18971c
+192.168.50.102	client-if3
18971c
diff --git a/test/TEST-60-MTUMAC/server-init.sh b/test/TEST-60-MTUMAC/server-init.sh
18971c
new file mode 100755
18971c
index 00000000..88ef2128
18971c
--- /dev/null
18971c
+++ b/test/TEST-60-MTUMAC/server-init.sh
18971c
@@ -0,0 +1,98 @@
18971c
+#!/bin/sh
18971c
+exec </dev/console >/dev/console 2>&1
18971c
+set -x
18971c
+export PATH=/sbin:/bin:/usr/sbin:/usr/bin
18971c
+export TERM=linux
18971c
+export PS1='nfstest-server:\w\$ '
18971c
+stty sane
18971c
+echo "made it to the rootfs!"
18971c
+echo server > /proc/sys/kernel/hostname
18971c
+
18971c
+wait_for_if_link() {
18971c
+    local cnt=0
18971c
+    local li
18971c
+    while [ $cnt -lt 600 ]; do
18971c
+        li=$(ip -o link show dev $1 2>/dev/null)
18971c
+        [ -n "$li" ] && return 0
18971c
+        sleep 0.1
18971c
+        cnt=$(($cnt+1))
18971c
+    done
18971c
+    return 1
18971c
+}
18971c
+
18971c
+wait_for_if_up() {
18971c
+    local cnt=0
18971c
+    local li
18971c
+    while [ $cnt -lt 200 ]; do
18971c
+        li=$(ip -o link show up dev $1)
18971c
+        [ -n "$li" ] && return 0
18971c
+        sleep 0.1
18971c
+        cnt=$(($cnt+1))
18971c
+    done
18971c
+    return 1
18971c
+}
18971c
+
18971c
+wait_for_route_ok() {
18971c
+    local cnt=0
18971c
+    while [ $cnt -lt 200 ]; do
18971c
+        li=$(ip route show)
18971c
+        [ -n "$li" ] && [ -z "${li##*$1*}" ] && return 0
18971c
+        sleep 0.1
18971c
+        cnt=$(($cnt+1))
18971c
+    done
18971c
+    return 1
18971c
+}
18971c
+
18971c
+linkup() {
18971c
+    wait_for_if_link $1 2>/dev/null\
18971c
+     && ip link set $1 up 2>/dev/null\
18971c
+     && wait_for_if_up $1 2>/dev/null
18971c
+}
18971c
+
18971c
+>/dev/watchdog
18971c
+ip addr add 127.0.0.1/8 dev lo
18971c
+linkup lo
18971c
+ip link set dev eth0 name ens3
18971c
+ip addr add 192.168.50.1/24 dev ens3
18971c
+linkup ens3
18971c
+>/dev/watchdog
18971c
+modprobe af_packet
18971c
+> /dev/watchdog
18971c
+modprobe sunrpc
18971c
+>/dev/watchdog
18971c
+mount -t rpc_pipefs sunrpc /var/lib/nfs/rpc_pipefs
18971c
+>/dev/watchdog
18971c
+[ -x /sbin/portmap ] && portmap
18971c
+>/dev/watchdog
18971c
+[ -x /sbin/rpcbind ] && rpcbind
18971c
+>/dev/watchdog
18971c
+modprobe nfsd
18971c
+>/dev/watchdog
18971c
+mount -t nfsd nfsd /proc/fs/nfsd
18971c
+>/dev/watchdog
18971c
+exportfs -r
18971c
+>/dev/watchdog
18971c
+rpc.nfsd
18971c
+>/dev/watchdog
18971c
+rpc.mountd
18971c
+>/dev/watchdog
18971c
+rpc.idmapd
18971c
+>/dev/watchdog
18971c
+exportfs -r
18971c
+>/dev/watchdog
18971c
+>/var/lib/dhcpd/dhcpd.leases
18971c
+>/dev/watchdog
18971c
+chmod 777 /var/lib/dhcpd/dhcpd.leases
18971c
+>/dev/watchdog
18971c
+dhcpd -cf /etc/dhcpd.conf -lf /var/lib/dhcpd/dhcpd.leases
18971c
+#echo -n 'V' > /dev/watchdog
18971c
+#sh -i
18971c
+#tcpdump -i ens3
18971c
+# Wait forever for the VM to die
18971c
+echo "Serving NFS mounts"
18971c
+while :; do
18971c
+	sleep 10
18971c
+	>/dev/watchdog
18971c
+done
18971c
+mount -n -o remount,ro /
18971c
+poweroff -f
18971c
diff --git a/test/TEST-60-MTUMAC/test.sh b/test/TEST-60-MTUMAC/test.sh
18971c
new file mode 100755
18971c
index 00000000..7633ac13
18971c
--- /dev/null
18971c
+++ b/test/TEST-60-MTUMAC/test.sh
18971c
@@ -0,0 +1,282 @@
18971c
+#!/bin/bash
18971c
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
18971c
+# ex: ts=8 sw=4 sts=4 et filetype=sh
18971c
+TEST_DESCRIPTION="root filesystem on NFS with multiple nics"
18971c
+KVERSION=${KVERSION-$(uname -r)}
18971c
+
18971c
+# Uncomment this to debug failures
18971c
+#DEBUGFAIL="rd.shell rd.break"
18971c
+#SERIAL="tcp:127.0.0.1:9999"
18971c
+
18971c
+run_server() {
18971c
+    # Start server first
18971c
+    echo "MULTINIC TEST SETUP: Starting DHCP/NFS server"
18971c
+
18971c
+    fsck -a "$TESTDIR"/server.ext3 || return 1
18971c
+    $testdir/run-qemu \
18971c
+        -hda "$TESTDIR"/server.ext3 \
18971c
+        -m 512M -smp 2 \
18971c
+        -display none \
18971c
+        -net socket,listen=127.0.0.1:12350 \
18971c
+        -net nic,macaddr=52:54:01:12:34:56,model=e1000 \
18971c
+        ${SERIAL:+-serial "$SERIAL"} \
18971c
+        -watchdog i6300esb -watchdog-action poweroff \
18971c
+        -kernel /boot/vmlinuz-"$KVERSION" \
18971c
+        -append "loglevel=7 root=/dev/sda rootfstype=ext3 rw console=ttyS0,115200n81 selinux=0" \
18971c
+        -initrd "$TESTDIR"/initramfs.server \
18971c
+        -pidfile "$TESTDIR"/server.pid -daemonize || return 1
18971c
+    sudo chmod 644 -- "$TESTDIR"/server.pid || return 1
18971c
+
18971c
+    # Cleanup the terminal if we have one
18971c
+    tty -s && stty sane
18971c
+
18971c
+    echo Sleeping 10 seconds to give the server a head start
18971c
+    sleep 10
18971c
+}
18971c
+
18971c
+client_test() {
18971c
+    local test_name="$1"
18971c
+    local cmdline="$2"
18971c
+    local check="$3"
18971c
+
18971c
+    echo "CLIENT TEST START: $test_name"
18971c
+
18971c
+    # Need this so kvm-qemu will boot (needs non-/dev/zero local disk)
18971c
+    if ! dd if=/dev/zero of="$TESTDIR"/client.img bs=1M count=1; then
18971c
+        echo "Unable to make client sda image" 1>&2
18971c
+        return 1
18971c
+    fi
18971c
+
18971c
+    $testdir/run-qemu -hda "$TESTDIR"/client.img -m 512M -smp 2 -nographic \
18971c
+        -net socket,connect=127.0.0.1:12350 \
18971c
+        -net nic,macaddr=52:54:00:12:34:01,model=e1000 \
18971c
+        -net nic,macaddr=52:54:00:12:34:02,model=e1000 \
18971c
+        -net nic,macaddr=52:54:00:12:34:03,model=e1000 \
18971c
+        -net nic,macaddr=52:54:00:12:34:04,model=e1000 \
18971c
+        -net nic,macaddr=52:54:00:12:34:05,model=e1000 \
18971c
+        -watchdog i6300esb -watchdog-action poweroff \
18971c
+        -kernel /boot/vmlinuz-"$KVERSION" \
18971c
+        -append "$cmdline $DEBUGFAIL rd.retry=5 rw console=ttyS0,115200n81 selinux=0 init=/sbin/init" \
18971c
+        -initrd "$TESTDIR"/initramfs.testing
18971c
+
18971c
+    { 
18971c
+        read OK
18971c
+        if [[ "$OK" != "OK" ]]; then
18971c
+            echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]"
18971c
+            return 1
18971c
+        fi
18971c
+
18971c
+        while read IFACE MTU MAC; do
18971c
+            [[ $IFACE == END ]] && break
18971c
+            IFACES+="${IFACE}-${MTU}-${MAC} "
18971c
+        done
18971c
+    } < "$TESTDIR"/client.img || return 1
18971c
+
18971c
+    echo "$IFACES"
18971c
+
18971c
+    for i in $check; do
18971c
+        if [[ " $IFACES " != *\ $i\ * ]]; then
18971c
+            echo "$i not in '$IFACES'"
18971c
+            echo "CLIENT TEST END: $test_name [FAILED - BAD IF]"
18971c
+            return 1
18971c
+        fi
18971c
+    done
18971c
+
18971c
+    for i in $IFACES; do
18971c
+        if [[ " $check " != *\ $i\ * ]]; then
18971c
+            echo "$i in '$IFACES', but should not be"
18971c
+            echo "CLIENT TEST END: $test_name [FAILED - BAD IF]"
18971c
+            return 1
18971c
+        fi
18971c
+    done
18971c
+
18971c
+    echo "CLIENT TEST END: $test_name [OK]"
18971c
+    return 0
18971c
+}
18971c
+
18971c
+
18971c
+test_run() {
18971c
+    if ! run_server; then
18971c
+        echo "Failed to start server" 1>&2
18971c
+        return 1
18971c
+    fi
18971c
+    test_client || { kill_server; return 1; }
18971c
+}
18971c
+
18971c
+test_client() {
18971c
+    client_test "MTUMAC format: ip=<interface>:{dhcp|on|any|dhcp6|auto6}[:[<mtu>][:<macaddr>]]" \
18971c
+        "
18971c
+ip=ens3:dhcp:1000
18971c
+ip=ens4:dhcp::54:52:00:ab:cd:01
18971c
+ip=ens5:dhcp::[54:52:00:ab:cd:02]
18971c
+ip=ens6:dhcp:1000:54:52:00:ab:cd:03
18971c
+ip=ens7:dhcp:1000:[54:52:00:ab:cd:04]
18971c
+rd.neednet=1
18971c
+root=nfs:192.168.50.1:/nfs/client bootdev=ens3
18971c
+" \
18971c
+        "ens3-1000-52:54:00:12:34:01 ens4-1500-54:52:00:ab:cd:01 ens5-1500-54:52:00:ab:cd:02 ens6-1000-54:52:00:ab:cd:03 ens7-1000-54:52:00:ab:cd:04" || return 1
18971c
+    client_test "MTUMAC format: format: ip=<client-IP>:[<peer>]:<gateway-IP>:<netmask>:<client_hostname>:<interface>:{none|off|dhcp|on|any|dhcp6|auto6|ibft}:[:[<mtu>][:<macaddr>]]" \
18971c
+        "
18971c
+ip=192.168.50.2::192.168.50.1:24:test:ens3:none:1000
18971c
+ip=192.168.50.3::192.168.50.1:24:test:ens4:none::54:52:00:ab:cd:01
18971c
+ip=192.168.50.4::192.168.50.1:24:test:ens5:none::[54:52:00:ab:cd:02]
18971c
+ip=192.168.50.5::192.168.50.1:24:test:ens6:none:1000:54:52:00:ab:cd:03
18971c
+ip=192.168.50.6::192.168.50.1:24:test:ens7:none:1000:[54:52:00:ab:cd:04]
18971c
+rd.neednet=1
18971c
+root=nfs:192.168.50.1:/nfs/client bootdev=ens3
18971c
+" \
18971c
+        "ens3-1000-52:54:00:12:34:01 ens4-1500-54:52:00:ab:cd:01 ens5-1500-54:52:00:ab:cd:02 ens6-1000-54:52:00:ab:cd:03 ens7-1000-54:52:00:ab:cd:04" || return 1
18971c
+
18971c
+    kill_server
18971c
+    return 0
18971c
+}
18971c
+
18971c
+test_setup() {
18971c
+     # Make server root
18971c
+    dd if=/dev/null of="$TESTDIR"/server.ext3 bs=1M seek=60
18971c
+    mke2fs -j -F -- "$TESTDIR"/server.ext3
18971c
+    mkdir -- "$TESTDIR"/mnt
18971c
+    sudo mount -o loop -- "$TESTDIR"/server.ext3 "$TESTDIR"/mnt
18971c
+
18971c
+    (
18971c
+        export initdir="$TESTDIR"/mnt
18971c
+        . "$basedir"/dracut-init.sh
18971c
+
18971c
+        (
18971c
+            cd "$initdir";
18971c
+            mkdir -p -- dev sys proc run etc var/run tmp var/lib/{dhcpd,rpcbind}
18971c
+            mkdir -p -- var/lib/nfs/{v4recovery,rpc_pipefs}
18971c
+            chmod 777 -- var/lib/rpcbind var/lib/nfs
18971c
+        )
18971c
+
18971c
+        for _f in modules.builtin.bin modules.builtin; do
18971c
+            [[ $srcmods/$_f ]] && break
18971c
+        done || {
18971c
+            dfatal "No modules.builtin.bin and modules.builtin found!"
18971c
+            return 1
18971c
+        }
18971c
+
18971c
+        for _f in modules.builtin.bin modules.builtin modules.order; do
18971c
+            [[ $srcmods/$_f ]] && inst_simple "$srcmods/$_f" "/lib/modules/$kernel/$_f"
18971c
+        done
18971c
+
18971c
+        inst_multiple sh ls shutdown poweroff stty cat ps ln ip \
18971c
+            dmesg mkdir cp ping exportfs \
18971c
+            modprobe rpc.nfsd rpc.mountd showmount tcpdump \
18971c
+            /etc/services sleep mount chmod
18971c
+        for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
18971c
+            [ -f "${_terminfodir}"/l/linux ] && break
18971c
+        done
18971c
+        inst_multiple -o "${_terminfodir}"/l/linux
18971c
+        type -P portmap >/dev/null && inst_multiple portmap
18971c
+        type -P rpcbind >/dev/null && inst_multiple rpcbind
18971c
+        [ -f /etc/netconfig ] && inst_multiple /etc/netconfig
18971c
+        type -P dhcpd >/dev/null && inst_multiple dhcpd
18971c
+        [ -x /usr/sbin/dhcpd3 ] && inst /usr/sbin/dhcpd3 /usr/sbin/dhcpd
18971c
+        instmods nfsd sunrpc ipv6 lockd af_packet
18971c
+        inst_simple /etc/os-release
18971c
+        inst ./server-init.sh /sbin/init
18971c
+        inst ./hosts /etc/hosts
18971c
+        inst ./exports /etc/exports
18971c
+        inst ./dhcpd.conf /etc/dhcpd.conf
18971c
+        inst_multiple /etc/nsswitch.conf /etc/rpc /etc/protocols
18971c
+
18971c
+        inst_multiple rpc.idmapd /etc/idmapd.conf
18971c
+
18971c
+        inst_libdir_file 'libnfsidmap_nsswitch.so*'
18971c
+        inst_libdir_file 'libnfsidmap/*.so*'
18971c
+        inst_libdir_file 'libnfsidmap*.so*'
18971c
+
18971c
+        _nsslibs=$(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' /etc/nsswitch.conf \
18971c
+            |  tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
18971c
+        _nsslibs=${_nsslibs#|}
18971c
+        _nsslibs=${_nsslibs%|}
18971c
+
18971c
+        inst_libdir_file -n "$_nsslibs" 'libnss_*.so*'
18971c
+
18971c
+        inst /etc/nsswitch.conf /etc/nsswitch.conf
18971c
+        inst /etc/passwd /etc/passwd
18971c
+        inst /etc/group /etc/group
18971c
+
18971c
+        cp -a -- /etc/ld.so.conf* "$initdir"/etc
18971c
+        ldconfig -r "$initdir"
18971c
+        dracut_kernel_post
18971c
+    )
18971c
+
18971c
+    # Make client root inside server root
18971c
+    (
18971c
+        export initdir="$TESTDIR"/mnt/nfs/client
18971c
+        . "$basedir"/dracut-init.sh
18971c
+        inst_multiple sh shutdown poweroff stty cat ps ln ip \
18971c
+            mount dmesg mkdir cp ping grep ls
18971c
+        for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
18971c
+            [[ -f ${_terminfodir}/l/linux ]] && break
18971c
+        done
18971c
+        inst_multiple -o "${_terminfodir}"/l/linux
18971c
+        inst_simple /etc/os-release
18971c
+        inst ./client-init.sh /sbin/init
18971c
+        (
18971c
+            cd "$initdir"
18971c
+            mkdir -p -- dev sys proc etc run
18971c
+            mkdir -p -- var/lib/nfs/rpc_pipefs
18971c
+        )
18971c
+        inst /etc/nsswitch.conf /etc/nsswitch.conf
18971c
+        inst /etc/passwd /etc/passwd
18971c
+        inst /etc/group /etc/group
18971c
+
18971c
+        inst_multiple rpc.idmapd /etc/idmapd.conf
18971c
+        inst_libdir_file 'libnfsidmap_nsswitch.so*'
18971c
+        inst_libdir_file 'libnfsidmap/*.so*'
18971c
+        inst_libdir_file 'libnfsidmap*.so*'
18971c
+
18971c
+        _nsslibs=$(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' -- /etc/nsswitch.conf \
18971c
+            |  tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
18971c
+        _nsslibs=${_nsslibs#|}
18971c
+        _nsslibs=${_nsslibs%|}
18971c
+
18971c
+        inst_libdir_file -n "$_nsslibs" 'libnss_*.so*'
18971c
+
18971c
+        cp -a -- /etc/ld.so.conf* "$initdir"/etc
18971c
+        sudo ldconfig -r "$initdir"
18971c
+    )
18971c
+
18971c
+    sudo umount "$TESTDIR"/mnt
18971c
+    rm -fr -- "$TESTDIR"/mnt
18971c
+
18971c
+    # Make an overlay with needed tools for the test harness
18971c
+    (
18971c
+        export initdir="$TESTDIR"/overlay
18971c
+        . "$basedir"/dracut-init.sh
18971c
+        inst_multiple poweroff shutdown
18971c
+        inst_hook emergency 000 ./hard-off.sh
18971c
+        inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
18971c
+    )
18971c
+
18971c
+    # Make server's dracut image
18971c
+    $basedir/dracut.sh -l -i "$TESTDIR"/overlay / \
18971c
+        --no-early-microcode \
18971c
+        -m "udev-rules base rootfs-block fs-lib debug kernel-modules watchdog" \
18971c
+        -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" \
18971c
+        -f "$TESTDIR"/initramfs.server "$KVERSION" || return 1
18971c
+
18971c
+    # Make client's dracut image
18971c
+    $basedir/dracut.sh -l -i "$TESTDIR"/overlay / \
18971c
+        --no-early-microcode \
18971c
+        -o "plymouth" \
18971c
+        -a "debug" \
18971c
+        -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" \
18971c
+        -f "$TESTDIR"/initramfs.testing "$KVERSION" || return 1
18971c
+}
18971c
+
18971c
+kill_server() {
18971c
+    if [[ -s "$TESTDIR"/server.pid ]]; then
18971c
+        sudo kill -TERM -- $(cat "$TESTDIR"/server.pid)
18971c
+        rm -f -- "$TESTDIR"/server.pid
18971c
+    fi
18971c
+}
18971c
+
18971c
+test_cleanup() {
18971c
+    kill_server
18971c
+}
18971c
+
18971c
+. "$testdir"/test-functions