aa1d6b471db49e6dc81fdae297568fc2b690105f
[metze/samba/wip.git] / ctdb / tests / cunit / sock_daemon_test_001.sh
1 #!/bin/sh
2
3 . "${TEST_SCRIPTS_DIR}/unit.sh"
4
5 pidfile="${TEST_VAR_DIR}/sock_daemon_test.pid.$$"
6 sockpath="${TEST_VAR_DIR}/sock_daemon_test.sock.$$"
7
8 remove_files ()
9 {
10         rm -f "$pidfile"
11         rm -f "$sockpath"
12 }
13
14 test_cleanup remove_files
15
16 result_filter ()
17 {
18         _pid="[0-9][0-9]*"
19         sed -e "s|pid=${_pid}|pid=PID|" \
20             -e "s|PID ${_pid}|PID PID|" \
21             -e "s|\[${_pid}\]|[PID]|"
22 }
23
24
25 ok <<EOF
26 test1[PID]: daemon started, pid=PID
27 test1[PID]: startup failed, ret=1
28 test1[PID]: daemon started, pid=PID
29 test1[PID]: startup failed, ret=2
30 test1[PID]: daemon started, pid=PID
31 test1[PID]: startup completed successfully
32 test1[PID]: listening on $sockpath
33 test1[PID]: Shutting down
34 EOF
35 unit_test sock_daemon_test "$pidfile" "$sockpath" 1
36
37 ok <<EOF
38 test2[PID]: daemon started, pid=PID
39 test2[PID]: startup completed successfully
40 test2[PID]: listening on $sockpath
41 test2[PID]: Received signal 1
42 test2[PID]: reconfigure failed, ret=1
43 test2[PID]: Received signal 10
44 test2[PID]: reconfigure completed successfully
45 test2[PID]: Received signal 15
46 test2[PID]: Shutting down
47 EOF
48 unit_test sock_daemon_test "$pidfile" "$sockpath" 2
49
50 ok <<EOF
51 test3[PID]: daemon started, pid=PID
52 test3[PID]: listening on $sockpath
53 test3[PID]: PID PID gone away, exiting
54 test3[PID]: Shutting down
55 EOF
56 unit_test sock_daemon_test "$pidfile" "$sockpath" 3
57
58 ok <<EOF
59 test4[PID]: daemon started, pid=PID
60 test4[PID]: Shutting down
61 EOF
62 unit_test sock_daemon_test "$pidfile" "$sockpath" 4
63
64 ok <<EOF
65 test5[PID]: daemon started, pid=PID
66 test5[PID]: listening on $sockpath
67 test5[PID]: Received signal 15
68 test5[PID]: Shutting down
69 EOF
70 unit_test sock_daemon_test "$pidfile" "$sockpath" 5
71
72 ok <<EOF
73 test6[PID]: daemon started, pid=PID
74 test6[PID]: listening on $sockpath
75 test6[PID]: Shutting down
76 EOF
77 unit_test sock_daemon_test "$pidfile" "$sockpath" 6
78
79 ok <<EOF
80 test7[PID]: daemon started, pid=PID
81 test7[PID]: startup completed successfully
82 test7[PID]: Received signal 15
83 test7[PID]: Shutting down
84 EOF
85 unit_test sock_daemon_test "$pidfile" "$sockpath" 7
86
87 ok <<EOF
88 test8[PID]: daemon started, pid=PID
89 test8[PID]: startup completed successfully
90 test8[PID]: Received signal 15
91 test8[PID]: Shutting down
92 test8[PID]: daemon started, pid=PID
93 test8[PID]: startup completed successfully
94 test8[PID]: Received signal 15
95 test8[PID]: Shutting down
96 EOF
97 unit_test sock_daemon_test "$pidfile" "$sockpath" 8
98
99 ok <<EOF
100 test9[PID]: daemon started, pid=PID
101 test9[PID]: startup completed successfully
102 test9[PID]: Received signal 15
103 test9[PID]: Shutting down
104 test9[PID]: daemon started, pid=PID
105 test9[PID]: startup completed successfully
106 test9[PID]: Received signal 15
107 test9[PID]: Shutting down
108 EOF
109 unit_test sock_daemon_test "$pidfile" "$sockpath" 9
110
111 ok <<EOF
112 test10[PID]: daemon started, pid=PID
113 test10[PID]: listening on $sockpath
114 test10[PID]: daemon started, pid=PID
115 test10[PID]: listening on $sockpath
116 test10[PID]: Received signal 15
117 test10[PID]: Shutting down
118 EOF
119 unit_test sock_daemon_test "$pidfile" "$sockpath" 10