Branch Coverage

blib/lib/IPC/Shareable.pm
Criterion Covered Total %
branch 519 650 79.8


line true false branch
173 7 728 unless _write_permitted($knot)
175 695 33 unless $knot->{'_lock'}
177 461 267 if ($knot->{'_type_int'} == 0) { }
174 93 elsif ($knot->{'_type_int'} == 1) { }
93 0 elsif ($knot->{'_type_int'} == 2) { }
180 93 368 if ref $val and $knot->_need_tie($val, $key)
186 36 138 if ref $val and $knot->_need_tie($val, $i)
191 17 76 if ($knot->{'_data'} and ref $knot->{'_data'})
194 15 78 if ref $val and $knot->_need_tie($val)
198 33 694 if ($knot->{'_lock'} & 2) { }
211 30 962 if ($knot->{'_lock'}) { }
222 646 344 if ($knot->{'_type_int'} == 0) { }
182 162 elsif ($knot->{'_type_int'} == 1) { }
162 0 elsif ($knot->{'_type_int'} == 2) { }
231 153 9 if (defined $data) { }
239 511 470 if (ref $val and my $inner = _is_child($val))
243 13 498 unless (exists $global_register{$inner->seg->id})
247 507 4 unless ($inner->{'_lock'})
258 1 169 unless _write_permitted($knot)
260 168 1 unless $knot->{'_lock'}
262 111 58 if ($knot->{'_type_int'} == 0) { }
58 0 elsif ($knot->{'_type_int'} == 1) { }
275 1 168 if ($knot->{'_lock'} & 2) { }
287 1 7 unless $knot->{'_type_int'} == 0
289 1 6 unless _write_permitted($knot)
291 5 1 unless $knot->{'_lock'}
296 1 5 if ($knot->{'_lock'} & 2) { }
309 14 2 unless $knot->{'_lock'}
314 28 1 unless $knot->{'_lock'}
335 1 15 unless $knot->{'_type_int'} == 1
337 1 14 unless _write_permitted($knot)
339 3 11 unless $knot->{'_lock'}
342 11 3 if ($knot->{'_lock'} & 2) { }
353 1 5 unless $knot->{'_type_int'} == 1
355 1 4 unless _write_permitted($knot)
357 3 1 unless $knot->{'_lock'}
360 1 3 if ($knot->{'_lock'} & 2) { }
372 1 15 unless $knot->{'_type_int'} == 1
374 1 14 unless _write_permitted($knot)
376 3 11 unless $knot->{'_lock'}
378 11 3 if ($knot->{'_lock'} & 2) { }
390 1 5 unless $knot->{'_type_int'} == 1
392 1 4 unless _write_permitted($knot)
394 3 1 unless $knot->{'_lock'}
396 1 3 if ($knot->{'_lock'} & 2) { }
408 1 5 unless $knot->{'_type_int'} == 1
410 1 4 unless _write_permitted($knot)
412 3 1 unless $knot->{'_lock'}
414 1 3 if ($knot->{'_lock'} & 2) { }
426 1 42 unless $knot->{'_type_int'} == 1
428 41 1 unless $knot->{'_lock'}
436 1 5 unless $knot->{'_type_int'} == 1
438 1 4 unless _write_permitted($knot)
440 3 1 unless $knot->{'_lock'}
443 1 3 if ($knot->{'_lock'} & 2) { }
464 3 4 if ($type eq "HASH")
468 2 2 if ($type eq "ARRAY")
472 2 0 if ($type eq "SCALAR")
482 9 136 if (scalar @_ == 2)
486 97 48 if (defined $_[0])
487 1 96 if (ref $_[0] eq 'CODE') { }
495 1 144 if (defined $code and ref $code ne "CODE")
499 49 95 unless defined $flags
503 0 144 if $flags & 8
507 3 141 if ($knot->{'_lock'} & $flags)
508 1 2 if ($code and $flags == 2)
516 0 141 if $knot->{'_lock'}
521 130 11 if ($lock_success)
527 2 128 if (not $locked_ref) { }
529 2 0 if $rflags & 4
539 5 88 if ($flags == 2 and $lock_success and $code)
548 154 129 unless $knot->{'_lock'}
550 54 75 if ($knot->{'_was_changed'})
556 3 25 if ($child->{'_was_changed'})
563 2 26 if $child_flags & 4
573 7 121 if $flags & 4
575 1 127 unless ($sem->op(@{$semop_args{$flags};}))
589 3 5 if (not defined $_[0] or $_[0] ne __PACKAGE__)
595 2 6 unless (defined $glue)
599 4 2 unless defined $warn
618 13489 222 if (defined $attr) { }
634 540 27 unless (defined $knot->{'_uuid'})
643 6967 0 if defined $knot->{'_shm'}
647 2550 0 if defined $knot->{'_sem'}
651 36 0 if ref $_[0] or defined $_[0] and not ref $_[0] and UNIVERSAL::isa($_[0], __PACKAGE__)
655 2 43 if defined $filter_key
659 0 45 unless open my $ipcs_fh, "-|", "ipcs", "-m"
663 0 420 if ($line =~ /^\s*m\s+(\d+)\s+(\S+)/) { }
0 420 elsif ($line =~ /^\s*(\d+)\s+(0x[0-9a-fA-F]+)\s+/) { }
240 180 elsif ($line =~ /^\s*(\S+)\s+(\d+)\s+\S+/) { }
679 0 0 $raw_key =~ /^\d+$/ ? :
240 0 $raw_key =~ /^0x[0-9a-fA-F]+$/ ? :
687 0 240 if $key_int == 0
692 0 240 unless shmctl $id, IPC_STAT(), $stat_buf
706 240 0 $IPC::Shareable::Config{'longsize'} == 8 ? :
0 0 $IPC::Shareable::Config{'longsize'} == 8 ? :
0 0 $^O eq 'dragonfly' && $IPC::Shareable::Config{'longsize'} == 8 ? :
0 0 $^O eq 'openbsd' && $IPC::Shareable::Config{'longsize'} == 8 ? :
0 0 $^O eq 'solaris' ? :
0 0 $^O eq 'freebsd' && $IPC::Shareable::Config{'longsize'} == 8 ? :
240 0 $^O eq 'linux' ? :
710 0 240 unless $segsz
716 0 240 unless shmread $id, $head, 0, 14
717 2 238 unless $head eq "IPC::Shareable"
720 0 238 unless shmread $id, $data, 0, $segsz
733 180 58 exists $process_register{$id} ? :
180 58 exists $global_register{$id} ? :
738 2 43 if (defined $filter_int)
749 0 2 if $related{$k_hex}++
758 1 3 if ref $_[0]
767 0 161 unless open my $ipcs_fh, "-|", "ipcs", "-m"
772 0 867 if ($line =~ /^\s*m\s+\d+\s+\S+/) { }
0 867 elsif ($line =~ /^\s*\d+\s+0x[0-9a-fA-F]+\s+/) { }
223 644 elsif ($line =~ /^\s*(?:0x[0-9a-fA-F]+|\d+)\s+\d+\s+\S+/) { }
789 0 130 unless open my $ipcs_fh, "-|", "ipcs", "-s"
794 0 648 if ($line =~ /^\s*s\s+\d+\s+\S+/) { }
0 648 elsif ($line =~ /^\s*\d+\s+0x[0-9a-fA-F]+\s+/) { }
128 520 elsif ($line =~ /^\s*(?:0x[0-9a-fA-F]+|\d+)\s+\d+\s+\S+/) { }
809 1 5 unless ref $_[0]
826 8 0 if defined $hex
839 0 5 $rtype eq 'ARRAY' ? :
3 5 $rtype eq 'HASH' ? :
844 2 1 unless ref $v
847 1 0 if ($vtype eq 'HASH') { }
0 0 elsif ($vtype eq 'ARRAY') { }
0 0 elsif ($vtype eq 'SCALAR') { }
850 0 1 unless $child_knot and $child_knot->{'_key_hex'}
858 5 0 if ($knot_filter and $knot_filter->{'_key_hex'})
863 0 6 if $in_tree{$h}++
877 0 1 unless exists $segs->{$hex}
886 0 5 unless (@roots)
899 6 0 $seg->{'known'} ? :
900 6 0 if $seg->{'local_process'}
910 6 0 $knot_by_hex{$hex} ? :
913 6 0 if (defined $sem) { }
934 6 0 $knot_by_hex{$hex} ? :
944 1 5 @child_keys ? :
968 0 7 if ($^O eq 'darwin') { }
1 6 elsif ($^O eq 'freebsd') { }
5 1 elsif ($^O eq 'linux') { }
969 0 0 defined $sysctl_out ? :
970 0 0 unless open my $fh, "-|", "sysctl", "kern.sysv"
977 0 0 if ($line =~ /^kern\.sysv\.(\w+):\s*(\S+)/)
983 1 0 defined $sysctl_out ? :
984 0 0 unless open my $fh, "-|", "sysctl", "kern.ipc"
991 5 1 if ($line =~ /^kern\.ipc\.(shm\w+):\s*(\S+)/)
999 16 4 if (open my $fh, "<", $file)
1006 6 1 %info ? :
1014 0 8 unless $s->attributes("owner") == $$
1015 0 8 if $s->attributes("protected")
1026 3 213 if $s->attributes("protected")
1033 5 4 if (scalar @_ == 2)
1036 3 6 if (scalar @_ == 1)
1040 1 8 unless (defined $protect_key)
1044 1 7 unless ($protect_key =~ /^\d+$/)
1055 8 0 if ($stored_key and $stored_key == $protect_key)
1066 10 349 if (defined $key)
1070 1 9 unless (defined $id)
1075 0 9 if (not shmctl($id, IPC_RMID(), 0)) { }
1086 1 8 if (defined $sem)
1087 0 1 unless $sem->remove
1100 0 349 if (not $seg->remove) { }
1114 1 348 if ($sem_remove_status != 1 and $sem_remove_status ne '0 but true') { }
1124 348 1 if ($seg_removed and $sem_removed)
1134 2 79 unless defined $dist_name and length $dist_name
1139 1 0 if @_ > 1 and not ref $_[0] and defined $_[0] and UNIVERSAL::isa($_[0], __PACKAGE__)
1143 0 6 unless defined $dist_name and length $dist_name
1156 0 6 unless open my $ipcs_fh, "-|", "ipcs", "-m"
1160 0 35 if ($line =~ /^\s*m\s+(\d+)\s+(\S+)/) { }
0 35 elsif ($line =~ /^\s*(\d+)\s+(0x[0-9a-fA-F]+)\s+/) { }
11 24 elsif ($line =~ /^\s*(\S+)\s+(\d+)\s+\S+/) { }
1176 0 0 $raw_key =~ /^-?\d+$/ ? :
11 0 $raw_key =~ /^0x[0-9a-fA-F]+$/ ? :
1183 0 11 if $key_int == 0
1186 0 11 unless defined $sem
1188 6 5 unless _testing_semaphore_value($sem) == $target
1190 5 0 if (shmctl $id, IPC_RMID(), 0) { }
1214 447 485 if ($serializer eq "storable")
1225 1221 1638 $serializer eq 'storable' ? :
1229 2306 547 if defined $data
1234 91 456 if $knot->{'_type_int'} == 1
1235 352 104 if $knot->{'_type_int'} == 0
1246 1 484 if (length $json > $seg->size)
1255 0 486 unless my $type = builtin::reftype($data)
1262 318 168 if ($type eq "HASH")
1266 68 1171 if (ref $val and _is_child($val))
1271 250 68 unless $has_child
1279 72 74 $inner ? :
1285 152 16 if ($type eq "ARRAY")
1289 26 322 if (ref $val and _is_child($val))
1294 126 26 unless $has_child
1301 43 7 if ($inner) { }
1307 15 1 if ($type eq "SCALAR" or $type eq "REF")
1311 6 9 $inner ? :
1322 343 1296 unless $json
1332 1295 1 if ($tag eq 'IPC::Shareable') { }
1335 1 1290 unless (defined $data)
1339 418 872 if defined $knot and index($json, "\"__ics__\"") != -1
1343 85 1205 if (defined $knot and $knot->{'_type_int'} == 2 and ref $data eq "HASH")
1344 44 41 if (exists $data->{'__ics__'})
1346 43 1 defined $prev && ref $prev ? :
1350 24 17 if (exists $data->{'__sv__'})
1364 0 418 unless my $type = builtin::reftype($data)
1372 311 107 if ($type eq 'HASH') { }
107 0 elsif ($type eq 'ARRAY') { }
1375 274 392 unless ref $data->{$key} eq "HASH" and exists $data->{$key}{'__ics__'}
1378 365 27 $prev_is_hash ? :
1385 92 15 $prev_is_array ? :
1387 44 187 unless ref $data->[$i] eq "HASH" and exists $data->[$i]{'__ics__'}
1389 165 22 $prev_is_array && $i <= $prev_max ? :
1399 558 65 if (defined $existing)
1401 547 11 if $inner and $inner->{'_key'} == $info->{'child_key'}
1417 34 42 if ($info->{'type'} eq 'HASH') { }
41 1 elsif ($info->{'type'} eq 'ARRAY') { }
1 0 elsif ($info->{'type'} eq 'SCALAR') { }
1437 0 447 unless defined $ice
1441 1 446 if (length $ice > $seg->size)
1452 7 1480 unless $ice
1456 1034 446 if ($tag eq 'IPC::Shareable') { }
1458 1 1033 unless (defined $water)
1472 178 362 if (scalar @_ == 4) { }
1491 2 538 if ($knot->attributes("limit") and $shm_size > 1073741824)
1499 8 530 if ($knot->attributes('graceful')) { }
1511 4 4 unless (defined $exclusive)
1512 1 3 if ($knot->attributes("warn"))
1530 7 525 unless (defined $seg)
1531 2 5 if ($!{'ENOMEM'})
1536 0 5 if ($!{'ENOSPC'})
1541 3 2 if (not $knot->attributes('create')) { }
1 1 elsif ($knot->attributes('create') and $knot->attributes('exclusive')) { }
1562 518 7 $knot->attributes('testing') ? :
1566 1 524 unless (defined $sem)
1570 1 523 unless ($sem->op(@{$semop_args{1};}))
1574 103 129 $type eq 'ARRAY' ? :
291 232 $type eq 'HASH' ? :
1589 261 262 if ($serializer eq 'json') { }
1593 4 257 if (not $decoded_ok) { }
1601 4 0 if ($thaw_ok and defined $storable_data) { }
1628 422 101 unless (exists $global_register{$knot->seg->id})
1632 399 124 if ($sem->getval(0) != 1) { }
1638 392 7 if ($knot->attributes("testing"))
1642 1 398 unless ($sem->setval(0, 1))
1653 3 121 if defined $stored_protected and $stored_protected != 0
1657 124 0 if ($stored_testing)
1671 30 115 if ($parent->{'_key'} == IPC_PRIVATE() and $parent->attributes('serializer') ne 'json') { }
1695 103 41 if ($type eq 'HASH') { }
38 3 elsif ($type eq 'ARRAY') { }
2 1 elsif ($type eq 'SCALAR') { }
1698 0 103 unless $child
1705 0 38 unless $child
1712 0 2 unless $child
1726 0 146 unless $type
1730 104 42 if ($type eq 'HASH') { }
38 4 elsif ($type eq 'ARRAY') { }
4 0 elsif ($type eq 'SCALAR') { }
1740 144 2 $need_tie ? :
1744 27 678 if (ref $val and my $child = _is_child($val))
1749 1348 14 $_have_xs ? :
1754 1 13 unless my $data = shift()
1757 2 11 unless $type
1761 6 5 if ($type eq 'HASH') { }
2 3 elsif ($type eq 'ARRAY') { }
2 1 elsif ($type eq 'SCALAR') { }
1771 7 4 if (ref $obj eq "IPC::Shareable")
1780 10 930 if (not defined $knot->_encode($knot->seg, $knot->{'_data'}))
1792 2 4 if not $ok
1800 2 3 if $key_str =~ /^0x[0-9a-fA-F]+$/i
1801 1 2 if $key_str =~ /^\d+$/
1804 1 1 if $int > 2147483648
1821 24 30 $rtype eq 'ARRAY' ? :
134 54 $rtype eq 'HASH' ? :
1828 244 32 unless ref $val
1830 0 32 unless $child and $child->seg
1833 0 32 if $seen{$id}++
1835 2 30 unless ($child->sem->op(@{$semop_args{$flags};}))
1838 2 0 if $rflags & 4
1854 156 30 unless $found
1865 3 3 if ($rtype eq "SCALAR")
1867 3 0 defined $v ? :
1870 3 0 if ($rtype eq "HASH")
1874 1 2 if (ref $v) { }
1876 0 0 $vt eq 'SCALAR' ? :
0 0 $vt eq 'ARRAY' ? :
1 0 $vt eq 'HASH' ? :
1881 1 0 $child && $child->{'_key_hex'} ? :
1885 2 0 defined $v ? :
1888 3 0 @parts ? :
1891 0 0 if ($rtype eq "ARRAY")
1894 0 0 if (ref $v) { }
1896 0 0 $vt eq 'SCALAR' ? :
0 0 $vt eq 'ARRAY' ? :
0 0 $vt eq 'HASH' ? :
1901 0 0 $child && $child->{'_key_hex'} ? :
1905 0 0 defined $v ? :
1921 401 139 if $knot->attributes("create")
1922 168 372 if $knot->attributes("exclusive")
1936 84 483 if ($key_str eq '') { }
28 455 elsif ($key_str =~ /^0x[0-9a-fA-F]+$/i) { }
213 242 elsif ($key_str =~ /^\d+$/) { }
1961 141 185 if ($key >= 2147483648)
1964 1 140 if ($key == 0)
1987 10 114 if $used_ids{$key}
2004 114 0 if ($shm_slot_available)
2006 114 0 if $seg
2010 1 114 unless ($verified_exclusive)
2031 13 949 unless $knot->attributes("enforced_read_locking")
2032 3 946 unless $knot->attributes("violated_read_lock_warn")
2039 0 946 unless defined $writers
2041 4 942 if ($writers > 0)
2055 30 932 unless $knot->attributes("enforced_write_locking")
2060 58 874 if $knot->{'_lock'} & 2
2069 12 862 if ($sem->getval(2) > 0)
2070 11 1 if ($knot->attributes("violated_write_lock_warn"))
2085 3 859 if ($sem->getval(1) > 0)
2086 3 0 if ($knot->attributes("violated_write_lock_warn"))
2113 0 135 unless my $stat = $sem->stat
2114 0 135 if $stat->nsems < 5
2123 538 2 defined $opts ? :
2131 3770 4870 if (not defined $opts->{$k}) { }
2 4868 elsif ($opts->{$k} eq 'no') { }
2135 1 1 if ($^W)
2148 308 232 if ($_testing_dist and not $testing_explicit)
2157 0 153 if $s->attributes("protected")
2158 17 136 unless $s->attributes("destroy")
2159 49 87 if $s->attributes("owner") != $$