summaryrefslogtreecommitdiffstats
path: root/test/TEST-04-FULL-SYSTEMD
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xtest/TEST-04-FULL-SYSTEMD/create-root.sh26
-rw-r--r--test/TEST-04-FULL-SYSTEMD/fstab2
-rwxr-xr-xtest/TEST-04-FULL-SYSTEMD/test-init.sh4
-rwxr-xr-xtest/TEST-04-FULL-SYSTEMD/test.sh40
4 files changed, 45 insertions, 27 deletions
diff --git a/test/TEST-04-FULL-SYSTEMD/create-root.sh b/test/TEST-04-FULL-SYSTEMD/create-root.sh
index 734f377..0436c18 100755
--- a/test/TEST-04-FULL-SYSTEMD/create-root.sh
+++ b/test/TEST-04-FULL-SYSTEMD/create-root.sh
@@ -13,21 +13,37 @@ set -e
udevadm settle
modprobe btrfs || :
mkfs.btrfs -q -L dracut /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_root
+printf test > keyfile
+cryptsetup -q luksFormat /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_root_crypt /keyfile
+cryptsetup luksOpen /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_root_crypt dracut_crypt_test < /keyfile
+mkfs.btrfs -q -L dracut_crypt /dev/mapper/dracut_crypt_test
mkfs.btrfs -q -L dracutusr /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_usr
btrfs device scan /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_root
+btrfs device scan /dev/mapper/dracut_crypt_test
btrfs device scan /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_usr
-mkdir -p /root
+mkdir -p /root /root_crypt
mount -t btrfs /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_root /root
+mount -t btrfs /dev/mapper/dracut_crypt_test /root_crypt
[ -d /root/usr ] || mkdir -p /root/usr
+[ -d /root-crypt/usr ] || mkdir -p /root_crypt/usr
mount -t btrfs /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_usr /root/usr
btrfs subvolume create /root/usr/usr
umount /root/usr
mount -t btrfs -o subvol=usr /dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_usr /root/usr
+mount --bind /root/usr /root_crypt/usr
cp -a -t /root /source/*
-mkdir -p /root/run
+cp -a -t /root_crypt /source/*
+mkdir -p /root/run /root_crypt/run
btrfs filesystem sync /root/usr
btrfs filesystem sync /root
-umount /root/usr
-umount /root
-echo "dracut-root-block-created" | dd oflag=direct,dsync of=/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_marker status=none
+btrfs filesystem sync /root_crypt/usr
+btrfs filesystem sync /root_crypt
+umount /root/usr /root_crypt/usr
+umount /root /root_crypt
+cryptsetup luksClose /dev/mapper/dracut_crypt_test
+eval "$(udevadm info --query=property --name=/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_root_crypt | while read -r line || [ -n "$line" ]; do [ "$line" != "${line#*ID_FS_UUID*}" ] && echo "$line"; done)"
+{
+ echo "dracut-root-block-created"
+ echo "ID_FS_UUID=$ID_FS_UUID"
+} | dd oflag=direct,dsync of=/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_marker status=none
poweroff -f
diff --git a/test/TEST-04-FULL-SYSTEMD/fstab b/test/TEST-04-FULL-SYSTEMD/fstab
deleted file mode 100644
index 114f945..0000000
--- a/test/TEST-04-FULL-SYSTEMD/fstab
+++ /dev/null
@@ -1,2 +0,0 @@
-/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_root / btrfs defaults 0 0
-/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_usr /usr btrfs subvol=usr,ro 0 0
diff --git a/test/TEST-04-FULL-SYSTEMD/test-init.sh b/test/TEST-04-FULL-SYSTEMD/test-init.sh
index eeec8a2..c60c0ff 100755
--- a/test/TEST-04-FULL-SYSTEMD/test-init.sh
+++ b/test/TEST-04-FULL-SYSTEMD/test-init.sh
@@ -5,7 +5,7 @@ export PATH=/usr/sbin:/usr/bin:/sbin:/bin
command -v plymouth > /dev/null 2>&1 && plymouth --quit
exec > /dev/console 2>&1
-systemctl --failed --no-legend --no-pager > /failed
+systemctl --failed --no-legend --no-pager > /run/failed
ismounted() {
findmnt "$1" > /dev/null 2>&1
@@ -14,7 +14,7 @@ ismounted() {
if ! ismounted /usr; then
echo "**************************FAILED**************************"
echo "/usr not mounted!!"
- cat /proc/mounts >> /failed
+ cat /proc/mounts >> /run/failed
echo "**************************FAILED**************************"
fi
diff --git a/test/TEST-04-FULL-SYSTEMD/test.sh b/test/TEST-04-FULL-SYSTEMD/test.sh
index afd7645..c9a0826 100755
--- a/test/TEST-04-FULL-SYSTEMD/test.sh
+++ b/test/TEST-04-FULL-SYSTEMD/test.sh
@@ -10,7 +10,6 @@ test_check() {
# Uncomment this to debug failures
#DEBUGFAIL="rd.shell rd.break"
#DEBUGOUT="quiet systemd.log_level=debug systemd.log_target=console loglevel=77 rd.info rd.debug"
-DEBUGOUT="loglevel=0 "
client_run() {
local test_name="$1"
shift
@@ -22,12 +21,13 @@ client_run() {
declare -i disk_index=0
qemu_add_drive disk_index disk_args "$TESTDIR"/marker.img marker
qemu_add_drive disk_index disk_args "$TESTDIR"/root.btrfs root
+ qemu_add_drive disk_index disk_args "$TESTDIR"/root_crypt.btrfs root_crypt
qemu_add_drive disk_index disk_args "$TESTDIR"/usr.btrfs usr
test_marker_reset
"$testdir"/run-qemu \
"${disk_args[@]}" \
- -append "systemd.unit=testsuite.target systemd.mask=systemd-firstboot rd.multipath=0 root=LABEL=dracut $client_opts rd.retry=3 $DEBUGOUT" \
+ -append "$TEST_KERNEL_CMDLINE systemd.unit=testsuite.target systemd.mask=systemd-firstboot systemd.mask=systemd-vconsole-setup root=LABEL=dracut mount.usr=LABEL=dracutusr mount.usrfstype=btrfs mount.usrflags=subvol=usr,ro $client_opts rd.retry=3 $DEBUGOUT" \
-initrd "$TESTDIR"/initramfs.testing || return 1
if ! test_marker_check; then
@@ -35,13 +35,23 @@ client_run() {
return 1
fi
echo "CLIENT TEST END: $test_name [OK]"
-
}
test_run() {
client_run "no option specified" || return 1
client_run "readonly root" "ro" || return 1
client_run "writeable root" "rw" || return 1
+
+ # volatile mode
+ client_run "volatile=overlayfs root" "systemd.volatile=overlayfs" || return 1
+ client_run "volatile=state root" "systemd.volatile=state" || return 1
+
+ # shellcheck source=$TESTDIR/luks.uuid
+ . "$TESTDIR"/luks.uuid
+
+ # luks
+ client_run "encrypted root with rd.luks.uuid" "root=LABEL=dracut_crypt rd.luks.uuid=$ID_FS_UUID rd.luks.key=/etc/key" || return 1
+ client_run "encrypted root with rd.luks.name" "root=/dev/mapper/crypt rd.luks.name=$ID_FS_UUID=crypt rd.luks.key=/etc/key" || return 1
return 0
}
@@ -55,8 +65,6 @@ test_setup() {
-m "test-root systemd-ldconfig" \
-i "${PKGLIBDIR}/modules.d/80test-root/test-init.sh" "/sbin/test-init.sh" \
-i ./test-init.sh /sbin/test-init \
- -I "findmnt" \
- -i ./fstab /etc/fstab \
-f "$TESTDIR"/initramfs.root "$KVERSION" || return 1
mkdir -p "$TESTDIR"/overlay/source && cp -a "$TESTDIR"/dracut.*/initramfs/* "$TESTDIR"/overlay/source && rm -rf "$TESTDIR"/dracut.* && export initdir=$TESTDIR/overlay/source
@@ -117,8 +125,8 @@ EOF
# We do it this way so that we do not risk trashing the host mdraid
# devices, volume groups, encrypted partitions, etc.
"$DRACUT" -N -l -i "$TESTDIR"/overlay / \
- -m "test-makeroot bash btrfs" \
- -I "mkfs.btrfs" \
+ -a "test-makeroot btrfs" \
+ -I "mkfs.btrfs cryptsetup" \
-i ./create-root.sh /lib/dracut/hooks/initqueue/01-create-root.sh \
-f "$TESTDIR"/initramfs.makeroot "$KVERSION" || return 1
rm -rf -- "$TESTDIR"/overlay/*
@@ -129,26 +137,22 @@ EOF
declare -i disk_index=0
qemu_add_drive disk_index disk_args "$TESTDIR"/marker.img marker 1
qemu_add_drive disk_index disk_args "$TESTDIR"/root.btrfs root 160
+ qemu_add_drive disk_index disk_args "$TESTDIR"/root_crypt.btrfs root_crypt 160
qemu_add_drive disk_index disk_args "$TESTDIR"/usr.btrfs usr 160
# Invoke KVM and/or QEMU to actually create the target filesystem.
"$testdir"/run-qemu \
"${disk_args[@]}" \
- -append "root=/dev/fakeroot rw rootfstype=btrfs quiet console=ttyS0,115200n81 selinux=0" \
+ -append "root=/dev/fakeroot rw rootfstype=btrfs quiet console=ttyS0,115200n81" \
-initrd "$TESTDIR"/initramfs.makeroot || return 1
+ test_marker_check dracut-root-block-created || return 1
- if ! test_marker_check dracut-root-block-created; then
- echo "Could not create root filesystem"
- return 1
- fi
-
- [ -e /etc/machine-id ] && EXTRA_MACHINE="/etc/machine-id"
- [ -e /etc/machine-info ] && EXTRA_MACHINE+=" /etc/machine-info"
+ grep -F -a -m 1 ID_FS_UUID "$TESTDIR"/marker.img > "$TESTDIR"/luks.uuid
+ echo -n test > /tmp/key
test_dracut \
- -a "systemd i18n qemu" \
- -d "btrfs" \
- ${EXTRA_MACHINE:+-I "$EXTRA_MACHINE"} \
+ -m "btrfs dracut-systemd i18n systemd-ac-power systemd-coredump systemd-creds systemd-cryptsetup systemd-integritysetup systemd-ldconfig systemd-pcrphase systemd-pstore systemd-repart systemd-sysext systemd-veritysetup" \
+ -i "/tmp/key" "/etc/key" \
"$TESTDIR"/initramfs.testing
rm -rf -- "$TESTDIR"/overlay