File 0018-TEST-09-ISSUE-2691-remove-qemu-from-testrun.patch of Package systemd-v234-testsuite
From ed2061e2da26de07bc3ce0594a85194428e4d36c Mon Sep 17 00:00:00 2001
From: Thomas Blume <thomas.blume@suse.com>
Date: Mon, 11 Mar 2019 17:14:21 +0100
Subject: [PATCH] TEST-09-ISSUE-2691: remove qemu from testrun
---
test/TEST-09-ISSUE-2691/test.sh | 73 ++++++++++++++++++++++++++++++++++++-----
1 file changed, 65 insertions(+), 8 deletions(-)
diff --git a/test/TEST-09-ISSUE-2691/test.sh b/test/TEST-09-ISSUE-2691/test.sh
index 4c3e9496b4..1a827c3bea 100755
--- a/test/TEST-09-ISSUE-2691/test.sh
+++ b/test/TEST-09-ISSUE-2691/test.sh
@@ -5,19 +5,27 @@ set -e
TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2691"
TEST_NO_NSPAWN=1
+export TEST_BASE_DIR=/var/opt/systemd-tests/test
. $TEST_BASE_DIR/test-functions
-SKIP_INITRD=yes
-QEMU_TIMEOUT=90
+
+test_run() {
+ ret=1
+ TESTSUITESTOP=$(sed -n '/testsuite.service: Control process exited, code=dumped status=11/s/\[ *\([[:digit:]]*\)\..*/\1/p' /shutdown-log.txt)
+ LASTLINE=$(sed -n '$ s/\[ *\([[:digit:]]*\)\..*/\1/p' /shutdown-log.txt)
+ [[ $(($LASTLINE-$TESTSUITESTOP)) < 90 ]] && echo -e "\ntestresult:\nOK" > /testok || rm /testok
+ test -s /failed && ret=$(($ret+1))
+ [[ -e /testok ]] && ret=0
+ return $ret
+}
test_setup() {
- create_empty_image
mkdir -p $TESTDIR/root
- mount ${LOOPDEV}p1 $TESTDIR/root
+ initdir=$TESTDIR/root
+ STRIP_BINARIES=no
# Create what will eventually be our root filesystem onto an overlay
(
LOG_LEVEL=5
- eval $(udevadm info --export --query=env --name=${LOOPDEV}p2)
setup_basic_environment
@@ -34,8 +42,22 @@ RemainAfterExit=yes
ExecStop=/bin/sh -c 'kill -SEGV $$$$'
TimeoutStopSec=180s
EOF
-
setup_testsuite
+
+ cat >$initdir/etc/systemd/system/end.service <<'EOF'
+[Unit]
+Description=Record status after stopping the test
+DefaultDependencies=no
+After=shutdown.target
+Before=umount.target
+
+[Service]
+Type=oneshot
+ExecStart=/bin/sh -x -c 'systemctl status testsuite.service > /failed'
+TimeoutStartSec=5m
+EOF
+
+
) || return 1
# mask some services that we do not want to run in these tests
@@ -45,8 +67,43 @@ EOF
ln -s /dev/null $initdir/etc/systemd/system/systemd-networkd.socket
ln -s /dev/null $initdir/etc/systemd/system/systemd-resolved.service
- ddebug "umount $TESTDIR/root"
- umount $TESTDIR/root
+
+ # copy the units used by this test
+ cp $initdir/etc/systemd/system/testsuite.service /etc/systemd/system/testsuite.service
+ cp $initdir/etc/systemd/system/end.service /etc/systemd/system/end.service
+
+ [[ -d /etc/systemd/system/reboot.target.wants ]] || mkdir /etc/systemd/system/reboot.target.wants
+ ln -s /etc/systemd/system/end.service /etc/systemd/system/reboot.target.wants/end.service
+
+ systemctl daemon-reload
+ systemctl start testsuite.service || return 1
+
+cat > /usr/lib/systemd/system-shutdown/debug.sh <<'EOF'
+#!/bin/sh
+mount -o remount,rw /
+dmesg > /shutdown-log.txt
+mount -o remount,ro /
+EOF
+ chmod ugo+x /usr/lib/systemd/system-shutdown/debug.sh
+
+ sed -i '/GRUB_CMDLINE_LINUX_DEFAULT.*/s/ resume=[[:graph:]]*/systemd.log_level=debug systemd.log_target=kmsg log_buf_len=1M printk.devkmsg=on enforcing=0/' /etc/default/grub
+ grub2-mkconfig -o /boot/grub2/grub.cfg || return 1
+}
+
+test_cleanup() {
+ for service in end.service testsuite.service; do
+ rm -f /etc/systemd/system/$service
+ done
+ rm -f /usr/lib/systemd/system-shutdown/debug.sh
+ rm -rf /etc/systemd/system/reboot.target.wants
+
+ rm /usr/lib/systemd/system-shutdown/debug.sh
+ rm /shutdown.log
+
+ [[ -e /testok ]] && rm /testok
+ [[ -e /failed ]] && rm /failed
+ return 0
+
}
do_test "$@"
--
2.16.4