summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Witschel <diabonas@archlinux.org>2021-11-11 22:25:40 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2021-11-12 13:31:46 +0900
commit6401279fee182af092f1f5adbf231957d4c8d298 (patch)
tree7958c191147a49c6a35a42eb01964b753fd0c3ed
parente7cef2a6ea56f701ee6214085b39508b9d7ede69 (diff)
downloadsystemd-6401279fee182af092f1f5adbf231957d4c8d298.tar.gz
test: add regression test for systemd-run --scope [--user]
systemd-run --scope --user failed to run in system 249.6, cf. #21297. Add tests for systemd-run --scope and systemd-run --scope --user to make sure this does not regress again.
-rwxr-xr-xtest/units/testsuite-20.sh17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/units/testsuite-20.sh b/test/units/testsuite-20.sh
index 17a27d7d7c..fc87c18c4c 100755
--- a/test/units/testsuite-20.sh
+++ b/test/units/testsuite-20.sh
@@ -143,6 +143,23 @@ systemd-run --unit=test20-mainpidsh3.service \
# Test that this failed due to timeout, and not some other error
test "$(systemctl show -P Result test20-mainpidsh3.service)" = timeout
+# Test that scope units work
+systemd-run --scope --unit test20-true.scope /bin/true
+test "$(systemctl show -P Result test20-true.scope)" = success
+
+# Test that user scope units work as well
+
+runas() {
+ declare userid=$1
+ shift
+ # shellcheck disable=SC2016
+ su "$userid" -s /bin/sh -c 'XDG_RUNTIME_DIR=/run/user/$UID exec "$@"' -- sh "$@"
+}
+
+systemctl start user@4711.service
+runas testuser systemd-run --scope --user --unit test20-true.scope /bin/true
+test "$(systemctl show -P Result test20-true.scope)" = success
+
systemd-analyze log-level info
echo OK >/testok