]> git.ipfire.org Git - thirdparty/dracut.git/blobdiff - test/TEST-20-NFS/test.sh
tests: untabify, reformat
[thirdparty/dracut.git] / test / TEST-20-NFS / test.sh
index 66e5e3e14768c390cde7e33cd27619018a306192..69d96f7b740b36ad8263aade0734740f48848978 100755 (executable)
@@ -14,14 +14,15 @@ run_server() {
     fsck -a $TESTDIR/server.ext3 || return 1
     $testdir/run-qemu \
         -drive format=raw,index=0,media=disk,file=$TESTDIR/server.ext3 \
-        -m 256M -cpu host -smp 2 \
+        -m 512M  -smp 2 \
         -display none \
         -net socket,listen=127.0.0.1:12320 \
         -net nic,macaddr=52:54:00:12:34:56,model=e1000 \
-        -serial ${SERIAL:-null} \
+        ${SERIAL:+-serial "$SERIAL"} \
+        ${SERIAL:--serial file:"$TESTDIR"/server.log} \
         -watchdog i6300esb -watchdog-action poweroff \
         -no-reboot \
-        -append "panic=1 rd.debug loglevel=77 root=/dev/sda rootfstype=ext3 rw console=ttyS0,115200n81 selinux=0" \
+        -append "panic=1 systemd.crash_reboot rd.debug loglevel=77 root=/dev/sda rootfstype=ext3 rw console=ttyS0,115200n81 selinux=0" \
         -initrd $TESTDIR/initramfs.server \
         -pidfile $TESTDIR/server.pid -daemonize || return 1
     sudo chmod 644 $TESTDIR/server.pid || return 1
@@ -29,8 +30,16 @@ run_server() {
     # Cleanup the terminal if we have one
     tty -s && stty sane
 
-    echo Sleeping 10 seconds to give the server a head start
-    sleep 10
+    if ! [[ $SERIAL ]]; then
+        echo "Waiting for the server to startup"
+        while : ; do
+            grep Serving "$TESTDIR"/server.log && break
+            sleep 1
+        done
+    else
+        echo Sleeping 10 seconds to give the server a head start
+        sleep 10
+    fi
 }
 
 client_test() {
@@ -51,12 +60,12 @@ client_test() {
 
     $testdir/run-qemu \
         -drive format=raw,index=0,media=disk,file=$TESTDIR/client.img \
-        -m 256M -cpu host -smp 2 -nographic \
+        -m 512M  -smp 2 -nographic \
         -net nic,macaddr=$mac,model=e1000 \
         -net socket,connect=127.0.0.1:12320 \
         -watchdog i6300esb -watchdog-action poweroff \
         -no-reboot \
-        -append "panic=1 rd.shell=0 $cmdline $DEBUGFAIL rd.debug rd.retry=10 rd.info quiet  ro console=ttyS0,115200n81 selinux=0" \
+        -append "panic=1 systemd.crash_reboot rd.shell=0 $cmdline $DEBUGFAIL rd.debug rd.retry=10 rd.info quiet  ro console=ttyS0,115200n81 selinux=0" \
         -initrd $TESTDIR/initramfs.testing
 
     if [[ $? -ne 0 ]] || ! grep -F -m 1 -q nfs-OK $TESTDIR/client.img; then
@@ -112,7 +121,7 @@ test_nfsv3() {
     # NFSv4: last octect starts at 0x80 and works up
 
     client_test "NFSv3 root=dhcp DHCP path only" 52:54:00:12:34:00 \
-        "root=dhcp" 192.168.50.1 -wsize=4096 || return 1
+                "root=dhcp" 192.168.50.1 -wsize=4096 || return 1
 
     if [[ "$(systemctl --version)" != *"systemd 230"* ]] 2>/dev/null; then
         client_test "NFSv3 Legacy root=/dev/nfs nfsroot=IP:path" 52:54:00:12:34:01 \
@@ -126,38 +135,38 @@ test_nfsv3() {
     fi
 
     client_test "NFSv3 root=dhcp DHCP IP:path" 52:54:00:12:34:01 \
-        "root=dhcp" 192.168.50.2 -wsize=4096 || return 1
+                "root=dhcp" 192.168.50.2 -wsize=4096 || return 1
 
     client_test "NFSv3 root=dhcp DHCP proto:IP:path" 52:54:00:12:34:02 \
-        "root=dhcp" 192.168.50.3 -wsize=4096 || return 1
+                "root=dhcp" 192.168.50.3 -wsize=4096 || return 1
 
     client_test "NFSv3 root=dhcp DHCP proto:IP:path:options" 52:54:00:12:34:03 \
-        "root=dhcp" 192.168.50.3 wsize=4096 || return 1
+                "root=dhcp" 192.168.50.3 wsize=4096 || return 1
 
     client_test "NFSv3 root=nfs:..." 52:54:00:12:34:04 \
-        "root=nfs:192.168.50.1:/nfs/client" 192.168.50.1 -wsize=4096 || return 1
+                "root=nfs:192.168.50.1:/nfs/client" 192.168.50.1 -wsize=4096 || return 1
 
     client_test "NFSv3 Bridge root=nfs:..." 52:54:00:12:34:04 \
-        "root=nfs:192.168.50.1:/nfs/client bridge net.ifnames=0" 192.168.50.1 -wsize=4096 || return 1
+                "root=nfs:192.168.50.1:/nfs/client bridge net.ifnames=0" 192.168.50.1 -wsize=4096 || return 1
 
     client_test "NFSv3 Legacy root=IP:path" 52:54:00:12:34:04 \
-        "root=192.168.50.1:/nfs/client" 192.168.50.1 -wsize=4096 || return 1
+                "root=192.168.50.1:/nfs/client" 192.168.50.1 -wsize=4096 || return 1
 
     # This test must fail: nfsroot= requires root=/dev/nfs
     client_test "NFSv3 Invalid root=dhcp nfsroot=/nfs/client" 52:54:00:12:34:04 \
-        "root=dhcp nfsroot=/nfs/client failme rd.debug" 192.168.50.1 -wsize=4096 && return 1
+                "root=dhcp nfsroot=/nfs/client failme rd.debug" 192.168.50.1 -wsize=4096 && return 1
 
     client_test "NFSv3 root=dhcp DHCP path,options" \
-        52:54:00:12:34:05 "root=dhcp" 192.168.50.1 wsize=4096 || return 1
+                52:54:00:12:34:05 "root=dhcp" 192.168.50.1 wsize=4096 || return 1
 
     client_test "NFSv3 Bridge Customized root=dhcp DHCP path,options" \
-        52:54:00:12:34:05 "root=dhcp bridge=foobr0:ens3" 192.168.50.1 wsize=4096 || return 1
+                52:54:00:12:34:05 "root=dhcp bridge=foobr0:ens3" 192.168.50.1 wsize=4096 || return 1
 
     client_test "NFSv3 root=dhcp DHCP IP:path,options" \
-        52:54:00:12:34:06 "root=dhcp" 192.168.50.2 wsize=4096 || return 1
+                52:54:00:12:34:06 "root=dhcp" 192.168.50.2 wsize=4096 || return 1
 
     client_test "NFSv3 root=dhcp DHCP proto:IP:path,options" \
-        52:54:00:12:34:07 "root=dhcp" 192.168.50.3 wsize=4096 || return 1
+                52:54:00:12:34:07 "root=dhcp" 192.168.50.3 wsize=4096 || return 1
 
     return 0
 }
@@ -168,17 +177,17 @@ test_nfsv4() {
     # switch_root
 
     client_test "NFSv4 root=dhcp DHCP proto:IP:path" 52:54:00:12:34:82 \
-        "root=dhcp" 192.168.50.3 -wsize=4096 || return 1
+                "root=dhcp" 192.168.50.3 -wsize=4096 || return 1
 
     client_test "NFSv4 root=dhcp DHCP proto:IP:path:options" 52:54:00:12:34:83 \
-        "root=dhcp" 192.168.50.3 wsize=4096 || return 1
+                "root=dhcp" 192.168.50.3 wsize=4096 || return 1
 
     client_test "NFSv4 root=nfs4:..." 52:54:00:12:34:84 \
-        "root=nfs4:192.168.50.1:/client" 192.168.50.1 \
-        -wsize=4096 || return 1
+                "root=nfs4:192.168.50.1:/client" 192.168.50.1 \
+                -wsize=4096 || return 1
 
     client_test "NFSv4 root=dhcp DHCP proto:IP:path,options" \
-        52:54:00:12:34:87 "root=dhcp" 192.168.50.3 wsize=4096 || return 1
+                52:54:00:12:34:87 "root=dhcp" 192.168.50.3 wsize=4096 || return 1
 
     return 0
 }
@@ -209,7 +218,7 @@ test_run() {
 
 test_setup() {
     # Make server root
-    dd if=/dev/null of=$TESTDIR/server.ext3 bs=1M seek=60
+    dd if=/dev/null of=$TESTDIR/server.ext3 bs=1M seek=120
     mke2fs -j -F $TESTDIR/server.ext3
     mkdir $TESTDIR/mnt
     sudo mount -o loop $TESTDIR/server.ext3 $TESTDIR/mnt
@@ -235,9 +244,9 @@ test_setup() {
         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 rm
+                      dmesg mkdir cp ping exportfs \
+                      modprobe rpc.nfsd rpc.mountd showmount tcpdump \
+                      /etc/services sleep mount chmod rm
         for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
             [ -f ${_terminfodir}/l/linux ] && break
         done
@@ -261,7 +270,7 @@ test_setup() {
         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:]' '|')
+                       |  tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
         _nsslibs=${_nsslibs#|}
         _nsslibs=${_nsslibs%|}
 
@@ -290,7 +299,7 @@ test_setup() {
         . $basedir/dracut-init.sh
 
         inst_multiple sh shutdown poweroff stty cat ps ln ip \
-            mount dmesg mkdir cp ping grep setsid ls vi /etc/virc less cat
+                      mount dmesg mkdir cp ping grep setsid ls vi /etc/virc less cat
         for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
             [ -f ${_terminfodir}/l/linux ] && break
         done
@@ -315,7 +324,7 @@ test_setup() {
         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:]' '|')
+                       |  tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
         _nsslibs=${_nsslibs#|}
         _nsslibs=${_nsslibs%|}
 
@@ -341,22 +350,23 @@ test_setup() {
         inst_hook shutdown-emergency 000 ./hard-off.sh
         inst_hook emergency 000 ./hard-off.sh
         inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
+        inst_simple ./99-default.link /etc/systemd/network/99-default.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" \
-        -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
+                       -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" \
-        -a "debug watchdog" \
-        -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
+                       -o "plymouth dash" \
+                       -a "debug watchdog" \
+                       -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
 }
 
 test_cleanup() {