Branch Coverage

blib/lib/IPC/Shareable.pm
Criterion Covered Total %
branch 565 718 78.6


line true false branch
181 7 785 unless _write_permitted($knot)
183 751 34 unless $knot->{'_lock'}
185 479 306 if ($knot->{'_type_int'} == 0) { }
187 119 elsif ($knot->{'_type_int'} == 1) { }
119 0 elsif ($knot->{'_type_int'} == 2) { }
188 98 381 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 750 if ($knot->{'_lock'} & 2) { }
221 31 1011 if ($knot->{'_lock'}) { }
232 658 382 if ($knot->{'_type_int'} == 0) { }
186 196 elsif ($knot->{'_type_int'} == 1) { }
196 0 elsif ($knot->{'_type_int'} == 2) { }
241 187 9 if (defined $data) { }
249 522 509 if (ref $val and my $inner = _is_child($val))
253 13 509 unless (exists $global_register{$inner->seg->id})
257 518 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 183 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 14541 236 if (defined $attr) { }
665 587 27 unless (defined $knot->{'_uuid'})
674 7370 0 if defined $knot->{'_shm'}
678 2695 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 50 unless open my $ipcs_fh, "-|", "ipcs", "-s"
830 0 248 if ($line =~ /^\s*s\s+\d+\s+\S+/) { }
0 248 elsif ($line =~ /^\s*\d+\s+0x[0-9a-fA-F]+\s+/) { }
48 200 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 59 if ($^O eq 'darwin') { }
1 58 elsif ($^O eq 'freebsd' or $^O eq 'midnightbsd' or $^O eq 'netbsd') { }
1 57 elsif ($^O eq 'openbsd') { }
56 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+)/)
1055 1 0 defined $sysctl_out ? :
1056 0 0 unless open my $fh, "-|", "sysctl", "kern.ipc"
1063 9 1 if ($line =~ /^kern\.ipc\.((?:shm|sem)\w+)\s*[:=]\s*(\S+)/)
1069 1 0 defined $sysctl_out ? :
1070 0 0 unless open my $fh, "-|", "sysctl", "kern.seminfo", "kern.shminfo"
1078 7 0 if ($line =~ /^kern\.(?:sem|shm)info\.(\w+)\s*=\s*(\S+)/)
1086 169 55 if (open my $fh, "<", $file)
1093 56 0 if (open my $fh, "<", "$proc_dir/sem")
1097 56 0 if (@vals >= 4)
1103 58 1 %info ? :
1113 0 8 unless $s->attributes("owner") == $$
1114 0 8 if $s->attributes("protected")
1125 3 220 if $s->attributes("protected")
1132 5 4 if (scalar @_ == 2)
1135 3 6 if (scalar @_ == 1)
1139 1 8 unless (defined $protect_key)
1143 1 7 unless ($protect_key =~ /^\d+$/)
1154 8 0 if ($stored_key and $stored_key == $protect_key)
1165 10 385 if (defined $key)
1169 1 9 unless (defined $id)
1174 0 9 if (not shmctl($id, IPC_RMID(), 0)) { }
1185 1 8 if (defined $sem)
1186 0 1 unless $sem->remove
1199 0 385 if (not $seg->remove) { }
1213 1 384 if ($sem_remove_status != 1 and $sem_remove_status ne '0 but true') { }
1223 384 1 if ($seg_removed and $sem_removed)
1234 2 85 unless defined $dist_name and length $dist_name
1240 6 0 if @_ > 1 and not ref $_[0] and defined $_[0] and UNIVERSAL::isa($_[0], __PACKAGE__)
1244 0 11 unless defined $dist_name and length $dist_name
1257 0 11 unless open my $ipcs_fh, "-|", "ipcs", "-m"
1262 0 61 if ($line =~ /^\s*m\s+(\d+)\s+(\S+)/) { }
0 61 elsif ($line =~ /^\s*(\d+)\s+(0x[0-9a-fA-F]+)\s+/) { }
17 44 elsif ($line =~ /^\s*(\S+)\s+(\d+)\s+\S+/) { }
1278 0 0 $raw_key =~ /^-?\d+$/ ? :
17 0 $raw_key =~ /^0x[0-9a-fA-F]+$/ ? :
1285 0 17 if $key_int == 0
1288 0 17 unless defined $sem
1290 11 6 unless _testing_semaphore_value($sem) == $target
1301 6 0 defined $stat ? :
1303 0 6 if defined $cpid and $cpid > 0 and $cpid != $$ and kill 0, $cpid
1305 6 0 if (shmctl $id, IPC_RMID(), 0) { }
1327 0 11 unless open $ipcs_fh, "-|", "ipcs", "-s"
1332 0 59 if ($line =~ /^\s*s\s+\d+\s+(\S+)/) { }
0 59 elsif ($line =~ /^\s*\d+\s+(0x[0-9a-fA-F]+)\s+/) { }
15 44 elsif ($line =~ /^\s*(\S+)\s+\d+\s+\S+/) { }
1348 0 0 $raw_key =~ /^-?\d+$/ ? :
15 0 $raw_key =~ /^0x[0-9a-fA-F]+$/ ? :
1354 0 15 if $key_int == 0
1358 11 4 if defined shmget($key_int, 0, 0)
1361 0 4 unless defined $sem
1363 2 2 unless _testing_semaphore_value($sem) == $target
1365 2 0 if $sem->remove
1384 98 897 if ($knot->{'_type_int'} == 2 and ref $data eq "SCALAR")
1387 96 2 if (defined $val and not ref $val)
1394 384 515 if ($serializer eq "storable")
1407 583 2691 if ($knot->{'_type_int'} == 2)
1409 107 476 if defined $verbatim
1414 1444 1723 $serializer eq 'storable' ? :
1418 2294 867 if defined $data
1423 128 739 if $knot->{'_type_int'} == 1
1424 495 244 if $knot->{'_type_int'} == 0
1436 0 515 if (length $json > $seg->size)
1445 0 516 unless my $type = builtin::reftype($data)
1453 339 177 if ($type eq "HASH")
1457 76 1171 if (ref $val and _is_child($val))
1462 263 76 unless $has_child
1472 80 80 $inner ? :
1479 166 11 if ($type eq "ARRAY")
1483 27 339 if (ref $val and _is_child($val))
1488 139 27 unless $has_child
1495 44 9 if ($inner) { }
1501 10 1 if ($type eq "SCALAR" or $type eq "REF")
1506 9 1 $inner ? :
1517 400 1324 unless $json
1527 1323 1 if ($tag eq 'IPC::Shareable') { }
1530 1 1318 unless (defined $data)
1534 436 882 if (defined $knot and index($json, "\"__ics__\"") != -1)
1541 74 1244 if (defined $knot and $knot->{'_type_int'} == 2 and ref $data eq "HASH")
1542 50 24 if (exists $data->{'__ics__'})
1544 49 1 defined $prev && ref $prev ? :
1548 2 22 if (exists $data->{'__sv__'})
1563 0 436 unless my $type = builtin::reftype($data)
1571 329 107 if ($type eq 'HASH') { }
107 0 elsif ($type eq 'ARRAY') { }
1575 291 404 unless ref $data->{$key} eq "HASH" and exists $data->{$key}{'__ics__'}
1579 373 31 $prev_is_hash ? :
1586 92 15 $prev_is_array ? :
1589 44 187 unless ref $data->[$i] eq "HASH" and exists $data->[$i]{'__ics__'}
1592 165 22 $prev_is_array && $i <= $prev_max ? :
1602 572 69 if (defined $existing)
1604 561 11 if $inner and $inner->{'_key'} == $info->{'child_key'}
1620 34 46 if ($info->{'type'} eq 'HASH') { }
45 1 elsif ($info->{'type'} eq 'ARRAY') { }
1 0 elsif ($info->{'type'} eq 'SCALAR') { }
1648 3 93 if (length $raw > $seg->size)
1665 7 576 unless defined $raw
1669 469 107 if substr($raw, 0, 15) ne "IPC::Shareable\36"
1680 0 384 unless defined $ice
1685 0 384 if (length $ice > $seg->size)
1696 7 1441 unless $ice
1700 981 460 if ($tag eq 'IPC::Shareable') { }
1702 1 980 unless (defined $water)
1717 190 401 if (scalar @_ == 4) { }
1736 2 585 if ($knot->attributes("limit") and $shm_size > 1073741824)
1744 8 577 if ($knot->attributes('graceful')) { }
1757 4 4 unless (defined $exclusive)
1758 1 3 if ($knot->attributes("warn"))
1776 7 572 unless (defined $seg)
1777 2 5 if ($!{'ENOMEM'})
1782 0 5 if ($!{'ENOSPC'})
1787 3 2 if (not $knot->attributes('create')) { }
1 1 elsif ($knot->attributes('create') and $knot->attributes('exclusive')) { }
1808 564 8 $knot->attributes('testing') ? :
1813 5 567 unless (defined $sem)
1828 4 1 if $knot->attributes("create") or $key == IPC_PRIVATE()
1834 2 565 unless ($sem->op(@{$semop_args{1};}))
1844 2 0 if $sem->getval(0) != 1
1845 2 0 if $knot->attributes("create") or $key == IPC_PRIVATE()
1851 112 148 $type eq 'ARRAY' ? :
305 260 $type eq 'HASH' ? :
1866 295 270 if ($serializer eq 'json') { }
1870 4 291 if (not $decoded_ok) { }
1878 4 0 if ($thaw_ok and defined $storable_data) { }
1905 459 106 unless (exists $global_register{$knot->seg->id})
1909 436 129 if ($sem->getval(0) != 1) { }
1915 429 7 if ($knot->attributes("testing"))
1919 1 435 unless ($sem->setval(0, 1))
1931 3 126 if (defined $stored_protected and $stored_protected != 0)
1937 129 0 if ($stored_testing)
1951 15 140 if ($parent->{'_key'} == IPC_PRIVATE() and $parent->attributes('serializer') ne 'json') { }
1975 109 45 if ($type eq 'HASH') { }
42 3 elsif ($type eq 'ARRAY') { }
2 1 elsif ($type eq 'SCALAR') { }
1978 0 109 unless $child
1985 0 42 unless $child
1992 0 2 unless $child
2006 0 156 unless $type
2010 110 46 if ($type eq 'HASH') { }
42 4 elsif ($type eq 'ARRAY') { }
4 0 elsif ($type eq 'SCALAR') { }
2020 154 2 $need_tie ? :
2025 28 718 if (ref $val and my $child = _is_child($val))
2030 1395 14 $_have_xs ? :
2035 1 13 unless my $data = shift()
2038 2 11 unless $type
2042 6 5 if ($type eq 'HASH') { }
2 3 elsif ($type eq 'ARRAY') { }
2 1 elsif ($type eq 'SCALAR') { }
2052 7 4 if (ref $obj eq "IPC::Shareable")
2063 10 992 if (not defined $knot->_encode($knot->seg, $knot->{'_data'}))
2078 2 4 if not $ok
2087 0 99 if $key_str =~ /^0x[0-9a-fA-F]+$/i
2088 9 90 if $key_str =~ /^\d+$/
2091 41 49 if $int > 2147483648
2109 15 32 $rtype eq 'ARRAY' ? :
135 47 $rtype eq 'HASH' ? :
2118 199 32 unless ref $val
2121 0 32 unless $child and $child->seg
2124 0 32 if $seen{$id}++
2126 2 30 unless ($child->sem->op(@{$semop_args{$flags};}))
2129 2 0 if $rflags & 4
2150 150 30 unless $found
2161 3 3 if ($rtype eq "SCALAR")
2163 3 0 defined $v ? :
2166 3 0 if ($rtype eq "HASH")
2170 1 2 if (ref $v) { }
2172 0 0 $vt eq 'SCALAR' ? :
0 0 $vt eq 'ARRAY' ? :
1 0 $vt eq 'HASH' ? :
2177 1 0 $child && $child->{'_key_hex'} ? :
2181 2 0 defined $v ? :
2184 3 0 @parts ? :
2187 0 0 if ($rtype eq "ARRAY")
2190 0 0 if (ref $v) { }
2192 0 0 $vt eq 'SCALAR' ? :
0 0 $vt eq 'ARRAY' ? :
0 0 $vt eq 'HASH' ? :
2197 0 0 $child && $child->{'_key_hex'} ? :
2201 0 0 defined $v ? :
2217 442 145 if $knot->attributes("create")
2218 178 409 if $knot->attributes("exclusive")
2232 65 546 if ($key_str eq '') { }
13 533 elsif ($key_str =~ /^0x[0-9a-fA-F]+$/i) { }
232 301 elsif ($key_str =~ /^\d+$/) { }
2257 150 216 if ($key >= 2147483648)
2260 1 149 if ($key == 0)
2283 10 139 if $used_ids{$key}
2301 139 0 if ($shm_slot_available)
2303 139 0 if $seg
2307 1 139 unless ($verified_exclusive)
2328 13 998 unless $knot->attributes("enforced_read_locking")
2329 3 995 unless $knot->attributes("violated_read_lock_warn")
2336 0 995 unless defined $writers
2338 4 991 if ($writers > 0)
2353 30 1005 unless $knot->attributes("enforced_write_locking")
2358 59 946 if $knot->{'_lock'} & 2
2373 1 945 unless defined $writers
2375 12 933 if ($writers > 0)
2376 11 1 if ($knot->attributes("violated_write_lock_warn"))
2393 0 933 unless defined $readers
2395 3 930 if ($readers > 0)
2396 3 0 if ($knot->attributes("violated_write_lock_warn"))
2428 0 150 unless my $stat = $sem->stat
2430 2 148 if $stat->nsems < 5
2439 588 3 defined $opts ? :
2448 4202 5254 if (not defined $opts->{$k}) { }
2 5252 elsif ($opts->{$k} eq 'no') { }
2452 1 1 if ($^W)
2466 4 587 if ($serializer ne "json" and $serializer ne "storable")
2476 340 247 if ($_testing_dist and not $testing_explicit)
2485 0 182 if $s->attributes("protected")
2486 18 164 unless $s->attributes("destroy")
2487 49 115 if $s->attributes("owner") != $$