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"
15 echo "MULTINIC TEST SETUP: Starting DHCP/NFS server"
17 $testdir/run-qemu
-hda $TESTDIR/server.ext3
-m 512M
-nographic \
18 -net nic
,macaddr
=52:54:00:12:34:56,model
=e1000 \
19 -net socket
,listen
=127.0.0.1:12350 \
21 -watchdog ib700
-watchdog-action poweroff \
22 -kernel /boot
/vmlinuz-
$KVERSION \
23 -append "selinux=0 root=/dev/sda rootfstype=ext3 rd.debug rd.info rw loglevel=77 console=ttyS0,115200n81" \
24 -initrd $TESTDIR/initramfs.server
-pidfile $TESTDIR/server.pid
-daemonize ||
return 1
25 sudo
chmod 644 $TESTDIR/server.pid ||
return 1
27 # Cleanup the terminal if we have one
30 echo Sleeping
10 seconds to give the server a
head start
42 echo "CLIENT TEST START: $test_name"
44 # Need this so kvm-qemu will boot (needs non-/dev/zero local disk)
45 if ! dd if=/dev
/zero of
=$TESTDIR/client.img bs
=1M count
=1; then
46 echo "Unable to make client sda image" 1>&2
50 $testdir/run-qemu
-hda $TESTDIR/client.img
-m 512M
-nographic \
51 -net nic
,macaddr
=52:54:00:12:34:$mac1,model
=e1000 \
52 -net nic
,macaddr
=52:54:00:12:34:$mac2,model
=e1000 \
53 -net nic
,macaddr
=52:54:00:12:34:$mac3,model
=e1000 \
54 -net socket
,connect
=127.0.0.1:12350 \
56 -watchdog ib700
-watchdog-action poweroff \
57 -kernel /boot
/vmlinuz-
$KVERSION \
58 -append "$cmdline $DEBUGFAIL rd.retry=5 rd.debug rd.info ro rd.systemd.log_level=debug console=ttyS0,115200n81 selinux=0 rd.copystate rd.chroot init=/sbin/init" \
59 -initrd $TESTDIR/initramfs.testing
61 if [[ $?
-ne 0 ]] ||
! grep -m 1 -q OK
$TESTDIR/client.img
; then
62 echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]"
69 if ! grep -m 1 -q $i $TESTDIR/client.img
; then
70 echo "CLIENT TEST END: $test_name [FAILED - BAD IF]"
75 echo "CLIENT TEST END: $test_name [OK]"
82 echo "Failed to start server" 1>&2
85 test_client ||
{ kill_server
; return 1; }
89 # Mac Numbering Scheme
90 # ...:00-02 receive IP adresses all others don't
91 # ...:02 receives a dhcp root-path
94 # client_test "MULTINIC root=nfs BOOTIF=" \
96 # "root=nfs:192.168.50.1:/nfs/client BOOTIF=52-54-00-12-34-00" \
99 # PXE Style BOOTIF= with dhcp root-path
100 client_test
"MULTINIC root=dhcp BOOTIF=" \
102 "root=dhcp BOOTIF=52-54-00-12-34-02" \
105 # Multinic case, where only one nic works
106 client_test
"MULTINIC root=nfs ip=dhcp" \
108 "root=nfs:192.168.50.1:/nfs/client ip=dhcp" \
111 # Require two interfaces
112 client_test
"MULTINIC root=nfs ip=eth1:dhcp ip=eth2:dhcp bootdev=eth1" \
114 "root=nfs:192.168.50.1:/nfs/client ip=eth1:dhcp ip=eth2:dhcp bootdev=eth1" \
115 "eth1 eth2" ||
return 1
117 # Require three interfaces with dhcp root-path
118 client_test
"MULTINIC root=dhcp ip=eth0:dhcp ip=eth1:dhcp ip=eth2:dhcp bootdev=eth2" \
120 "root=dhcp ip=eth0:dhcp ip=eth1:dhcp ip=eth2:dhcp bootdev=eth2" \
121 "eth0 eth1 eth2" ||
return 1
129 dd if=/dev
/null of
=$TESTDIR/server.ext3 bs
=1M seek
=60
130 mke2fs
-j -F $TESTDIR/server.ext3
132 sudo mount
-o loop
$TESTDIR/server.ext3
$TESTDIR/mnt
135 export initdir
=$TESTDIR/mnt
136 .
$basedir/dracut-functions.sh
140 mkdir
-p dev sys proc run etc var
/run tmp var
/lib
/{dhcpd
,rpcbind
}
141 mkdir
-p var
/lib
/nfs
/{v4recovery
,rpc_pipefs
}
142 chmod 777 var
/lib
/rpcbind var
/lib
/nfs
145 for _f
in modules.
builtin.bin modules.
builtin; do
146 [[ $srcmods/$_f ]] && break
148 dfatal
"No modules.builtin.bin and modules.builtin found!"
152 for _f
in modules.
builtin.bin modules.
builtin modules.order
; do
153 [[ $srcmods/$_f ]] && inst_simple
"$srcmods/$_f" "/lib/modules/$kernel/$_f"
156 dracut_install sh
ls shutdown poweroff stty
cat ps
ln ip \
157 dmesg mkdir
cp ping exportfs \
158 modprobe rpc.nfsd rpc.mountd showmount tcpdump \
159 /etc
/services
sleep mount
chmod
160 for _terminfodir
in /lib
/terminfo
/etc
/terminfo
/usr
/share
/terminfo
; do
161 [ -f ${_terminfodir}/l
/linux
] && break
163 dracut_install
-o ${_terminfodir}/l
/linux
164 type -P portmap
>/dev
/null
&& dracut_install portmap
165 type -P rpcbind
>/dev
/null
&& dracut_install rpcbind
166 [ -f /etc
/netconfig
] && dracut_install
/etc
/netconfig
167 type -P dhcpd
>/dev
/null
&& dracut_install dhcpd
168 [ -x /usr
/sbin
/dhcpd3
] && inst
/usr
/sbin
/dhcpd3
/usr
/sbin
/dhcpd
169 instmods nfsd sunrpc ipv6 lockd
170 inst .
/server-init.sh
/sbin
/init
171 inst .
/hosts
/etc
/hosts
172 inst .
/exports
/etc
/exports
173 inst .
/dhcpd.conf
/etc
/dhcpd.conf
174 dracut_install
/etc
/nsswitch.conf
/etc
/rpc
/etc
/protocols
176 dracut_install rpc.idmapd
/etc
/idmapd.conf
178 inst_libdir_file
'libnfsidmap_nsswitch.so*'
179 inst_libdir_file
'libnfsidmap/*.so*'
180 inst_libdir_file
'libnfsidmap*.so*'
182 _nsslibs
=$
(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' /etc
/nsswitch.conf \
183 |
tr -s '[:space:]' '\n' |
sort -u |
tr -s '[:space:]' '|')
184 _nsslibs
=${_nsslibs#|}
185 _nsslibs
=${_nsslibs%|}
187 inst_libdir_file
-n "$_nsslibs" 'libnss*.so*'
189 inst
/etc
/nsswitch.conf
/etc
/nsswitch.conf
190 inst
/etc
/passwd
/etc
/passwd
191 inst
/etc
/group
/etc
/group
193 cp -a /etc
/ld.so.conf
* $initdir/etc
194 sudo ldconfig
-r "$initdir"
198 # Make client root inside server root
200 export initdir
=$TESTDIR/mnt
/nfs
/client
201 .
$basedir/dracut-functions.sh
202 dracut_install sh shutdown poweroff stty
cat ps
ln ip \
203 mount dmesg mkdir
cp ping grep ls
204 for _terminfodir
in /lib
/terminfo
/etc
/terminfo
/usr
/share
/terminfo
; do
205 [ -f ${_terminfodir}/l
/linux
] && break
207 dracut_install
-o ${_terminfodir}/l
/linux
208 inst .
/client-init.sh
/sbin
/init
211 mkdir
-p dev sys proc etc run
212 mkdir
-p var
/lib
/nfs
/rpc_pipefs
214 inst
/etc
/nsswitch.conf
/etc
/nsswitch.conf
215 inst
/etc
/passwd
/etc
/passwd
216 inst
/etc
/group
/etc
/group
218 dracut_install rpc.idmapd
/etc
/idmapd.conf
219 inst_libdir_file
'libnfsidmap_nsswitch.so*'
220 inst_libdir_file
'libnfsidmap/*.so*'
221 inst_libdir_file
'libnfsidmap*.so*'
223 _nsslibs
=$
(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' /etc
/nsswitch.conf \
224 |
tr -s '[:space:]' '\n' |
sort -u |
tr -s '[:space:]' '|')
225 _nsslibs
=${_nsslibs#|}
226 _nsslibs
=${_nsslibs%|}
228 inst_libdir_file
-n "$_nsslibs" 'libnss*.so*'
230 cp -a /etc
/ld.so.conf
* $initdir/etc
231 sudo ldconfig
-r "$initdir"
234 sudo umount
$TESTDIR/mnt
237 # Make an overlay with needed tools for the test harness
239 export initdir
=$TESTDIR/overlay
240 .
$basedir/dracut-functions.sh
241 dracut_install poweroff shutdown
242 inst_hook emergency
000 .
/hard-off.sh
243 inst_simple .
/99-idesymlinks.rules
/etc
/udev
/rules.d
/99-idesymlinks.rules
246 # Make server's dracut image
247 $basedir/dracut.sh
-l -i $TESTDIR/overlay
/ \
248 -m "dash udev-rules base rootfs-block debug kernel-modules watchdog" \
249 -d "piix ide-gd_mod ata_piix ext3 sd_mod e1000 ib700wdt" \
250 -f $TESTDIR/initramfs.server
$KVERSION ||
return 1
252 # Make client's dracut image
253 $basedir/dracut.sh
-l -i $TESTDIR/overlay
/ \
256 -d "piix sd_mod sr_mod ata_piix ide-gd_mod e1000 nfs sunrpc ib700wdt" \
257 -f $TESTDIR/initramfs.testing
$KVERSION ||
return 1
261 if [[ -s $TESTDIR/server.pid
]]; then
262 sudo
kill -TERM $
(cat $TESTDIR/server.pid
)
263 rm -f $TESTDIR/server.pid
271 .
$testdir/test-functions