Branch Coverage

blib/lib/IPC/Shareable.pm
Criterion Covered Total %
branch 551 696 79.1


line true false branch
181 7 782 unless _write_permitted($knot)
183 748 34 unless $knot->{'_lock'}
185 476 306 if ($knot->{'_type_int'} == 0) { }
187 119 elsif ($knot->{'_type_int'} == 1) { }
119 0 elsif ($knot->{'_type_int'} == 2) { }
188 98 378 if ref $val and $knot->_need_tie($val)
194 37 150 if ref $val and $knot->_need_tie($val)
200 27 92 if ($knot->{'_data'} and ref $knot->{'_data'})
203 19 100 if ref $val and $knot->_need_tie($val)
207 34 747 if ($knot->{'_lock'} & 2) { }
221 31 1007 if ($knot->{'_lock'}) { }
232 656 380 if ($knot->{'_type_int'} == 0) { }
186 194 elsif ($knot->{'_type_int'} == 1) { }
194 0 elsif ($knot->{'_type_int'} == 2) { }
241 185 9 if (defined $data) { }
249 520 507 if (ref $val and my $inner = _is_child($val))
253 13 507 unless (exists $global_register{$inner->seg->id})
257 516 4 unless ($inner->{'_lock'})
268 1 184 unless _write_permitted($knot)
270 183 1 unless $knot->{'_lock'}
272 122 62 if ($knot->{'_type_int'} == 0) { }
62 0 elsif ($knot->{'_type_int'} == 1) { }
285 1 183 if ($knot->{'_lock'} & 2) { }
297 1 7 unless $knot->{'_type_int'} == 0
299 1 6 unless _write_permitted($knot)
301 5 1 unless $knot->{'_lock'}
306 1 5 if ($knot->{'_lock'} & 2) { }
319 14 2 unless $knot->{'_lock'}
324 28 1 unless $knot->{'_lock'}
345 1 15 unless $knot->{'_type_int'} == 1
347 1 14 unless _write_permitted($knot)
349 3 11 unless $knot->{'_lock'}
352 11 3 if ($knot->{'_lock'} & 2) { }
363 1 5 unless $knot->{'_type_int'} == 1
365 1 4 unless _write_permitted($knot)
367 3 1 unless $knot->{'_lock'}
370 1 3 if ($knot->{'_lock'} & 2) { }
382 1 15 unless $knot->{'_type_int'} == 1
384 1 14 unless _write_permitted($knot)
386 3 11 unless $knot->{'_lock'}
388 11 3 if ($knot->{'_lock'} & 2) { }
400 1 5 unless $knot->{'_type_int'} == 1
402 1 4 unless _write_permitted($knot)
404 3 1 unless $knot->{'_lock'}
406 1 3 if ($knot->{'_lock'} & 2) { }
418 1 5 unless $knot->{'_type_int'} == 1
420 1 4 unless _write_permitted($knot)
422 3 1 unless $knot->{'_lock'}
424 1 3 if ($knot->{'_lock'} & 2) { }
436 1 39 unless $knot->{'_type_int'} == 1
438 27 12 unless $knot->{'_lock'}
446 1 5 unless $knot->{'_type_int'} == 1
448 1 4 unless _write_permitted($knot)
450 3 1 unless $knot->{'_lock'}
453 1 3 if ($knot->{'_lock'} & 2) { }
474 3 4 if ($type eq "HASH")
478 2 2 if ($type eq "ARRAY")
482 2 0 if ($type eq "SCALAR")
492 9 130 if (scalar @_ == 2)
496 99 40 if (defined $_[0])
497 1 98 if (ref $_[0] eq 'CODE') { }
505 1 138 if (defined $code and ref $code ne "CODE")
509 41 97 unless defined $flags
513 0 138 if $flags & 8
517 3 135 if ($knot->{'_lock'} & $flags)
518 1 2 if ($code and $flags == 2)
526 0 135 if $knot->{'_lock'}
531 124 11 if ($lock_success)
537 2 122 if (not $locked_ref) { }
539 2 0 if $rflags & 4
549 5 81 if ($flags == 2 and $lock_success and $code)
558 182 123 unless $knot->{'_lock'}
560 46 77 if ($knot->{'_was_changed'})
568 3 25 if ($child->{'_was_changed'})
575 2 26 if $child_flags & 4
587 7 115 if $flags & 4
589 2 120 unless ($sem->op(@{$semop_args{$flags};}))
590 1 1 if ($!{'EINVAL'}) { }
599 1 0 unless $_unlock_einval_warned
620 3 5 if (not defined $_[0] or $_[0] ne __PACKAGE__)
626 2 6 unless (defined $glue)
630 4 2 unless defined $warn
649 14494 236 if (defined $attr) { }
665 585 27 unless (defined $knot->{'_uuid'})
674 7350 0 if defined $knot->{'_shm'}
678 2688 0 if defined $knot->{'_sem'}
682 36 23 if ref $_[0] or defined $_[0] and not ref $_[0] and UNIVERSAL::isa($_[0], __PACKAGE__)
686 25 43 if defined $filter_key
690 0 68 unless open my $ipcs_fh, "-|", "ipcs", "-m"
695 0 535 if ($line =~ /^\s*m\s+(\d+)\s+(\S+)/) { }
0 535 elsif ($line =~ /^\s*(\d+)\s+(0x[0-9a-fA-F]+)\s+/) { }
263 272 elsif ($line =~ /^\s*(\S+)\s+(\d+)\s+\S+/) { }
711 0 0 $raw_key =~ /^\d+$/ ? :
263 0 $raw_key =~ /^0x[0-9a-fA-F]+$/ ? :
719 0 263 if $key_int == 0
724 0 263 unless shmctl $id, IPC_STAT(), $stat_buf
738 263 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 ? :
263 0 $^O eq 'linux' ? :
742 0 263 unless $segsz
748 0 263 unless shmread $id, $head, 0, 14
749 2 261 unless $head eq "IPC::Shareable"
752 0 261 unless shmread $id, $data, 0, $segsz
765 180 81 exists $process_register{$id} ? :
180 81 exists $global_register{$id} ? :
770 25 43 if (defined $filter_int)
784 0 2 if $related{$k_hex}++
794 1 3 if ref $_[0]
803 0 4 unless open my $ipcs_fh, "-|", "ipcs", "-m"
806 0 18 if ($line =~ /^\s*m\s+\d+\s+\S+/) { }
0 18 elsif ($line =~ /^\s*\d+\s+0x[0-9a-fA-F]+\s+/) { }
2 16 elsif ($line =~ /^\s*(?:0x[0-9a-fA-F]+|\d+)\s+\d+\s+\S+/) { }
827 0 3 unless open my $ipcs_fh, "-|", "ipcs", "-s"
830 0 13 if ($line =~ /^\s*s\s+\d+\s+\S+/) { }
0 13 elsif ($line =~ /^\s*\d+\s+0x[0-9a-fA-F]+\s+/) { }
1 12 elsif ($line =~ /^\s*(?:0x[0-9a-fA-F]+|\d+)\s+\d+\s+\S+/) { }
849 1 5 unless ref $_[0]
866 8 0 if defined $hex
880 0 5 $rtype eq 'ARRAY' ? :
3 5 $rtype eq 'HASH' ? :
885 2 1 unless ref $v
890 1 0 if ($vtype eq 'HASH') { }
0 0 elsif ($vtype eq 'ARRAY') { }
0 0 elsif ($vtype eq 'SCALAR') { }
900 0 1 unless $child_knot and $child_knot->{'_key_hex'}
909 5 0 if ($knot_filter and $knot_filter->{'_key_hex'})
916 0 6 if $in_tree{$h}++
934 0 1 unless exists $segs->{$hex}
944 0 5 unless (@roots)
958 6 0 $seg->{'known'} ? :
959 6 0 if $seg->{'local_process'}
970 6 0 $knot_by_hex{$hex} ? :
973 6 0 if (defined $sem) { }
996 6 0 $knot_by_hex{$hex} ? :
1008 1 5 @child_keys ? :
1035 0 12 if ($^O eq 'darwin') { }
1 11 elsif ($^O eq 'freebsd') { }
1 10 elsif ($^O eq 'openbsd') { }
9 1 elsif ($^O eq 'linux') { }
1036 0 0 defined $sysctl_out ? :
1037 0 0 unless open my $fh, "-|", "sysctl", "kern.sysv"
1044 0 0 if ($line =~ /^kern\.sysv\.(\w+):\s*(\S+)/)
1050 1 0 defined $sysctl_out ? :
1051 0 0 unless open my $fh, "-|", "sysctl", "kern.ipc"
1058 9 1 if ($line =~ /^kern\.ipc\.((?:shm|sem)\w+):\s*(\S+)/)
1064 1 0 defined $sysctl_out ? :
1065 0 0 unless open my $fh, "-|", "sysctl", "kern.seminfo", "kern.shminfo"
1073 7 0 if ($line =~ /^kern\.(?:sem|shm)info\.(\w+)\s*=\s*(\S+)/)
1081 28 8 if (open my $fh, "<", $file)
1088 9 0 if (open my $fh, "<", "$proc_dir/sem")
1092 9 0 if (@vals >= 4)
1098 11 1 %info ? :
1108 0 8 unless $s->attributes("owner") == $$
1109 0 8 if $s->attributes("protected")
1120 3 220 if $s->attributes("protected")
1127 5 4 if (scalar @_ == 2)
1130 3 6 if (scalar @_ == 1)
1134 1 8 unless (defined $protect_key)
1138 1 7 unless ($protect_key =~ /^\d+$/)
1149 8 0 if ($stored_key and $stored_key == $protect_key)
1160 10 385 if (defined $key)
1164 1 9 unless (defined $id)
1169 0 9 if (not shmctl($id, IPC_RMID(), 0)) { }
1180 1 8 if (defined $sem)
1181 0 1 unless $sem->remove
1194 0 385 if (not $seg->remove) { }
1208 1 384 if ($sem_remove_status != 1 and $sem_remove_status ne '0 but true') { }
1218 384 1 if ($seg_removed and $sem_removed)
1229 2 83 unless defined $dist_name and length $dist_name
1235 1 0 if @_ > 1 and not ref $_[0] and defined $_[0] and UNIVERSAL::isa($_[0], __PACKAGE__)
1239 0 6 unless defined $dist_name and length $dist_name
1252 0 6 unless open my $ipcs_fh, "-|", "ipcs", "-m"
1257 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+/) { }
1273 0 0 $raw_key =~ /^-?\d+$/ ? :
11 0 $raw_key =~ /^0x[0-9a-fA-F]+$/ ? :
1280 0 11 if $key_int == 0
1283 0 11 unless defined $sem
1285 6 5 unless _testing_semaphore_value($sem) == $target
1296 5 0 defined $stat ? :
1298 0 5 if defined $cpid and $cpid > 0 and $cpid != $$ and kill 0, $cpid
1300 5 0 if (shmctl $id, IPC_RMID(), 0) { }
1327 98 894 if ($knot->{'_type_int'} == 2 and ref $data eq "SCALAR")
1330 96 2 if (defined $val and not ref $val)
1337 382 514 if ($serializer eq "storable")
1350 579 2685 if ($knot->{'_type_int'} == 2)
1352 107 472 if defined $verbatim
1357 1436 1721 $serializer eq 'storable' ? :
1361 2286 865 if defined $data
1366 128 737 if $knot->{'_type_int'} == 1
1367 493 244 if $knot->{'_type_int'} == 0
1379 0 514 if (length $json > $seg->size)
1388 0 515 unless my $type = builtin::reftype($data)
1396 338 177 if ($type eq "HASH")
1400 73 1162 if (ref $val and _is_child($val))
1405 265 73 unless $has_child
1415 77 79 $inner ? :
1422 166 11 if ($type eq "ARRAY")
1426 27 339 if (ref $val and _is_child($val))
1431 139 27 unless $has_child
1438 44 9 if ($inner) { }
1444 10 1 if ($type eq "SCALAR" or $type eq "REF")
1449 9 1 $inner ? :
1460 398 1324 unless $json
1470 1323 1 if ($tag eq 'IPC::Shareable') { }
1473 1 1318 unless (defined $data)
1477 433 885 if (defined $knot and index($json, "\"__ics__\"") != -1)
1484 74 1244 if (defined $knot and $knot->{'_type_int'} == 2 and ref $data eq "HASH")
1485 50 24 if (exists $data->{'__ics__'})
1487 49 1 defined $prev && ref $prev ? :
1491 2 22 if (exists $data->{'__sv__'})
1506 0 433 unless my $type = builtin::reftype($data)
1514 326 107 if ($type eq 'HASH') { }
107 0 elsif ($type eq 'ARRAY') { }
1518 290 401 unless ref $data->{$key} eq "HASH" and exists $data->{$key}{'__ics__'}
1522 370 31 $prev_is_hash ? :
1529 92 15 $prev_is_array ? :
1532 44 187 unless ref $data->[$i] eq "HASH" and exists $data->[$i]{'__ics__'}
1535 165 22 $prev_is_array && $i <= $prev_max ? :
1545 569 69 if (defined $existing)
1547 558 11 if $inner and $inner->{'_key'} == $info->{'child_key'}
1563 34 46 if ($info->{'type'} eq 'HASH') { }
45 1 elsif ($info->{'type'} eq 'ARRAY') { }
1 0 elsif ($info->{'type'} eq 'SCALAR') { }
1591 3 93 if (length $raw > $seg->size)
1608 7 572 unless defined $raw
1612 465 107 if substr($raw, 0, 15) ne "IPC::Shareable\36"
1623 0 382 unless defined $ice
1628 0 382 if (length $ice > $seg->size)
1639 7 1433 unless $ice
1643 973 460 if ($tag eq 'IPC::Shareable') { }
1645 1 972 unless (defined $water)
1660 190 399 if (scalar @_ == 4) { }
1679 2 583 if ($knot->attributes("limit") and $shm_size > 1073741824)
1687 8 575 if ($knot->attributes('graceful')) { }
1700 4 4 unless (defined $exclusive)
1701 1 3 if ($knot->attributes("warn"))
1719 7 570 unless (defined $seg)
1720 2 5 if ($!{'ENOMEM'})
1725 0 5 if ($!{'ENOSPC'})
1730 3 2 if (not $knot->attributes('create')) { }
1 1 elsif ($knot->attributes('create') and $knot->attributes('exclusive')) { }
1751 563 7 $knot->attributes('testing') ? :
1756 4 566 unless (defined $sem)
1767 3 1 if $knot->attributes("create")
1773 2 564 unless ($sem->op(@{$semop_args{1};}))
1781 2 0 if $sem->getval(0) != 1
1782 2 0 if $knot->attributes("create")
1788 112 148 $type eq 'ARRAY' ? :
304 260 $type eq 'HASH' ? :
1803 294 270 if ($serializer eq 'json') { }
1807 4 290 if (not $decoded_ok) { }
1815 4 0 if ($thaw_ok and defined $storable_data) { }
1842 458 106 unless (exists $global_register{$knot->seg->id})
1846 435 129 if ($sem->getval(0) != 1) { }
1852 428 7 if ($knot->attributes("testing"))
1856 1 434 unless ($sem->setval(0, 1))
1868 3 126 if (defined $stored_protected and $stored_protected != 0)
1874 129 0 if ($stored_testing)
1888 15 140 if ($parent->{'_key'} == IPC_PRIVATE() and $parent->attributes('serializer') ne 'json') { }
1912 109 45 if ($type eq 'HASH') { }
42 3 elsif ($type eq 'ARRAY') { }
2 1 elsif ($type eq 'SCALAR') { }
1915 0 109 unless $child
1922 0 42 unless $child
1929 0 2 unless $child
1943 0 156 unless $type
1947 110 46 if ($type eq 'HASH') { }
42 4 elsif ($type eq 'ARRAY') { }
4 0 elsif ($type eq 'SCALAR') { }
1957 154 2 $need_tie ? :
1962 28 715 if (ref $val and my $child = _is_child($val))
1967 1384 14 $_have_xs ? :
1972 1 13 unless my $data = shift()
1975 2 11 unless $type
1979 6 5 if ($type eq 'HASH') { }
2 3 elsif ($type eq 'ARRAY') { }
2 1 elsif ($type eq 'SCALAR') { }
1989 7 4 if (ref $obj eq "IPC::Shareable")
2000 10 989 if (not defined $knot->_encode($knot->seg, $knot->{'_data'}))
2015 2 4 if not $ok
2024 0 91 if $key_str =~ /^0x[0-9a-fA-F]+$/i
2025 9 82 if $key_str =~ /^\d+$/
2028 42 40 if $int > 2147483648
2046 15 32 $rtype eq 'ARRAY' ? :
135 47 $rtype eq 'HASH' ? :
2055 199 32 unless ref $val
2058 0 32 unless $child and $child->seg
2061 0 32 if $seen{$id}++
2063 2 30 unless ($child->sem->op(@{$semop_args{$flags};}))
2066 2 0 if $rflags & 4
2087 150 30 unless $found
2098 3 3 if ($rtype eq "SCALAR")
2100 3 0 defined $v ? :
2103 3 0 if ($rtype eq "HASH")
2107 1 2 if (ref $v) { }
2109 0 0 $vt eq 'SCALAR' ? :
0 0 $vt eq 'ARRAY' ? :
1 0 $vt eq 'HASH' ? :
2114 1 0 $child && $child->{'_key_hex'} ? :
2118 2 0 defined $v ? :
2121 3 0 @parts ? :
2124 0 0 if ($rtype eq "ARRAY")
2127 0 0 if (ref $v) { }
2129 0 0 $vt eq 'SCALAR' ? :
0 0 $vt eq 'ARRAY' ? :
0 0 $vt eq 'HASH' ? :
2134 0 0 $child && $child->{'_key_hex'} ? :
2138 0 0 defined $v ? :
2154 441 144 if $knot->attributes("create")
2155 178 407 if $knot->attributes("exclusive")
2169 64 548 if ($key_str eq '') { }
13 535 elsif ($key_str =~ /^0x[0-9a-fA-F]+$/i) { }
232 303 elsif ($key_str =~ /^\d+$/) { }
2194 169 198 if ($key >= 2147483648)
2197 1 168 if ($key == 0)
2220 10 139 if $used_ids{$key}
2238 139 0 if ($shm_slot_available)
2240 139 0 if $seg
2244 1 139 unless ($verified_exclusive)
2265 13 994 unless $knot->attributes("enforced_read_locking")
2266 3 991 unless $knot->attributes("violated_read_lock_warn")
2273 0 991 unless defined $writers
2275 4 987 if ($writers > 0)
2290 30 1002 unless $knot->attributes("enforced_write_locking")
2295 59 943 if $knot->{'_lock'} & 2
2310 1 942 unless defined $writers
2312 12 930 if ($writers > 0)
2313 11 1 if ($knot->attributes("violated_write_lock_warn"))
2330 0 930 unless defined $readers
2332 3 927 if ($readers > 0)
2333 3 0 if ($knot->attributes("violated_write_lock_warn"))
2365 0 140 unless my $stat = $sem->stat
2367 0 140 if $stat->nsems < 5
2376 587 2 defined $opts ? :
2385 4188 5236 if (not defined $opts->{$k}) { }
2 5234 elsif ($opts->{$k} eq 'no') { }
2389 1 1 if ($^W)
2403 4 585 if ($serializer ne "json" and $serializer ne "storable")
2413 339 246 if ($_testing_dist and not $testing_explicit)
2422 0 181 if $s->attributes("protected")
2423 17 164 unless $s->attributes("destroy")
2424 49 115 if $s->attributes("owner") != $$