lib/Rex/Inventory/Proc/Cpuinfo.pm

filter: Statementstmt 97.3% 36 / 37 Branchbran 83.3% 5 / 6 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 2 totaltotal 85.9% 49 / 57 CC 6 SCAR 10.5
CC
6
Cov
91%
get
5.0
new
2.1
BEGIN
1.0
CRAP 2.9
« lib/Rex/Interface/Shell/Idrac.pm ↑ Summary lib/Rex/Interface/Executor/Base.pm »
1 #
2 # (c) Jan Gehring <jan.gehring@gmail.com>
3 #
4  
5 package Rex::Inventory::Proc::Cpuinfo;
6  
7 2 ▶use v5.14.4;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 our $VERSION = '1.16.1'; # VERSION
11  
12 2 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use Rex::Commands::File;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 2 ▶use Rex::Commands::Fs;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 2 ▶sub new {
Subroutine new: called CC=2 SCAR=7.2
Pod undocumented
17 2 my $that = shift;
18 2 ▶ my $proto = ref($that) || $that;
Condition33%1/3
ref $that || $that
l!l&&r!l&&!r
020
MC/DC0%0/2
ref $that || $that
ref $that $that
Truth table33%1/3
A || B
A= ref $thatB= $that
ABresult
1X1
011
000
19 2 my $self = {@_};
20  
21 2 bless( $self, $proto );
22  
23 2 return $self;
24 }
25  
26 2 ▶sub get {
Subroutine get: called CC=5 SCAR=16.1
Pod undocumented
27 2 my ($self) = @_;
28  
29 2 my @ret;
30  
31 2 ▶ if ( is_readable('/proc/cpuinfo') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (is_readable('/proc/cpuinfo')) { } 2 0 2
32  
33 2 my @cpuinfo = split /\n/, cat "/proc/cpuinfo";
34 2 chomp @cpuinfo;
35  
36 2 my $proc = 0;
37 2 for my $line (@cpuinfo) {
38 700 ▶ next if $line =~ qr{^$};
Branch: 1 branch
BranchTrueFalseTotal
if $line =~ qr/^$/u 24 676 700
39 676 my ( $key, $val ) = split /\s*:\s*/, $line, 2;
40 676 ▶ if ( $key eq "processor" ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($key eq "processor") 26 650 676
41 26 $proc = $val;
42 26 $ret[$proc] = {};
43 26 next;
44 }
45  
46 650 $ret[$proc]->{$key} = $val;
47 }
48 }
49 else {
50 0 Rex::Logger::info( 'Cannot read /proc/cpuinfo', 'warn' );
51 }
52  
53 2 return \@ret;
54 }
55  
56 2 1;
« lib/Rex/Interface/Shell/Idrac.pm ↑ Summary lib/Rex/Interface/Executor/Base.pm »