]> git.pld-linux.org Git - projects/rc-scripts.git/blame - t/service-fork-makepid.sh
drop generic install instructions
[projects/rc-scripts.git] / t / service-fork-makepid.sh
CommitLineData
43f8f34f
ER
1#!/bin/sh
2#
3# testcase experimenting whether daemon --pidfile --fork --makepid works with RC_LOGGING=on and off
4#
5
6dir=$(readlink -f $(dirname "$0"))
7testname=$(basename "$0")
8# save flags, as want to load functions with set +x
9set=$-
10
11set +x
12. $dir/../lib/functions
13set -$set
14
15pidfile=$dir/$testname.pid
16makepid="$dir/../lib/makepid"
17# use /bin/sleep to avoid using sleep builtin
18testprog="/bin/sleep 300"
19
20# fail on errors
21set -e
22
23assert_pidfile() {
24 pid=$(cat $pidfile)
25 # pid must exist
26 test -n "$pid"
27
28 # command must match what was started
29 cmd=$(ps -o cmd= -p $pid)
30 test "$cmd" = "$testprog"
31}
32
33test_makepid() {
34 rm -f $pidfile
35 PIDFILE=$pidfile $makepid $testprog
36 assert_pidfile
37}
38
39test_daemon() {
40 rm -f $pidfile
41 daemon --pidfile $pidfile --fork --makepid $testprog
42 assert_pidfile
43}
44
45test_makepid
46
47RC_LOGGING=yes
48test_daemon
49
50RC_LOGGING=no
51test_daemon
This page took 0.123432 seconds and 4 git commands to generate.