MCPcopy Create free account
hub / github.com/corosync/corosync / test_signal

Function test_signal

test/testsam.c:194–245  ·  view source on GitHub ↗

* This tests recovery policy quit and callback. */

Source from the content-addressed store, hash-verified

192 * This tests recovery policy quit and callback.
193 */
194static int test_signal (void) {
195 cs_error_t error;
196 unsigned int instance_id;
197
198 test_sig_delivered = 0;
199
200 printf ("%s: initialize\n", __FUNCTION__);
201 error = sam_initialize (2000, SAM_RECOVERY_POLICY_QUIT);
202 if (error != CS_OK) {
203 fprintf (stderr, "Can't initialize SAM API. Error %d\n", error);
204 return 1;
205 }
206 printf ("%s: register\n", __FUNCTION__);
207 error = sam_register (&instance_id);
208 if (error != CS_OK) {
209 fprintf (stderr, "Can't register. Error %d\n", error);
210 return 1;
211 }
212
213 if (instance_id == 1) {
214 signal (SIGTERM, test_signal_handler);
215
216 printf ("%s iid %d: start\n", __FUNCTION__, instance_id);
217 error = sam_start ();
218 if (error != CS_OK) {
219 fprintf (stderr, "Can't start hc. Error %d\n", error);
220 return 1;
221 }
222
223 printf ("%s iid %d: sleep 1\n", __FUNCTION__, instance_id);
224 sleep (1);
225
226 printf ("%s iid %d: hc send\n", __FUNCTION__, instance_id);
227 error = sam_hc_send ();
228 if (error != CS_OK) {
229 fprintf (stderr, "Can't send hc. Error %d\n", error);
230 return 1;
231 }
232
233
234 printf ("%s iid %d: wait for delivery of signal\n", __FUNCTION__, instance_id);
235 while (!test_sig_delivered) {
236 sleep (1);
237 }
238
239 printf ("%s iid %d: wait for real kill\n", __FUNCTION__, instance_id);
240
241 sleep (3);
242 }
243
244 return 1;
245}
246
247
248/*

Callers

nothing calls this directly

Calls 4

sam_initializeFunction · 0.85
sam_registerFunction · 0.85
sam_startFunction · 0.85
sam_hc_sendFunction · 0.85

Tested by

no test coverage detected