File: failing-sysv.sh

package info (click to toggle)
finit 4.14-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,216 kB
  • sloc: ansic: 17,060; sh: 6,281; makefile: 532
file content (44 lines) | stat: -rwxr-xr-x 1,057 bytes parent folder | download
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
34
35
36
37
38
39
40
41
42
43
44
#!/bin/sh
# Verify what happens when sysv scripts start services that keep
# crashing -- hint: crashing sysv services should be detected by
# Finit just like regular services.
set -eu

TEST_DIR=$(dirname "$0")

test_setup()
{
    run "mkdir -p /etc/default"
}

test_teardown()
{
    say "Running test teardown."
    run "rm -f $FINIT_CONF"
}

# shellcheck source=/dev/null
. "$TEST_DIR/lib/setup.sh"

# This instructs serv to check the environment, and exit
# if it cannot find "xyzzy", thus triggering a premature
# exit which Finit should act on to retstart it.
say "Setting up bogus /etc/default/serv"
run "echo 'SERV_ARGS=\"-e xyzzy:lives\"' > /etc/default/serv"

say "Add sysv stanza to $FINIT_CONF"
run "echo 'sysv restart:5 [2345] pid:!/run/serv.pid name:serv /etc/init.d/S02-serv.sh -- Crashing SysV service' > $FINIT_CONF"

#run "initctl debug"

say 'Reload Finit'
run "initctl reload"
#run "initctl status serv"
#run "ps"

say 'Pending sysv restarts by Finit ...'
#run "initctl status serv"
#run "ps"
retry 'assert_restarts 5 serv' 20 1

return 0