chiark / gitweb /
bus: make PropertiesChanged emission work
[elogind.git] / test / TEST-03-JOBS / test-jobs.sh
1 #!/bin/bash -x
2
3 # Test merging of a --ignore-dependencies job into a previously
4 # installed job.
5
6 systemctl start --no-block hello-after-sleep.target
7 # sleep is now running, hello/start is waiting. Verify that:
8 systemctl list-jobs > /root/list-jobs.txt
9 grep 'sleep\.service.*running' /root/list-jobs.txt || exit 1
10 grep 'hello\.service.*waiting' /root/list-jobs.txt || exit 1
11
12 # This is supposed to finish quickly, not wait for sleep to finish.
13 START_SEC=$(date -u '+%s')
14 systemctl start --ignore-dependencies hello
15 END_SEC=$(date -u '+%s')
16 ELAPSED=$(($END_SEC-$START_SEC))
17
18 [ "$ELAPSED" -lt 3 ] || exit 1
19
20 # sleep should still be running, hello not.
21 systemctl list-jobs > /root/list-jobs.txt
22 grep 'sleep\.service.*running' /root/list-jobs.txt || exit 1
23 grep 'hello\.service' /root/list-jobs.txt && exit 1
24
25 # TODO: add more job queueing/merging tests here.
26
27 # Test for irreversible jobs
28 systemctl start unstoppable.service || exit 1
29
30 # This is expected to fail with 'job cancelled'
31 systemctl stop unstoppable.service && exit 1
32 # But this should succeed
33 systemctl stop --irreversible unstoppable.service || exit 1
34
35 # We're going to shutdown soon. Let's see if it succeeds when
36 # there's an active service that tries to be unstoppable.
37 # Shutdown of the container/VM will hang if not.
38 systemctl start unstoppable.service || exit 1
39
40 touch /testok
41 exit 0