File: ready-serv.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 (48 lines) | stat: -rwxr-xr-x 1,178 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
45
46
47
48
#!/bin/sh
# Verify ready:script for pid/systemd/s6 style services
set -eu

TEST_DIR=$(dirname "$0")

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

test_one()
{
    service=$(echo "$1" | tr -s " ")
    file=/tmp/ready

    sep
    say "Add service stanza '$service' to $FINIT_CONF ..."
    run "echo '$service' > $FINIT_CONF"

    say 'Reload Finit'
    run "initctl reload"

    retry 'assert_num_children 1 serv'
    retry 'assert_ready "serv"' 5 1
#    run "initctl status"
#    run "initctl cond dump"
    assert_file_contains "$file" "READY"
    run "rm -f $file"

    say 'Stop the service'
    run "initctl stop serv"
    retry 'assert_num_children 0 serv'

    say "Done, drop service from $FINIT_CONF ..."
    run "rm $FINIT_CONF"
    run "initctl reload"
}

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

#run "initctl debug"

test_one "service                ready:/bin/ready.sh serv -np       -- Native PID style notification"
test_one "service notify:s6      ready:/bin/ready.sh serv -n -N %n  -- s6 style notification"
test_one "service notify:systemd ready:/bin/ready.sh serv -n        -- systemd style notification"