chiark / gitweb /
test: add test for jobs
[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 touch /testok
28 exit 0