File 0006-TEST-05-RLIMITS-adapt-for-SUSE-openQA.patch of Package systemd-v244-testsuite

From 4689e3ae5fc1f650e10cedc641d7ff20945b4949 Mon Sep 17 00:00:00 2001
From: Thomas Blume <Thomas.Blume@suse.com>
Date: Thu, 19 Dec 2019 08:43:33 +0100
Subject: [PATCH 06/24] TEST-05-RLIMITS: adapt for SUSE openQA

---
 test/TEST-05-RLIMITS/test.sh | 49 +++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 44 insertions(+), 5 deletions(-)

diff --git a/test/TEST-05-RLIMITS/test.sh b/test/TEST-05-RLIMITS/test.sh
index 87fb89e781..c5c50a6e1e 100755
--- a/test/TEST-05-RLIMITS/test.sh
+++ b/test/TEST-05-RLIMITS/test.sh
@@ -2,19 +2,38 @@
 set -e
 TEST_DESCRIPTION="Resource limits-related tests"
 
+export TEST_BASE_DIR=/var/opt/systemd-tests/test
 . $TEST_BASE_DIR/test-functions
 
+test_run() {
+    ret=1
+    systemctl daemon-reload
+    systemctl start testsuite.service || return 1
+    systemctl status --full testsuite.service
+    if [ -z "$TEST_NO_NSPAWN" ]; then
+        if run_nspawn; then
+            check_result_nspawn || return 1
+        else
+            dwarn "can't run systemd-nspawn, skipping"
+        fi
+    fi
+    test -s /failed && ret=$(($ret+1))
+    [[ -e /testok ]] && ret=0
+    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
 
+        #set test limit
         cat >$initdir/etc/systemd/system.conf <<EOF
 [Manager]
 DefaultLimitNOFILE=10000:16384
@@ -26,15 +45,35 @@ EOF
 Description=Testsuite service
 
 [Service]
-ExecStart=/test-rlimits.sh
+ExecStart=$TESTDIR/nspawn-root/test-rlimits.sh
+ExecStart=/bin/sh -e -x -c 'systemctl --state=failed --no-pager > /failed ; systemctl daemon-reload ; echo SUSEtest OK > /testok'
 Type=oneshot
 EOF
 
+        # copy the units used by this test
+        cp $initdir/etc/systemd/system/testsuite.service /etc/systemd/system/testsuite.service
+        mv /etc/systemd/system.conf /etc/systemd/system.conf.orig
+        cp $initdir/etc/systemd/system.conf /etc/systemd/
         cp test-rlimits.sh $initdir/
 
         setup_testsuite
-    )
+    ) || return 1
+
     setup_nspawn_root
+    rm -r $TESTDIR/root
+
+    mask_supporting_services
+}
+
+test_cleanup() {
+    for service in testsuite.service; do
+         rm /etc/systemd/system/$service
+    done
+    mv /etc/systemd/system.conf.orig /etc/systemd/system.conf
+    [[ -e /testok ]] && rm /testok
+    [[ -e /failed ]] && rm /failed
+    return 0
+
 }
 
 do_test "$@"
-- 
2.16.4

openSUSE Build Service is sponsored by