2 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3 # ex: ts=8 sw=4 sts=4 et filetype=sh
4 TEST_DESCRIPTION
="root filesystem on NFS with multiple nics"
6 KVERSION
=${KVERSION-$(uname -r)}
8 # Uncomment this to debug failures
10 #SERIAL="tcp:127.0.0.1:9999"
14 echo "MULTINIC TEST SETUP: Starting DHCP/NFS server"
16 fsck
-a "$TESTDIR"/server.ext3 ||
return 1
18 -hda "$TESTDIR"/server.ext3 \
21 -net socket
,listen
=127.0.0.1:12350 \
22 -net nic
,macaddr
=52:54:01:12:34:56,model
=e1000 \
23 ${SERIAL+-serial "$SERIAL"} \
24 -watchdog i6300esb
-watchdog-action poweroff \
25 -kernel /boot
/vmlinuz-
"$KVERSION" \
26 -append "loglevel=7 root=/dev/sda rootfstype=ext3 rw console=ttyS0,115200n81 selinux=0" \
27 -initrd "$TESTDIR"/initramfs.server \
28 -pidfile "$TESTDIR"/server.pid
-daemonize ||
return 1
29 sudo
chmod 644 -- "$TESTDIR"/server.pid ||
return 1
31 # Cleanup the terminal if we have one
34 echo Sleeping
10 seconds to give the server a
head start
46 echo "CLIENT TEST START: $test_name"
48 # Need this so kvm-qemu will boot (needs non-/dev/zero local disk)
49 if ! dd if=/dev
/zero of
="$TESTDIR"/client.img bs
=1M count
=1; then
50 echo "Unable to make client sda image" 1>&2
54 $testdir/run-qemu
-hda "$TESTDIR"/client.img
-m 512M
-smp 2 -nographic \
55 -net socket
,connect
=127.0.0.1:12350 \
56 -net nic
,macaddr
=52:54:00:12:34:$mac1,model
=e1000 \
57 -net nic
,macaddr
=52:54:00:12:34:$mac2,model
=e1000 \
58 -net nic
,macaddr
=52:54:00:12:34:$mac3,model
=e1000 \
59 -watchdog i6300esb
-watchdog-action poweroff \
60 -kernel /boot
/vmlinuz-
"$KVERSION" \
61 -append "$cmdline $DEBUGFAIL rd.retry=5 ro console=ttyS0,115200n81 selinux=0 init=/sbin/init rd.debug systemd.log_target=console loglevel=7" \
62 -initrd "$TESTDIR"/initramfs.testing
64 if [[ $?
-ne 0 ]] ||
! grep -F -m 1 -q OK
-- "$TESTDIR"/client.img
; then
65 echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]"
72 if ! grep -F -m 1 -q $i -- "$TESTDIR"/client.img
; then
73 echo "CLIENT TEST END: $test_name [FAILED - BAD IF]"
78 echo "CLIENT TEST END: $test_name [OK]"
85 echo "Failed to start server" 1>&2
88 test_client ||
{ kill_server
; return 1; }
92 # Mac Numbering Scheme
93 # ...:00-02 receive IP adresses all others don't
94 # ...:02 receives a dhcp root-path
97 client_test
"MULTINIC root=nfs BOOTIF=" \
99 "root=nfs:192.168.50.1:/nfs/client BOOTIF=52-54-00-12-34-00" \
102 # PXE Style BOOTIF= with dhcp root-path
103 client_test
"MULTINIC root=dhcp BOOTIF=" \
105 "root=dhcp BOOTIF=52-54-00-12-34-02" \
108 # Multinic case, where only one nic works
109 client_test
"MULTINIC root=nfs ip=dhcp" \
111 "root=nfs:192.168.50.1:/nfs/client ip=dhcp" \
114 # Require two interfaces
115 client_test
"MULTINIC root=nfs ip=ens4:dhcp ip=ens5:dhcp bootdev=ens4" \
117 "root=nfs:192.168.50.1:/nfs/client ip=ens4:dhcp ip=ens5:dhcp bootdev=ens4" \
118 "ens4 ens5" ||
return 1
120 # Require three interfaces with dhcp root-path
121 client_test
"MULTINIC root=dhcp ip=ens3:dhcp ip=ens4:dhcp ip=ens5:dhcp bootdev=ens5" \
123 "root=dhcp ip=ens3:dhcp ip=ens4:dhcp ip=ens5:dhcp bootdev=ens5" \
124 "ens3 ens4 ens5" ||
return 1
132 dd if=/dev
/null of
="$TESTDIR"/server.ext3 bs
=1M seek
=60
133 mke2fs
-j -F -- "$TESTDIR"/server.ext3
134 mkdir
-- "$TESTDIR"/mnt
135 sudo mount
-o loop
-- "$TESTDIR"/server.ext3
"$TESTDIR"/mnt
138 export initdir
="$TESTDIR"/mnt
139 .
"$basedir"/dracut-functions.sh
143 mkdir
-p -- dev sys proc run etc var
/run tmp var
/lib
/{dhcpd
,rpcbind
}
144 mkdir
-p -- var
/lib
/nfs
/{v4recovery
,rpc_pipefs
}
145 chmod 777 -- var
/lib
/rpcbind var
/lib
/nfs
148 for _f
in modules.
builtin.bin modules.
builtin; do
149 [[ $srcmods/$_f ]] && break
151 dfatal
"No modules.builtin.bin and modules.builtin found!"
155 for _f
in modules.
builtin.bin modules.
builtin modules.order
; do
156 [[ $srcmods/$_f ]] && inst_simple
"$srcmods/$_f" "/lib/modules/$kernel/$_f"
159 inst_multiple sh
ls shutdown poweroff stty
cat ps
ln ip \
160 dmesg mkdir
cp ping exportfs \
161 modprobe rpc.nfsd rpc.mountd showmount tcpdump \
162 /etc
/services
sleep mount
chmod
163 for _terminfodir
in /lib
/terminfo
/etc
/terminfo
/usr
/share
/terminfo
; do
164 [ -f "${_terminfodir}"/l
/linux
] && break
166 inst_multiple
-o "${_terminfodir}"/l
/linux
167 type -P portmap
>/dev
/null
&& inst_multiple portmap
168 type -P rpcbind
>/dev
/null
&& inst_multiple rpcbind
169 [ -f /etc
/netconfig
] && inst_multiple
/etc
/netconfig
170 type -P dhcpd
>/dev
/null
&& inst_multiple dhcpd
171 [ -x /usr
/sbin
/dhcpd3
] && inst
/usr
/sbin
/dhcpd3
/usr
/sbin
/dhcpd
172 instmods nfsd sunrpc ipv6 lockd af_packet
173 inst_simple
/etc
/os-release
174 inst .
/server-init.sh
/sbin
/init
175 inst .
/hosts
/etc
/hosts
176 inst .
/exports
/etc
/exports
177 inst .
/dhcpd.conf
/etc
/dhcpd.conf
178 inst_multiple
/etc
/nsswitch.conf
/etc
/rpc
/etc
/protocols
180 inst_multiple rpc.idmapd
/etc
/idmapd.conf
182 inst_libdir_file
'libnfsidmap_nsswitch.so*'
183 inst_libdir_file
'libnfsidmap/*.so*'
184 inst_libdir_file
'libnfsidmap*.so*'
186 _nsslibs
=$
(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' /etc
/nsswitch.conf \
187 |
tr -s '[:space:]' '\n' |
sort -u |
tr -s '[:space:]' '|')
188 _nsslibs
=${_nsslibs#|}
189 _nsslibs
=${_nsslibs%|}
191 inst_libdir_file
-n "$_nsslibs" 'libnss_*.so*'
193 inst
/etc
/nsswitch.conf
/etc
/nsswitch.conf
194 inst
/etc
/passwd
/etc
/passwd
195 inst
/etc
/group
/etc
/group
197 cp -a -- /etc
/ld.so.conf
* "$initdir"/etc
198 sudo ldconfig
-r -- "$initdir"
202 # Make client root inside server root
204 export initdir
="$TESTDIR"/mnt
/nfs
/client
205 .
"$basedir"/dracut-functions.sh
206 inst_multiple sh shutdown poweroff stty
cat ps
ln ip \
207 mount dmesg mkdir
cp ping grep ls
208 for _terminfodir
in /lib
/terminfo
/etc
/terminfo
/usr
/share
/terminfo
; do
209 [[ -f ${_terminfodir}/l
/linux
]] && break
211 inst_multiple
-o "${_terminfodir}"/l
/linux
212 inst_simple
/etc
/os-release
213 inst .
/client-init.sh
/sbin
/init
216 mkdir
-p -- dev sys proc etc run
217 mkdir
-p -- var
/lib
/nfs
/rpc_pipefs
219 inst
/etc
/nsswitch.conf
/etc
/nsswitch.conf
220 inst
/etc
/passwd
/etc
/passwd
221 inst
/etc
/group
/etc
/group
223 inst_multiple rpc.idmapd
/etc
/idmapd.conf
224 inst_libdir_file
'libnfsidmap_nsswitch.so*'
225 inst_libdir_file
'libnfsidmap/*.so*'
226 inst_libdir_file
'libnfsidmap*.so*'
228 _nsslibs
=$
(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' -- /etc
/nsswitch.conf \
229 |
tr -s '[:space:]' '\n' |
sort -u |
tr -s '[:space:]' '|')
230 _nsslibs
=${_nsslibs#|}
231 _nsslibs
=${_nsslibs%|}
233 inst_libdir_file
-n "$_nsslibs" 'libnss_*.so*'
235 cp -a -- /etc
/ld.so.conf
* "$initdir"/etc
236 sudo ldconfig
-r "$initdir"
239 sudo umount
"$TESTDIR"/mnt
240 rm -fr -- "$TESTDIR"/mnt
242 # Make an overlay with needed tools for the test harness
244 export initdir
="$TESTDIR"/overlay
245 .
"$basedir"/dracut-functions.sh
246 inst_multiple poweroff shutdown
247 inst_hook emergency
000 .
/hard-off.sh
248 inst_simple .
/99-idesymlinks.rules
/etc
/udev
/rules.d
/99-idesymlinks.rules
251 # Make server's dracut image
252 $basedir/dracut.sh
-l -i "$TESTDIR"/overlay
/ \
253 -m "dash udev-rules base rootfs-block debug kernel-modules watchdog" \
254 -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" \
255 -f "$TESTDIR"/initramfs.server
"$KVERSION" ||
return 1
257 # Make client's dracut image
258 $basedir/dracut.sh
-l -i "$TESTDIR"/overlay
/ \
261 -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" \
262 -f "$TESTDIR"/initramfs.testing
"$KVERSION" ||
return 1
266 if [[ -s "$TESTDIR"/server.pid
]]; then
267 sudo
kill -TERM -- $
(cat "$TESTDIR"/server.pid
)
268 rm -f -- "$TESTDIR"/server.pid
276 .
"$testdir"/test-functions