summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPhilip Withnall <withnall@endlessm.com>2019-06-12 08:45:26 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-10-28 09:44:31 +0100
commit9ed7de605d7c1a3290e544e92ea5de6141c26bbc (patch)
tree2f9331649c36deec0a112f6001b46ce43b3275e4 /test
parent7508f7f273cb2957dbdf7cd8d5d7fe040c80d8e4 (diff)
downloadsystemd-9ed7de605d7c1a3290e544e92ea5de6141c26bbc.tar.gz
scope: Support RuntimeMaxSec= directive in scope units
Just as `RuntimeMaxSec=` is supported for service units, add support for it to scope units. This will gracefully kill a scope after the timeout expires from the moment the scope enters the running state. This could be used for time-limited login sessions, for example. Signed-off-by: Philip Withnall <withnall@endlessm.com> Fixes: #12035
Diffstat (limited to 'test')
-rwxr-xr-xtest/TEST-03-JOBS/test-jobs.sh10
-rw-r--r--test/fuzz/fuzz-unit-file/directives.scope2
2 files changed, 12 insertions, 0 deletions
diff --git a/test/TEST-03-JOBS/test-jobs.sh b/test/TEST-03-JOBS/test-jobs.sh
index 42190cf478..fca6cccb4f 100755
--- a/test/TEST-03-JOBS/test-jobs.sh
+++ b/test/TEST-03-JOBS/test-jobs.sh
@@ -84,4 +84,14 @@ END_SEC=$(date -u '+%s')
ELAPSED=$(($END_SEC-$START_SEC))
[[ "$ELAPSED" -ge 5 ]] && [[ "$ELAPSED" -le 7 ]] || exit 1
+# Test time-limited scopes
+START_SEC=$(date -u '+%s')
+set +e
+systemd-run --scope --property=RuntimeMaxSec=3s sleep 10
+RESULT=$?
+END_SEC=$(date -u '+%s')
+ELAPSED=$(($END_SEC-$START_SEC))
+[[ "$ELAPSED" -ge 3 ]] && [[ "$ELAPSED" -le 5 ]] || exit 1
+[[ "$RESULT" -ne 0 ]] || exit 1
+
touch /testok
diff --git a/test/fuzz/fuzz-unit-file/directives.scope b/test/fuzz/fuzz-unit-file/directives.scope
new file mode 100644
index 0000000000..d0e194c371
--- /dev/null
+++ b/test/fuzz/fuzz-unit-file/directives.scope
@@ -0,0 +1,2 @@
+scope
+RuntimeMaxSec=