Branch Coverage

blib/lib/IPC/Shareable.pm
Criterion Covered Total %
branch 502 620 80.9


line true false branch
176 7 719 unless _write_permitted($knot)
178 686 33 unless $knot->{'_lock'}
180 457 262 if ($knot->{'_type_int'} == 0) { }
174 88 elsif ($knot->{'_type_int'} == 1) { }
88 0 elsif ($knot->{'_type_int'} == 2) { }
183 93 364 if ref $val and $knot->_need_tie($val, $key)
188 36 138 if ref $val and $knot->_need_tie($val, $i)
193 14 74 if ref $val and $knot->_need_tie($val)
197 33 685 if ($knot->{'_lock'} & 2) { }
201 1 682 unless (defined $knot->_encode($knot->seg, $knot->{'_data'}))
212 29 948 if ($knot->{'_lock'}) { }
223 634 341 if ($knot->{'_type_int'} == 0) { }
182 159 elsif ($knot->{'_type_int'} == 1) { }
159 0 elsif ($knot->{'_type_int'} == 2) { }
232 150 9 if (defined $data) { }
240 503 463 if (ref $val and my $inner = _is_child($val))
244 13 490 unless (exists $global_register{$inner->seg->id})
257 1 168 unless _write_permitted($knot)
259 167 1 unless $knot->{'_lock'}
261 110 58 if ($knot->{'_type_int'} == 0) { }
58 0 elsif ($knot->{'_type_int'} == 1) { }
264 2 25 if (ref $val and my $child = _is_child($val))
273 0 20 if (ref $val and my $child = _is_child($val))
280 1 167 if ($knot->{'_lock'} & 2) { }
284 1 166 if (not defined $knot->_encode($knot->seg, $knot->{'_data'}))
293 1 6 unless _write_permitted($knot)
295 5 1 unless $knot->{'_lock'}
300 2 4 if (ref $val and my $child = _is_child($val))
304 1 5 if ($knot->{'_lock'} & 2) { }
308 1 4 unless (defined $knot->_encode($knot->seg, $knot->{'_data'}))
319 30 2 unless $knot->{'_lock'}
325 28 1 unless $knot->{'_lock'}
347 1 14 unless _write_permitted($knot)
349 3 11 unless $knot->{'_lock'}
352 11 3 if ($knot->{'_lock'} & 2) { }
356 1 2 if (not defined $knot->_encode($knot->seg, $knot->{'_data'}))
364 1 4 unless _write_permitted($knot)
366 3 1 unless $knot->{'_lock'}
369 1 3 if ($knot->{'_lock'} & 2) { }
373 1 2 unless (defined $knot->_encode($knot->seg, $knot->{'_data'}))
382 1 14 unless _write_permitted($knot)
384 3 11 unless $knot->{'_lock'}
386 11 3 if ($knot->{'_lock'} & 2) { }
390 1 2 unless (defined $knot->_encode($knot->seg, $knot->{'_data'}))
399 1 4 unless _write_permitted($knot)
401 3 1 unless $knot->{'_lock'}
403 1 3 if ($knot->{'_lock'} & 2) { }
407 1 2 unless (defined $knot->_encode($knot->seg, $knot->{'_data'}))
416 1 4 unless _write_permitted($knot)
418 3 1 unless $knot->{'_lock'}
420 1 3 if ($knot->{'_lock'} & 2) { }
424 1 2 unless (defined $knot->_encode($knot->seg, $knot->{'_data'}))
433 59 1 unless $knot->{'_lock'}
440 1 4 unless _write_permitted($knot)
442 3 1 unless $knot->{'_lock'}
444 1 3 if ($knot->{'_lock'} & 2) { }
448 1 2 unless (defined $knot->_encode($knot->seg, $knot->{'_data'}))
467 3 4 if ($type eq "HASH")
471 2 2 if ($type eq "ARRAY")
475 2 0 if ($type eq "SCALAR")
485 5 132 if (scalar @_ == 2)
489 89 48 if (defined $_[0])
490 1 88 if (ref $_[0] eq 'CODE') { }
498 1 136 if (defined $code and ref $code ne "CODE")
502 49 87 unless defined $flags
504 0 136 if $flags & 8
506 0 136 if $knot->{'_lock'} & $flags
510 0 136 if $knot->{'_lock'}
515 125 11 if ($lock_success)
521 2 123 if (not $locked_ref) { }
523 2 0 if $rflags & 4
533 90 46 if ($flags == 2 and $lock_success)
534 4 86 if ($code)
538 2 2 unless $ok
547 140 124 unless $knot->{'_lock'}
549 54 70 if ($knot->{'_was_changed'})
550 1 53 unless (defined $knot->_encode($knot->seg, $knot->{'_data'}))
557 3 22 if ($child->{'_was_changed'})
562 2 23 if $child_flags & 4
571 6 117 if $flags & 4
573 1 122 unless ($sem->op(@{$semop_args{$flags};}))
587 3 5 if (not defined $_[0] or $_[0] ne __PACKAGE__)
593 2 6 unless (defined $glue)
597 4 2 unless defined $warn
616 11733 215 if (defined $attr) { }
632 504 27 unless (defined $knot->{'_uuid'})
641 5884 0 if defined $knot->{'_shm'}
645 2490 0 if defined $knot->{'_sem'}
649 19 0 if ref $_[0] or defined $_[0] and not ref $_[0] and UNIVERSAL::isa($_[0], __PACKAGE__)
653 2 24 if defined $filter_key
657 0 26 unless open my $ipcs_fh, "-|", "ipcs", "-m"
662 0 229 if ($line =~ /^\s*m\s+(\d+)\s+(\S+)/) { }
125 104 elsif ($line =~ /^\s*(\S+)\s+(\d+)\s+\S+/) { }
673 0 0 $raw_key =~ /^\d+$/ ? :
125 0 $raw_key =~ /^0x[0-9a-fA-F]+$/ ? :
681 0 125 if $key_int == 0
685 0 125 unless shmctl $id, IPC_STAT(), $stat_buf
694 125 0 $IPC::Shareable::Config{'longsize'} == 8 ? :
0 0 $IPC::Shareable::Config{'longsize'} == 8 ? :
0 0 $^O eq 'solaris' ? :
0 0 $^O eq 'freebsd' && $IPC::Shareable::Config{'longsize'} == 8 ? :
125 0 $^O eq 'linux' ? :
699 0 125 unless $segsz
702 0 125 unless shmread $id, $data, 0, $segsz
709 1 124 unless substr($data, 0, 14) eq "IPC::Shareable"
719 92 32 exists $process_register{$id} ? :
92 32 exists $global_register{$id} ? :
724 2 24 if (defined $filter_int)
734 0 2 if $related{$k_hex}++
743 1 1 if ref $_[0]
752 0 134 unless open my $ipcs_fh, "-|", "ipcs", "-m"
756 0 688 if $line =~ /^\s*m\s+\d+\s+\S+/
757 152 536 if $line =~ /^\s*(?:0x[0-9a-fA-F]+|\d+)\s+\d+\s+\S+/
766 0 125 unless open my $ipcs_fh, "-|", "ipcs", "-s"
770 0 623 if $line =~ /^\s*s\s+\d+\s+\S+/
771 123 500 if $line =~ /^\s*(?:0x[0-9a-fA-F]+|\d+)\s+\d+\s+\S+/
778 1 5 unless ref $_[0]
793 8 0 if defined $hex
805 0 5 $rtype eq 'ARRAY' ? :
3 5 $rtype eq 'HASH' ? :
810 2 1 unless ref $v
813 1 0 if ($vtype eq 'HASH') { }
0 0 elsif ($vtype eq 'ARRAY') { }
0 0 elsif ($vtype eq 'SCALAR') { }
816 0 1 unless $child_knot and $child_knot->{'_key_hex'}
823 5 0 if ($knot_filter and $knot_filter->{'_key_hex'})
828 0 6 if $in_tree{$h}++
841 0 1 unless exists $segs->{$hex}
850 0 5 unless (@roots)
863 6 0 $seg->{'known'} ? :
864 6 0 if $seg->{'local_process'}
873 6 0 $knot_by_hex{$hex} ? :
876 6 0 if (defined $sem) { }
897 6 0 $knot_by_hex{$hex} ? :
906 1 5 @child_keys ? :
930 0 6 if ($^O eq 'darwin') { }
1 5 elsif ($^O eq 'freebsd') { }
5 0 elsif ($^O eq 'linux') { }
931 0 0 defined $sysctl_out ? :
932 0 0 unless open my $fh, "-|", "sysctl", "kern.sysv"
939 0 0 if ($line =~ /^kern\.sysv\.(\w+):\s*(\S+)/)
945 1 0 defined $sysctl_out ? :
946 0 0 unless open my $fh, "-|", "sysctl", "kern.ipc"
953 5 1 if ($line =~ /^kern\.ipc\.(shm\w+):\s*(\S+)/)
961 16 4 if (open my $fh, "<", $file)
968 6 0 %info ? :
976 0 8 unless $s->attributes("owner") == $$
977 0 8 if $s->attributes("protected")
988 3 216 if $s->attributes("protected")
995 5 4 if (scalar @_ == 2)
998 3 6 if (scalar @_ == 1)
1002 1 8 unless (defined $protect_key)
1006 1 7 unless ($protect_key =~ /^\d+$/)
1017 8 0 if ($stored_key and $stored_key == $protect_key)
1028 5 333 if (defined $key)
1032 1 4 unless (defined $id)
1037 0 4 if (not shmctl($id, IPC_RMID(), 0)) { }
1048 0 4 if (defined $sem)
1049 0 0 unless $sem->remove
1062 0 333 if (not $seg->remove) { }
1076 1 332 if ($sem_remove_status != 1 and $sem_remove_status ne '0 but true') { }
1086 332 1 if ($seg_removed and $sem_removed)
1101 508 414 if ($serializer eq "storable")
1112 1335 1477 $serializer eq 'storable' ? :
1116 2316 491 if defined $data
1120 83 408 if $knot->{'_type_int'} == 1
1121 308 100 if $knot->{'_type_int'} == 0
1132 1 413 if (length $json > $seg->size)
1141 0 415 unless my $type = builtin::reftype($data)
1148 272 143 if ($type eq "HASH")
1152 51 1141 if (ref $val and _is_child($val))
1154 221 51 unless $has_child
1162 55 63 $inner ? :
1168 128 15 if ($type eq "ARRAY")
1172 20 298 if (ref $val and _is_child($val))
1174 108 20 unless $has_child
1181 37 3 if ($inner) { }
1187 14 1 if ($type eq "SCALAR" or $type eq "REF")
1191 6 8 $inner ? :
1202 276 1202 unless $json
1212 1201 1 if ($tag eq 'IPC::Shareable') { }
1215 1 1197 unless (defined $data)
1219 375 822 if defined $knot and index($json, "\"__ics__\"") != -1
1222 84 1113 if (defined $knot and $knot->{'_type_int'} == 2 and ref $data eq "HASH")
1223 44 40 if (exists $data->{'__ics__'})
1225 43 1 defined $prev && ref $prev ? :
1229 23 17 if (exists $data->{'__sv__'})
1243 0 375 unless my $type = builtin::reftype($data)
1251 284 91 if ($type eq 'HASH') { }
91 0 elsif ($type eq 'ARRAY') { }
1254 248 365 unless ref $data->{$key} eq "HASH" and exists $data->{$key}{'__ics__'}
1257 339 26 $prev_is_hash ? :
1264 77 14 $prev_is_array ? :
1266 21 171 unless ref $data->[$i] eq "HASH" and exists $data->[$i]{'__ics__'}
1268 151 20 $prev_is_array && $i <= $prev_max ? :
1278 520 60 if (defined $existing)
1280 510 10 if $inner and $inner->{'_key'} == $info->{'child_key'}
1296 31 39 if ($info->{'type'} eq 'HASH') { }
38 1 elsif ($info->{'type'} eq 'ARRAY') { }
1 0 elsif ($info->{'type'} eq 'SCALAR') { }
1319 1 507 if (length $ice > $seg->size)
1330 7 1602 unless $ice
1334 1136 466 if ($tag eq 'IPC::Shareable') { }
1336 1 1135 unless (defined $water)
1350 177 327 if (scalar @_ == 4) { }
1369 2 502 if ($knot->attributes("limit") and $shm_size > 1073741824)
1377 8 494 if ($knot->attributes('graceful')) { }
1389 4 4 unless (defined $exclusive)
1390 1 3 if ($knot->attributes("warn"))
1408 7 489 unless (defined $seg)
1409 2 5 if ($!{'ENOMEM'})
1414 0 5 if ($!{'ENOSPC'})
1419 3 2 if (not $knot->attributes('create')) { }
1 1 elsif ($knot->attributes('create') and $knot->attributes('exclusive')) { }
1442 1 488 unless (defined $sem)
1446 1 487 unless ($sem->op(@{$semop_args{1};}))
1450 99 125 $type eq 'ARRAY' ? :
263 224 $type eq 'HASH' ? :
1465 216 271 if ($serializer eq 'json') { }
1469 3 213 if (not $decoded_ok) { }
1476 3 0 if ($thaw_ok and defined $storable_data) { }
1503 394 93 unless (exists $global_register{$knot->seg->id})
1507 371 116 if ($sem->getval(0) != 1) { }
1513 1 370 unless ($sem->setval(0, 1))
1522 3 113 if defined $stored_protected and $stored_protected != 0
1535 49 95 if ($parent->{'_key'} == IPC_PRIVATE() and $parent->attributes('serializer') ne 'json') { }
1559 102 41 if ($type eq 'HASH') { }
38 3 elsif ($type eq 'ARRAY') { }
2 1 elsif ($type eq 'SCALAR') { }
1562 0 102 unless $child
1564 91 11 if $opts{'tidy'}
1571 0 38 unless $child
1573 32 6 if $opts{'tidy'}
1580 0 2 unless $child
1591 1231 14 $_have_xs ? :
1597 1 13 unless my $data = shift()
1600 2 11 unless $type
1604 6 5 if ($type eq 'HASH') { }
2 3 elsif ($type eq 'ARRAY') { }
2 1 elsif ($type eq 'SCALAR') { }
1614 7 4 if (ref $obj eq "IPC::Shareable")
1624 0 144 unless $type
1628 103 41 if ($type eq 'HASH') { }
38 3 elsif ($type eq 'ARRAY') { }
3 0 elsif ($type eq 'SCALAR') { }
1638 143 1 $need_tie ? :
1649 2 3 if $key_str =~ /^0x[0-9a-fA-F]+$/i
1650 1 2 if $key_str =~ /^\d+$/
1653 1 1 if $int > 2147483648
1670 24 29 $rtype eq 'ARRAY' ? :
124 53 $rtype eq 'HASH' ? :
1677 243 29 unless ref $val
1679 0 29 unless $child and $child->seg
1682 0 29 if $seen{$id}++
1684 2 27 unless ($child->sem->op(@{$semop_args{$flags};}))
1687 2 0 if $rflags & 4
1703 148 27 unless $found
1713 81 42 if ($parent_type eq 'HASH') { }
30 12 elsif ($parent_type eq 'ARRAY') { }
1715 9 72 if (exists $data->{$id})
1717 7 2 if ($child_type eq 'HASH' and tied %{$$data{$id};}) { }
0 4 elsif ($child_type eq 'ARRAY' and tied @{$$data{$id};}) { }
1727 3 27 if (exists $data->[$id])
1729 0 3 if ($child_type eq 'HASH' and tied %{$$data[$id];}) { }
3 0 elsif ($child_type eq 'ARRAY' and tied @{$$data[$id];}) { }
1744 3 3 if ($rtype eq "SCALAR")
1746 3 0 defined $v ? :
1749 3 0 if ($rtype eq "HASH")
1753 1 2 if (ref $v) { }
1755 0 0 $vt eq 'SCALAR' ? :
0 0 $vt eq 'ARRAY' ? :
1 0 $vt eq 'HASH' ? :
1760 1 0 $child && $child->{'_key_hex'} ? :
1764 2 0 defined $v ? :
1767 3 0 @parts ? :
1770 0 0 if ($rtype eq "ARRAY")
1773 0 0 if (ref $v) { }
1775 0 0 $vt eq 'SCALAR' ? :
0 0 $vt eq 'ARRAY' ? :
0 0 $vt eq 'HASH' ? :
1780 0 0 $child && $child->{'_key_hex'} ? :
1784 0 0 defined $v ? :
1800 373 131 if $knot->attributes("create")
1801 166 338 if $knot->attributes("exclusive")
1815 101 420 if ($key_str eq '') { }
20 400 elsif ($key_str =~ /^0x[0-9a-fA-F]+$/i) { }
183 217 elsif ($key_str =~ /^\d+$/) { }
1839 129 189 if ($key > 2147483648)
1842 0 129 if ($key == 0)
1865 10 94 if $used_ids{$key}
1882 94 0 if ($shm_slot_available)
1884 94 0 if $seg
1888 1 94 unless ($verified_exclusive)
1909 12 936 unless $knot->attributes("enforced_read_locking")
1910 3 933 unless $knot->attributes("violated_read_lock_warn")
1917 0 933 unless defined $writers
1919 4 929 if ($writers > 0)
1933 28 924 unless $knot->attributes("enforced_write_locking")
1938 58 866 if $knot->{'_lock'} & 2
1947 12 854 if ($sem->getval(2) > 0)
1948 11 1 if ($knot->attributes("violated_write_lock_warn"))
1963 3 851 if ($sem->getval(1) > 0)
1964 3 0 if ($knot->attributes("violated_write_lock_warn"))
1983 502 2 defined $opts ? :
1986 3416 4648 if (not defined $opts->{$k}) { }
2 4646 elsif ($opts->{$k} eq 'no') { }
1990 1 1 if ($^W)
2005 0 140 if $s->attributes("protected")
2006 16 124 unless $s->attributes("destroy")
2007 43 81 if $s->attributes("owner") != $$