ctdb-common: Return status from sock_daemon startup()/reconfigure()
[samba.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]: listening on $sockpath
29 test1[PID]: Shutting down
30 EOF
31 unit_test sock_daemon_test "$pidfile" "$sockpath" 1
32
33 ok <<EOF
34 test2[PID]: listening on $sockpath
35 test2[PID]: daemon started, pid=PID
36 test2[PID]: startup completed successfully
37 test2[PID]: Received signal 1
38 test2[PID]: reconfigure failed, ret=1
39 test2[PID]: Received signal 10
40 test2[PID]: reconfigure completed successfully
41 test2[PID]: Received signal 15
42 test2[PID]: Shutting down
43 EOF
44 unit_test sock_daemon_test "$pidfile" "$sockpath" 2
45
46 ok <<EOF
47 test3[PID]: listening on $sockpath
48 test3[PID]: daemon started, pid=PID
49 test3[PID]: PID PID gone away, exiting
50 test3[PID]: Shutting down
51 EOF
52 unit_test sock_daemon_test "$pidfile" "$sockpath" 3
53
54 ok <<EOF
55 test4[PID]: daemon started, pid=PID
56 test4[PID]: Shutting down
57 EOF
58 unit_test sock_daemon_test "$pidfile" "$sockpath" 4
59
60 ok <<EOF
61 test5[PID]: listening on $sockpath
62 test5[PID]: daemon started, pid=PID
63 test5[PID]: startup completed successfully
64 test5[PID]: Received signal 15
65 test5[PID]: Shutting down
66 EOF
67 unit_test sock_daemon_test "$pidfile" "$sockpath" 5
68
69 ok <<EOF
70 test6[PID]: listening on $sockpath
71 test6[PID]: daemon started, pid=PID
72 test6[PID]: startup completed successfully
73 test6[PID]: Shutting down
74 EOF
75 unit_test sock_daemon_test "$pidfile" "$sockpath" 6
76
77 ok <<EOF
78 test7[PID]: daemon started, pid=PID
79 test7[PID]: startup completed successfully
80 test7[PID]: Received signal 15
81 test7[PID]: Shutting down
82 EOF
83 unit_test sock_daemon_test "$pidfile" "$sockpath" 7
84
85 ok <<EOF
86 test8[PID]: daemon started, pid=PID
87 test8[PID]: startup completed successfully
88 test8[PID]: Received signal 15
89 test8[PID]: Shutting down
90 test8[PID]: daemon started, pid=PID
91 test8[PID]: startup completed successfully
92 test8[PID]: Received signal 15
93 test8[PID]: Shutting down
94 EOF
95 unit_test sock_daemon_test "$pidfile" "$sockpath" 8
96
97 ok <<EOF
98 test9[PID]: daemon started, pid=PID
99 test9[PID]: startup completed successfully
100 test9[PID]: Received signal 15
101 test9[PID]: Shutting down
102 test9[PID]: daemon started, pid=PID
103 test9[PID]: startup completed successfully
104 test9[PID]: Received signal 15
105 test9[PID]: Shutting down
106 EOF
107 unit_test sock_daemon_test "$pidfile" "$sockpath" 9
108
109 ok <<EOF
110 test10[PID]: listening on $sockpath
111 test10[PID]: daemon started, pid=PID
112 test10[PID]: startup completed successfully
113 test10[PID]: listening on $sockpath
114 test10[PID]: daemon started, pid=PID
115 test10[PID]: startup completed successfully
116 test10[PID]: Received signal 15
117 test10[PID]: Shutting down
118 EOF
119 unit_test sock_daemon_test "$pidfile" "$sockpath" 10