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