File 0001-TEST-09-ISSUE-2691-adapt-for-SUSE-openQA.patch of Package systemd-v245-testsuite
From 854b6b2f8f938706e9551ff0a6245f32e3f95e9f Mon Sep 17 00:00:00 2001
From: Thomas Blume <Thomas.Blume@suse.com>
Date: Thu, 19 Dec 2019 08:51:29 +0100
Subject: [PATCH] TEST-09-ISSUE-2691: adapt for SUSE openQA
---
test/TEST-09-ISSUE-2691/test.sh | 72 ++++++++++++++++++++++++++++++---
1 file changed, 66 insertions(+), 6 deletions(-)
diff --git a/test/TEST-09-ISSUE-2691/test.sh b/test/TEST-09-ISSUE-2691/test.sh
index efe75d140b..dc19f255b9 100755
--- a/test/TEST-09-ISSUE-2691/test.sh
+++ b/test/TEST-09-ISSUE-2691/test.sh
@@ -3,19 +3,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
-QEMU_TIMEOUT=300
+
+test_run() {
+ ret=1
+ grep 'code=dumped, signal=SEGV' /testsuitestatus && echo SUSEtest OK > /testok || rm /testok
+ systemctl --state=failed --no-pager > /failed
+ [[ -e /testok ]] && ret=0 || ret=$(($ret+1))
+ return $ret
+}
test_setup() {
- create_empty_image_rootdir
+ mkdir -p $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
- mask_supporting_services
# setup the testsuite service
cat >$initdir/etc/systemd/system/testsuite.service <<'EOF'
@@ -24,14 +32,66 @@ Description=Testsuite service
[Service]
Type=oneshot
-ExecStart=/bin/sh -c '>/testok'
+ExecStart=/bin/sh -c 'echo SUSEtest-firststage OK >/testok'
RemainAfterExit=yes
ExecStop=/bin/sh -c 'kill -SEGV $$$$'
TimeoutStopSec=270s
EOF
+ cat >$initdir/etc/systemd/system/end.service <<'EOF'
+[Unit]
+Description=Record status after stopping the test
+DefaultDependencies=no
+After=shutdown.target
+Before=umount.target
- setup_testsuite
+[Service]
+Type=oneshot
+ExecStart=/bin/sh -x -c 'systemctl status testsuite.service > /testsuitestatus'
+TimeoutStartSec=5m
+EOF
)
+
+
+ # 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
+
+ systemctl log-level debug
+ systemctl log-target kmsg
+
+ mask_supporting_services
+}
+
+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
+ [[ -e /testesuitestatus ]] && rm /testsuitestatus
+ return 0
+
}
do_test "$@"
--
2.26.2