summaryrefslogtreecommitdiff
path: root/test/TEST-41-ONESHOT-RESTART/testsuite.sh
blob: f7423dbf9a1d47b4a09a85b0443e90920c5f5021 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
set -ex
set -o pipefail

systemd-analyze log-level debug
systemd-analyze log-target console

# These three commands should succeed.
! systemd-run --unit=one -p Type=oneshot -p Restart=on-failure /bin/bash -c "exit 1"

sleep 5

if [[ "$(systemctl show one.service -p NRestarts --value)" -le 0 ]]; then
  exit 1
fi

TMP_FILE="/test-41-oneshot-restart-test"

touch $TMP_FILE

! systemd-run --unit=two -p StartLimitBurst=3 -p Type=oneshot -p Restart=on-failure -p ExecStart="/bin/bash -c \"printf a >>  $TMP_FILE\"" /bin/bash -c "exit 1"

sleep 5

if [[ $(cat $TMP_FILE) != "aaa" ]]; then
  exit 1
fi

systemd-analyze log-level info

echo OK > /testok

exit 0