]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: add regression test for systemd-run --scope [--user]
authorJonas Witschel <diabonas@archlinux.org>
Thu, 11 Nov 2021 21:25:40 +0000 (22:25 +0100)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 12 Nov 2021 04:31:46 +0000 (13:31 +0900)
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.

test/units/testsuite-20.sh

index 17a27d7d7c8abeb254516907f3a0464e04905d67..fc87c18c4c1e4e4249caceaba3540d7c0bcca5ba 100755 (executable)
@@ -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