Branch Coverage

SocketAlarm_action.c
Criterion Covered Total %
branch 98 184 53.2


line true false branch
8 50 2 if (!spec || n_spec == 0) {
8 42 if (!spec || n_spec == 0) {
9 5 5 if (*n_actions) {
17 42 42 else for (spec_i= 0; spec_i < n_spec; spec_i++) {
27 42 0 if (!(spec[spec_i] && SvROK(spec[spec_i]) && SvTYPE(SvRV(spec[spec_i])) == SVt_PVAV))
42 0 if (!(spec[spec_i] && SvROK(spec[spec_i]) && SvTYPE(SvRV(spec[spec_i])) == SVt_PVAV))
0 42 if (!(spec[spec_i] && SvROK(spec[spec_i]) && SvTYPE(SvRV(spec[spec_i])) == SVt_PVAV))
33 42 0 if (n_el < 1 || !(el= av_fetch(action_spec, 0, 0)) || !SvPOK(*el))
42 0 if (n_el < 1 || !(el= av_fetch(action_spec, 0, 0)) || !SvPOK(*el))
0 42 if (n_el < 1 || !(el= av_fetch(action_spec, 0, 0)) || !SvPOK(*el))
40 2 2 if (strcmp(act_name, "sig") == 0) {
41 0 2 if (n_el > 2)
43 2 0 common_signal= (n_el == 2 && (el= av_fetch(action_spec, 1, 0)) != NULL && SvOK(*el))?
2 0 common_signal= (n_el == 2 && (el= av_fetch(action_spec, 1, 0)) != NULL && SvOK(*el))?
44 2 0 parse_signal(*el) : SIGALRM;
48 2 0 if (strcmp(act_name, "run") == 0) {
53 2 2 if (strcmp(act_name, "kill") == 0) {
54 0 2 if (n_el != 3)
57 2 0 if (!el || !SvOK(*el))
0 2 if (!el || !SvOK(*el))
61 2 0 if (!el || !SvIOK(*el))
0 2 if (!el || !SvIOK(*el))
66 2 0 if (strcmp(act_name, "exec") == 0) {
71 2 6 if (strcmp(act_name, "sleep") == 0) {
72 0 2 if (n_el != 2)
75 2 0 if (!el || !SvOK(*el) || !looks_like_number(*el))
2 0 if (!el || !SvOK(*el) || !looks_like_number(*el))
0 2 if (!el || !SvOK(*el) || !looks_like_number(*el))
77 1 1 if (action_pos < *n_actions) {
85 6 0 if (strcmp(act_name, "close") == 0) {
117 4 20 if (strcmp(act_name, "shut_r") == 0) {
121 20 0 if (strcmp(act_name, "shut_w") == 0) {
126 2 0 if (strcmp(act_name, "shut_rw") == 0) {
136 2 2 if (action_pos < *n_actions) {
149 0 4 if (n_el < 2)
156 2 2 if (aux_pos + sizeof(void*) * n_el <= *aux_len)
160 8 4 for (j= 0; j < argc; j++) {
162 8 0 if (!el || !*el || !SvOK(*el))
8 0 if (!el || !*el || !SvOK(*el))
0 8 if (!el || !*el || !SvOK(*el))
165 4 4 if (argv && aux_pos + len + 1 <= *aux_len) {
4 0 if (argv && aux_pos + len + 1 <= *aux_len) {
172 2 2 if (argv)
175 2 2 if (action_pos < *n_actions) {
188 0 32 if (n_el < 2)
191 40 32 for (j= 1; j < n_el; j++) {
193 40 0 if (!el || !*el || !SvOK(*el))
40 0 if (!el || !*el || !SvOK(*el))
0 40 if (!el || !*el || !SvOK(*el))
196 22 18 if (!SvROK(*el)) {
198 20 2 if (looks_like_number(*el)) {
200 20 0 if (fd >= 0 && fd < 0x10000) {
20 0 if (fd >= 0 && fd < 0x10000) {
201 10 10 if (action_pos < *n_actions) {
212 0 2 if (len == sizeof(struct sockaddr)
213 0 0 || len == sizeof(struct sockaddr_in)
214 0 0 || len == sizeof(struct sockaddr_un)
216 1 1 if (action_pos < *n_actions) {
222 1 1 if (aux_pos + len <= *aux_len)
233 18 0 if (fd >= 0) {
234 9 9 if (action_pos < *n_actions) {
251 26 26 success= (action_pos <= *n_actions) && (aux_pos <= *aux_len);
26 0 success= (action_pos <= *n_actions) && (aux_pos <= *aux_len);
265 0 3 if (kill(act->act.kill.pid, act->act.kill.signal) != 0)
271 0 0 if (!resume) {
278 0 0 if (!parent->wake_ts.tv_nsec)
283 0 0 if (now_ts->tv_sec > parent->wake_ts.tv_sec
284 0 0 || (now_ts->tv_sec == parent->wake_ts.tv_sec && now_ts->tv_nsec >= parent->wake_ts.tv_nsec))
0 0 || (now_ts->tv_sec == parent->wake_ts.tv_sec && now_ts->tv_nsec >= parent->wake_ts.tv_nsec))
296 0 9 if (shutdown(act->act.fd.fd, how) < 0) perror("shutdown");
299 0 0 if (close(act->act.fd.fd) < 0) perror("close");
307 0 0 for (i= 0; i < 1024; i++) {
310 0 0 : getsockname(i, (struct sockaddr*)&addr, &len);
311 0 0 if (ret == 0 && len == act->act.nam.addr_len
0 0 if (ret == 0 && len == act->act.nam.addr_len
312 0 0 && memcmp(act->act.nam.addr, &addr, len) == 0
318 0 0 if (shutdown(i, how) < 0) perror("shutdown");
321 0 0 if (close(i) < 0) perror("close");
329 0 0 if (act->op == ACT_RUN) {
332 0 0 if ((child= fork()) < 0) { // fork failure
336 0 0 else if (child > 0) { // parent - wait for immediate child to return
339 0 0 if (status != 0)
343 0 0 else if ((gchild= fork()) != 0) { // second fork
344 0 0 if (gchild < 0) perror("fork");
406 1 1 av_push(dest, newSVpv(act->op == ACT_RUN? "run":"exec", 0));
407 4 2 for (i= 0; i < act->act.run.argc; i++)
425 1 0 int pos= snprintf(buffer, buflen, "%s %s ",
429 1 0 return pos + snprint_sockaddr(buffer+pos, buflen > pos? buflen-pos : 0, act->act.nam.addr);
432 1 1 int i, pos= snprintf(buffer, buflen, "%sexec(", act->op == ACT_RUN? "fork,fork," : "");
433 4 2 for (i= 0; i < act->act.run.argc; i++) {
434 4 0 pos += snprintf(buffer+pos, buflen > pos? buflen-pos : 0, "'%s',", act->act.run.argv[i]);
437 2 0 if (pos < buflen)