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