Branch Coverage

blib/lib/IPC/Shareable.pm
Criterion Covered Total %
branch 487 602 80.9


line true false branch
166 7 714 unless _write_permitted($knot)
168 682 32 unless $knot->{'_lock'}
170 452 262 if ($knot->{'_type_int'} == 0) { }
174 88 elsif ($knot->{'_type_int'} == 1) { }
88 0 elsif ($knot->{'_type_int'} == 2) { }
173 92 360 if ref $val and $knot->_need_tie($val, $key)
178 36 138 if ref $val and $knot->_need_tie($val, $i)
183 14 74 if ref $val and $knot->_need_tie($val)
187 32 681 if ($knot->{'_lock'} & 2) { }
191 1 678 unless (defined $knot->_encode($knot->seg, $knot->{'_data'}))
202 28 943 if ($knot->{'_lock'}) { }
213 628 341 if ($knot->{'_type_int'} == 0) { }
182 159 elsif ($knot->{'_type_int'} == 1) { }
159 0 elsif ($knot->{'_type_int'} == 2) { }
222 150 9 if (defined $data) { }
230 501 459 if (ref $val and my $inner = _is_child($val))
234 13 488 unless (exists $global_register{$inner->seg->id})
247 1 167 unless _write_permitted($knot)
249 166 1 unless $knot->{'_lock'}
251 109 58 if ($knot->{'_type_int'} == 0) { }
58 0 elsif ($knot->{'_type_int'} == 1) { }
254 2 25 if (ref $val and my $child = _is_child($val))
263 0 20 if (ref $val and my $child = _is_child($val))
270 1 166 if ($knot->{'_lock'} & 2) { }
274 1 165 if (not defined $knot->_encode($knot->seg, $knot->{'_data'}))
283 1 6 unless _write_permitted($knot)
285 5 1 unless $knot->{'_lock'}
290 2 4 if (ref $val and my $child = _is_child($val))
294 1 5 if ($knot->{'_lock'} & 2) { }
298 1 4 unless (defined $knot->_encode($knot->seg, $knot->{'_data'}))
309 28 2 unless $knot->{'_lock'}
315 27 1 unless $knot->{'_lock'}
337 1 14 unless _write_permitted($knot)
339 3 11 unless $knot->{'_lock'}
342 11 3 if ($knot->{'_lock'} & 2) { }
346 1 2 if (not defined $knot->_encode($knot->seg, $knot->{'_data'}))
354 1 4 unless _write_permitted($knot)
356 3 1 unless $knot->{'_lock'}
359 1 3 if ($knot->{'_lock'} & 2) { }
363 1 2 unless (defined $knot->_encode($knot->seg, $knot->{'_data'}))
372 1 14 unless _write_permitted($knot)
374 3 11 unless $knot->{'_lock'}
376 11 3 if ($knot->{'_lock'} & 2) { }
380 1 2 unless (defined $knot->_encode($knot->seg, $knot->{'_data'}))
389 1 4 unless _write_permitted($knot)
391 3 1 unless $knot->{'_lock'}
393 1 3 if ($knot->{'_lock'} & 2) { }
397 1 2 unless (defined $knot->_encode($knot->seg, $knot->{'_data'}))
406 1 4 unless _write_permitted($knot)
408 3 1 unless $knot->{'_lock'}
410 1 3 if ($knot->{'_lock'} & 2) { }
414 1 2 unless (defined $knot->_encode($knot->seg, $knot->{'_data'}))
423 59 1 unless $knot->{'_lock'}
430 1 4 unless _write_permitted($knot)
432 3 1 unless $knot->{'_lock'}
434 1 3 if ($knot->{'_lock'} & 2) { }
438 1 2 unless (defined $knot->_encode($knot->seg, $knot->{'_data'}))
457 3 4 if ($type eq "HASH")
461 2 2 if ($type eq "ARRAY")
465 2 0 if ($type eq "SCALAR")
475 5 131 if (scalar @_ == 2)
479 89 47 if (defined $_[0])
480 1 88 if (ref $_[0] eq 'CODE') { }
488 1 135 if (defined $code and ref $code ne "CODE")
492 48 87 unless defined $flags
494 0 135 if $flags & 8
496 0 135 if $knot->{'_lock'} & $flags
500 0 135 if $knot->{'_lock'}
505 124 11 if ($lock_success)
512 2 122 if (not _lock_children($knot, $flags, \@locked_children, \%seen)) { }
514 2 0 if $rflags & 4
524 89 46 if ($flags == 2 and $lock_success)
525 4 85 if ($code)
529 2 2 unless $ok
538 140 123 unless $knot->{'_lock'}
540 53 70 if ($knot->{'_was_changed'})
541 1 52 unless (defined $knot->_encode($knot->seg, $knot->{'_data'}))
548 3 21 if ($child->{'_was_changed'})
553 2 22 if $child_flags & 4
562 6 116 if $flags & 4
564 1 121 unless ($sem->op(@{$semop_args{$flags};}))
578 3 5 if (not defined $_[0] or $_[0] ne __PACKAGE__)
584 2 6 unless (defined $glue)
588 4 2 unless defined $warn
607 11638 214 if (defined $attr) { }
623 499 27 unless (defined $knot->{'_uuid'})
632 5836 0 if defined $knot->{'_shm'}
636 2471 0 if defined $knot->{'_sem'}
640 19 0 if ref $_[0] or defined $_[0] and not ref $_[0] and UNIVERSAL::isa($_[0], __PACKAGE__)
644 2 24 if defined $filter_key
652 0 229 if ($line =~ /^\s*m\s+(\d+)\s+(\S+)/) { }
125 104 elsif ($line =~ /^\s*(\S+)\s+(\d+)\s+\S+/) { }
663 0 0 $raw_key =~ /^\d+$/ ? :
125 0 $raw_key =~ /^0x[0-9a-fA-F]+$/ ? :
671 0 125 if $key_int == 0
675 0 125 unless shmctl $id, IPC_STAT(), $stat_buf
684 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' ? :
689 0 125 unless $segsz
692 0 125 unless shmread $id, $data, 0, $segsz
699 1 124 unless substr($data, 0, 14) eq "IPC::Shareable"
708 92 32 exists $process_register{$id} ? :
92 32 exists $global_register{$id} ? :
712 2 24 if (defined $filter_int)
722 0 2 if $related{$k_hex}++
731 1 1 if ref $_[0]
743 0 678 if $line =~ /^\s*m\s+\d+\s+\S+/
744 150 528 if $line =~ /^\s*(?:0x[0-9a-fA-F]+|\d+)\s+\d+\s+\S+/
755 0 613 if $line =~ /^\s*s\s+\d+\s+\S+/
756 121 492 if $line =~ /^\s*(?:0x[0-9a-fA-F]+|\d+)\s+\d+\s+\S+/
762 1 5 unless ref $_[0]
771 0 33 if ($line =~ /^\s*m\s+(\d+)\s+(\S+)/) { }
13 20 elsif ($line =~ /^\s*(\S+)\s+(\d+)\s+\S+/) { }
775 0 0 $raw_key =~ /^\d+$/ ? :
13 0 $raw_key =~ /^0x[0-9a-fA-F]+$/ ? :
786 8 0 if defined $hex
798 0 5 $rtype eq 'ARRAY' ? :
3 5 $rtype eq 'HASH' ? :
803 2 1 unless ref $v
806 1 0 if ($vtype eq 'HASH') { }
0 0 elsif ($vtype eq 'ARRAY') { }
0 0 elsif ($vtype eq 'SCALAR') { }
809 0 1 unless $child_knot and $child_knot->{'_key_hex'}
816 5 0 if ($knot_filter and $knot_filter->{'_key_hex'})
821 0 6 if $in_tree{$h}++
834 0 1 unless exists $segs->{$hex}
843 0 5 unless (@roots)
856 6 0 $seg->{'known'} ? :
857 6 0 if $seg->{'local_process'}
866 6 0 $knot_by_hex{$hex} ? :
869 6 0 if (defined $sem) { }
890 6 0 $knot_by_hex{$hex} ? :
899 1 5 @child_keys ? :
923 0 6 if ($^O eq 'darwin') { }
1 5 elsif ($^O eq 'freebsd') { }
5 0 elsif ($^O eq 'linux') { }
926 0 0 if ($line =~ /^kern\.sysv\.(\w+):\s*(\S+)/)
934 5 1 if ($line =~ /^kern\.ipc\.(shm\w+):\s*(\S+)/)
942 16 4 if (open my $fh, "<", $file)
949 6 0 %info ? :
957 0 3 unless $s->attributes("owner") == $$
958 0 3 if $s->attributes("protected")
969 3 216 if $s->attributes("protected")
976 5 4 if (scalar @_ == 2)
979 3 6 if (scalar @_ == 1)
983 1 8 unless (defined $protect_key)
987 1 7 unless ($protect_key =~ /^\d+$/)
998 8 0 if ($stored_key and $stored_key == $protect_key)
1009 5 328 if (defined $key)
1013 1 4 unless (defined $id)
1018 0 4 if (not shmctl($id, IPC_RMID(), 0)) { }
1029 0 4 if (defined $sem)
1030 0 0 unless $sem->remove
1043 0 328 if (not $seg->remove) { }
1057 1 327 if ($sem_remove_status != 1 and $sem_remove_status ne '0 but true') { }
1067 327 1 if ($seg_removed and $sem_removed)
1082 502 414 if ($serializer eq "storable")
1093 1318 1477 $serializer eq 'storable' ? :
1097 2301 489 if defined $data
1101 83 406 if $knot->{'_type_int'} == 1
1102 306 100 if $knot->{'_type_int'} == 0
1113 1 413 if (length $json > $seg->size)
1122 0 415 unless my $type = builtin::reftype($data)
1129 272 143 if ($type eq "HASH")
1135 55 1165 $inner ? :
1141 128 15 if ($type eq "ARRAY")
1146 37 298 if ($inner) { }
1152 14 1 if ($type eq "SCALAR" or $type eq "REF")
1156 6 8 $inner ? :
1167 276 1202 unless $json
1177 1201 1 if ($tag eq 'IPC::Shareable') { }
1180 1 1197 unless (defined $data)
1184 375 822 if defined $knot and index($json, "\"__ics__\"") != -1
1187 84 1113 if (defined $knot and $knot->{'_type_int'} == 2 and ref $data eq "HASH")
1188 44 40 if (exists $data->{'__ics__'})
1190 43 1 defined $prev && ref $prev ? :
1194 23 17 if (exists $data->{'__sv__'})
1208 0 375 unless my $type = builtin::reftype($data)
1216 284 91 if ($type eq 'HASH') { }
91 0 elsif ($type eq 'ARRAY') { }
1218 248 365 unless ref $data->{$key} eq "HASH" and exists $data->{$key}{'__ics__'}
1221 339 26 ref $prev eq 'HASH' ? :
1228 21 171 unless ref $data->[$i] eq "HASH" and exists $data->[$i]{'__ics__'}
1230 151 20 ref $prev eq 'ARRAY' && $i <= $prev->$#* ? :
1240 520 60 if (defined $existing)
1242 510 10 if $inner and $inner->{'_key'} == $info->{'child_key'}
1258 31 39 if ($info->{'type'} eq 'HASH') { }
38 1 elsif ($info->{'type'} eq 'ARRAY') { }
1 0 elsif ($info->{'type'} eq 'SCALAR') { }
1281 1 501 if (length $ice > $seg->size)
1292 7 1580 unless $ice
1296 1121 459 if ($tag eq 'IPC::Shareable') { }
1298 1 1120 unless (defined $water)
1312 176 323 if (scalar @_ == 4) { }
1331 2 497 if ($knot->attributes("limit") and $shm_size > 1073741824)
1339 8 489 if ($knot->attributes('graceful')) { }
1351 4 4 unless (defined $exclusive)
1352 1 3 if ($knot->attributes("warn"))
1370 7 484 unless (defined $seg)
1371 2 5 if ($!{'ENOMEM'})
1376 0 5 if ($!{'ENOSPC'})
1381 3 2 if (not $knot->attributes('create')) { }
1 1 elsif ($knot->attributes('create') and $knot->attributes('exclusive')) { }
1404 1 483 unless (defined $sem)
1408 1 482 unless ($sem->op(@{$semop_args{1};}))
1412 98 124 $type eq 'ARRAY' ? :
260 222 $type eq 'HASH' ? :
1427 216 266 if ($serializer eq 'json') { }
1431 3 213 if (not $decoded_ok) { }
1438 3 0 if ($thaw_ok and defined $storable_data) { }
1465 389 93 unless (exists $global_register{$knot->seg->id})
1469 366 116 if ($sem->getval(0) != 1) { }
1475 1 365 unless ($sem->setval(0, 1))
1484 3 113 if defined $stored_protected and $stored_protected != 0
1497 48 95 if ($parent->{'_key'} == IPC_PRIVATE() and $parent->attributes('serializer') ne 'json') { }
1521 101 41 if ($type eq 'HASH') { }
38 3 elsif ($type eq 'ARRAY') { }
2 1 elsif ($type eq 'SCALAR') { }
1524 0 101 unless $child
1526 90 11 if $opts{'tidy'}
1533 0 38 unless $child
1535 32 6 if $opts{'tidy'}
1542 0 2 unless $child
1553 0 1150 unless my $data = shift()
1556 0 1150 unless $type
1560 884 266 if ($type eq 'HASH') { }
248 18 elsif ($type eq 'ARRAY') { }
18 0 elsif ($type eq 'SCALAR') { }
1570 1149 1 if (ref $obj eq "IPC::Shareable")
1580 0 143 unless $type
1584 102 41 if ($type eq 'HASH') { }
38 3 elsif ($type eq 'ARRAY') { }
3 0 elsif ($type eq 'SCALAR') { }
1594 142 1 $need_tie ? :
1605 2 3 if $key_str =~ /^0x[0-9a-fA-F]+$/i
1606 1 2 if $key_str =~ /^\d+$/
1609 1 1 if $int > 2147483648
1618 24 29 $rtype eq 'ARRAY' ? :
97 53 $rtype eq 'HASH' ? :
1623 240 28 unless ref $val
1625 0 28 unless $child and $child->seg
1628 0 28 if $seen->{$id}++
1630 2 26 unless ($child->sem->op(@{$semop_args{$flags};}))
1633 2 0 if $rflags & 4
1645 2 24 unless _lock_children($child, $flags, $accumulator, $seen)
1655 80 42 if ($parent_type eq 'HASH') { }
30 12 elsif ($parent_type eq 'ARRAY') { }
1657 9 71 if (exists $data->{$id})
1659 7 2 if ($child_type eq 'HASH' and tied %{$$data{$id};}) { }
0 4 elsif ($child_type eq 'ARRAY' and tied @{$$data{$id};}) { }
1669 3 27 if (exists $data->[$id])
1671 0 3 if ($child_type eq 'HASH' and tied %{$$data[$id];}) { }
3 0 elsif ($child_type eq 'ARRAY' and tied @{$$data[$id];}) { }
1686 3 3 if ($rtype eq "SCALAR")
1688 3 0 defined $v ? :
1691 3 0 if ($rtype eq "HASH")
1695 1 2 if (ref $v) { }
1697 0 0 $vt eq 'SCALAR' ? :
0 0 $vt eq 'ARRAY' ? :
1 0 $vt eq 'HASH' ? :
1702 1 0 $child && $child->{'_key_hex'} ? :
1706 2 0 defined $v ? :
1709 3 0 @parts ? :
1712 0 0 if ($rtype eq "ARRAY")
1715 0 0 if (ref $v) { }
1717 0 0 $vt eq 'SCALAR' ? :
0 0 $vt eq 'ARRAY' ? :
0 0 $vt eq 'HASH' ? :
1722 0 0 $child && $child->{'_key_hex'} ? :
1726 0 0 defined $v ? :
1742 368 131 if $knot->attributes("create")
1743 165 334 if $knot->attributes("exclusive")
1757 96 420 if ($key_str eq '') { }
20 400 elsif ($key_str =~ /^0x[0-9a-fA-F]+$/i) { }
183 217 elsif ($key_str =~ /^\d+$/) { }
1781 129 184 if ($key > 2147483648)
1784 0 129 if ($key == 0)
1807 10 94 if $used_ids{$key}
1824 94 0 if ($shm_slot_available)
1826 94 0 if $seg
1830 1 94 unless ($verified_exclusive)
1851 12 931 unless $knot->attributes("enforced_read_locking")
1852 3 928 unless $knot->attributes("violated_read_lock_warn")
1859 0 928 unless defined $writers
1861 4 924 if ($writers > 0)
1875 28 918 unless $knot->attributes("enforced_write_locking")
1880 57 861 if $knot->{'_lock'} & 2
1889 12 849 if ($sem->getval(2) > 0)
1890 11 1 if ($knot->attributes("violated_write_lock_warn"))
1905 3 846 if ($sem->getval(1) > 0)
1906 3 0 if ($knot->attributes("violated_write_lock_warn"))
1925 497 2 defined $opts ? :
1928 3364 4620 if (not defined $opts->{$k}) { }
2 4618 elsif ($opts->{$k} eq 'no') { }
1932 1 1 if ($^W)
1947 0 140 if $s->attributes("protected")
1948 16 124 unless $s->attributes("destroy")
1949 43 81 if $s->attributes("owner") != $$