|
Harald Hoyer |
08211a |
From badda27f61706a4ceed2098b2057c3ec0206617d Mon Sep 17 00:00:00 2001
|
|
Harald Hoyer |
08211a |
From: Harald Hoyer <harald@redhat.com>
|
|
Harald Hoyer |
08211a |
Date: Wed, 11 Jul 2012 15:15:41 +0200
|
|
Harald Hoyer |
08211a |
Subject: [PATCH] test/TEST-04-FULL-SYSTEMD: full test with systemd and /usr
|
|
Harald Hoyer |
08211a |
mount
|
|
Harald Hoyer |
08211a |
|
|
Harald Hoyer |
08211a |
---
|
|
Harald Hoyer |
08211a |
test/TEST-04-FULL-SYSTEMD/99-idesymlinks.rules | 8 +
|
|
Harald Hoyer |
08211a |
test/TEST-04-FULL-SYSTEMD/Makefile | 10 +
|
|
Harald Hoyer |
08211a |
test/TEST-04-FULL-SYSTEMD/create-root.sh | 39 ++++
|
|
Harald Hoyer |
08211a |
test/TEST-04-FULL-SYSTEMD/cryptroot-ask.sh | 6 +
|
|
Harald Hoyer |
08211a |
test/TEST-04-FULL-SYSTEMD/fstab | 2 +
|
|
Harald Hoyer |
08211a |
test/TEST-04-FULL-SYSTEMD/hard-off.sh | 3 +
|
|
Harald Hoyer |
08211a |
test/TEST-04-FULL-SYSTEMD/test-init.sh | 29 +++
|
|
Harald Hoyer |
08211a |
test/TEST-04-FULL-SYSTEMD/test.sh | 273 ++++++++++++++++++++++++
|
|
Harald Hoyer |
08211a |
8 files changed, 370 insertions(+)
|
|
Harald Hoyer |
08211a |
create mode 100644 test/TEST-04-FULL-SYSTEMD/99-idesymlinks.rules
|
|
Harald Hoyer |
08211a |
create mode 100644 test/TEST-04-FULL-SYSTEMD/Makefile
|
|
Harald Hoyer |
08211a |
create mode 100755 test/TEST-04-FULL-SYSTEMD/create-root.sh
|
|
Harald Hoyer |
08211a |
create mode 100755 test/TEST-04-FULL-SYSTEMD/cryptroot-ask.sh
|
|
Harald Hoyer |
08211a |
create mode 100644 test/TEST-04-FULL-SYSTEMD/fstab
|
|
Harald Hoyer |
08211a |
create mode 100755 test/TEST-04-FULL-SYSTEMD/hard-off.sh
|
|
Harald Hoyer |
08211a |
create mode 100755 test/TEST-04-FULL-SYSTEMD/test-init.sh
|
|
Harald Hoyer |
08211a |
create mode 100755 test/TEST-04-FULL-SYSTEMD/test.sh
|
|
Harald Hoyer |
08211a |
|
|
Harald Hoyer |
08211a |
diff --git a/test/TEST-04-FULL-SYSTEMD/99-idesymlinks.rules b/test/TEST-04-FULL-SYSTEMD/99-idesymlinks.rules
|
|
Harald Hoyer |
08211a |
new file mode 100644
|
|
Harald Hoyer |
08211a |
index 0000000..d557790
|
|
Harald Hoyer |
08211a |
--- /dev/null
|
|
Harald Hoyer |
08211a |
+++ b/test/TEST-04-FULL-SYSTEMD/99-idesymlinks.rules
|
|
Harald Hoyer |
08211a |
@@ -0,0 +1,8 @@
|
|
Harald Hoyer |
08211a |
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hda", SYMLINK+="sda"
|
|
Harald Hoyer |
08211a |
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hda*", SYMLINK+="sda$env{MINOR}"
|
|
Harald Hoyer |
08211a |
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hdb", SYMLINK+="sdb"
|
|
Harald Hoyer |
08211a |
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hdb*", SYMLINK+="sdb$env{MINOR}"
|
|
Harald Hoyer |
08211a |
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hdc", SYMLINK+="sdc"
|
|
Harald Hoyer |
08211a |
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hdc*", SYMLINK+="sdc$env{MINOR}"
|
|
Harald Hoyer |
08211a |
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hdd", SYMLINK+="sdd"
|
|
Harald Hoyer |
08211a |
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hdd*", SYMLINK+="sdd$env{MINOR}"
|
|
Harald Hoyer |
08211a |
diff --git a/test/TEST-04-FULL-SYSTEMD/Makefile b/test/TEST-04-FULL-SYSTEMD/Makefile
|
|
Harald Hoyer |
08211a |
new file mode 100644
|
|
Harald Hoyer |
08211a |
index 0000000..3cc8993
|
|
Harald Hoyer |
08211a |
--- /dev/null
|
|
Harald Hoyer |
08211a |
+++ b/test/TEST-04-FULL-SYSTEMD/Makefile
|
|
Harald Hoyer |
08211a |
@@ -0,0 +1,10 @@
|
|
Harald Hoyer |
08211a |
+all:
|
|
Harald Hoyer |
08211a |
+ $(MAKE) -s --no-print-directory -C ../.. all
|
|
Harald Hoyer |
08211a |
+ V=$(V) basedir=../.. testdir=../ ./test.sh --all
|
|
Harald Hoyer |
08211a |
+setup:
|
|
Harald Hoyer |
08211a |
+ @$(MAKE) --no-print-directory -C ../.. all
|
|
Harald Hoyer |
08211a |
+ @basedir=../.. testdir=../ ./test.sh --setup
|
|
Harald Hoyer |
08211a |
+clean:
|
|
Harald Hoyer |
08211a |
+ @basedir=../.. testdir=../ ./test.sh --clean
|
|
Harald Hoyer |
08211a |
+run:
|
|
Harald Hoyer |
08211a |
+ @basedir=../.. testdir=../ ./test.sh --run
|
|
Harald Hoyer |
08211a |
diff --git a/test/TEST-04-FULL-SYSTEMD/create-root.sh b/test/TEST-04-FULL-SYSTEMD/create-root.sh
|
|
Harald Hoyer |
08211a |
new file mode 100755
|
|
Harald Hoyer |
08211a |
index 0000000..2e33920
|
|
Harald Hoyer |
08211a |
--- /dev/null
|
|
Harald Hoyer |
08211a |
+++ b/test/TEST-04-FULL-SYSTEMD/create-root.sh
|
|
Harald Hoyer |
08211a |
@@ -0,0 +1,39 @@
|
|
Harald Hoyer |
08211a |
+#!/bin/sh
|
|
Harald Hoyer |
08211a |
+# don't let udev and this script step on eachother's toes
|
|
Harald Hoyer |
08211a |
+for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
|
|
Harald Hoyer |
08211a |
+ > "/etc/udev/rules.d/$x"
|
|
Harald Hoyer |
08211a |
+done
|
|
Harald Hoyer |
08211a |
+rm /etc/lvm/lvm.conf
|
|
Harald Hoyer |
08211a |
+udevadm control --reload-rules
|
|
Harald Hoyer |
08211a |
+set -e
|
|
Harald Hoyer |
08211a |
+# save a partition at the beginning for future flagging purposes
|
|
Harald Hoyer |
08211a |
+sfdisk -C 10240 -H 2 -S 32 -L /dev/sda <
|
|
Harald Hoyer |
08211a |
+,16
|
|
Harald Hoyer |
08211a |
+,
|
|
Harald Hoyer |
08211a |
+EOF
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+sfdisk -C 10240 -H 2 -S 32 -L /dev/sdb <
|
|
Harald Hoyer |
08211a |
+,16
|
|
Harald Hoyer |
08211a |
+,
|
|
Harald Hoyer |
08211a |
+EOF
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+mkfs.btrfs -L dracut /dev/sda2
|
|
Harald Hoyer |
08211a |
+mkfs.btrfs -L dracutusr /dev/sdb2
|
|
Harald Hoyer |
08211a |
+btrfs device scan /dev/sda2
|
|
Harald Hoyer |
08211a |
+btrfs device scan /dev/sdb2
|
|
Harald Hoyer |
08211a |
+mkdir -p /root
|
|
Harald Hoyer |
08211a |
+mount -t btrfs /dev/sda2 /root
|
|
Harald Hoyer |
08211a |
+[ -d /root/usr ] || mkdir /root/usr
|
|
Harald Hoyer |
08211a |
+mount -t btrfs /dev/sdb2 /root/usr
|
|
Harald Hoyer |
08211a |
+btrfs subvolume create /root/usr/usr
|
|
Harald Hoyer |
08211a |
+umount /root/usr
|
|
Harald Hoyer |
08211a |
+mount -t btrfs -o subvol=usr /dev/sdb2 /root/usr
|
|
Harald Hoyer |
08211a |
+cp -a -t /root /source/*
|
|
Harald Hoyer |
08211a |
+mkdir -p /root/run
|
|
Harald Hoyer |
08211a |
+umount /root/usr
|
|
Harald Hoyer |
08211a |
+umount /root
|
|
Harald Hoyer |
08211a |
+echo "dracut-root-block-created" >/dev/sda1
|
|
Harald Hoyer |
08211a |
+sync
|
|
Harald Hoyer |
08211a |
+poweroff -f
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
diff --git a/test/TEST-04-FULL-SYSTEMD/cryptroot-ask.sh b/test/TEST-04-FULL-SYSTEMD/cryptroot-ask.sh
|
|
Harald Hoyer |
08211a |
new file mode 100755
|
|
Harald Hoyer |
08211a |
index 0000000..db27c5b
|
|
Harald Hoyer |
08211a |
--- /dev/null
|
|
Harald Hoyer |
08211a |
+++ b/test/TEST-04-FULL-SYSTEMD/cryptroot-ask.sh
|
|
Harald Hoyer |
08211a |
@@ -0,0 +1,6 @@
|
|
Harald Hoyer |
08211a |
+#!/bin/sh
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+[ -b /dev/mapper/$2 ] && exit 0
|
|
Harald Hoyer |
08211a |
+echo -n test >/keyfile
|
|
Harald Hoyer |
08211a |
+/sbin/cryptsetup luksOpen $1 $2
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
diff --git a/test/TEST-04-FULL-SYSTEMD/fstab b/test/TEST-04-FULL-SYSTEMD/fstab
|
|
Harald Hoyer |
08211a |
new file mode 100644
|
|
Harald Hoyer |
08211a |
index 0000000..0cc3370
|
|
Harald Hoyer |
08211a |
--- /dev/null
|
|
Harald Hoyer |
08211a |
+++ b/test/TEST-04-FULL-SYSTEMD/fstab
|
|
Harald Hoyer |
08211a |
@@ -0,0 +1,2 @@
|
|
Harald Hoyer |
08211a |
+/dev/sda2 / btrfs defaults 0 0
|
|
Harald Hoyer |
08211a |
+/dev/sdb2 /usr btrfs subvol=usr,ro 0 0
|
|
Harald Hoyer |
08211a |
diff --git a/test/TEST-04-FULL-SYSTEMD/hard-off.sh b/test/TEST-04-FULL-SYSTEMD/hard-off.sh
|
|
Harald Hoyer |
08211a |
new file mode 100755
|
|
Harald Hoyer |
08211a |
index 0000000..12c3d5a
|
|
Harald Hoyer |
08211a |
--- /dev/null
|
|
Harald Hoyer |
08211a |
+++ b/test/TEST-04-FULL-SYSTEMD/hard-off.sh
|
|
Harald Hoyer |
08211a |
@@ -0,0 +1,3 @@
|
|
Harald Hoyer |
08211a |
+#!/bin/sh
|
|
Harald Hoyer |
08211a |
+getarg rd.shell || poweroff -f
|
|
Harald Hoyer |
08211a |
+getarg failme && poweroff -f
|
|
Harald Hoyer |
08211a |
diff --git a/test/TEST-04-FULL-SYSTEMD/test-init.sh b/test/TEST-04-FULL-SYSTEMD/test-init.sh
|
|
Harald Hoyer |
08211a |
new file mode 100755
|
|
Harald Hoyer |
08211a |
index 0000000..cc26017
|
|
Harald Hoyer |
08211a |
--- /dev/null
|
|
Harald Hoyer |
08211a |
+++ b/test/TEST-04-FULL-SYSTEMD/test-init.sh
|
|
Harald Hoyer |
08211a |
@@ -0,0 +1,29 @@
|
|
Harald Hoyer |
08211a |
+#!/bin/sh
|
|
Harald Hoyer |
08211a |
+>/dev/watchdog
|
|
Harald Hoyer |
08211a |
+export PATH=/sbin:/bin:/usr/sbin:/usr/bin
|
|
Harald Hoyer |
08211a |
+strstr() { [ "${1#*$2*}" != "$1" ]; }
|
|
Harald Hoyer |
08211a |
+CMDLINE=$(while read line; do echo $line;done < /proc/cmdline)
|
|
Harald Hoyer |
08211a |
+plymouth --quit
|
|
Harald Hoyer |
08211a |
+exec </dev/console >/dev/console 2>&1
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+ismounted() {
|
|
Harald Hoyer |
08211a |
+ while read a m a; do
|
|
Harald Hoyer |
08211a |
+ [ "$m" = "$1" ] && return 0
|
|
Harald Hoyer |
08211a |
+ done < /proc/mounts
|
|
Harald Hoyer |
08211a |
+ return 1
|
|
Harald Hoyer |
08211a |
+}
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+if ismounted /usr; then
|
|
Harald Hoyer |
08211a |
+ echo "dracut-root-block-success" >/dev/sdc
|
|
Harald Hoyer |
08211a |
+fi
|
|
Harald Hoyer |
08211a |
+export TERM=linux
|
|
Harald Hoyer |
08211a |
+export PS1='initramfs-test:\w\$ '
|
|
Harald Hoyer |
08211a |
+[ -f /etc/mtab ] || ln -sfn /proc/mounts /etc/mtab
|
|
Harald Hoyer |
08211a |
+[ -f /etc/fstab ] || ln -sfn /proc/mounts /etc/fstab
|
|
Harald Hoyer |
08211a |
+stty sane
|
|
Harald Hoyer |
08211a |
+echo "made it to the rootfs!"
|
|
Harald Hoyer |
08211a |
+if strstr "$CMDLINE" "rd.shell"; then
|
|
Harald Hoyer |
08211a |
+ strstr "$(setsid --help)" "control" && CTTY="-c"
|
|
Harald Hoyer |
08211a |
+ setsid $CTTY sh -i
|
|
Harald Hoyer |
08211a |
+fi
|
|
Harald Hoyer |
08211a |
+echo "Powering down."
|
|
Harald Hoyer |
08211a |
diff --git a/test/TEST-04-FULL-SYSTEMD/test.sh b/test/TEST-04-FULL-SYSTEMD/test.sh
|
|
Harald Hoyer |
08211a |
new file mode 100755
|
|
Harald Hoyer |
08211a |
index 0000000..921189f
|
|
Harald Hoyer |
08211a |
--- /dev/null
|
|
Harald Hoyer |
08211a |
+++ b/test/TEST-04-FULL-SYSTEMD/test.sh
|
|
Harald Hoyer |
08211a |
@@ -0,0 +1,273 @@
|
|
Harald Hoyer |
08211a |
+#!/bin/bash
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+TEST_DESCRIPTION="Full systemd serialization/deserialization test with /usr mount"
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+KVERSION=${KVERSION-$(uname -r)}
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+# Uncomment this to debug failures
|
|
Harald Hoyer |
08211a |
+#DEBUGFAIL="rd.shell rd.break"
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+client_run() {
|
|
Harald Hoyer |
08211a |
+ local test_name="$1"; shift
|
|
Harald Hoyer |
08211a |
+ local client_opts="$*"
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+ echo "CLIENT TEST START: $test_name"
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+ dd if=/dev/zero of=$TESTDIR/result bs=1M count=1
|
|
Harald Hoyer |
08211a |
+ $testdir/run-qemu \
|
|
Harald Hoyer |
08211a |
+ -hda $TESTDIR/root.btrfs \
|
|
Harald Hoyer |
08211a |
+ -hdb $TESTDIR/usr.btrfs \
|
|
Harald Hoyer |
08211a |
+ -hdc $TESTDIR/result \
|
|
Harald Hoyer |
08211a |
+ -m 256M -nographic \
|
|
Harald Hoyer |
08211a |
+ -net none -kernel /boot/vmlinuz-$KVERSION \
|
|
Harald Hoyer |
08211a |
+ -append "root=LABEL=dracut $client_opts quiet systemd.log_level=debug systemd.log_target=console loglevel=77 rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL" \
|
|
Harald Hoyer |
08211a |
+ -initrd $TESTDIR/initramfs.testing
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+ if (($? != 0)); then
|
|
Harald Hoyer |
08211a |
+ echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]"
|
|
Harald Hoyer |
08211a |
+ return 1
|
|
Harald Hoyer |
08211a |
+ fi
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+ if ! grep -m 1 -q dracut-root-block-success $TESTDIR/result; then
|
|
Harald Hoyer |
08211a |
+ echo "CLIENT TEST END: $test_name [FAILED]"
|
|
Harald Hoyer |
08211a |
+ return 1
|
|
Harald Hoyer |
08211a |
+ fi
|
|
Harald Hoyer |
08211a |
+ echo "CLIENT TEST END: $test_name [OK]"
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+}
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+test_run() {
|
|
Harald Hoyer |
08211a |
+ client_run "no option specified" || return 1
|
|
Harald Hoyer |
08211a |
+ client_run "readonly root" "ro" || return 1
|
|
Harald Hoyer |
08211a |
+ client_run "writeable root" "rw" || return 1
|
|
Harald Hoyer |
08211a |
+ return 0
|
|
Harald Hoyer |
08211a |
+}
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+test_setup() {
|
|
Harald Hoyer |
08211a |
+ rm -f $TESTDIR/root.btrfs
|
|
Harald Hoyer |
08211a |
+ rm -f $TESTDIR/usr.btrfs
|
|
Harald Hoyer |
08211a |
+ # Create the blank file to use as a root filesystem
|
|
Harald Hoyer |
08211a |
+ dd if=/dev/null of=$TESTDIR/root.btrfs bs=1M seek=320
|
|
Harald Hoyer |
08211a |
+ dd if=/dev/null of=$TESTDIR/usr.btrfs bs=1M seek=320
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+ kernel=$KVERSION
|
|
Harald Hoyer |
08211a |
+ # Create what will eventually be our root filesystem onto an overlay
|
|
Harald Hoyer |
08211a |
+ (
|
|
Harald Hoyer |
08211a |
+ export initdir=$TESTDIR/overlay/source
|
|
Harald Hoyer |
08211a |
+ mkdir -p $initdir
|
|
Harald Hoyer |
08211a |
+ . $basedir/dracut-functions.sh
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+ for d in usr/bin usr/sbin bin etc lib "$libdir" sbin tmp usr var var/log dev proc sys sysroot root run run/lock run/initramfs; do
|
|
Harald Hoyer |
08211a |
+ if [ -L "/$d" ]; then
|
|
Harald Hoyer |
08211a |
+ inst_symlink "/$d"
|
|
Harald Hoyer |
08211a |
+ else
|
|
Harald Hoyer |
08211a |
+ inst_dir "/$d"
|
|
Harald Hoyer |
08211a |
+ fi
|
|
Harald Hoyer |
08211a |
+ done
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+ ln -sfn /run "$initdir/var/run"
|
|
Harald Hoyer |
08211a |
+ ln -sfn /run/lock "$initdir/var/lock"
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+ dracut_install sh df free ls shutdown poweroff stty cat ps ln ip route \
|
|
Harald Hoyer |
08211a |
+ mount dmesg ifconfig dhclient mkdir cp ping dhclient \
|
|
Harald Hoyer |
08211a |
+ umount strace less setsid
|
|
Harald Hoyer |
08211a |
+ for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
|
|
Harald Hoyer |
08211a |
+ [ -f ${_terminfodir}/l/linux ] && break
|
|
Harald Hoyer |
08211a |
+ done
|
|
Harald Hoyer |
08211a |
+ dracut_install -o ${_terminfodir}/l/linux
|
|
Harald Hoyer |
08211a |
+ inst "$basedir/modules.d/40network/dhclient-script.sh" "/sbin/dhclient-script"
|
|
Harald Hoyer |
08211a |
+ inst "$basedir/modules.d/40network/ifup.sh" "/sbin/ifup"
|
|
Harald Hoyer |
08211a |
+ dracut_install grep
|
|
Harald Hoyer |
08211a |
+ inst_simple ./fstab /etc/fstab
|
|
Harald Hoyer |
08211a |
+ rpm -ql systemd | xargs -r $DRACUT_INSTALL ${initdir+-D "$initdir"} -o -a -l
|
|
Harald Hoyer |
08211a |
+ inst /lib/systemd/system/systemd-journal-flush.service
|
|
Harald Hoyer |
08211a |
+ inst /etc/sysconfig/init
|
|
Harald Hoyer |
08211a |
+ # activate kmsg import
|
|
Harald Hoyer |
08211a |
+ echo 'ImportKernel=yes' >> $initdir/etc/systemd/journald.conf
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+ # make a journal directory
|
|
Harald Hoyer |
08211a |
+ mkdir -p $initdir/var/log/journal
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+ # install some basic config files
|
|
Harald Hoyer |
08211a |
+ dracut_install -o \
|
|
Harald Hoyer |
08211a |
+ /etc/sysconfig/init \
|
|
Harald Hoyer |
08211a |
+ /etc/passwd \
|
|
Harald Hoyer |
08211a |
+ /etc/shadow \
|
|
Harald Hoyer |
08211a |
+ /etc/group \
|
|
Harald Hoyer |
08211a |
+ /etc/shells \
|
|
Harald Hoyer |
08211a |
+ /etc/nsswitch.conf \
|
|
Harald Hoyer |
08211a |
+ /etc/pam.conf \
|
|
Harald Hoyer |
08211a |
+ /etc/securetty \
|
|
Harald Hoyer |
08211a |
+ /etc/os-release \
|
|
Harald Hoyer |
08211a |
+ /etc/localtime
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+ # we want an empty environment
|
|
Harald Hoyer |
08211a |
+ > $initdir/etc/environment
|
|
Harald Hoyer |
08211a |
+ > $initdir/etc/machine-id
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+ # set the hostname
|
|
Harald Hoyer |
08211a |
+ echo systemd-testsuite > $initdir/etc/hostname
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+ # setup the testsuite target
|
|
Harald Hoyer |
08211a |
+ cat >$initdir/etc/systemd/system/testsuite.target <
|
|
Harald Hoyer |
08211a |
+[Unit]
|
|
Harald Hoyer |
08211a |
+Description=Testsuite target
|
|
Harald Hoyer |
08211a |
+Requires=multi-user.target
|
|
Harald Hoyer |
08211a |
+After=multi-user.target
|
|
Harald Hoyer |
08211a |
+Conflicts=rescue.target
|
|
Harald Hoyer |
08211a |
+AllowIsolate=yes
|
|
Harald Hoyer |
08211a |
+EOF
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+ inst ./test-init.sh /sbin/test-init
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+ # setup the testsuite service
|
|
Harald Hoyer |
08211a |
+ cat >$initdir/etc/systemd/system/testsuite.service <
|
|
Harald Hoyer |
08211a |
+[Unit]
|
|
Harald Hoyer |
08211a |
+Description=Testsuite service
|
|
Harald Hoyer |
08211a |
+After=multi-user.target
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+[Service]
|
|
Harald Hoyer |
08211a |
+ExecStart=/sbin/test-init
|
|
Harald Hoyer |
08211a |
+ExecStopPost=/usr/bin/systemctl poweroff
|
|
Harald Hoyer |
08211a |
+Type=oneshot
|
|
Harald Hoyer |
08211a |
+EOF
|
|
Harald Hoyer |
08211a |
+ mkdir -p $initdir/etc/systemd/system/testsuite.target.wants
|
|
Harald Hoyer |
08211a |
+ ln -fs ../testsuite.service $initdir/etc/systemd/system/testsuite.target.wants/testsuite.service
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+ # make the testsuite the default target
|
|
Harald Hoyer |
08211a |
+ ln -fs testsuite.target $initdir/etc/systemd/system/default.target
|
|
Harald Hoyer |
08211a |
+ mkdir -p $initdir/etc/rc.d
|
|
Harald Hoyer |
08211a |
+ cat >$initdir/etc/rc.d/rc.local <
|
|
Harald Hoyer |
08211a |
+#!/bin/bash
|
|
Harald Hoyer |
08211a |
+exit 0
|
|
Harald Hoyer |
08211a |
+EOF
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+ # install basic tools needed
|
|
Harald Hoyer |
08211a |
+ dracut_install sh bash setsid loadkeys setfont \
|
|
Harald Hoyer |
08211a |
+ login sushell sulogin gzip sleep echo mount umount
|
|
Harald Hoyer |
08211a |
+ dracut_install modprobe
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+ # install libnss_files for login
|
|
Harald Hoyer |
08211a |
+ inst_libdir_file "libnss_files*"
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+ # install dbus and pam
|
|
Harald Hoyer |
08211a |
+ find \
|
|
Harald Hoyer |
08211a |
+ /etc/dbus-1 \
|
|
Harald Hoyer |
08211a |
+ /etc/pam.d \
|
|
Harald Hoyer |
08211a |
+ /etc/security \
|
|
Harald Hoyer |
08211a |
+ /lib64/security \
|
|
Harald Hoyer |
08211a |
+ /lib/security -xtype f \
|
|
Harald Hoyer |
08211a |
+ | while read file; do
|
|
Harald Hoyer |
08211a |
+ dracut_install -o $file
|
|
Harald Hoyer |
08211a |
+ done
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+ # install dbus socket and service file
|
|
Harald Hoyer |
08211a |
+ inst /usr/lib/systemd/system/dbus.socket
|
|
Harald Hoyer |
08211a |
+ inst /usr/lib/systemd/system/dbus.service
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+ # install basic keyboard maps and fonts
|
|
Harald Hoyer |
08211a |
+ for i in \
|
|
Harald Hoyer |
08211a |
+ /usr/lib/kbd/consolefonts/latarcyrheb-sun16* \
|
|
Harald Hoyer |
08211a |
+ /usr/lib/kbd/keymaps/include/* \
|
|
Harald Hoyer |
08211a |
+ /usr/lib/kbd/keymaps/i386/include/* \
|
|
Harald Hoyer |
08211a |
+ /usr/lib/kbd/keymaps/i386/qwerty/us.*; do
|
|
Harald Hoyer |
08211a |
+ [[ -f $i ]] || continue
|
|
Harald Hoyer |
08211a |
+ inst $i
|
|
Harald Hoyer |
08211a |
+ done
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+ # some basic terminfo files
|
|
Harald Hoyer |
08211a |
+ for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
|
|
Harald Hoyer |
08211a |
+ [ -f ${_terminfodir}/l/linux ] && break
|
|
Harald Hoyer |
08211a |
+ done
|
|
Harald Hoyer |
08211a |
+ dracut_install -o ${_terminfodir}/l/linux
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+ # softlink mtab
|
|
Harald Hoyer |
08211a |
+ ln -fs /proc/self/mounts $initdir/etc/mtab
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+ # install any Exec's from the service files
|
|
Harald Hoyer |
08211a |
+ egrep -ho '^Exec[^ ]*=[^ ]+' $initdir/lib/systemd/system/*.service \
|
|
Harald Hoyer |
08211a |
+ | while read i; do
|
|
Harald Hoyer |
08211a |
+ i=${i##Exec*=}; i=${i##-}
|
|
Harald Hoyer |
08211a |
+ dracut_install -o $i
|
|
Harald Hoyer |
08211a |
+ done
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+ # some helper tools for debugging
|
|
Harald Hoyer |
08211a |
+ [[ $DEBUGTOOLS ]] && dracut_install $DEBUGTOOLS
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+ # install ld.so.conf* and run ldconfig
|
|
Harald Hoyer |
08211a |
+ cp -a /etc/ld.so.conf* $initdir/etc
|
|
Harald Hoyer |
08211a |
+ ldconfig -r "$initdir"
|
|
Harald Hoyer |
08211a |
+ ddebug "Strip binaeries"
|
|
Harald Hoyer |
08211a |
+ find "$initdir" -perm +111 -type f | xargs strip --strip-unneeded | ddebug
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+ # copy depmod files
|
|
Harald Hoyer |
08211a |
+ inst /lib/modules/$KERNEL_VER/modules.order
|
|
Harald Hoyer |
08211a |
+ inst /lib/modules/$KERNEL_VER/modules.builtin
|
|
Harald Hoyer |
08211a |
+ # generate module dependencies
|
|
Harald Hoyer |
08211a |
+ if [[ -d $initdir/lib/modules/$KERNEL_VER ]] && \
|
|
Harald Hoyer |
08211a |
+ ! depmod -a -b "$initdir" $KERNEL_VER; then
|
|
Harald Hoyer |
08211a |
+ dfatal "\"depmod -a $KERNEL_VER\" failed."
|
|
Harald Hoyer |
08211a |
+ exit 1
|
|
Harald Hoyer |
08211a |
+ fi
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+ )
|
|
Harald Hoyer |
08211a |
+#exit 1
|
|
Harald Hoyer |
08211a |
+ # second, install the files needed to make the root filesystem
|
|
Harald Hoyer |
08211a |
+ (
|
|
Harald Hoyer |
08211a |
+ export initdir=$TESTDIR/overlay
|
|
Harald Hoyer |
08211a |
+ . $basedir/dracut-functions.sh
|
|
Harald Hoyer |
08211a |
+ dracut_install sfdisk mkfs.btrfs btrfs poweroff cp umount sync
|
|
Harald Hoyer |
08211a |
+ inst_hook initqueue 01 ./create-root.sh
|
|
Harald Hoyer |
08211a |
+ inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
|
|
Harald Hoyer |
08211a |
+ )
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+ # create an initramfs that will create the target root filesystem.
|
|
Harald Hoyer |
08211a |
+ # We do it this way so that we do not risk trashing the host mdraid
|
|
Harald Hoyer |
08211a |
+ # devices, volume groups, encrypted partitions, etc.
|
|
Harald Hoyer |
08211a |
+ $basedir/dracut.sh -l -i $TESTDIR/overlay / \
|
|
Harald Hoyer |
08211a |
+ -m "dash udev-rules btrfs base rootfs-block kernel-modules" \
|
|
Harald Hoyer |
08211a |
+ -d "piix ide-gd_mod ata_piix btrfs sd_mod" \
|
|
Harald Hoyer |
08211a |
+ --nomdadmconf \
|
|
Harald Hoyer |
08211a |
+ --nohardlink \
|
|
Harald Hoyer |
08211a |
+ -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+ # Invoke KVM and/or QEMU to actually create the target filesystem.
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+# echo $TESTDIR/overlay
|
|
Harald Hoyer |
08211a |
+# echo $TESTDIR/initramfs.makeroot
|
|
Harald Hoyer |
08211a |
+#exit 1
|
|
Harald Hoyer |
08211a |
+ rm -rf $TESTDIR/overlay
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+ $testdir/run-qemu \
|
|
Harald Hoyer |
08211a |
+ -hda $TESTDIR/root.btrfs \
|
|
Harald Hoyer |
08211a |
+ -hdb $TESTDIR/usr.btrfs \
|
|
Harald Hoyer |
08211a |
+ -m 256M -nographic -net none \
|
|
Harald Hoyer |
08211a |
+ -kernel "/boot/vmlinuz-$kernel" \
|
|
Harald Hoyer |
08211a |
+ -append "root=/dev/dracut/root rw rootfstype=btrfs quiet console=ttyS0,115200n81 selinux=0" \
|
|
Harald Hoyer |
08211a |
+ -initrd $TESTDIR/initramfs.makeroot || return 1
|
|
Harald Hoyer |
08211a |
+ grep -m 1 -q dracut-root-block-created $TESTDIR/root.btrfs || return 1
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+ (
|
|
Harald Hoyer |
08211a |
+ export initdir=$TESTDIR/overlay
|
|
Harald Hoyer |
08211a |
+ . $basedir/dracut-functions.sh
|
|
Harald Hoyer |
08211a |
+ dracut_install poweroff shutdown
|
|
Harald Hoyer |
08211a |
+ inst_hook emergency 000 ./hard-off.sh
|
|
Harald Hoyer |
08211a |
+ inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
|
|
Harald Hoyer |
08211a |
+ )
|
|
Harald Hoyer |
08211a |
+ sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
|
|
Harald Hoyer |
08211a |
+ -a "debug watchdog" \
|
|
Harald Hoyer |
08211a |
+ -o "network" \
|
|
Harald Hoyer |
08211a |
+ -d "piix ide-gd_mod ata_piix btrfs sd_mod ib700wdt" \
|
|
Harald Hoyer |
08211a |
+ -f $TESTDIR/initramfs.testing $KVERSION || return 1
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+ rm -rf $TESTDIR/overlay
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+# -o "plymouth network md dmraid multipath fips caps crypt btrfs resume dmsquash-live dm"
|
|
Harald Hoyer |
08211a |
+}
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+test_cleanup() {
|
|
Harald Hoyer |
08211a |
+ return 0
|
|
Harald Hoyer |
08211a |
+}
|
|
Harald Hoyer |
08211a |
+
|
|
Harald Hoyer |
08211a |
+. $testdir/test-functions
|