File 0001-TEST-42-EXECSTOPPOST-adapt-for-openQA.patch of Package systemd-v245-testsuite

From 3ab6758f0439950cdb4f566cf5c227143b34e041 Mon Sep 17 00:00:00 2001
From: Elisei Roca <eroca@suse.de>
Date: Fri, 8 May 2020 15:36:32 +0200
Subject: [PATCH] TEST-42-EXECSTOPPOST: adapt for openQA

---
 test/TEST-42-EXECSTOPPOST/test.sh      | 32 ++++++++++++++++++++++++++
 test/TEST-42-EXECSTOPPOST/testsuite.sh | 30 ++++++++++++------------
 2 files changed, 47 insertions(+), 15 deletions(-)

diff --git a/test/TEST-42-EXECSTOPPOST/test.sh b/test/TEST-42-EXECSTOPPOST/test.sh
index 0c393597c7..007f6e5c47 100755
--- a/test/TEST-42-EXECSTOPPOST/test.sh
+++ b/test/TEST-42-EXECSTOPPOST/test.sh
@@ -2,6 +2,7 @@
 set -e
 TEST_DESCRIPTION="test that ExecStopPost= is always run"
 
+export TEST_BASE_DIR=/var/opt/systemd-tests/test
 . $TEST_BASE_DIR/test-functions
 
 test_setup() {
@@ -40,10 +41,41 @@ ExecStart=/testsuite.sh
 Type=oneshot
 EOF
         cp testsuite.sh $initdir/
+        cp testsuite.sh /
+        cp $initdir/etc/systemd/system/testsuite.service /etc/systemd/system/
+        mkdir -p /etc/dbus-1/system.d
+        cp $initdir/etc/dbus-1/system.d/systemd.test.ExecStopPost.conf /etc/dbus-1/system.d/
 
         setup_testsuite
     )
     setup_nspawn_root
 }
 
+test_run() {
+    systemctl daemon-reload
+    systemctl start testsuite.service || return 1
+    if [ -z "$TEST_NO_NSPAWN" ]; then
+        if run_nspawn "nspawn-root"; then
+            check_result_nspawn "nspawn-root" || return 1
+        else
+            dwarn "can't run systemd-nspawn, skipping"
+        fi
+    fi
+    ret=1
+    test -s /failed && ret=$(($ret+1))
+    [[ -e /testok ]] && ret=0
+    return $ret
+}
+
+test_cleanup() {
+    _test_cleanup
+    rm -f /etc/dbus-1/system.d/systemd.test.ExecStopPost.conf
+    rm -f /etc/systemd/system/testsuite.service
+    rm -f /testsuite.sh
+    for file in $(ls /testok* /failed* 2>/dev/null); do
+      rm $file
+    done
+    return 0
+}
+
 do_test "$@"
diff --git a/test/TEST-42-EXECSTOPPOST/testsuite.sh b/test/TEST-42-EXECSTOPPOST/testsuite.sh
index 154398dd66..9ba628a356 100755
--- a/test/TEST-42-EXECSTOPPOST/testsuite.sh
+++ b/test/TEST-42-EXECSTOPPOST/testsuite.sh
@@ -3,16 +3,16 @@ set -ex
 
 systemd-analyze log-level debug
 
-systemd-run --unit=simple1.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=simple -p ExecStopPost='/bin/touch /run/simple1' true
+systemd-run --unit=simple1.service --wait -p StandardOutput=kmsg -p StandardError=kmsg -p Type=simple -p ExecStopPost='/bin/touch /run/simple1' true
 test -f /run/simple1
 
-! systemd-run --unit=simple2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=simple -p ExecStopPost='/bin/touch /run/simple2' false
+! systemd-run --unit=simple2.service --wait -p StandardOutput=kmsg -p StandardError=kmsg -p Type=simple -p ExecStopPost='/bin/touch /run/simple2' false
 test -f /run/simple2
 
-systemd-run --unit=exec1.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=exec -p ExecStopPost='/bin/touch /run/exec1' sleep 1
+systemd-run --unit=exec1.service --wait -p StandardOutput=kmsg -p StandardError=kmsg -p Type=exec -p ExecStopPost='/bin/touch /run/exec1' sleep 1
 test -f /run/exec1
 
-! systemd-run --unit=exec2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=exec -p ExecStopPost='/bin/touch /run/exec2' sh -c 'sleep 1; false'
+! systemd-run --unit=exec2.service --wait -p StandardOutput=kmsg -p StandardError=kmsg -p Type=exec -p ExecStopPost='/bin/touch /run/exec2' sh -c 'sleep 1; false'
 test -f /run/exec2
 
 cat > /tmp/forking1.sh <<EOF
@@ -28,7 +28,7 @@ systemd-notify MAINPID=\$MAINPID
 EOF
 chmod +x /tmp/forking1.sh
 
-systemd-run --unit=forking1.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=forking -p NotifyAccess=exec -p ExecStopPost='/bin/touch /run/forking1' /tmp/forking1.sh
+systemd-run --unit=forking1.service --wait -p StandardOutput=kmsg -p StandardError=kmsg -p Type=forking -p NotifyAccess=exec -p ExecStopPost='/bin/touch /run/forking1' /tmp/forking1.sh
 test -f /run/forking1
 
 cat > /tmp/forking2.sh <<EOF
@@ -44,21 +44,21 @@ systemd-notify MAINPID=\$MAINPID
 EOF
 chmod +x /tmp/forking2.sh
 
-! systemd-run --unit=forking2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=forking -p NotifyAccess=exec -p ExecStopPost='/bin/touch /run/forking2' /tmp/forking2.sh
+! systemd-run --unit=forking2.service --wait -p StandardOutput=kmsg -p StandardError=kmsg -p Type=forking -p NotifyAccess=exec -p ExecStopPost='/bin/touch /run/forking2' /tmp/forking2.sh
 test -f /run/forking2
 
-systemd-run --unit=oneshot1.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=oneshot -p ExecStopPost='/bin/touch /run/oneshot1' true
+systemd-run --unit=oneshot1.service --wait -p StandardOutput=kmsg -p StandardError=kmsg -p Type=oneshot -p ExecStopPost='/bin/touch /run/oneshot1' true
 test -f /run/oneshot1
 
-! systemd-run --unit=oneshot2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=oneshot -p ExecStopPost='/bin/touch /run/oneshot2' false
+! systemd-run --unit=oneshot2.service --wait -p StandardOutput=kmsg -p StandardError=kmsg -p Type=oneshot -p ExecStopPost='/bin/touch /run/oneshot2' false
 test -f /run/oneshot2
 
-systemd-run --unit=dbus1.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=dbus -p BusName=systemd.test.ExecStopPost -p ExecStopPost='/bin/touch /run/dbus1' \
+systemd-run --unit=dbus1.service --wait -p StandardOutput=kmsg -p StandardError=kmsg -p Type=dbus -p BusName=systemd.test.ExecStopPost -p ExecStopPost='/bin/touch /run/dbus1' \
     busctl call org.freedesktop.DBus /org/freedesktop/DBus org.freedesktop.DBus RequestName su systemd.test.ExecStopPost 4 \
     || :
 test -f /run/dbus1
 
-! systemd-run --unit=dbus2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=dbus -p BusName=systemd.test.ExecStopPost -p ExecStopPost='/bin/touch /run/dbus2' true
+! systemd-run --unit=dbus2.service --wait -p StandardOutput=kmsg -p StandardError=kmsg -p Type=dbus -p BusName=systemd.test.ExecStopPost -p ExecStopPost='/bin/touch /run/dbus2' true
 test -f /run/dbus2
 
 cat > /tmp/notify1.sh <<EOF
@@ -70,20 +70,20 @@ systemd-notify --ready
 EOF
 chmod +x /tmp/notify1.sh
 
-systemd-run --unit=notify1.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=notify -p ExecStopPost='/bin/touch /run/notify1' /tmp/notify1.sh
+systemd-run --unit=notify1.service --wait -p StandardOutput=kmsg -p StandardError=kmsg -p Type=notify -p ExecStopPost='/bin/touch /run/notify1' /tmp/notify1.sh
 test -f /run/notify1
 
-! systemd-run --unit=notify2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=notify -p ExecStopPost='/bin/touch /run/notify2' true
+! systemd-run --unit=notify2.service --wait -p StandardOutput=kmsg -p StandardError=kmsg -p Type=notify -p ExecStopPost='/bin/touch /run/notify2' true
 test -f /run/notify2
 
-systemd-run --unit=idle1.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=idle -p ExecStopPost='/bin/touch /run/idle1' true
+systemd-run --unit=idle1.service --wait -p StandardOutput=kmsg -p StandardError=kmsg -p Type=idle -p ExecStopPost='/bin/touch /run/idle1' true
 test -f /run/idle1
 
-! systemd-run --unit=idle2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=idle -p ExecStopPost='/bin/touch /run/idle2' false
+! systemd-run --unit=idle2.service --wait -p StandardOutput=kmsg -p StandardError=kmsg -p Type=idle -p ExecStopPost='/bin/touch /run/idle2' false
 test -f /run/idle2
 
 systemd-analyze log-level info
 
-echo OK > /testok
+echo SUSEtest OK > /testok
 
 exit 0
-- 
2.26.2

openSUSE Build Service is sponsored by