Branch Coverage

lib/RPC/Switch/Client/Tiny.pm
Criterion Covered Total %
branch 188 292 64.3


line true false branch
24 0 234 unless my $s = $args{'sock'}
25 234 0 unless ($^O eq "MSWin32")
26 0 234 unless defined(my $b = $s->blocking)
27 19 215 unless ($b)
29 0 215 unless (exists $args{'who'})
40 0 215 if (ref $self->{'sock'} eq 'IO::Socket::SSL') { }
41 0 0 unless exists $self->{'auth_method'}
42 0 0 unless exists $self->{'token'}
44 0 215 unless exists $self->{'auth_method'}
46 38 177 $self->{'client_encoding_utf8'} ? :
58 0 864 if ($self->{'msglimit'} and $len > $self->{'msglimit'})
64 117 747 if $self->{'trace_cb'}
74 320 152 if $method =~ /^rpcswitch\./
75 5 467 unless $self->rpc_send($msg)
82 0 176 if (defined $reqauth) { }
98 0 172 unless ($msg->{'jsonrpc'} eq "2.0" and exists $msg->{'id'} || exists $msg->{'method'})
101 420 429 if (exists $msg->{'method'}) { }
0 429 elsif (not defined $msg->{'id'}) { }
0 429 elsif (not exists $self->{'reqs'}{$msg->{'id'}}) { }
110 0 429 if (exists $msg->{'error'})
113 0 429 unless (exists $msg->{'result'})
116 0 27 if (ref $msg->{'result'} ne "ARRAY" and $rsp ne "rpcswitch.ping" and $rsp ne "rpcswitch.withdraw")
128 29 130 if keys %{$$self{"announced"};}
131 10 135 if exists $self->{'methods'}{$method}{'id'}
134 0 135 if exists $self->{'methods'}{$method}{'filter'}
136 0 135 unless defined $id
149 8 8 if exists $self->{'methods'}{$method}{'id'}
152 0 8 if exists $self->{'methods'}{$method}{'filter'}
154 0 8 unless defined $id
164 132 452 unless $self->{'state'} and $self->{'state'} ne "rpcswitch.hello"
166 102 350 if ($self->{'flowcontrol'})
169 31 71 if ($cnt >= $self->{'async'}{'max_async'} * 2) { }
44 27 elsif ($cnt < $self->{'async'}{'max_async'}) { }
180 0 19 unless ref $err
181 0 19 unless exists $err->{'class'}
201 38 190 if ($req eq 'rpcswitch.greetings') { }
19 171 elsif ($rsp eq 'rpcswitch.hello') { }
19 152 elsif ($rsp eq 'rpcswitch.ping') { }
133 19 elsif ($rsp eq $method) { }
0 19 elsif ($req eq 'rpcswitch.result') { }
19 0 elsif ($req eq 'rpcswitch.channel_gone') { }
202 38 0 $self->{'token'} ? :
206 0 19 unless ($msg->{'result'}[0])
213 133 0 if (exists $msg->{'rpcswitch'})
216 19 114 if ($msg->{'result'}[0] eq 'RES_WAIT') { }
19 95 elsif ($msg->{'result'}[0] eq 'RES_ERROR') { }
95 0 elsif ($msg->{'result'}[0] eq 'RES_OK') { }
226 0 0 if ($msg->{'params'}[0] eq 'RES_OK' and $msg->{'params'}[1] eq $self->{'channels'}{$channel}) { }
0 0 elsif ($msg->{'params'}[0] eq 'RES_ERROR' and $msg->{'params'}[1] eq $self->{'channels'}{$channel}) { }
235 19 0 if (exists $self->{'channels'}{$channel})
250 115 506 if ($req eq 'rpcswitch.greetings') { }
115 391 elsif ($rsp eq 'rpcswitch.hello') { }
135 256 elsif ($rsp eq 'rpcswitch.announce') { }
0 256 elsif ($req eq 'rpcswitch.ping') { }
248 8 elsif (exists $self->{'announced'}{$req}) { }
8 0 elsif ($rsp eq 'rpcswitch.withdraw') { }
0 0 elsif ($req eq 'rpcswitch.channel_gone') { }
251 115 0 $self->{'token'} ? :
255 0 115 unless ($msg->{'result'}[0])
260 0 135 unless ($msg->{'result'}[0])
263 150 15 if exists $self->{'methods'}{$_}{'id'}
264 0 135 unless (defined $method)
278 199 49 if ($self->{'async'}) { }
283 15 34 if ($@) { }
292 0 8 unless ($msg->{'result'})
295 8 0 if exists $self->{'methods'}{$_}{'id'}
296 0 8 unless (defined $method)
304 0 0 if ($self->{'async'})
306 0 0 if (@$msgs)
310 0 0 if (exists $self->{'channels'}{$channel}) { }
323 14 20 unless $self->{'sessioncache'}
325 20 0 if (exists $params->{'session'} and exists $params->{'session'}{'id'})
333 14 20 unless $self->{'sessioncache'}
335 20 0 if (ref $params eq "ARRAY" and $params->[0] eq "RES_OK" and ref $params->[2] and exists $params->[2]{'set_session'})
348 0 18 if (ref $self->{'sock'} eq 'IO::Socket::SSL') { }
363 4 20 unless ($b)
364 0 4 if $@ and $@ =~ /^EINTR/
365 0 4 if $@
369 0 20 if $@
381 0 20 if (my $err = $@) { }
387 0 20 if $@
389 0 20 unless $res
391 14 6 unless $self->is_session_resp($params) or $self->is_session_req($msg->{'params'})
393 1 17 unless close $self->{'sock'}
402 0 177 unless $res
411 20 175 if (my $sessioncache = $self->{'sessioncache'})
412 20 0 if (my $session_req = $self->is_session_req($msg->{'params'})) { }
0 0 elsif ($sessioncache->{'session_persist_user'}) { }
413 6 14 if (my $child = $sessioncache->session_get($session_req->{'id'}, $msg->{'id'}, $msg->{'rpcswitch'}{'vci'}))
417 0 0 if (exists $msg->{'params'}{$sessioncache->{'session_persist_user'}})
419 0 0 if (my $child = $sessioncache->session_get_per_user($user, $msg->{'id'}, $msg->{'rpcswitch'}{'vci'}))
438 0 177 if ($@) { }
442 0 177 if ($@) { }
459 152 14 if ($b) { }
460 0 14 $@ ? :
465 0 152 if ($@) { }
470 0 152 unless ($res)
477 14 138 if (my $sessioncache = $self->{'sessioncache'})
478 14 0 if (my $set_session = $self->is_session_resp($params))
479 8 6 if (not exists $child->{'session'} or $child->{'session'}{'id'} ne $set_session->{'id'})
485 9 5 if ($sessioncache->session_put($child)) { }
0 5 elsif (my $idle_child = $sessioncache->session_get_per_user_idle($child)) { }
487 0 9 if ($cnt > $sessioncache->{'max_session'})
488 0 0 if ($child = $sessioncache->lru_dequeue)
498 0 0 if ($sessioncache->session_put($child))
503 143 9 if ($child)
513 542 60 unless $self->{'sessioncache'}
528 19 1072 if ($call_timeout and keys %{$$self{"reqs"};} > 0)
537 0 1109 if ($self->{'stop'})
538 0 0 if ($self->{'stop'} eq 'withdraw' and keys %{$$self{'announced'};}) { }
0 0 elsif ($self->{'stop'} eq 'withdraw' and $self->{'async'} and keys %{$$self{'async'}{'jobs'};}) { }
555 602 507 if ($self->{'async'})
557 602 0 unless $self->{'stop'}
564 440 651 if ($timeout or @pipes)
566 0 19 if @ready == 0 and $!{'EINTR'}
567 19 421 unless @ready > 0
570 166 0 if ($fh != $self->{'sock'} and $self->{'async'})
571 0 166 unless (exists $self->{'async'}{'jobs'}{$fh->fileno})
579 126 295 unless grep {$_ == $self->{'sock'};} @ready
584 97 849 unless ($b)
585 0 97 if $@ and $@ =~ /^EINTR/
586 0 97 if $@
590 19 830 if $@
591 93 737 if $self->{'trace_cb'}
593 38 792 if (my $err = $@)
594 38 0 if ref $err
597 114 678 if ($res)
613 49 81 defined $methods->{$method}{'doc'} ? :
614 0 130 if exists $methods->{$method}{'filter'}
616 14 120 if exists $self->{'trace_cb'}
617 66 68 if $opts->{'max_async'}
618 0 134 if $opts->{'flowcontrol'}
619 8 126 if $opts->{'max_session'}
622 0 97 if ($self->{'stop'})
634 48 49 if (my $async = $self->{'async'})
637 4 44 if (my $sessioncache = $self->{'sessioncache'})
639 3 0 if (my $child = $sessioncache->session_get($session_id))
646 48 0 if (keys %{$$async{"finished"};})
649 0 48 unless ($async->childs_reap)
665 0 48 if @childs
666 0 48 if @$msgs
676 133 38 if ($self->{'state'} eq "rpcswitch.hello")
681 0 114 unless my $res = $self->rpc_handler($call_timeout, \&RPC::Switch::Client::Tiny::client, $method, $params, $reqauth)
682 19 95 wantarray ? :
707 0 0 $opts->{'gracetime'} ? :
730 47 149 if $self->{'async'}