| 1 | # Declare our package | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | package POE::Devel::ProcAlike::POEInfo; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # Initialize our version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use vars qw( $VERSION ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | $VERSION = '0.02'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # Set our superclass | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use base 'Filesys::Virtual::Async::inMemory'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # portable tools | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | # import the useful $poe_kernel | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use POE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use POE::API::Peek; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | my $api = POE::API::Peek->new(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | my $have_stats = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | my $have_eventprofile = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | # do we have stats available? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | eval { $have_stats = POE::Kernel::TRACE_STATISTICS() }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | if ( $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | $have_stats = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | eval { $have_eventprofile = POE::Kernel::TRACE_PROFILE() }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | if ( $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | $have_eventprofile = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | # do we have a new-enough POE to introspect the profile data? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | if ( ! $poe_kernel->can( 'stat_getprofile' ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | $have_eventprofile = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | # make sure we set a readonly filesystem! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | return __PACKAGE__->SUPER::new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 'readonly' => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | #/kernel | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | # # place for kernel stuff | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | # id # $poe_kernel->ID | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | # is_running # $api->is_kernel_running | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | # which_loop # $poe_kernel->poe_kernel_loop | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | # safe_signals # $api->get_safe_signals | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | # active_session # $poe_kernel->get_active_session->ID | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | # active_event # $poe_kernel->get_active_event | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | # memory_size # $api->kernel_memory_size | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | # session_count # $api->session_count | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | # extref_count # $api->extref_count | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | # handle_count # $api->handle_count | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | # event_count # $poe_kernel->get_event_count | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | # next_event # $poe_kernel->get_next_event_time | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | # /statistics | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | # # stats gathered via TRACE_STATISTICS if available | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | # interval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | # blocked | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | # blocked_seconds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | # idle_seconds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | # total_duration | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | # user_events | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | # user_seconds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | # avg_blocked | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | # avg_blocked_seconds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | # avg_idle_seconds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | # avg_total_duration | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | # avg_user_events | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | # avg_user_seconds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | # derived_idle | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | # derived_user | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | # derived_blocked | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | # derived_userload | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | # event_profile | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | # /eventqueue | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | # # a place for the event queue data ( basically a dump of POE::Queue::Array ) - from $api->event_queue_dump() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | # /N | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | # # N is the ID of event in the queue | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | # id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | # index | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | # priority | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | # event | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | # source | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | # destination | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | # type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | # /sessions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | # # place for all session info ( like /proc/pid ) - from $api->session_list | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | # /id | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | # # the id is the session ID | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | # id # $session->ID | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | # type # ref( $session ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | # memory_size # $api->session_memory_size( $session ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | # extref_count # $api->get_session_extref_count( $session ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | # handle_count # $api->session_handle_count( $session ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | # events_to # $api->event_count_to( $session ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | # events_from # $api->event_count_from( $session ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | # event_profile # $kernel->stat_getprofile( $session ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | # watched_signals # $api->signals_watched_by_session( $session ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | # events # $api->session_event_list( $session ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | # aliases # $api->session_alias_list( $session ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | # heap # Data::Dumper( $session->get_heap() ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | my %fs = ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 'id' => $poe_kernel->ID . "\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 'is_running' => [ $api, 'is_kernel_running' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 'which_loop' => $poe_kernel->poe_kernel_loop . "\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 'safe_signals' => join( "\n", $api->get_safe_signals() ) . "\n", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | 'active_session' => [ $poe_kernel, 'get_active_session', sub { $_[0]->ID } ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 'active_event' => [ $poe_kernel, 'get_active_event' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | # 'memory_size' => [ $api, 'kernel_memory_size' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | 'session_count' => [ $api, 'session_count', sub { $_[0] - 1 } ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 'extref_count' => [ $api, 'extref_count' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 'handle_count' => [ $api, 'handle_count' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 'event_count' => [ $poe_kernel, 'get_event_count' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 'next_event' => [ $poe_kernel, 'get_next_event_time' ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 'statistics' => \&manage_statistics, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 'eventqueue' => \&manage_queue, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 'sessions' => \&manage_sessions, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | # helper sub to keep track of stat variables | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | sub _get_statistics_metrics { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_statistics_metrics: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | my @stats; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | # do we have event profiling? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | if ( $have_eventprofile ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | push( @stats, 'event_profile' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | if ( $have_stats ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | push( @stats, qw( blocked blocked_seconds idle_seconds interval total_duration user_events user_seconds | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | avg_blocked avg_blocked_seconds avg_idle_seconds avg_user_events avg_user_seconds | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | derived_idle derived_user derived_blocked derived_userload | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | return \@stats; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | sub _get_statistics_metric { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_statistics_metric: not called CC=12 SCAR=50.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | my $metric = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | # what metric? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | if ( $metric eq 'event_profile' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | my %profile = $poe_kernel->stat_getprofile(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | # do we have stats? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | if ( keys %profile == 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | return "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | my $data = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | foreach my $p ( keys %profile ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | $data .= $profile{ $p } . ":$p\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | return $data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | my %average = $poe_kernel->stat_getdata(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | # do we have stats? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | if ( keys %average == 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | return "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | # derived require calculations | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | if ( $metric =~ /^derived/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | # Division by zero sucks. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | $average{'interval'} ||= 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$average{"interval"} ||= 1
MC/DC0%0/1
$average{"interval"} ||= 1
$average{"interval"}
Truth table0%0/2
A
A= $average{"interval"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | $average{'user_events'} ||= 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$average{"user_events"} ||= 1
MC/DC0%0/1
$average{"user_events"} ||= 1
$average{"user_events"}
Truth table0%0/2
A
A= $average{"user_events"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | if ( $metric eq 'derived_idle' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | return sprintf( "%2.1f%%\n", 100 * $average{'avg_idle_seconds'} / $average{'interval'} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } elsif ( $metric eq 'derived_user' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | return sprintf( "%2.1f%%\n", 100 * $average{'avg_user_seconds'} / $average{'interval'} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | } elsif ( $metric eq 'derived_blocked' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | return sprintf( "%2.1f%%\n", 100 * $average{'avg_blocked'} / $average{'user_events'} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | } elsif ( $metric eq 'derived_userload' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | return sprintf( "%2.1f%%\n", 100 * $average{'avg_user_events'} / $average{'interval'} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | # simple hash access | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | return $average{ $metric } . "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | sub manage_statistics { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
manage_statistics: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | my( $type, @path ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | # what's the operation? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | if ( $type eq 'readdir' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | return _get_statistics_metrics(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | } elsif ( $type eq 'stat' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | # set some default data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | my ($atime, $ctime, $mtime, $size, $modes); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | $atime = $ctime = $mtime = time(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | my ($dev, $ino, $rdev, $blocks, $gid, $uid, $nlink, $blksize) = ( 0, 0, 0, 1, (split( /\s+/, $) ))[0], $>, 1, 1024 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | # trying to stat the dir or stuff inside it? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | if ( defined $path[0] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | # is it a valid stat metric? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | if ( ! grep { $_ eq $path[0] } @{ _get_statistics_metrics() } or defined $path[1] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not grep({$_ eq $path[0];} @{_get_statistics_metrics();}) or defined $path[1]
MC/DC0%0/2
not grep({$_ eq $path[0];} @{_get_statistics_metrics();}) or defined $path[1]
not grep({$_ eq $path[0];} @{_get_statistics_metrics();})
defined $path[1]
Truth table0%0/3
not(A) or B
A= not grep({$_ eq $path[0];} @{_get_statistics_metrics();})B= defined $path[1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | # a file, munge the data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | $size = length( _get_statistics_metric( $path[0] ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | $modes = oct( '100644' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | # a directory, munge the data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | $size = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | $modes = oct( '040755' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | $nlink = 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | # finally, return the darn data! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | return( [ $dev, $ino, $modes, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | } elsif ( $type eq 'open' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | # is it a valid stat metric? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | if ( ! grep { $_ eq $path[0] } @{ _get_statistics_metrics() } or defined $path[1] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not grep({$_ eq $path[0];} @{_get_statistics_metrics();}) or defined $path[1]
MC/DC0%0/2
not grep({$_ eq $path[0];} @{_get_statistics_metrics();}) or defined $path[1]
not grep({$_ eq $path[0];} @{_get_statistics_metrics();})
defined $path[1]
Truth table0%0/3
not(A) or B
A= not grep({$_ eq $path[0];} @{_get_statistics_metrics();})B= defined $path[1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | # return a scalar ref | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | my $data = _get_statistics_metric( $path[0] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | return \$data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | # helper sub to simplify queue item processing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | ▶ | sub _get_queue_metrics { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_queue_metrics: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | return [ qw( id index priority event source destination type ) ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | sub _get_queue_metric { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_queue_metric: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | my $queuedata = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | my $metric = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | # some metrics require manipulation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | if ( $metric eq 'source' or $metric eq 'destination' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$metric eq "source" or $metric eq "destination"
MC/DC0%0/2
$metric eq "source" or $metric eq "destination"
$metric eq "source"
$metric eq "destination"
Truth table0%0/3
A or B
A= $metric eq "source"B= $metric eq "destination"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | if ( ref $queuedata->{ $metric } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | return $queuedata->{ $metric }->ID . "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | # simple hash access | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | return $queuedata->{ $metric } . "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | sub manage_queue { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
manage_queue: not called CC=14 SCAR=53.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | my( $type, @path ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | # what's the operation? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | if ( $type eq 'readdir' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | # trying to read the root or the queue event itself? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | if ( defined $path[0] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | return _get_queue_metrics(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | # get the queue events | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | my @queue = map { $_->{'ID'} } $api->event_queue_dump(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | return \@queue; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | } elsif ( $type eq 'stat' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | # set some default data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | my ($atime, $ctime, $mtime, $size, $modes); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | $atime = $ctime = $mtime = time(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | my ($dev, $ino, $rdev, $blocks, $gid, $uid, $nlink, $blksize) = ( 0, 0, 0, 1, (split( /\s+/, $) ))[0], $>, 1, 1024 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | # get the data to start off | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | my @queue = $api->event_queue_dump(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | # trying to stat the dir or stuff inside it? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | if ( defined $path[0] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | # does the id exist? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | my @data = grep { $_->{'ID'} eq $path[0] } @queue; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | if ( ! @data ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | # trying to stat the queue id or data inside it? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | ▶ | if ( defined $path[1] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | # is it a valid queue metric? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | if ( ! grep { $_ eq $path[1] } @{ _get_queue_metrics() } or defined $path[2] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not grep({$_ eq $path[1];} @{_get_queue_metrics();}) or defined $path[2]
MC/DC0%0/2
not grep({$_ eq $path[1];} @{_get_queue_metrics();}) or defined $path[2]
not grep({$_ eq $path[1];} @{_get_queue_metrics();})
defined $path[2]
Truth table0%0/3
not(A) or B
A= not grep({$_ eq $path[1];} @{_get_queue_metrics();})B= defined $path[2]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | # a file, munge the data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | $size = length( _get_queue_metric( $data[0], $path[1] ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | $modes = oct( '100644' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | # a directory, munge the data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | $size = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | $modes = oct( '040755' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | $nlink = 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | # a directory, munge the data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | $size = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | $modes = oct( '040755' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | $nlink = 2 + scalar @queue; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | # finally, return the darn data! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | return( [ $dev, $ino, $modes, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | } elsif ( $type eq 'open' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | # get the data to start off | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | my @queue = $api->event_queue_dump(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | my @data = grep { $_->{'ID'} eq $path[0] } @queue; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | ▶ | if ( ! @data or ! defined $path[1] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@data and defined $path[1]
MC/DC0%0/2
@data and defined $path[1]
@data
defined $path[1]
Truth table0%0/3
A and B
A= @dataB= defined $path[1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | # is it a valid queue metric? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | ▶ | if ( ! grep { $_ eq $path[1] } @{ _get_queue_metrics() } or defined $path[2] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not grep({$_ eq $path[1];} @{_get_queue_metrics();}) or defined $path[2]
MC/DC0%0/2
not grep({$_ eq $path[1];} @{_get_queue_metrics();}) or defined $path[2]
not grep({$_ eq $path[1];} @{_get_queue_metrics();})
defined $path[2]
Truth table0%0/3
not(A) or B
A= not grep({$_ eq $path[1];} @{_get_queue_metrics();})B= defined $path[2]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | # get the metric! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | my $data = _get_queue_metric( $data[0], $path[1] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | return \$data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | # helper sub to simplify session item processing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | ▶ | sub _get_sessions_metrics { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_sessions_metrics: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | my @stats; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | # removed memory_size, watched_signals due to complications | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | push( @stats, qw( id type extref_count handle_count events_to events_from | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | events aliases heap | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | ) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | # do we have profiling? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | if ( $have_eventprofile ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | push( @stats, 'event_profile' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | return \@stats; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | ▶ | sub _get_sessions_metric { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_sessions_metric: not called CC=15 SCAR=51.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | my $session = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | my $metric = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | # determine what to do | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | ▶ | if ( $metric eq 'id' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 12 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | return $session->ID . "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | } elsif ( $metric eq 'type' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | return ref( $session ) . "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | } elsif ( $metric eq 'memory_size' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | return $api->session_memory_size( $session ) . "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | } elsif ( $metric eq 'extref_count' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | return $api->get_session_extref_count( $session ) . "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | } elsif ( $metric eq 'handle_count' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | return $api->session_handle_count( $session ) . "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | } elsif ( $metric eq 'events_to' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | return $api->event_count_to( $session ) . "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | } elsif ( $metric eq 'events_from' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | return $api->event_count_from( $session ) . "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | } elsif ( $metric eq 'watched_signals' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | return join( "\n", $api->signals_watched_by_session( $session ) ) . "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | } elsif ( $metric eq 'events' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | return join( "\n", $api->session_event_list( $session ) ) . "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | } elsif ( $metric eq 'aliases' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | return join( "\n", $api->session_alias_list( $session ) ) . "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | } elsif ( $metric eq 'heap' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | require Data::Dumper; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | # make sure we have "consistent" data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 1 | ▶ | no warnings; # shutup "possible used only once" warning! | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | local $Data::Dumper::Terse = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | local $Data::Dumper::Sortkeys = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | return Data::Dumper::Dumper( $session->get_heap() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | } elsif ( $metric eq 'event_profile' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | my %profile = $poe_kernel->stat_getprofile( $session ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | # do we have stats? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | ▶ | if ( keys %profile == 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | return "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | my $data = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | foreach my $p ( keys %profile ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | $data .= $profile{ $p } . ":$p\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | return $data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | die "unknown sessions metric: $metric\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | ▶ | sub manage_sessions { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
manage_sessions: not called CC=14 SCAR=53.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | my( $type, @path ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | # what's the operation? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | ▶ | if ( $type eq 'readdir' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | # trying to read the root or the session itself? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | ▶ | if ( defined $path[0] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | return _get_sessions_metrics(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | # get the sessions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | my @sessions = map { $_->ID } $api->session_list(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | return \@sessions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | } elsif ( $type eq 'stat' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | # set some default data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | my ($atime, $ctime, $mtime, $size, $modes); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | $atime = $ctime = $mtime = time(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | my ($dev, $ino, $rdev, $blocks, $gid, $uid, $nlink, $blksize) = ( 0, 0, 0, 1, (split( /\s+/, $) ))[0], $>, 1, 1024 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | # get the data to start off | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | my @sessions = $api->session_list(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | # trying to stat the dir or stuff inside it? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | ▶ | if ( defined $path[0] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | # does the id exist? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | my @data = grep { $_->ID eq $path[0] } @sessions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | ▶ | if ( ! @data ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | # trying to stat the session id or data inside it? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | ▶ | if ( defined $path[1] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | # is it a valid session metric? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | ▶ | if ( ! grep { $_ eq $path[1] } @{ _get_sessions_metrics() } or defined $path[2] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not grep({$_ eq $path[1];} @{_get_sessions_metrics();}) or defined $path[2]
MC/DC0%0/2
not grep({$_ eq $path[1];} @{_get_sessions_metrics();}) or defined $path[2]
not grep({$_ eq $path[1];} @{_get_sessions_metrics();})
defined $path[2]
Truth table0%0/3
not(A) or B
A= not grep({$_ eq $path[1];} @{_get_sessions_metrics();})B= defined $path[2]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | # a file, munge the data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | $size = length( _get_sessions_metric( $data[0], $path[1] ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | $modes = oct( '100644' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | # a directory, munge the data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | $size = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | $modes = oct( '040755' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | $nlink = 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | # a directory, munge the data | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | $size = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | $modes = oct( '040755' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | $nlink = 2 + scalar @sessions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | # finally, return the darn data! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | return( [ $dev, $ino, $modes, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | } elsif ( $type eq 'open' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | # get the data to start off | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | my @sessions = $api->session_list(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | my @data = grep { $_->ID eq $path[0] } @sessions; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | ▶ | if ( ! @data or ! defined $path[1] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@data and defined $path[1]
MC/DC0%0/2
@data and defined $path[1]
@data
defined $path[1]
Truth table0%0/3
A and B
A= @dataB= defined $path[1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | # is it a valid session metric? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | ▶ | if ( ! grep { $_ eq $path[1] } @{ _get_sessions_metrics() } or defined $path[2] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not grep({$_ eq $path[1];} @{_get_sessions_metrics();}) or defined $path[2]
MC/DC0%0/2
not grep({$_ eq $path[1];} @{_get_sessions_metrics();}) or defined $path[2]
not grep({$_ eq $path[1];} @{_get_sessions_metrics();})
defined $path[2]
Truth table0%0/3
not(A) or B
A= not grep({$_ eq $path[1];} @{_get_sessions_metrics();})B= defined $path[2]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | # get the metric! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | my $data = _get_sessions_metric( $data[0], $path[1] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | return \$data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | # we cheat here and not implement a lot of stuff because we know the FUSE api never calls the "extra" APIs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | # that ::Async provides. Furthermore, this is a read-only filesystem so we can skip even more APIs :) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | # _rmtree | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | # _scandir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | # _move | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | # _copy | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | # _load | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | ▶ | sub _readdir { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_readdir: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | my( $self, $path ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | ▶ | if ( $path eq File::Spec->rootdir() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | return [ keys %fs ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | # sanitize the path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | my @dirs = File::Spec->splitdir( $path ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | shift( @dirs ); # get rid of the root entry which is always '' for me | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | return $fs{ $dirs[0] }->( 'readdir', @dirs[ 1 .. $#dirs ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | # _rmdir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | # _mkdir | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | # _rename | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | # _mknod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | # _unlink | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | # _chmod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | # _truncate | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | # _chown | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | # _utime | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | # helper to process ARRAY fs type | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | ▶ | sub _stat_arraymode { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_stat_arraymode: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | my $file = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | my $method = $fs{ $file }->[1]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | my $data = $fs{ $file }->[0]->$method(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | # do we need to do more munging? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | ▶ | if ( defined $fs{ $file }->[2] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | $data = $fs{ $file }->[2]->( $data ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | # all done! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | return $data . "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | ▶ | sub _stat { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_stat: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | my( $self, $path ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | # stating the root? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | ▶ | if ( $path eq File::Spec->rootdir() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | my ($atime, $ctime, $mtime, $size, $modes); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | $atime = $ctime = $mtime = time(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 0 | my ($dev, $ino, $rdev, $blocks, $gid, $uid, $nlink, $blksize) = ( 0, 0, 0, 1, (split( /\s+/, $) ))[0], $>, 1, 1024 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | $size = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 0 | $modes = oct( '040755' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | # count subdirs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | ▶ | $nlink = 2 + grep { ref $fs{ $_ } and ref( $fs{ $_ } ) ne 'ARRAY' } keys %fs; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
ref $fs{$_} && ref $fs{$_} ne 'ARRAY'
MC/DC0%0/2
ref $fs{$_} && ref $fs{$_} ne 'ARRAY'
ref $fs{$_}
ref $fs{$_} ne 'ARRAY'
Truth table0%0/3
A && B
A= ref $fs{$_}B= ref $fs{$_} ne 'ARRAY'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | return( [ $dev, $ino, $modes, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | # sanitize the path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | my @dirs = File::Spec->splitdir( $path ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | shift( @dirs ); # get rid of the root entry which is always '' for me | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | ▶ | if ( exists $fs{ $dirs[0] } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | # arg, stat is a finicky beast! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | my $modes = oct( '100644' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | my ($dev, $ino, $rdev, $blocks, $gid, $uid, $nlink, $blksize) = ( 0, 0, 0, 1, (split( /\s+/, $) ))[0], $>, 1, 1024 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | my ($atime, $ctime, $mtime, $size); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | $atime = $ctime = $mtime = time(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | # directory or file? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | ▶ | if ( ref $fs{ $dirs[0] } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | # array or code? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | ▶ | if ( ref( $fs{ $dirs[0] } ) eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | # array operation, do what the data tells us to do! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | $size = length( _stat_arraymode( $dirs[0] ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | # trying to stat the dir or the subpath? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | return $fs{ $dirs[0] }->( 'stat', @dirs[ 1 .. $#dirs ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | # arg, stat is a finicky beast! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | $size = length( $fs{ $dirs[0] } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | # finally, return the darn data! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | return( [ $dev, $ino, $modes, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | # _write | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | ▶ | sub _open { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_open: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | my( $self, $path ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | # sanitize the path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | my @dirs = File::Spec->splitdir( $path ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | shift( @dirs ); # get rid of the root entry which is always '' for me | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | ▶ | if ( exists $fs{ $dirs[0] } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | # directory or file? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | ▶ | if ( ref $fs{ $dirs[0] } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | # array or code? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | ▶ | if ( ref( $fs{ $dirs[0] } ) eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | # array operation, do what the data tells us to do! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | my $data = _stat_arraymode( $dirs[0] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 0 | return \$data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 0 | return $fs{ $dirs[0] }->( 'open', @dirs[ 1 .. $#dirs ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | # return a scalar ref | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | return \$fs{ $dirs[0] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||