]> git.ipfire.org Git - thirdparty/dracut.git/blame - test/TEST-16-DMSQUASH/test.sh
test: remove "sudo" calls in test scripts
[thirdparty/dracut.git] / test / TEST-16-DMSQUASH / test.sh
CommitLineData
ea8e543b
HH
1#!/bin/bash
2TEST_DESCRIPTION="root filesystem on a LiveCD dmsquash filesystem"
3
b093aa2d 4KVERSION="${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 9test_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 20test_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 \
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
90ac2d24
HH
31
32 # mediacheck test with qemu GUI
33 # "$testdir"/run-qemu \
2f78bafa
HH
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
90ac2d24 40
b093aa2d 41 grep -F -m 1 -q dracut-root-block-success -- "$TESTDIR"/root.img || return 1
ea8e543b
HH
42}
43
44test_setup() {
b093aa2d 45 mkdir -p -- "$TESTDIR"/overlay
ea8e543b 46 (
2f78bafa
HH
47 export initdir="$TESTDIR"/overlay
48 . "$basedir"/dracut-init.sh
49 inst_multiple poweroff shutdown
50 inst_hook shutdown-emergency 000 ./hard-off.sh
781f1971 51 inst_hook emergency 000 ./hard-off.sh
2f78bafa 52 inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
ea8e543b
HH
53 )
54
b093aa2d 55 dd if=/dev/zero of="$TESTDIR"/root.img count=100
ea8e543b 56
4bd0ab61 57 $basedir/dracut.sh -l -i "$TESTDIR"/overlay / \
2f78bafa
HH
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
ea8e543b 63
b093aa2d
HH
64 mkdir -p -- "$TESTDIR"/root-source
65 kernel="$KVERSION"
ea8e543b
HH
66 # Create what will eventually be our root filesystem onto an overlay
67 (
2f78bafa
HH
68 export initdir="$TESTDIR"/root-source
69 . "$basedir"/dracut-init.sh
70 (
06853123
HH
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 )
2f78bafa
HH
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
96d22bd7 81 for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
2f78bafa
HH
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
021b2fdd 91 inst_simple /etc/os-release
2f78bafa
HH
92 inst ./test-init.sh /sbin/init
93 inst "$TESTDIR"/initramfs.testing "/boot/initramfs-$KVERSION.img"
97ff396a
HH
94 [[ -f /etc/machine-id ]] && read MACHINE_ID < /etc/machine-id
95
2f78bafa 96 VMLINUZ="/lib/modules/${KVERSION}/vmlinuz"
97ff396a
HH
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
2f78bafa
HH
104 inst "$VMLINUZ" "/boot/vmlinuz-${KVERSION}"
105 find_binary plymouth >/dev/null && inst_multiple plymouth
106 cp -a -- /etc/ld.so.conf* "$initdir"/etc
4bd0ab61 107 ldconfig -r "$initdir"
ea8e543b
HH
108 )
109 python create.py -d -c livecd-fedora-minimal.ks
0be1785a 110 return 0
ea8e543b
HH
111}
112
113test_cleanup() {
0be1785a 114 return 0
ea8e543b
HH
115}
116
b093aa2d 117. "$testdir"/test-functions