forked from troglobit/finit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-task-tricks.sh
executable file
·59 lines (49 loc) · 1.39 KB
/
run-task-tricks.sh
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
49
50
51
52
53
54
55
56
57
58
59
#!/bin/sh
#
# Verifies that a run task can call initctl at bootstrap and runlevel 2,
# without blocking, performing serveral tasks:
#
# 1. Query running services
# 2. Stop/Start a running service
# 3. Restart a service
#
TEST_DIR=$(dirname "$0")
#DEBUG=1
# shellcheck disable=SC2034
BOOTSTRAP="run [S] /bin/ready.sh -- Ready steady go\n\
run [S] name:one initctl -- Query status\n\
service [S234] /sbin/service.sh -- Background service\n\
run [2] name:two initctl stop service.sh -- Stopping service\n\
run [3] name:three initctl start service.sh -- Starting service again\n\
run [4] name:four initctl restart service.sh -- Restart service"
# shellcheck disable=SC2034
RCLOCAL="echo \"$0 ==============\" &1>2"
# shellcheck source=/dev/null
. "$TEST_DIR/lib/setup.sh"
test_setup()
{
say "Test start $(date)"
}
test_teardown()
{
say "Test done $(date)"
}
say "$FINIT_CONF:"
run "cat $FINIT_CONF"
say "/etc/rc.local:"
run "cat /etc/rc.local"
say "Waiting for runlevel 2"
sleep 2
assert_status "service.sh" "stopped"
say "Changing to runlevel 3"
run "initctl runlevel 3"
sleep 2
assert_status "service.sh" "running"
run "initctl"
oldpid=$(texec initctl |awk '/service.sh/{print $1}')
say "Changing to runlevel 4"
run "initctl runlevel 4"
sleep 2
assert_status "service.sh" "running"
assert_pidiff "service.sh" "$oldpid"
run "initctl"