]>
Commit | Line | Data |
---|---|---|
9ecbe2e4 | 1 | #!/bin/bash |
967cc19a | 2 | |
9ecbe2e4 DD |
3 | TEST_DESCRIPTION="root filesystem on NBD" |
4 | ||
5 | KVERSION=${KVERSION-$(uname -r)} | |
6 | ||
7 | # Uncomment this to debug failures | |
66a3d405 | 8 | #DEBUGFAIL="rd.shell rd.break rd.debug systemd.log_target=console loglevel=7 systemd.log_level=debug" |
b0d6254d | 9 | #SERIAL="tcp:127.0.0.1:9999" |
9ecbe2e4 | 10 | |
d63a4e28 HH |
11 | test_check() { |
12 | echo "nbd is constantly broken. skipping" | |
13 | return 1 | |
14 | } | |
15 | ||
9ecbe2e4 DD |
16 | run_server() { |
17 | # Start server first | |
b2c5f5dc | 18 | echo "NBD TEST SETUP: Starting DHCP/NBD server" |
9ecbe2e4 | 19 | |
0be1785a | 20 | $testdir/run-qemu \ |
4358ace4 HH |
21 | -drive format=raw,index=0,media=disk,file=$TESTDIR/server.ext2 \ |
22 | -drive format=raw,index=1,media=disk,file=$TESTDIR/nbd.ext2 \ | |
23 | -drive format=raw,index=2,media=disk,file=$TESTDIR/encrypted.ext2 \ | |
9b8e6e40 | 24 | -m 512M -smp 2 \ |
44f870be | 25 | -display none \ |
83691c41 HH |
26 | -net nic,macaddr=52:54:00:12:34:56,model=e1000 \ |
27 | -net socket,listen=127.0.0.1:12340 \ | |
b0d6254d HH |
28 | ${SERIAL:+-serial "$SERIAL"} \ |
29 | ${SERIAL:--serial file:"$TESTDIR"/server.log} \ | |
36867f1a | 30 | -no-reboot \ |
7934c6f9 | 31 | -append "panic=1 systemd.crash_reboot root=/dev/sda rootfstype=ext2 rw quiet console=ttyS0,115200n81 selinux=0" \ |
83691c41 | 32 | -initrd $TESTDIR/initramfs.server -pidfile $TESTDIR/server.pid -daemonize || return 1 |
0be1785a | 33 | sudo chmod 644 $TESTDIR/server.pid || return 1 |
9ecbe2e4 DD |
34 | |
35 | # Cleanup the terminal if we have one | |
36 | tty -s && stty sane | |
37 | ||
38 | echo Sleeping 10 seconds to give the server a head start | |
39 | sleep 10 | |
40 | } | |
41 | ||
42 | client_test() { | |
43 | local test_name="$1" | |
44 | local mac=$2 | |
45 | local cmdline="$3" | |
a29f15a5 DD |
46 | local fstype=$4 |
47 | local fsopt=$5 | |
48 | local found opts nbdinfo | |
49 | ||
50 | [[ $fstype ]] || fstype=ext3 | |
75e8f476 | 51 | [[ $fsopt ]] || fsopt="ro" |
9ecbe2e4 DD |
52 | |
53 | echo "CLIENT TEST START: $test_name" | |
54 | ||
55 | # Clear out the flags for each test | |
0be1785a | 56 | if ! dd if=/dev/zero of=$TESTDIR/flag.img bs=1M count=1; then |
83691c41 HH |
57 | echo "Unable to make client sda image" 1>&2 |
58 | return 1 | |
9ecbe2e4 | 59 | fi |
83691c41 | 60 | |
0be1785a | 61 | $testdir/run-qemu \ |
4358ace4 | 62 | -drive format=raw,index=0,media=disk,file=$TESTDIR/flag.img \ |
bdd62605 | 63 | -m 512M -smp 2 \ |
83691c41 HH |
64 | -nographic \ |
65 | -net nic,macaddr=$mac,model=e1000 \ | |
66 | -net socket,connect=127.0.0.1:12340 \ | |
36867f1a | 67 | -no-reboot \ |
7934c6f9 | 68 | -append "panic=1 systemd.crash_reboot rd.shell=0 $cmdline $DEBUGFAIL rd.auto rd.info rd.retry=10 ro console=ttyS0,115200n81 selinux=0 " \ |
83691c41 | 69 | -initrd $TESTDIR/initramfs.testing |
9ecbe2e4 | 70 | |
021b2fdd | 71 | if [[ $? -ne 0 ]] || ! grep -F -m 1 -q nbd-OK $TESTDIR/flag.img; then |
83691c41 HH |
72 | echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]" |
73 | return 1 | |
9ecbe2e4 DD |
74 | fi |
75 | ||
a29f15a5 | 76 | # nbdinfo=( fstype fsoptions ) |
0be1785a | 77 | nbdinfo=($(awk '{print $2, $3; exit}' $TESTDIR/flag.img)) |
a29f15a5 DD |
78 | |
79 | if [[ "${nbdinfo[0]}" != "$fstype" ]]; then | |
83691c41 HH |
80 | echo "CLIENT TEST END: $test_name [FAILED - WRONG FS TYPE] \"${nbdinfo[0]}\" != \"$fstype\"" |
81 | return 1 | |
a29f15a5 DD |
82 | fi |
83 | ||
84 | opts=${nbdinfo[1]}, | |
85 | while [[ $opts ]]; do | |
83691c41 HH |
86 | if [[ ${opts%%,*} = $fsopt ]]; then |
87 | found=1 | |
88 | break | |
89 | fi | |
90 | opts=${opts#*,} | |
a29f15a5 DD |
91 | done |
92 | ||
93 | if [[ ! $found ]]; then | |
83691c41 HH |
94 | echo "CLIENT TEST END: $test_name [FAILED - BAD FS OPTS] \"${nbdinfo[1]}\" != \"$fsopt\"" |
95 | return 1 | |
a29f15a5 DD |
96 | fi |
97 | ||
9ecbe2e4 DD |
98 | echo "CLIENT TEST END: $test_name [OK]" |
99 | } | |
100 | ||
101 | test_run() { | |
ebcfda6c | 102 | modinfo nbd &>/dev/null || { echo "Kernel does not support nbd"; exit 1; } |
9ecbe2e4 | 103 | if ! run_server; then |
83691c41 HH |
104 | echo "Failed to start server" 1>&2 |
105 | return 1 | |
9ecbe2e4 | 106 | fi |
57aa1e91 HH |
107 | client_run |
108 | kill_server | |
97add1b3 HH |
109 | } |
110 | ||
111 | client_run() { | |
a29f15a5 DD |
112 | # The default is ext3,errors=continue so use that to determine |
113 | # if our options were parsed and used | |
b070c1d3 | 114 | client_test "NBD root=nbd:IP:port" 52:54:00:12:34:00 \ |
d63a4e28 | 115 | "root=nbd:192.168.50.1:raw rd.luks=0" || return 1 |
b070c1d3 | 116 | |
83691c41 | 117 | client_test "NBD root=nbd:IP:port::fsopts" 52:54:00:12:34:00 \ |
d63a4e28 HH |
118 | "root=nbd:192.168.50.1:raw::errors=panic rd.luks=0" \ |
119 | ext3 errors=panic || return 1 | |
83691c41 | 120 | |
bcf94bba | 121 | client_test "NBD root=nbd:IP:port:fstype" 52:54:00:12:34:00 \ |
d63a4e28 | 122 | "root=nbd:192.168.50.1:raw:ext2 rd.luks=0" ext2 || return 1 |
a29f15a5 | 123 | |
bcf94bba | 124 | client_test "NBD root=nbd:IP:port:fstype:fsopts" 52:54:00:12:34:00 \ |
d63a4e28 HH |
125 | "root=nbd:192.168.50.1:raw:ext2:errors=panic rd.luks=0" \ |
126 | ext2 errors=panic || return 1 | |
a29f15a5 | 127 | |
bcf94bba | 128 | client_test "NBD Bridge root=nbd:IP:port:fstype:fsopts" 52:54:00:12:34:00 \ |
d63a4e28 HH |
129 | "root=nbd:192.168.50.1:raw:ext2:errors=panic bridge rd.luks=0" \ |
130 | ext2 errors=panic || return 1 | |
beb097d9 | 131 | |
d63a4e28 HH |
132 | # There doesn't seem to be a good way to validate the NBD options, so |
133 | # just check that we don't screw up the other options | |
a29f15a5 | 134 | |
bcf94bba | 135 | client_test "NBD root=nbd:IP:port:::NBD opts" 52:54:00:12:34:00 \ |
d63a4e28 | 136 | "root=nbd:192.168.50.1:raw:::bs=2048 rd.luks=0" || return 1 |
a29f15a5 | 137 | |
bcf94bba | 138 | client_test "NBD root=nbd:IP:port:fstype::NBD opts" 52:54:00:12:34:00 \ |
d63a4e28 | 139 | "root=nbd:192.168.50.1:raw:ext2::bs=2048 rd.luks=0" ext2 || return 1 |
a29f15a5 | 140 | |
bcf94bba | 141 | client_test "NBD root=nbd:IP:port:fstype:fsopts:NBD opts" \ |
d63a4e28 HH |
142 | 52:54:00:12:34:00 \ |
143 | "root=nbd:192.168.50.1:raw:ext2:errors=panic:bs=2048 rd.luks=0" \ | |
144 | ext2 errors=panic || return 1 | |
a29f15a5 | 145 | |
a29f15a5 DD |
146 | # DHCP root-path parsing |
147 | ||
9ecbe2e4 | 148 | client_test "NBD root=dhcp DHCP root-path nbd:srv:port" 52:54:00:12:34:01 \ |
d63a4e28 | 149 | "root=dhcp rd.luks=0" || return 1 |
a29f15a5 | 150 | |
beb097d9 | 151 | client_test "NBD Bridge root=dhcp DHCP root-path nbd:srv:port" 52:54:00:12:34:01 \ |
d63a4e28 | 152 | "root=dhcp bridge rd.luks=0" || return 1 |
beb097d9 | 153 | |
a29f15a5 | 154 | client_test "NBD root=dhcp DHCP root-path nbd:srv:port:fstype" \ |
d63a4e28 | 155 | 52:54:00:12:34:02 "root=dhcp rd.luks=0" ext2 || return 1 |
a29f15a5 DD |
156 | |
157 | client_test "NBD root=dhcp DHCP root-path nbd:srv:port::fsopts" \ | |
d63a4e28 | 158 | 52:54:00:12:34:03 "root=dhcp rd.luks=0" ext3 errors=panic || return 1 |
a29f15a5 DD |
159 | |
160 | client_test "NBD root=dhcp DHCP root-path nbd:srv:port:fstype:fsopts" \ | |
d63a4e28 | 161 | 52:54:00:12:34:04 "root=dhcp rd.luks=0" ext2 errors=panic || return 1 |
aec48753 DD |
162 | |
163 | # netroot handling | |
164 | ||
165 | client_test "NBD netroot=nbd:IP:port" 52:54:00:12:34:00 \ | |
d63a4e28 | 166 | "netroot=nbd:192.168.50.1:raw rd.luks=0" || return 1 |
aec48753 DD |
167 | |
168 | client_test "NBD netroot=dhcp DHCP root-path nbd:srv:port:fstype:fsopts" \ | |
d63a4e28 | 169 | 52:54:00:12:34:04 "netroot=dhcp rd.luks=0" ext2 errors=panic || return 1 |
8bd5873f DD |
170 | |
171 | # Encrypted root handling via LVM/LUKS over NBD | |
172 | ||
83691c41 HH |
173 | . $TESTDIR/luks.uuid |
174 | ||
bb278147 | 175 | client_test "NBD root=LABEL=dracut netroot=nbd:IP:port" \ |
d63a4e28 HH |
176 | 52:54:00:12:34:00 \ |
177 | "root=LABEL=dracut rd.luks.uuid=$ID_FS_UUID rd.lv.vg=dracut netroot=nbd:192.168.50.1:encrypted" || return 1 | |
8bd5873f DD |
178 | |
179 | # XXX This should be ext2,errors=panic but that doesn't currently | |
180 | # XXX work when you have a real root= line in addition to netroot= | |
181 | # XXX How we should work here needs clarification | |
bb278147 | 182 | client_test "NBD root=LABEL=dracut netroot=dhcp (w/ fstype and opts)" \ |
d63a4e28 HH |
183 | 52:54:00:12:34:05 \ |
184 | "root=LABEL=dracut rd.luks.uuid=$ID_FS_UUID rd.lv.vg=dracut netroot=dhcp" || return 1 | |
9ca74ffe HH |
185 | |
186 | if [[ -s server.pid ]]; then | |
83691c41 | 187 | sudo kill -TERM $(cat $TESTDIR/server.pid) |
32bd2fbb | 188 | rm -f -- $TESTDIR/server.pid |
9ca74ffe HH |
189 | fi |
190 | ||
8bd5873f DD |
191 | } |
192 | ||
193 | make_encrypted_root() { | |
194 | # Create the blank file to use as a root filesystem | |
66a3d405 | 195 | dd if=/dev/null of=$TESTDIR/encrypted.ext2 bs=1M seek=40 |
0be1785a | 196 | dd if=/dev/null of=$TESTDIR/flag.img bs=1M seek=1 |
8bd5873f DD |
197 | |
198 | kernel=$KVERSION | |
199 | # Create what will eventually be our root filesystem onto an overlay | |
200 | ( | |
83691c41 | 201 | export initdir=$TESTDIR/overlay/source |
777f2db0 | 202 | . $basedir/dracut-init.sh |
28f0b27f | 203 | mkdir -p "$initdir" |
06853123 | 204 | ( |
d63a4e28 HH |
205 | cd "$initdir" |
206 | mkdir -p dev sys proc etc var tmp run root usr/bin usr/lib usr/lib64 usr/sbin | |
06853123 HH |
207 | for i in bin sbin lib lib64; do |
208 | ln -sfnr usr/$i $i | |
209 | done | |
d63a4e28 | 210 | ln -s ../run var/run |
06853123 | 211 | ) |
af119460 | 212 | inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \ |
d63a4e28 | 213 | mount dmesg mkdir cp ping |
96d22bd7 | 214 | for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do |
83691c41 HH |
215 | [ -f ${_terminfodir}/l/linux ] && break |
216 | done | |
af119460 | 217 | inst_multiple -o ${_terminfodir}/l/linux |
83691c41 | 218 | inst ./client-init.sh /sbin/init |
021b2fdd | 219 | inst_simple /etc/os-release |
af119460 | 220 | find_binary plymouth >/dev/null && inst_multiple plymouth |
83691c41 HH |
221 | cp -a /etc/ld.so.conf* $initdir/etc |
222 | sudo ldconfig -r "$initdir" | |
8bd5873f DD |
223 | ) |
224 | ||
225 | # second, install the files needed to make the root filesystem | |
226 | ( | |
83691c41 | 227 | export initdir=$TESTDIR/overlay |
777f2db0 | 228 | . $basedir/dracut-init.sh |
06853123 | 229 | ( |
d63a4e28 HH |
230 | cd "$initdir" |
231 | mkdir -p dev sys proc etc tmp var run root usr/bin usr/lib usr/lib64 usr/sbin | |
06853123 HH |
232 | for i in bin sbin lib lib64; do |
233 | ln -sfnr usr/$i $i | |
234 | done | |
d63a4e28 | 235 | ln -s ../run var/run |
06853123 | 236 | ) |
af119460 | 237 | inst_multiple mke2fs poweroff cp umount tune2fs |
4e882b80 | 238 | inst_hook shutdown-emergency 000 ./hard-off.sh |
781f1971 | 239 | inst_hook emergency 000 ./hard-off.sh |
83691c41 | 240 | inst_hook initqueue 01 ./create-root.sh |
356333b3 | 241 | inst_hook initqueue/finished 01 ./finished-false.sh |
83691c41 | 242 | inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules |
8bd5873f DD |
243 | ) |
244 | ||
245 | # create an initramfs that will create the target root filesystem. | |
246 | # We do it this way so that we do not risk trashing the host mdraid | |
247 | # devices, volume groups, encrypted partitions, etc. | |
552ecca6 | 248 | $basedir/dracut.sh -l -i $TESTDIR/overlay / \ |
8996d3df | 249 | -m "dash crypt lvm mdraid udev-rules base rootfs-block fs-lib kernel-modules qemu" \ |
d63a4e28 HH |
250 | -d "piix ide-gd_mod ata_piix ext2 ext3 sd_mod" \ |
251 | --no-hostonly-cmdline -N \ | |
252 | -f $TESTDIR/initramfs.makeroot $KVERSION || return 1 | |
32bd2fbb | 253 | rm -rf -- $TESTDIR/overlay |
8bd5873f DD |
254 | |
255 | # Invoke KVM and/or QEMU to actually create the target filesystem. | |
0be1785a | 256 | $testdir/run-qemu \ |
4358ace4 HH |
257 | -drive format=raw,index=0,media=disk,file=$TESTDIR/flag.img \ |
258 | -drive format=raw,index=1,media=disk,file=$TESTDIR/encrypted.ext2 \ | |
9b8e6e40 | 259 | -m 512M -smp 2\ |
83691c41 | 260 | -nographic -net none \ |
bb278147 | 261 | -append "root=/dev/fakeroot rw quiet console=ttyS0,115200n81 selinux=0" \ |
83691c41 | 262 | -initrd $TESTDIR/initramfs.makeroot || return 1 |
021b2fdd HH |
263 | grep -F -m 1 -q dracut-root-block-created $TESTDIR/flag.img || return 1 |
264 | grep -F -a -m 1 ID_FS_UUID $TESTDIR/flag.img > $TESTDIR/luks.uuid | |
9ecbe2e4 DD |
265 | } |
266 | ||
267 | make_client_root() { | |
66a3d405 | 268 | dd if=/dev/null of=$TESTDIR/nbd.ext2 bs=1M seek=60 |
0be1785a HH |
269 | mke2fs -F -j $TESTDIR/nbd.ext2 |
270 | mkdir $TESTDIR/mnt | |
271 | sudo mount -o loop $TESTDIR/nbd.ext2 $TESTDIR/mnt | |
9ecbe2e4 DD |
272 | |
273 | kernel=$KVERSION | |
274 | ( | |
83691c41 | 275 | export initdir=$TESTDIR/mnt |
777f2db0 | 276 | . $basedir/dracut-init.sh |
28f0b27f | 277 | mkdir -p "$initdir" |
06853123 | 278 | ( |
d63a4e28 HH |
279 | cd "$initdir" |
280 | mkdir -p dev sys proc etc var tmp run root usr/bin usr/lib usr/lib64 usr/sbin | |
06853123 HH |
281 | for i in bin sbin lib lib64; do |
282 | ln -sfnr usr/$i $i | |
283 | done | |
d63a4e28 | 284 | ln -s ../run var/run |
06853123 | 285 | ) |
af119460 | 286 | inst_multiple sh ls shutdown poweroff stty cat ps ln ip \ |
d63a4e28 | 287 | dmesg mkdir cp ping |
96d22bd7 | 288 | for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do |
83691c41 HH |
289 | [ -f ${_terminfodir}/l/linux ] && break |
290 | done | |
af119460 | 291 | inst_multiple -o ${_terminfodir}/l/linux |
83691c41 | 292 | inst ./client-init.sh /sbin/init |
021b2fdd | 293 | inst_simple /etc/os-release |
83691c41 HH |
294 | inst /etc/nsswitch.conf /etc/nsswitch.conf |
295 | inst /etc/passwd /etc/passwd | |
296 | inst /etc/group /etc/group | |
297 | for i in /usr/lib*/libnss_files* /lib*/libnss_files*;do | |
28f0b27f | 298 | [ -e "$i" ] || continue |
83691c41 HH |
299 | inst $i |
300 | done | |
301 | cp -a /etc/ld.so.conf* $initdir/etc | |
302 | sudo ldconfig -r "$initdir" | |
9ecbe2e4 DD |
303 | ) |
304 | ||
0be1785a | 305 | sudo umount $TESTDIR/mnt |
32bd2fbb | 306 | rm -fr -- $TESTDIR/mnt |
9ecbe2e4 DD |
307 | } |
308 | ||
309 | make_server_root() { | |
66a3d405 | 310 | dd if=/dev/null of=$TESTDIR/server.ext2 bs=1M seek=60 |
0be1785a HH |
311 | mke2fs -F $TESTDIR/server.ext2 |
312 | mkdir $TESTDIR/mnt | |
313 | sudo mount -o loop $TESTDIR/server.ext2 $TESTDIR/mnt | |
9ecbe2e4 DD |
314 | |
315 | kernel=$KVERSION | |
316 | ( | |
83691c41 | 317 | export initdir=$TESTDIR/mnt |
777f2db0 | 318 | . $basedir/dracut-init.sh |
28f0b27f | 319 | mkdir -p "$initdir" |
83691c41 HH |
320 | ( |
321 | cd "$initdir"; | |
d63a4e28 HH |
322 | mkdir -p run dev sys proc etc var var/lib/dhcpd tmp etc/nbd-server |
323 | ln -s ../run var/run | |
83691c41 | 324 | ) |
b070c1d3 HH |
325 | cat > "$initdir/etc/nbd-server/config" <<EOF |
326 | [generic] | |
327 | [raw] | |
328 | exportname = /dev/sdb | |
329 | port = 2000 | |
330 | [encrypted] | |
331 | exportname = /dev/sdc | |
332 | port = 2001 | |
333 | EOF | |
af119460 | 334 | inst_multiple sh ls shutdown poweroff stty cat ps ln ip \ |
d63a4e28 HH |
335 | dmesg mkdir cp ping grep \ |
336 | sleep nbd-server chmod modprobe vi | |
96d22bd7 | 337 | for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do |
83691c41 HH |
338 | [ -f ${_terminfodir}/l/linux ] && break |
339 | done | |
af119460 | 340 | inst_multiple -o ${_terminfodir}/l/linux |
83691c41 | 341 | instmods af_packet |
af119460 | 342 | type -P dhcpd >/dev/null && inst_multiple dhcpd |
83691c41 HH |
343 | [ -x /usr/sbin/dhcpd3 ] && inst /usr/sbin/dhcpd3 /usr/sbin/dhcpd |
344 | inst ./server-init.sh /sbin/init | |
021b2fdd | 345 | inst_simple /etc/os-release |
83691c41 HH |
346 | inst ./hosts /etc/hosts |
347 | inst ./dhcpd.conf /etc/dhcpd.conf | |
348 | inst /etc/nsswitch.conf /etc/nsswitch.conf | |
349 | inst /etc/passwd /etc/passwd | |
350 | inst /etc/group /etc/group | |
351 | for i in /usr/lib*/libnss_files* /lib*/libnss_files*;do | |
28f0b27f | 352 | [ -e "$i" ] || continue |
83691c41 HH |
353 | inst $i |
354 | done | |
9ecbe2e4 | 355 | |
83691c41 HH |
356 | cp -a /etc/ld.so.conf* $initdir/etc |
357 | sudo ldconfig -r "$initdir" | |
9ecbe2e4 DD |
358 | ) |
359 | ||
0be1785a | 360 | sudo umount $TESTDIR/mnt |
32bd2fbb | 361 | rm -fr -- $TESTDIR/mnt |
9ecbe2e4 DD |
362 | } |
363 | ||
364 | test_setup() { | |
ebcfda6c HH |
365 | |
366 | modinfo nbd &>/dev/null || { echo "Kernel does not support nbd"; exit 1; } | |
367 | ||
8bd5873f | 368 | make_encrypted_root || return 1 |
9ecbe2e4 DD |
369 | make_client_root || return 1 |
370 | make_server_root || return 1 | |
371 | ||
372 | # Make the test image | |
373 | ( | |
83691c41 | 374 | export initdir=$TESTDIR/overlay |
777f2db0 | 375 | . $basedir/dracut-init.sh |
af119460 | 376 | inst_multiple poweroff shutdown |
4e882b80 | 377 | inst_hook shutdown-emergency 000 ./hard-off.sh |
83691c41 | 378 | inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules |
3f7e5358 | 379 | inst ./cryptroot-ask.sh /sbin/cryptroot-ask |
83691c41 | 380 | |
d63a4e28 HH |
381 | # inst ./debug-shell.service /lib/systemd/system/debug-shell.service |
382 | # mkdir -p "${initdir}/lib/systemd/system/sysinit.target.wants" | |
383 | # ln -fs ../debug-shell.service "${initdir}/lib/systemd/system/sysinit.target.wants/debug-shell.service" | |
83691c41 | 384 | |
3f7e5358 HH |
385 | . $TESTDIR/luks.uuid |
386 | mkdir -p $initdir/etc | |
83691c41 | 387 | echo "luks-$ID_FS_UUID /dev/nbd0 /etc/key" > $initdir/etc/crypttab |
3f7e5358 | 388 | echo -n test > $initdir/etc/key |
9ecbe2e4 DD |
389 | ) |
390 | ||
552ecca6 | 391 | sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \ |
d63a4e28 HH |
392 | -m "dash udev-rules rootfs-block fs-lib base debug kernel-modules" \ |
393 | -d "af_packet piix ide-gd_mod ata_piix ext2 ext3 sd_mod e1000" \ | |
394 | --no-hostonly-cmdline -N \ | |
395 | -f $TESTDIR/initramfs.server $KVERSION || return 1 | |
9ecbe2e4 | 396 | |
552ecca6 | 397 | sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \ |
d63a4e28 HH |
398 | -o "plymouth" \ |
399 | -a "debug watchdog" \ | |
400 | -d "af_packet piix ide-gd_mod ata_piix ext2 ext3 sd_mod e1000 i6300esb ib700wdt" \ | |
401 | --no-hostonly-cmdline -N \ | |
402 | -f $TESTDIR/initramfs.testing $KVERSION || return 1 | |
9ecbe2e4 DD |
403 | } |
404 | ||
97add1b3 | 405 | kill_server() { |
0be1785a | 406 | if [[ -s $TESTDIR/server.pid ]]; then |
83691c41 | 407 | sudo kill -TERM $(cat $TESTDIR/server.pid) |
32bd2fbb | 408 | rm -f -- $TESTDIR/server.pid |
9ecbe2e4 | 409 | fi |
97add1b3 HH |
410 | } |
411 | ||
412 | test_cleanup() { | |
413 | kill_server | |
9ecbe2e4 DD |
414 | } |
415 | ||
416 | . $testdir/test-functions |