File 0001-TEST-28-PERCENTJ-WANTEDBY-adapt-for-openQA.patch of Package systemd-v245-testsuite
From 324034470f2cb282076aebcad0f802cd99e2f108 Mon Sep 17 00:00:00 2001
From: Elisei Roca <eroca@suse.de>
Date: Fri, 8 May 2020 18:16:46 +0200
Subject: [PATCH] TEST-28-PERCENTJ-WANTEDBY: adapt for openQA
---
test/TEST-28-PERCENTJ-WANTEDBY/test.sh | 41 +++++++++++++++++++++++++-
1 file changed, 40 insertions(+), 1 deletion(-)
diff --git a/test/TEST-28-PERCENTJ-WANTEDBY/test.sh b/test/TEST-28-PERCENTJ-WANTEDBY/test.sh
index 934e1bc70c..bc6b7efa00 100755
--- a/test/TEST-28-PERCENTJ-WANTEDBY/test.sh
+++ b/test/TEST-28-PERCENTJ-WANTEDBY/test.sh
@@ -3,6 +3,7 @@ set -e
TEST_DESCRIPTION="Ensure %j Wants directives work"
RUN_IN_UNPRIVILEGED_CONTAINER=yes
+export TEST_BASE_DIR=/var/opt/systemd-tests/test
. $TEST_BASE_DIR/test-functions
test_setup() {
@@ -26,7 +27,7 @@ After=specifier-j-depends-%j.service
[Service]
Type=oneshot
ExecStart=test -f /tmp/test-specifier-j-%j
-ExecStart=/bin/sh -c 'echo OK > /testok'
+ExecStart=/bin/sh -c 'echo SUSEtest OK > /testok'
EOF
cat >$initdir/etc/systemd/system/specifier-j-depends-wants.service << EOF
[Unit]
@@ -46,6 +47,9 @@ After=specifier-j-wants.service
Type=oneshot
ExecStart=/bin/true
EOF
+ for service in testsuite.service specifier-j-wants.service specifier-j-depends-wants.service; do
+ cp $initdir/etc/systemd/system/$service /etc/systemd/system/
+ done
setup_testsuite
)
@@ -53,4 +57,39 @@ 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
+
+ if [[ "$RUN_IN_UNPRIVILEGED_CONTAINER" = "yes" ]]; then
+ if NSPAWN_ARGUMENTS="-U --private-network $NSPAWN_ARGUMENTS" run_nspawn "unprivileged-nspawn-root"; then
+ check_result_nspawn "unprivileged-nspawn-root" || return 1
+ else
+ dwarn "can't run systemd-nspawn, skipping"
+ fi
+ fi
+ fi
+ ret=1
+ test -s /failed && ret=$(($ret+1))
+ [[ -e /testok ]] && ret=0
+ return $ret
+}
+
+test_cleanup() {
+ _test_cleanup
+ for service in testsuite.service specifier-j-wants.service specifier-j-depends-wants.service; do
+ rm -f /etc/systemd/system/$service
+ done
+ for file in $(ls /testok* /failed* 2>/dev/null); do
+ rm $file
+ done
+ return 0
+}
+
do_test "$@"
--
2.26.2