]>
Commit | Line | Data |
---|---|---|
61a02cac | 1 | #!/bin/bash |
d0c9fd66 | 2 | # shellcheck disable=SC2034 |
61a02cac HH |
3 | TEST_DESCRIPTION="root filesystem on LVM PV with thin pool" |
4 | ||
61a02cac HH |
5 | # Uncomment this to debug failures |
6 | #DEBUGFAIL="rd.break rd.shell" | |
7 | ||
8 | test_run() { | |
b80ee080 HH |
9 | declare -a disk_args=() |
10 | # shellcheck disable=SC2034 | |
11 | declare -i disk_index=0 | |
12 | qemu_add_drive_args disk_index disk_args "$TESTDIR"/marker.img marker | |
13 | qemu_add_drive_args disk_index disk_args "$TESTDIR"/disk-1.img disk1 | |
14 | qemu_add_drive_args disk_index disk_args "$TESTDIR"/disk-2.img disk2 | |
15 | qemu_add_drive_args disk_index disk_args "$TESTDIR"/disk-3.img disk3 | |
16 | ||
f1346763 | 17 | test_marker_reset |
d0c9fd66 | 18 | "$testdir"/run-qemu \ |
b80ee080 | 19 | "${disk_args[@]}" \ |
b2cf61d9 | 20 | -append "panic=1 oops=panic softlockup_panic=1 systemd.crash_reboot root=/dev/dracut/root rw rd.auto=1 quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug rd.shell=0 $DEBUGFAIL" \ |
b80ee080 | 21 | -initrd "$TESTDIR"/initramfs.testing || return 1 |
f1346763 | 22 | test_marker_check || return 1 |
61a02cac HH |
23 | } |
24 | ||
25 | test_setup() { | |
61a02cac HH |
26 | kernel=$KVERSION |
27 | # Create what will eventually be our root filesystem onto an overlay | |
28 | ( | |
d0c9fd66 | 29 | # shellcheck disable=SC2030 |
2f78bafa | 30 | export initdir=$TESTDIR/overlay/source |
d0c9fd66 HH |
31 | # shellcheck disable=SC1090 |
32 | . "$basedir"/dracut-init.sh | |
06853123 | 33 | ( |
d0c9fd66 | 34 | cd "$initdir" || exit |
06853123 HH |
35 | mkdir -p -- dev sys proc etc var/run tmp |
36 | mkdir -p root usr/bin usr/lib usr/lib64 usr/sbin | |
06853123 | 37 | ) |
31c4aac3 LG |
38 | inst_multiple sh df free ls shutdown poweroff stty cat ps ln \ |
39 | mount dmesg mkdir cp dd sync | |
61a02cac | 40 | for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do |
2f78bafa HH |
41 | [ -f ${_terminfodir}/l/linux ] && break |
42 | done | |
43 | inst_multiple -o ${_terminfodir}/l/linux | |
d0c9fd66 HH |
44 | |
45 | inst_simple "${basedir}/modules.d/99base/dracut-lib.sh" "/lib/dracut-lib.sh" | |
c08bc810 | 46 | inst_simple "${basedir}/modules.d/99base/dracut-dev-lib.sh" "/lib/dracut-dev-lib.sh" |
d0c9fd66 HH |
47 | inst_binary "${basedir}/dracut-util" "/usr/bin/dracut-util" |
48 | ln -s dracut-util "${initdir}/usr/bin/dracut-getarg" | |
49 | ln -s dracut-util "${initdir}/usr/bin/dracut-getargs" | |
50 | ||
2f78bafa | 51 | inst_multiple grep |
61a02cac | 52 | inst_simple /etc/os-release |
2f78bafa | 53 | inst ./test-init.sh /sbin/init |
9a52c3fd | 54 | find_binary plymouth > /dev/null && inst_multiple plymouth |
d0c9fd66 HH |
55 | cp -a /etc/ld.so.conf* "$initdir"/etc |
56 | mkdir -p "$initdir"/run | |
4bd0ab61 | 57 | ldconfig -r "$initdir" |
61a02cac HH |
58 | ) |
59 | ||
60 | # second, install the files needed to make the root filesystem | |
61 | ( | |
d0c9fd66 HH |
62 | # shellcheck disable=SC2030 |
63 | # shellcheck disable=SC2031 | |
2f78bafa | 64 | export initdir=$TESTDIR/overlay |
d0c9fd66 HH |
65 | # shellcheck disable=SC1090 |
66 | . "$basedir"/dracut-init.sh | |
006890a2 | 67 | inst_multiple sfdisk mkfs.ext4 poweroff cp umount grep dmsetup dd sync |
2f78bafa | 68 | inst_hook initqueue 01 ./create-root.sh |
61a02cac | 69 | inst_hook initqueue/finished 01 ./finished-false.sh |
61a02cac HH |
70 | ) |
71 | ||
72 | # create an initramfs that will create the target root filesystem. | |
73 | # We do it this way so that we do not risk trashing the host mdraid | |
74 | # devices, volume groups, encrypted partitions, etc. | |
f9939d0e | 75 | "$DRACUT" -l -i "$TESTDIR"/overlay / \ |
1573bb81 | 76 | -m "bash lvm mdraid kernel-modules qemu" \ |
006890a2 | 77 | -d "piix ide-gd_mod ata_piix ext4 sd_mod" \ |
9a52c3fd | 78 | --no-hostonly-cmdline -N \ |
d0c9fd66 HH |
79 | -f "$TESTDIR"/initramfs.makeroot "$KVERSION" || return 1 |
80 | rm -rf -- "$TESTDIR"/overlay | |
b80ee080 HH |
81 | |
82 | # Create the blank files to use as a root filesystem | |
b80ee080 HH |
83 | declare -a disk_args=() |
84 | # shellcheck disable=SC2034 | |
85 | declare -i disk_index=0 | |
f1346763 HG |
86 | qemu_add_drive_args disk_index disk_args "$TESTDIR"/marker.img marker 1 |
87 | qemu_add_drive_args disk_index disk_args "$TESTDIR"/disk-1.img disk1 40 | |
88 | qemu_add_drive_args disk_index disk_args "$TESTDIR"/disk-2.img disk2 40 | |
89 | qemu_add_drive_args disk_index disk_args "$TESTDIR"/disk-3.img disk3 40 | |
b80ee080 HH |
90 | |
91 | "$testdir"/run-qemu \ | |
92 | "${disk_args[@]}" \ | |
006890a2 | 93 | -append "root=/dev/fakeroot rw rootfstype=ext4 quiet console=ttyS0,115200n81 selinux=0" \ |
d0c9fd66 | 94 | -initrd "$TESTDIR"/initramfs.makeroot || return 1 |
f1346763 | 95 | test_marker_check dracut-root-block-created || return 1 |
b80ee080 | 96 | |
61a02cac | 97 | ( |
d0c9fd66 | 98 | # shellcheck disable=SC2031 |
2f78bafa | 99 | export initdir=$TESTDIR/overlay |
d0c9fd66 HH |
100 | # shellcheck disable=SC1090 |
101 | . "$basedir"/dracut-init.sh | |
2f78bafa HH |
102 | inst_multiple poweroff shutdown |
103 | inst_hook shutdown-emergency 000 ./hard-off.sh | |
781f1971 | 104 | inst_hook emergency 000 ./hard-off.sh |
61a02cac | 105 | ) |
f9939d0e | 106 | "$DRACUT" -l -i "$TESTDIR"/overlay / \ |
9a52c3fd HH |
107 | -o "plymouth network kernel-network-modules" \ |
108 | -a "debug" -I lvs \ | |
006890a2 | 109 | -d "piix ide-gd_mod ata_piix ext4 sd_mod" \ |
9a52c3fd | 110 | --no-hostonly-cmdline -N \ |
d0c9fd66 | 111 | -f "$TESTDIR"/initramfs.testing "$KVERSION" || return 1 |
61a02cac HH |
112 | } |
113 | ||
d0c9fd66 HH |
114 | # shellcheck disable=SC1090 |
115 | . "$testdir"/test-functions |