diff options
author | Frantisek Sumsal <frantisek@sumsal.cz> | 2021-11-22 22:12:09 +0100 |
---|---|---|
committer | Frantisek Sumsal <frantisek@sumsal.cz> | 2021-11-22 22:12:41 +0100 |
commit | c83f126a41cfc964f43a30f1089a73e61908868a (patch) | |
tree | aa6d1fd2184bf8631f282488cf8fb38b4e7cbbca /test/units/testsuite-55.sh | |
parent | test: suppress certain leaks reported by LSan (diff) | |
download | systemd-c83f126a41cfc964f43a30f1089a73e61908868a.tar.xz systemd-c83f126a41cfc964f43a30f1089a73e61908868a.zip |
test: drop the `su` wrapper and use `systemctl` directly
ASan is having a hard time to get its LD_PRELOAD= shenanigans straight
with all the shells flying around. Let's make it a bit easier by using
one of the nifty systemctl's features instead.
Diffstat (limited to '')
-rwxr-xr-x | test/units/testsuite-55.sh | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/test/units/testsuite-55.sh b/test/units/testsuite-55.sh index b265c8cce7..db13964311 100755 --- a/test/units/testsuite-55.sh +++ b/test/units/testsuite-55.sh @@ -60,36 +60,29 @@ if ! systemctl status testsuite-55-testchill.service; then exit 24; fi # Make sure we also work correctly on user units. -runas() { - declare userid=$1 - shift - # shellcheck disable=SC2016 - su "$userid" -s /bin/sh -c 'XDG_RUNTIME_DIR=/run/user/$UID exec "$@"' -- sh "$@" -} - -runas testuser systemctl start --user testsuite-55-testchill.service -runas testuser systemctl start --user testsuite-55-testbloat.service +systemctl start --machine "testuser@.host" --user testsuite-55-testchill.service +systemctl start --machine "testuser@.host" --user testsuite-55-testbloat.service # Verify systemd-oomd is monitoring the expected units oomctl | grep -E "/user.slice.*/testsuite-55-workload.slice" oomctl | grep "20.00%" oomctl | grep "Default Memory Pressure Duration: 2s" -runas testuser systemctl --user status testsuite-55-testchill.service +systemctl --machine "testuser@.host" --user status testsuite-55-testchill.service # systemd-oomd watches for elevated pressure for 2 seconds before acting. # It can take time to build up pressure so either wait 2 minutes or for the service to fail. timeout="$(date -ud "2 minutes" +%s)" while [[ $(date -u +%s) -le $timeout ]]; do - if ! runas testuser systemctl --user status testsuite-55-testbloat.service; then + if ! systemctl --machine "testuser@.host" --user status testsuite-55-testbloat.service; then break fi sleep 2 done # testbloat should be killed and testchill should be fine -if runas testuser systemctl --user status testsuite-55-testbloat.service; then exit 42; fi -if ! runas testuser systemctl --user status testsuite-55-testchill.service; then exit 24; fi +if systemctl --machine "testuser@.host" --user status testsuite-55-testbloat.service; then exit 42; fi +if ! systemctl --machine "testuser@.host" --user status testsuite-55-testchill.service; then exit 24; fi # only run this portion of the test if we can set xattrs if setfattr -n user.xattr_test -v 1 /sys/fs/cgroup/; then |