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