Skip to content

Commit

Permalink
test: add regression test for systemd-run --scope [--user]
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
diabonas authored and yuwata committed Nov 12, 2021
1 parent e7cef2a commit 6401279
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/units/testsuite-20.sh
Expand Up @@ -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
Expand Down

0 comments on commit 6401279

Please sign in to comment.