Branch Coverage

blib/lib/IPC/Shareable.pm
Criterion Covered Total %
branch 487 598 81.4


line true false branch
165 7 716 unless _write_permitted($knot)
167 684 32 unless $knot->{'_lock'}
169 454 262 if ($knot->{'_type_int'} == 0) { }
174 88 elsif ($knot->{'_type_int'} == 1) { }
88 0 elsif ($knot->{'_type_int'} == 2) { }
172 92 362 if ref $val and $knot->_need_tie($val, $key)
177 36 138 if ref $val and $knot->_need_tie($val, $i)
182 14 74 if ref $val and $knot->_need_tie($val)
186 32 683 if ($knot->{'_lock'} & 2) { }
190 1 680 unless (defined $knot->_encode($knot->seg, $knot->{'_data'}))
201 28 947 if ($knot->{'_lock'}) { }
212 630 343 if ($knot->{'_type_int'} == 0) { }
182 161 elsif ($knot->{'_type_int'} == 1) { }
161 0 elsif ($knot->{'_type_int'} == 2) { }
221 152 9 if (defined $data) { }
229 503 461 if (ref $val and my $inner = _is_child($val))
233 13 490 unless (exists $global_register{$inner->seg->id})
246 1 167 unless _write_permitted($knot)
248 166 1 unless $knot->{'_lock'}
250 109 58 if ($knot->{'_type_int'} == 0) { }
58 0 elsif ($knot->{'_type_int'} == 1) { }
253 2 25 if (ref $val and my $child = _is_child($val))
262 0 20 if (ref $val and my $child = _is_child($val))
269 1 166 if ($knot->{'_lock'} & 2) { }
273 1 165 if (not defined $knot->_encode($knot->seg, $knot->{'_data'}))
282 1 6 unless _write_permitted($knot)
284 5 1 unless $knot->{'_lock'}
289 2 4 if (ref $val and my $child = _is_child($val))
293 1 5 if ($knot->{'_lock'} & 2) { }
297 1 4 unless (defined $knot->_encode($knot->seg, $knot->{'_data'}))
308 28 2 unless $knot->{'_lock'}
314 27 1 unless $knot->{'_lock'}
336 1 14 unless _write_permitted($knot)
338 3 11 unless $knot->{'_lock'}
341 11 3 if ($knot->{'_lock'} & 2) { }
345 1 2 if (not defined $knot->_encode($knot->seg, $knot->{'_data'}))
353 1 4 unless _write_permitted($knot)
355 3 1 unless $knot->{'_lock'}
358 1 3 if ($knot->{'_lock'} & 2) { }
362 1 2 unless (defined $knot->_encode($knot->seg, $knot->{'_data'}))
371 1 14 unless _write_permitted($knot)
373 3 11 unless $knot->{'_lock'}
375 11 3 if ($knot->{'_lock'} & 2) { }
379 1 2 unless (defined $knot->_encode($knot->seg, $knot->{'_data'}))
388 1 4 unless _write_permitted($knot)
390 3 1 unless $knot->{'_lock'}
392 1 3 if ($knot->{'_lock'} & 2) { }
396 1 2 unless (defined $knot->_encode($knot->seg, $knot->{'_data'}))
405 1 4 unless _write_permitted($knot)
407 3 1 unless $knot->{'_lock'}
409 1 3 if ($knot->{'_lock'} & 2) { }
413 1 2 unless (defined $knot->_encode($knot->seg, $knot->{'_data'}))
422 59 1 unless $knot->{'_lock'}
429 1 4 unless _write_permitted($knot)
431 3 1 unless $knot->{'_lock'}
433 1 3 if ($knot->{'_lock'} & 2) { }
437 1 2 unless (defined $knot->_encode($knot->seg, $knot->{'_data'}))
456 3 4 if ($type eq "HASH")
460 2 2 if ($type eq "ARRAY")
464 2 0 if ($type eq "SCALAR")
474 5 131 if (scalar @_ == 2)
478 89 47 if (defined $_[0])
479 1 88 if (ref $_[0] eq 'CODE') { }
487 1 135 if (defined $code and ref $code ne "CODE")
491 48 87 unless defined $flags
493 0 135 if $flags & 8
495 0 135 if $knot->{'_lock'} & $flags
499 0 135 if $knot->{'_lock'}
504 124 11 if ($lock_success)
511 2 122 if (not _lock_children($knot, $flags, \@locked_children, \%seen)) { }
513 2 0 if $rflags & 4
523 89 46 if ($flags == 2 and $lock_success)
524 4 85 if ($code)
528 2 2 unless $ok
537 140 123 unless $knot->{'_lock'}
539 53 70 if ($knot->{'_was_changed'})
540 1 52 unless (defined $knot->_encode($knot->seg, $knot->{'_data'}))
547 3 21 if ($child->{'_was_changed'})
552 2 22 if $child_flags & 4
561 6 116 if $flags & 4
563 1 121 unless ($sem->op(@{$semop_args{$flags};}))
577 3 5 if (not defined $_[0] or $_[0] ne __PACKAGE__)
583 2 6 unless (defined $glue)
587 4 2 unless defined $warn
606 11658 214 if (defined $attr) { }
622 499 27 unless (defined $knot->{'_uuid'})
631 5848 0 if defined $knot->{'_shm'}
635 2477 0 if defined $knot->{'_sem'}
639 19 0 if ref $_[0] or defined $_[0] and not ref $_[0] and UNIVERSAL::isa($_[0], __PACKAGE__)
643 2 24 if defined $filter_key
651 0 229 if ($line =~ /^\s*m\s+(\d+)\s+(\S+)/) { }
125 104 elsif ($line =~ /^\s*(\S+)\s+(\d+)\s+\S+/) { }
662 0 0 $raw_key =~ /^\d+$/ ? :
125 0 $raw_key =~ /^0x[0-9a-fA-F]+$/ ? :
670 0 125 if $key_int == 0
674 0 125 unless shmctl $id, IPC_STAT(), $stat_buf
680 125 0 $IPC::Shareable::Config{'longsize'} == 8 ? :
0 0 $^O eq 'freebsd' && $IPC::Shareable::Config{'longsize'} == 8 ? :
125 0 $^O eq 'linux' ? :
684 0 125 unless $segsz
687 0 125 unless shmread $id, $data, 0, $segsz
694 1 124 unless substr($data, 0, 14) eq "IPC::Shareable"
703 92 32 exists $process_register{$id} ? :
92 32 exists $global_register{$id} ? :
707 2 24 if (defined $filter_int)
717 0 2 if $related{$k_hex}++
726 1 1 if ref $_[0]
738 0 673 if $line =~ /^\s*m\s+\d+\s+\S+/
739 149 524 if $line =~ /^\s*(?:0x[0-9a-fA-F]+|\d+)\s+\d+\s+\S+/
750 0 608 if $line =~ /^\s*s\s+\d+\s+\S+/
751 120 488 if $line =~ /^\s*(?:0x[0-9a-fA-F]+|\d+)\s+\d+\s+\S+/
757 1 5 unless ref $_[0]
766 0 33 if ($line =~ /^\s*m\s+(\d+)\s+(\S+)/) { }
13 20 elsif ($line =~ /^\s*(\S+)\s+(\d+)\s+\S+/) { }
770 0 0 $raw_key =~ /^\d+$/ ? :
13 0 $raw_key =~ /^0x[0-9a-fA-F]+$/ ? :
781 8 0 if defined $hex
793 0 5 $rtype eq 'ARRAY' ? :
3 5 $rtype eq 'HASH' ? :
798 2 1 unless ref $v
801 1 0 if ($vtype eq 'HASH') { }
0 0 elsif ($vtype eq 'ARRAY') { }
0 0 elsif ($vtype eq 'SCALAR') { }
804 0 1 unless $child_knot and $child_knot->{'_key_hex'}
811 5 0 if ($knot_filter and $knot_filter->{'_key_hex'})
816 0 6 if $in_tree{$h}++
829 0 1 unless exists $segs->{$hex}
838 0 5 unless (@roots)
851 6 0 $seg->{'known'} ? :
852 6 0 if $seg->{'local_process'}
861 6 0 $knot_by_hex{$hex} ? :
864 6 0 if (defined $sem) { }
885 6 0 $knot_by_hex{$hex} ? :
894 1 5 @child_keys ? :
918 0 6 if ($^O eq 'darwin') { }
1 5 elsif ($^O eq 'freebsd') { }
5 0 elsif ($^O eq 'linux') { }
921 0 0 if ($line =~ /^kern\.sysv\.(\w+):\s*(\S+)/)
929 5 1 if ($line =~ /^kern\.ipc\.(shm\w+):\s*(\S+)/)
937 16 4 if (open my $fh, "<", $file)
944 6 0 %info ? :
952 0 3 unless $s->attributes("owner") == $$
953 0 3 if $s->attributes("protected")
964 3 216 if $s->attributes("protected")
971 5 4 if (scalar @_ == 2)
974 3 6 if (scalar @_ == 1)
978 1 8 unless (defined $protect_key)
982 1 7 unless ($protect_key =~ /^\d+$/)
993 8 0 if ($stored_key and $stored_key == $protect_key)
1004 5 328 if (defined $key)
1008 1 4 unless (defined $id)
1013 0 4 if (not shmctl($id, IPC_RMID(), 0)) { }
1024 0 4 if (defined $sem)
1025 0 0 unless $sem->remove
1038 0 328 if (not $seg->remove) { }
1052 1 327 if ($sem_remove_status != 1 and $sem_remove_status ne '0 but true') { }
1062 327 1 if ($seg_removed and $sem_removed)
1077 504 414 if ($serializer eq "storable")
1088 1326 1477 $serializer eq 'storable' ? :
1092 2309 489 if defined $data
1096 83 406 if $knot->{'_type_int'} == 1
1097 306 100 if $knot->{'_type_int'} == 0
1108 1 413 if (length $json > $seg->size)
1117 0 415 unless my $type = builtin::reftype($data)
1124 272 143 if ($type eq "HASH")
1130 55 1165 $inner ? :
1136 128 15 if ($type eq "ARRAY")
1141 37 298 if ($inner) { }
1147 14 1 if ($type eq "SCALAR" or $type eq "REF")
1151 6 8 $inner ? :
1162 276 1202 unless $json
1172 1201 1 if ($tag eq 'IPC::Shareable') { }
1175 1 1197 unless (defined $data)
1179 375 822 if defined $knot and index($json, "\"__ics__\"") != -1
1182 84 1113 if (defined $knot and $knot->{'_type_int'} == 2 and ref $data eq "HASH")
1183 44 40 if (exists $data->{'__ics__'})
1185 43 1 defined $prev && ref $prev ? :
1189 23 17 if (exists $data->{'__sv__'})
1203 0 375 unless my $type = builtin::reftype($data)
1211 284 91 if ($type eq 'HASH') { }
91 0 elsif ($type eq 'ARRAY') { }
1213 248 365 unless ref $data->{$key} eq "HASH" and exists $data->{$key}{'__ics__'}
1216 339 26 ref $prev eq 'HASH' ? :
1223 21 171 unless ref $data->[$i] eq "HASH" and exists $data->[$i]{'__ics__'}
1225 151 20 ref $prev eq 'ARRAY' && $i <= $prev->$#* ? :
1235 520 60 if (defined $existing)
1237 510 10 if $inner and $inner->{'_key'} == $info->{'child_key'}
1253 31 39 if ($info->{'type'} eq 'HASH') { }
38 1 elsif ($info->{'type'} eq 'ARRAY') { }
1 0 elsif ($info->{'type'} eq 'SCALAR') { }
1276 1 503 if (length $ice > $seg->size)
1287 7 1588 unless $ice
1291 1129 459 if ($tag eq 'IPC::Shareable') { }
1293 1 1128 unless (defined $water)
1307 176 323 if (scalar @_ == 4) { }
1326 2 497 if ($knot->attributes("limit") and $shm_size > 1073741824)
1334 8 489 if ($knot->attributes('graceful')) { }
1346 4 4 unless (defined $exclusive)
1347 1 3 if ($knot->attributes("warn"))
1365 7 484 unless (defined $seg)
1366 2 5 if ($! =~ /Cannot allocate memory/)
1371 0 5 if ($! =~ /No space left on device/)
1376 3 2 if (not $knot->attributes('create')) { }
1 1 elsif ($knot->attributes('create') and $knot->attributes('exclusive')) { }
1399 1 483 unless (defined $sem)
1403 1 482 unless ($sem->op(@{$semop_args{1};}))
1407 98 124 $type eq 'ARRAY' ? :
260 222 $type eq 'HASH' ? :
1422 216 266 if ($serializer eq 'json') { }
1426 3 213 if (not $decoded_ok) { }
1433 3 0 if ($thaw_ok and defined $storable_data) { }
1460 389 93 unless (exists $global_register{$knot->seg->id})
1464 366 116 if ($sem->getval(0) != 1) { }
1470 1 365 unless ($sem->setval(0, 1))
1479 3 113 if defined $stored_protected and $stored_protected != 0
1492 48 95 if ($parent->{'_key'} == IPC_PRIVATE() and $parent->attributes('serializer') ne 'json') { }
1516 101 41 if ($type eq 'HASH') { }
38 3 elsif ($type eq 'ARRAY') { }
2 1 elsif ($type eq 'SCALAR') { }
1519 0 101 unless $child
1521 90 11 if $opts{'tidy'}
1528 0 38 unless $child
1530 32 6 if $opts{'tidy'}
1537 0 2 unless $child
1548 0 1152 unless my $data = shift()
1551 0 1152 unless $type
1555 886 266 if ($type eq 'HASH') { }
248 18 elsif ($type eq 'ARRAY') { }
18 0 elsif ($type eq 'SCALAR') { }
1565 1151 1 if (ref $obj eq "IPC::Shareable")
1575 0 143 unless $type
1579 102 41 if ($type eq 'HASH') { }
38 3 elsif ($type eq 'ARRAY') { }
3 0 elsif ($type eq 'SCALAR') { }
1589 142 1 $need_tie ? :
1600 2 3 if $key_str =~ /^0x[0-9a-fA-F]+$/i
1601 1 2 if $key_str =~ /^\d+$/
1604 1 1 if $int > 2147483648
1613 24 29 $rtype eq 'ARRAY' ? :
97 53 $rtype eq 'HASH' ? :
1618 240 28 unless ref $val
1620 0 28 unless $child and $child->seg
1623 0 28 if $seen->{$id}++
1625 2 26 unless ($child->sem->op(@{$semop_args{$flags};}))
1628 2 0 if $rflags & 4
1640 2 24 unless _lock_children($child, $flags, $accumulator, $seen)
1650 80 42 if ($parent_type eq 'HASH') { }
30 12 elsif ($parent_type eq 'ARRAY') { }
1652 9 71 if (exists $data->{$id})
1654 7 2 if ($child_type eq 'HASH' and tied %{$$data{$id};}) { }
0 4 elsif ($child_type eq 'ARRAY' and tied @{$$data{$id};}) { }
1664 3 27 if (exists $data->[$id])
1666 0 3 if ($child_type eq 'HASH' and tied %{$$data[$id];}) { }
3 0 elsif ($child_type eq 'ARRAY' and tied @{$$data[$id];}) { }
1681 3 3 if ($rtype eq "SCALAR")
1683 3 0 defined $v ? :
1686 3 0 if ($rtype eq "HASH")
1690 1 2 if (ref $v) { }
1692 0 0 $vt eq 'SCALAR' ? :
0 0 $vt eq 'ARRAY' ? :
1 0 $vt eq 'HASH' ? :
1697 1 0 $child && $child->{'_key_hex'} ? :
1701 2 0 defined $v ? :
1704 3 0 @parts ? :
1707 0 0 if ($rtype eq "ARRAY")
1710 0 0 if (ref $v) { }
1712 0 0 $vt eq 'SCALAR' ? :
0 0 $vt eq 'ARRAY' ? :
0 0 $vt eq 'HASH' ? :
1717 0 0 $child && $child->{'_key_hex'} ? :
1721 0 0 defined $v ? :
1737 368 131 if $knot->attributes("create")
1738 165 334 if $knot->attributes("exclusive")
1752 96 420 if ($key_str eq '') { }
20 400 elsif ($key_str =~ /^0x[0-9a-fA-F]+$/i) { }
183 217 elsif ($key_str =~ /^\d+$/) { }
1776 129 184 if ($key > 2147483648)
1779 0 129 if ($key == 0)
1802 10 94 if $used_ids{$key}
1819 94 0 if ($shm_slot_available)
1821 94 0 if $seg
1825 1 94 unless ($verified_exclusive)
1846 12 935 unless $knot->attributes("enforced_read_locking")
1847 3 932 unless $knot->attributes("violated_read_lock_warn")
1854 0 932 unless defined $writers
1856 4 928 if ($writers > 0)
1870 28 920 unless $knot->attributes("enforced_write_locking")
1875 57 863 if $knot->{'_lock'} & 2
1884 12 851 if ($sem->getval(2) > 0)
1885 11 1 if ($knot->attributes("violated_write_lock_warn"))
1900 3 848 if ($sem->getval(1) > 0)
1901 3 0 if ($knot->attributes("violated_write_lock_warn"))
1920 497 2 defined $opts ? :
1923 3364 4620 if (not defined $opts->{$k}) { }
2 4618 elsif ($opts->{$k} eq 'no') { }
1927 1 1 if ($^W)
1942 0 140 if $s->attributes("protected")
1943 16 124 unless $s->attributes("destroy")
1944 43 81 if $s->attributes("owner") != $$