blib/lib/Linux/Smaps/Tiny/PP.pm

filter: Statementstmt 100% 27 / 27 Branchbran 87.5% 7 / 8 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 97.6% 42 / 43 CC 6 SCAR 13.9
CC
6
Cov
97%
__get_smaps_summary
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 4.0
↑ Summary blib/lib/Linux/Smaps/Tiny.pm »
1 package Linux::Smaps::Tiny::PP;
2 3 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 $Linux::Smaps::Tiny::PP::AUTHORITY = 'cpan:AVAR';
4 }
5 {
6 3 $Linux::Smaps::Tiny::PP::VERSION = '0.10';
7 }
8 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use warnings FATAL => "all";
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 3 ▶sub __get_smaps_summary {
Subroutine __get_smaps_summary: called CC=6 SCAR=17.9
12 3 ▶ my $proc_id= shift || "self";
Condition100%2/2
shift() || 'self'
l!l
21
MC/DC100%1/1
shift() || 'self'
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
13 3 my $smaps_file= "/proc/$proc_id/smaps";
14 open my $fh, "<", $smaps_file
15 3 ▶ or do {
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $smaps_file or do { my $errnum = 0 + $!; my $errmsg = "$!"; my $msg = "In get_smaps_summary, failed to read '${smaps_file}': [$errnum] $errmsg"; die $msg } 2 1 3
16 1 my $errnum= 0+$!; # numify
17 1 my $errmsg= "$!"; # stringify
18 1 my $msg= "In get_smaps_summary, failed to read '$smaps_file': [$errnum] $errmsg";
19  
20 1 die $msg;
21 };
22 2 my %sum;
23 2 ▶ while (<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 6150 2 6152
24 6150 ▶ next unless substr($_,-3) eq "kB\n";
Branch: 1 branch
BranchTrueFalseTotal
unless substr($_, -3) eq "kB\n" 738 5412 6150
25 5412 my ($field, $value)= split /:/,$_;
26 3 ▶ no warnings 'numeric';
Subroutine BEGIN: called CC=1 SCAR=0.0
27 5412 ▶ $sum{$field}+=$value if $value;
Branch: 1 branch
BranchTrueFalseTotal
if $value 5412 0 5412
28 }
29 2 close $fh;
30 2 return \%sum;
31 }
32  
33 3 1;
↑ Summary blib/lib/Linux/Smaps/Tiny.pm »