File 0001-TEST-20-MAINPIDGAMES-adapt-for-openQA.patch of Package systemd-v245-testsuite

From 3f91df7b5eba1b2980405f20174ffe70c8852b49 Mon Sep 17 00:00:00 2001
From: Elisei Roca <eroca@suse.de>
Date: Fri, 8 May 2020 18:37:12 +0200
Subject: [PATCH] TEST-20-MAINPIDGAMES: adapt for openQA

---
 test/TEST-20-MAINPIDGAMES/test.sh      | 29 ++++++++++++++++++++++++++
 test/TEST-20-MAINPIDGAMES/testsuite.sh | 10 ++++-----
 2 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/test/TEST-20-MAINPIDGAMES/test.sh b/test/TEST-20-MAINPIDGAMES/test.sh
index 4cf1b79f9a..f37d0cfe6b 100755
--- a/test/TEST-20-MAINPIDGAMES/test.sh
+++ b/test/TEST-20-MAINPIDGAMES/test.sh
@@ -2,6 +2,7 @@
 set -e
 TEST_DESCRIPTION="test changing main PID"
 
+export TEST_BASE_DIR=/var/opt/systemd-tests/test
 . $TEST_BASE_DIR/test-functions
 
 test_setup() {
@@ -27,6 +28,8 @@ Type=oneshot
 NotifyAccess=all
 EOF
         cp testsuite.sh $initdir/
+        cp testsuite.sh /
+        cp $initdir/etc/systemd/system/testsuite.service /etc/systemd/system/
 
         setup_testsuite
     )
@@ -34,4 +37,30 @@ EOF
     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 /testsuite.sh
+    rm -f /etc/systemd/system/testsuite.service
+    for file in $(ls /testok* /failed* 2>/dev/null); do
+      rm $file
+    done
+    return 0
+}
+
 do_test "$@"
diff --git a/test/TEST-20-MAINPIDGAMES/testsuite.sh b/test/TEST-20-MAINPIDGAMES/testsuite.sh
index f894026070..3f42c24945 100755
--- a/test/TEST-20-MAINPIDGAMES/testsuite.sh
+++ b/test/TEST-20-MAINPIDGAMES/testsuite.sh
@@ -3,7 +3,7 @@ set -ex
 set -o pipefail
 
 systemd-analyze log-level debug
-systemd-analyze log-target console
+systemd-analyze log-target kmsg
 
 test `systemctl show -p MainPID --value testsuite.service` -eq $$
 
@@ -75,7 +75,7 @@ echo \$MAINPID > /run/mainpidsh/pid
 EOF
 chmod +x /tmp/mainpid.sh
 
-systemd-run --unit=mainpidsh.service -p StandardOutput=tty -p StandardError=tty -p Type=forking -p RuntimeDirectory=mainpidsh -p PIDFile=/run/mainpidsh/pid /tmp/mainpid.sh
+systemd-run --unit=mainpidsh.service -p StandardOutput=kmsg -p StandardError=kmsg -p Type=forking -p RuntimeDirectory=mainpidsh -p PIDFile=/run/mainpidsh/pid /tmp/mainpid.sh
 test `systemctl show -p MainPID --value mainpidsh.service` -eq `cat /run/mainpidsh/pid`
 
 cat >/tmp/mainpid2.sh <<EOF
@@ -100,7 +100,7 @@ chown 1001:1001 /run/mainpidsh2/pid
 EOF
 chmod +x /tmp/mainpid2.sh
 
-systemd-run --unit=mainpidsh2.service -p StandardOutput=tty -p StandardError=tty -p Type=forking -p RuntimeDirectory=mainpidsh2 -p PIDFile=/run/mainpidsh2/pid /tmp/mainpid2.sh
+systemd-run --unit=mainpidsh2.service -p StandardOutput=kmsg -p StandardError=kmsg -p Type=forking -p RuntimeDirectory=mainpidsh2 -p PIDFile=/run/mainpidsh2/pid /tmp/mainpid2.sh
 test `systemctl show -p MainPID --value mainpidsh2.service` -eq `cat /run/mainpidsh2/pid`
 
 cat >/dev/shm/mainpid3.sh <<EOF
@@ -127,13 +127,13 @@ EOF
 chmod 755 /dev/shm/mainpid3.sh
 
 # This has to fail, as we shouldn't accept the dangerous PID file, and then inotify-wait on it to be corrected which we never do
-! systemd-run --unit=mainpidsh3.service -p StandardOutput=tty -p StandardError=tty -p Type=forking -p RuntimeDirectory=mainpidsh3 -p PIDFile=/run/mainpidsh3/pid -p DynamicUser=1 -p TimeoutStartSec=2s /dev/shm/mainpid3.sh
+! systemd-run --unit=mainpidsh3.service -p StandardOutput=kmsg -p StandardError=kmsg -p Type=forking -p RuntimeDirectory=mainpidsh3 -p PIDFile=/run/mainpidsh3/pid -p DynamicUser=1 -p TimeoutStartSec=2s /dev/shm/mainpid3.sh
 
 # Test that this failed due to timeout, and not some other error
 test `systemctl show -p Result --value mainpidsh3.service` = timeout
 
 systemd-analyze log-level info
 
-echo OK > /testok
+echo SUSEtest OK > /testok
 
 exit 0
-- 
2.26.2

openSUSE Build Service is sponsored by