Skip to content

Commit

Permalink
test(16): make DMSQUASH test use the test dracut modules
Browse files Browse the repository at this point in the history
  • Loading branch information
LaszloGombos authored and aafeijoo-suse committed Nov 22, 2022
1 parent fe88c3f commit ab23d89
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 63 deletions.
2 changes: 0 additions & 2 deletions test/TEST-16-DMSQUASH/finished-false.sh

This file was deleted.

3 changes: 0 additions & 3 deletions test/TEST-16-DMSQUASH/hard-off.sh

This file was deleted.

73 changes: 15 additions & 58 deletions test/TEST-16-DMSQUASH/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ KVERSION="${KVERSION-$(uname -r)}"

# Uncomment these to debug failures
#DEBUGFAIL="rd.shell rd.debug rd.live.debug loglevel=7"
#DEBUGTOOLS="setsid ls cat sfdisk"

test_run() {
dd if=/dev/zero of="$TESTDIR"/marker.img bs=1MiB count=1
declare -a disk_args=()
# shellcheck disable=SC2034
declare -i disk_index=0
qemu_add_drive_args disk_index disk_args "$TESTDIR"/marker.img marker
qemu_add_drive_args disk_index disk_args "$TESTDIR"/root.img root
Expand Down Expand Up @@ -60,53 +58,25 @@ test_run() {
}

test_setup() {
mkdir -p -- "$TESTDIR"/overlay/source
# Create what will eventually be our root filesystem onto an overlay
(
# shellcheck disable=SC2030
# shellcheck disable=SC2031
export initdir="$TESTDIR"/overlay/source
# shellcheck disable=SC1090
. "$basedir"/dracut-init.sh
(
cd "$initdir" || exit
mkdir -p -- dev sys proc etc var/run tmp
mkdir -p root usr/bin usr/lib usr/lib64 usr/sbin
)
inst_simple /etc/os-release
[[ -f /etc/machine-id ]] && read -r MACHINE_ID < /etc/machine-id

inst ./test-init.sh /sbin/init
inst_simple "${basedir}/modules.d/99base/dracut-lib.sh" "/lib/dracut-lib.sh"
inst_simple "${basedir}/modules.d/99base/dracut-dev-lib.sh" "/lib/dracut-dev-lib.sh"
inst_binary "${basedir}/dracut-util" "/usr/bin/dracut-util"
ln -s dracut-util "${initdir}/usr/bin/dracut-getarg"
ln -s dracut-util "${initdir}/usr/bin/dracut-getargs"

inst_multiple mkdir ln dd stty mount poweroff grep "$DEBUGTOOLS"

cp -a -- /etc/ld.so.conf* "$initdir"/etc
ldconfig -r "$initdir"
)
"$basedir"/dracut.sh -l --keep --tmpdir "$TESTDIR" \
-m "test-root" \
-i ./test-init.sh /sbin/init \
-i "${basedir}/modules.d/99base/dracut-lib.sh" "/lib/dracut-lib.sh" \
-i "${basedir}/modules.d/99base/dracut-dev-lib.sh" "/lib/dracut-dev-lib.sh" \
--no-hostonly --no-hostonly-cmdline --nomdadmconf --nohardlink \
-f "$TESTDIR"/initramfs.root "$KVERSION" || return 1
mkdir -p "$TESTDIR"/overlay/source && mv "$TESTDIR"/dracut.*/initramfs/* "$TESTDIR"/overlay/source && rm -rf "$TESTDIR"/dracut.*

# second, install the files needed to make the root filesystem
(
# shellcheck disable=SC2030
# shellcheck disable=SC2031
export initdir=$TESTDIR/overlay
# shellcheck disable=SC1090
. "$basedir"/dracut-init.sh
inst_multiple sfdisk poweroff cp umount sync dd mkfs.ext4 mksquashfs
inst_hook initqueue 01 ./create-root.sh
inst_hook initqueue/finished 01 ./finished-false.sh
)

# create an initramfs that will create the target root filesystem.
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
"$basedir"/dracut.sh -l -i "$TESTDIR"/overlay / \
--modules "rootfs-block qemu" \
--modules "test-makeroot rootfs-block qemu" \
--drivers "ext4 sd_mod" \
--install "sfdisk mkfs.ext4 mksquashfs" \
--include ./create-root.sh /lib/dracut/hooks/initqueue/01-create-root.sh \
--no-hostonly --no-hostonly-cmdline --no-early-microcode --nofscks --nomdadmconf --nohardlink --nostrip \
--force "$TESTDIR"/initramfs.makeroot "$KVERSION" || return 1
rm -rf -- "$TESTDIR"/overlay
Expand All @@ -115,7 +85,6 @@ test_setup() {
dd if=/dev/zero of="$TESTDIR"/marker.img bs=1MiB count=1
dd if=/dev/zero of="$TESTDIR"/root.img bs=1MiB count=160
declare -a disk_args=()
# shellcheck disable=SC2034
declare -i disk_index=0
qemu_add_drive_args disk_index disk_args "$TESTDIR"/marker.img marker
qemu_add_drive_args disk_index disk_args "$TESTDIR"/root.img root
Expand All @@ -131,34 +100,22 @@ test_setup() {
return 1
fi

(
# shellcheck disable=SC2030
# shellcheck disable=SC2031
export initdir="$TESTDIR"/overlay
# shellcheck disable=SC1090
. "$basedir"/dracut-init.sh
inst_multiple poweroff shutdown mkfs.ext4
inst_hook shutdown-emergency 000 ./hard-off.sh
inst_hook emergency 000 ./hard-off.sh
)
"$basedir"/dracut.sh -l -i "$TESTDIR"/overlay / \
--modules "dash dmsquash-live qemu" \
--modules "test dash dmsquash-live qemu" \
--omit "rngd" \
--drivers "ext4 sd_mod" \
--install "mkfs.ext4" \
--no-hostonly --no-hostonly-cmdline \
--force "$TESTDIR"/initramfs.testing "$KVERSION" || return 1

ls -sh "$TESTDIR"/initramfs.testing

"$basedir"/dracut.sh -l -i "$TESTDIR"/overlay / \
--modules "dmsquash-live-autooverlay qemu" \
--modules "test dmsquash-live-autooverlay qemu" \
--omit "rngd" \
--drivers "ext4 sd_mod" \
--install "mkfs.ext4" \
--no-hostonly --no-hostonly-cmdline \
--force "$TESTDIR"/initramfs.testing-autooverlay "$KVERSION" || return 1

ls -sh "$TESTDIR"/initramfs.testing-autooverlay

rm -rf -- "$TESTDIR"/overlay
}

Expand Down

0 comments on commit ab23d89

Please sign in to comment.