]> git.ipfire.org Git - thirdparty/dracut.git/blob - test/TEST-16-DMSQUASH/test.sh
test: use hosts randomness, not rngd
[thirdparty/dracut.git] / test / TEST-16-DMSQUASH / test.sh
1 #!/bin/bash
2 TEST_DESCRIPTION="root filesystem on a LiveCD dmsquash filesystem"
3
4 KVERSION="${KVERSION-$(uname -r)}"
5
6 # Uncomment this to debug failures
7 #DEBUGFAIL="rd.shell rd.break rd.debug systemd.log_level=debug systemd.log_target=console"
8
9 test_check() {
10 for pdir in $(python -c "import site; print(site.getsitepackages())" | sed -e 's/\[\(.*\)\]/\1/' -e "s/', /' /g") ; do
11 pdir1=$(echo $pdir | sed "s/^'\(.*\)'$/\1/")
12 if [[ -d $pdir1/imgcreate ]]; then
13 return 0
14 fi
15 done
16 echo "python-imgcreate not installed"
17 return 1
18 }
19
20 test_run() {
21 "$testdir"/run-qemu \
22 -boot order=d \
23 -drive format=raw,bps=1000000,index=0,media=disk,file="$TESTDIR"/livecd.iso \
24 -drive format=raw,index=1,media=disk,file="$TESTDIR"/root.img \
25 -m 512M -smp 2 \
26 -nographic \
27 -net none \
28 -no-reboot \
29 -append "panic=1 systemd.crash_reboot root=live:CDLABEL=LiveCD live rw quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.shell=0 $DEBUGFAIL" \
30 -initrd "$TESTDIR"/initramfs.testing
31
32 # mediacheck test with qemu GUI
33 # "$testdir"/run-qemu \
34 # -drive format=raw,bps=1000000,index=0,media=disk,file="$TESTDIR"/livecd.iso \
35 # -drive format=raw,index=1,media=disk,file="$TESTDIR"/root.img \
36 # -m 512M -smp 2 \
37 # -net none \
38 # -append "root=live:CDLABEL=LiveCD live quiet rhgb selinux=0 rd.live.check" \
39 # -initrd "$TESTDIR"/initramfs.testing
40
41 grep -F -m 1 -q dracut-root-block-success -- "$TESTDIR"/root.img || return 1
42 }
43
44 test_setup() {
45 mkdir -p -- "$TESTDIR"/overlay
46 (
47 export initdir="$TESTDIR"/overlay
48 . "$basedir"/dracut-init.sh
49 inst_multiple poweroff shutdown
50 inst_hook shutdown-emergency 000 ./hard-off.sh
51 inst_hook emergency 000 ./hard-off.sh
52 inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
53 )
54
55 dd if=/dev/zero of="$TESTDIR"/root.img count=100
56
57 sudo $basedir/dracut.sh -l -i "$TESTDIR"/overlay / \
58 -a "debug dmsquash-live qemu" \
59 -o "rngd" \
60 -d "piix ide-gd_mod ata_piix ext3 sd_mod" \
61 --no-hostonly-cmdline -N \
62 -f "$TESTDIR"/initramfs.testing "$KVERSION" || return 1
63
64 mkdir -p -- "$TESTDIR"/root-source
65 kernel="$KVERSION"
66 # Create what will eventually be our root filesystem onto an overlay
67 (
68 export initdir="$TESTDIR"/root-source
69 . "$basedir"/dracut-init.sh
70 (
71 cd "$initdir"
72 mkdir -p -- dev sys proc etc var/run tmp
73 mkdir -p root usr/bin usr/lib usr/lib64 usr/sbin
74 for i in bin sbin lib lib64; do
75 ln -sfnr usr/$i $i
76 done
77 )
78 inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip \
79 mount dmesg dhclient mkdir cp ping dhclient \
80 umount strace less
81 for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
82 [[ -f ${_terminfodir}/l/linux ]] && break
83 done
84 inst_multiple -o "${_terminfodir}"/l/linux
85 inst "$basedir/modules.d/35network-legacy/dhclient-script.sh" "/sbin/dhclient-script"
86 inst "$basedir/modules.d/35network-legacy/ifup.sh" "/sbin/ifup"
87 inst_multiple grep syslinux isohybrid
88 for f in /usr/share/syslinux/*; do
89 inst_simple "$f"
90 done
91 inst_simple /etc/os-release
92 inst ./test-init.sh /sbin/init
93 inst "$TESTDIR"/initramfs.testing "/boot/initramfs-$KVERSION.img"
94 [[ -f /etc/machine-id ]] && read MACHINE_ID < /etc/machine-id
95
96 VMLINUZ="/lib/modules/${KVERSION}/vmlinuz"
97 if ! [[ -e $VMLINUZ ]]; then
98 if [[ $MACHINE_ID ]] && ( [[ -d /boot/${MACHINE_ID} ]] || [[ -L /boot/${MACHINE_ID} ]] ); then
99 VMLINUZ="/boot/${MACHINE_ID}/$KVERSION/linux"
100 fi
101 fi
102 [[ -e $VMLINUZ ]] || VMLINUZ="/boot/vmlinuz-${KVERSION}"
103
104 inst "$VMLINUZ" "/boot/vmlinuz-${KVERSION}"
105 find_binary plymouth >/dev/null && inst_multiple plymouth
106 cp -a -- /etc/ld.so.conf* "$initdir"/etc
107 sudo ldconfig -r "$initdir"
108 )
109 python create.py -d -c livecd-fedora-minimal.ks
110 return 0
111 }
112
113 test_cleanup() {
114 return 0
115 }
116
117 . "$testdir"/test-functions