| 1 | package System::Info::Linux; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use base "System::Info::Base"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 3 | our $VERSION = "0.055"; | |||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | System::Info::Linux - Object for specific Linux info. | ||||||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||||||
| 14 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||
| 16 | =head2 $si->prepare_sysinfo | ||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||
| 18 | Use os-specific tools to find out more about the system. | ||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||
| 20 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 137 | ▶ | sub prepare_sysinfo { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prepare_sysinfo: called CC=8 SCAR=21.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 137 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 24 | 137 | $self->SUPER::prepare_sysinfo; | |||||||||||||||||||||||||||||||||||||||||||||
| 25 | 137 | $self->prepare_os; | |||||||||||||||||||||||||||||||||||||||||||||
| 26 | 137 | ▶ | $self->prepare_proc_cpuinfo or return; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 137 | for ($self->get_cpu_type) { | |||||||||||||||||||||||||||||||||||||||||||||
| 29 | 137 | ▶ | m/arm/ and do { $self->linux_arm; last }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | m/aarch64/ and do { $self->linux_arm; last }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 134 | ▶ | m/ppc/ and do { $self->linux_ppc; last }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | m/sparc/ and do { $self->linux_sparc; last }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 133 | ▶ | m/s390x/ and do { $self->linux_s390x; last }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 34 | # default | ||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 131 | $self->linux_generic; | |||||||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 137 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||
| 38 | } # prepare_sysinfo | ||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||
| 40 | =head2 $si->prepare_os | ||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||
| 42 | Use os-specific tools to find out more about the operating system. | ||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||
| 44 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 551 | ▶ | sub _file_info { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_file_info: called CC=11 SCAR=24.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 551 | my ($file, $os) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 48 | 551 | ▶ | open my $fh, "<", $file or return; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 551 | ▶ | while (<$fh>) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 2477 | ▶ | m/^\s*[;#]/ and next; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 2465 | chomp; | |||||||||||||||||||||||||||||||||||||||||||||
| 52 | 2465 | ▶ | m/\S/ or next; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 2277 | s/^\s+//; | |||||||||||||||||||||||||||||||||||||||||||||
| 54 | 2277 | s/\s+$//; | |||||||||||||||||||||||||||||||||||||||||||||
| 55 | 2277 | ▶ | if (my ($k, $v) = (m/^\s*(.*\S)\s*=\s*(\S.*?)\s*$/)) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 56 | # Having a value prevails over being defined | ||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 1779 | ▶ | defined $os->{$k} and next; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 1767 | $v =~ s/^"\s*(.*?)\s*"$/$1/; | |||||||||||||||||||||||||||||||||||||||||||||
| 59 | 1767 | $v =~ s/^'\s*(.*?)\s*'$/$1/; | |||||||||||||||||||||||||||||||||||||||||||||
| 60 | 1767 | ▶ | $v =~ m{^["(]?undef(?:ined)?[")]$}i and $v = "undefined"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 1767 | $os->{$k} = $v; | |||||||||||||||||||||||||||||||||||||||||||||
| 62 | 1767 | next; | |||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 498 | ▶ | m/^[12][0-9]{3}(?:,\s*[12][0-9]{3})*(?:\s*,\s*)*$/ and next; # Copyright years | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 495 | ▶ | m/^[12][0-9]{3}(?:,\s*[12][0-9]{3})*.*All rights reserved/i and next; # Copyright years | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 494 | ▶ | exists $os->{$_} or $os->{$_} = undef; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 551 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||
| 69 | } # _file_info | ||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 137 | ▶ | sub _lsb_release { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_lsb_release: called CC=11 SCAR=41.5
| |||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 137 | my $os = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 137 | ▶ | $ENV{SMOKE_USE_ETC} and return; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||
| 76 | $os->{DISTRIB_ID} || $os->{DISTRIB_RELEASE} || $os->{DISTRIB_CODENAME} | ||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 16 | ▶ | and return; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$os->{"DISTRIB_ID"} or $os->{"DISTRIB_RELEASE"} or $os->{"DISTRIB_CODENAME"}
$os->{"DISTRIB_ID"} or $os->{"DISTRIB_RELEASE"}
MC/DC0%0/3
$os->{"DISTRIB_ID"} or $os->{"DISTRIB_RELEASE"} or $os->{"DISTRIB_CODENAME"}
$os->{"DISTRIB_ID"}
$os->{"DISTRIB_RELEASE"}
$os->{"DISTRIB_CODENAME"}
Truth table25%1/4
A or B or C
A= $os->{"DISTRIB_ID"}B= $os->{"DISTRIB_RELEASE"}C= $os->{"DISTRIB_CODENAME"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | open my $ch, "lsb_release -a 2>&1 |" or return; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | my %map = ( | |||||||||||||||||||||||||||||||||||||||||||||
| 81 | "LSB Version" => "don't care", | ||||||||||||||||||||||||||||||||||||||||||||||
| 82 | "Distributor ID" => "DISTRIB_ID", | ||||||||||||||||||||||||||||||||||||||||||||||
| 83 | "Description" => "DISTRIB_DESCRIPTION", | ||||||||||||||||||||||||||||||||||||||||||||||
| 84 | "Release" => "DISTRIB_RELEASE", | ||||||||||||||||||||||||||||||||||||||||||||||
| 85 | "Code" => "DISTRIB_CODENAME", | ||||||||||||||||||||||||||||||||||||||||||||||
| 86 | ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | while (<$ch>) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | chomp; | |||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | m/^\s*(\S.*?)\s*:\s*(.*?)\s*$/ or next; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | $os->{$map{$1} || $1} ||= $2 unless $2 eq "n/a"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$$os{$map{$1} or $1} ||= $2
$map{$1} || $1
MC/DC0%0/2
$$os{$map{$1} or $1} ||= $2
$$os{$map{$1} or $1}
$2
MC/DC0%0/2
$map{$1} || $1
$map{$1}
$1
Truth table0%0/3
A ||= B
A= $$os{$map{$1} or $1}B= $2
Truth table0%0/3
A || B
A= $map{$1}B= $1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } # _lsb_release | ||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 137 | ▶ | sub prepare_os { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prepare_os: called CC=55 SCAR=42.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 137 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 137 | ▶ | my $etc = $ENV{SMOKE_USE_ETC} || "/etc"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$ENV{'SMOKE_USE_ETC'} || '/etc'
MC/DC100%1/1
$ENV{'SMOKE_USE_ETC'} || '/etc'
$ENV{'SMOKE_USE_ETC'}
Truth table100%2/2
A
A= $ENV{'SMOKE_USE_ETC'}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 1142 | ▶ | my @dist_file = grep { -f $_ && -s _ } map { | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
-f $_ && -s _
MC/DC100%2/2
-f $_ && -s _
-f $_
-s _
Truth table100%3/3
A && B
A= -f $_B= -s _
| |||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 3 | ▶ | -d $_ ? glob ("$_/*") : ($_) | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 100 | } glob ("$etc/*[-_][rRvV][eE][lLrR]*"), "$etc/issue", | ||||||||||||||||||||||||||||||||||||||||||||||
| 101 | "$etc.defaults/VERSION", "$etc/VERSION", "$etc/release"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 137 | my $os = $self->_os; | |||||||||||||||||||||||||||||||||||||||||||||
| 104 | 137 | my %os; | |||||||||||||||||||||||||||||||||||||||||||||
| 105 | my $distro; | ||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 137 | foreach my $df (@dist_file) { | |||||||||||||||||||||||||||||||||||||||||||||
| 107 | # use "debian" out of /etc/debian-release | ||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 551 | ▶ | unless (defined $distro or $df =~ m/\blsb-/) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $distro or $df =~ /\blsb-/
MC/DC100%2/2
defined $distro or $df =~ /\blsb-/
defined $distro
$df =~ /\blsb-/
Truth table100%3/3
A or B
A= defined $distroB= $df =~ /\blsb-/
| |||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 137 | ($distro = $df) =~ s{^$etc(?:\.defaults)?/}{}i; | |||||||||||||||||||||||||||||||||||||||||||||
| 110 | 137 | $distro =~ s{[-_]?(?:release|version)\b}{}i; | |||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 551 | _file_info ($df, \%os); | |||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 137 | _lsb_release (\%os); | |||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 137 | ▶ | keys %os or return; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 137 | foreach my $key (keys %os) { | |||||||||||||||||||||||||||||||||||||||||||||
| 119 | 2161 | my $KEY = uc $key; | |||||||||||||||||||||||||||||||||||||||||||||
| 120 | 2161 | ▶ | defined $os{$key} or next; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 1767 | ▶ | exists $os{$KEY} or $os{$KEY} = $os{$key}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 137 | ▶ | if ($os{DISTRIB_DESCRIPTION}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 7 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 29 | $distro = $os{DISTRIB_DESCRIPTION}; | |||||||||||||||||||||||||||||||||||||||||||||
| 126 | 29 | ▶ | $os{DISTRIB_CODENAME} && $distro !~ m{\b$os{DISTRIB_CODENAME}\b}i and | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$os{"DISTRIB_CODENAME"} and not $distro =~ /\b$os{"DISTRIB_CODENAME"}\b/i
MC/DC100%2/2
$os{"DISTRIB_CODENAME"} and not $distro =~ /\b$os{"DISTRIB_CODENAME"}\b/i
$os{"DISTRIB_CODENAME"}
not $distro =~ /\b$os{"DISTRIB_CODENAME"}\b/i
Truth table100%3/3
A and not(B)
A= $os{"DISTRIB_CODENAME"}B= not $distro =~ /\b$os{"DISTRIB_CODENAME"}\b/i
| |||||||||||||||||||||||||||||||||||||||||||||||
| 127 | $distro .= " ($os{DISTRIB_CODENAME})"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 29 | ▶ | if ($os{VERSION_ID} && $distro !~ m{\b$os{VERSION_ID}\b}i) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
$os{"VERSION_ID"} and not $distro =~ /\b$os{"VERSION_ID"}\b/i
MC/DC100%2/2
$os{"VERSION_ID"} and not $distro =~ /\b$os{"VERSION_ID"}\b/i
$os{"VERSION_ID"}
not $distro =~ /\b$os{"VERSION_ID"}\b/i
Truth table100%3/3
A and not(B)
A= $os{"VERSION_ID"}B= not $distro =~ /\b$os{"VERSION_ID"}\b/i
| |||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 1 | $distro .= " $os{VERSION_ID}"; | |||||||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 131 | ▶ | elsif ($os{DISTRIB_RELEASE} && $distro !~ m{\b$os{DISTRIB_RELEASE}\b}i) { | |||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$os{"DISTRIB_RELEASE"} and not $distro =~ /\b$os{"DISTRIB_RELEASE"}\b/i
MC/DC0%0/2
$os{"DISTRIB_RELEASE"} and not $distro =~ /\b$os{"DISTRIB_RELEASE"}\b/i
$os{"DISTRIB_RELEASE"}
not $distro =~ /\b$os{"DISTRIB_RELEASE"}\b/i
Truth table33%1/3
A and not(B)
A= $os{"DISTRIB_RELEASE"}B= not $distro =~ /\b$os{"DISTRIB_RELEASE"}\b/i
| |||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | $distro .= " $os{DISTRIB_RELEASE}"; | |||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 135 | ▶ | elsif ($os{DISTRIBVER} && defined $os{NETBSD_OFFICIAL_RELEASE}) { # NetBSD 9 | |||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$os{"DISTRIBVER"} and defined $os{"NETBSD_OFFICIAL_RELEASE"}
MC/DC100%2/2
$os{"DISTRIBVER"} and defined $os{"NETBSD_OFFICIAL_RELEASE"}
$os{"DISTRIBVER"}
defined $os{"NETBSD_OFFICIAL_RELEASE"}
Truth table100%3/3
A and B
A= $os{"DISTRIBVER"}B= defined $os{"NETBSD_OFFICIAL_RELEASE"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 1 | my @k = grep m/^netbsd\s+\d/i => keys %os; | |||||||||||||||||||||||||||||||||||||||||||||
| 137 | 1 | ▶ | ($distro = @k == 1 ? $k[0] : "NetBSD $os{DISTRIBVER}") =~ s{/.*}{}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 139 | elsif ($os{PRETTY_NAME}) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 76 | $distro = $os{PRETTY_NAME}; # "openSUSE 12.1 (Asparagus) (x86_64)" | |||||||||||||||||||||||||||||||||||||||||||||
| 141 | 76 | ▶ | if (my $vid = $os{VERSION_ID}) { # wheezy 7 => 7.2 | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 75 | my @rv; | |||||||||||||||||||||||||||||||||||||||||||||
| 143 | 75 | ▶ | if (@rv = grep m{^$vid\.} => sort keys %os) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 144 | # from /etc/debian_version | ||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 14 | ▶ | $rv[0] =~ m/^[0-9]+\.\w+$/ and | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 146 | $distro =~ s/\b$vid\b/$rv[0]/; | ||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 75 | ▶ | if (!@rv && defined $os{NAME} and # CentOS Linux 7 = CentOS Linux 7.1.1503 | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
not @rv and defined $os{"NAME"} and @rv = grep(/^$os{"NAME"} (?:(?:release|version)\s+)?$vid\./, sort(keys %os))
not @rv and defined $os{"NAME"}
MC/DC66%2/3
not @rv and defined $os{"NAME"} and @rv = grep(/^$os{"NAME"} (?:(?:release|version)\s+)?$vid\./, sort(keys %os))
not @rv
defined $os{"NAME"}
@rv = grep(/^$os{"NAME"} (?:(?:release|version)\s+)?$vid\./, sort(keys %os))
Truth table75%3/4
not(A) and B and C
A= not @rvB= defined $os{"NAME"}C= @rv = grep(/^$os{"NAME"} (?:(?:release|version)\s+)?$vid\./, sort(keys %os))
| |||||||||||||||||||||||||||||||||||||||||||||||
| 149 | @rv = grep m{^$os{NAME} (?:(?:release|version)\s+)?$vid\.} => sort keys %os) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 13 | ▶ | if ($rv[0] =~ m/\s($vid\.[-.\w]+)/) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 13 | my $vr = $1; | |||||||||||||||||||||||||||||||||||||||||||||
| 152 | 13 | $distro =~ s/\s$vid\b/ $vr/; | |||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 76 | $distro =~ s{\s*[-:/,]\s*Version\s*:?\s*}{ }; | |||||||||||||||||||||||||||||||||||||||||||||
| 157 | 76 | $distro =~ s/\)\s+\(\w+\)\s*$/)/; # remove architectural part | |||||||||||||||||||||||||||||||||||||||||||||
| 158 | 76 | $distro =~ s/\s+\(?(?:i\d86|x86_64)\)?\s*$//; # i386 i486 i586 x86_64 | |||||||||||||||||||||||||||||||||||||||||||||
| 159 | 76 | ▶ | $os{VERSION_ID} && $distro !~ m{\b$os{VERSION_ID}\b}i and | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$os{"VERSION_ID"} and not $distro =~ /\b$os{"VERSION_ID"}\b/i
MC/DC100%2/2
$os{"VERSION_ID"} and not $distro =~ /\b$os{"VERSION_ID"}\b/i
$os{"VERSION_ID"}
not $distro =~ /\b$os{"VERSION_ID"}\b/i
Truth table100%3/3
A and not(B)
A= $os{"VERSION_ID"}B= not $distro =~ /\b$os{"VERSION_ID"}\b/i
| |||||||||||||||||||||||||||||||||||||||||||||||
| 160 | $distro .= " $os{VERSION_ID}"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 162 | ▶ | elsif ($os{VERSION} && $os{NAME}) { | |||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$os{"VERSION"} and $os{"NAME"}
MC/DC0%0/2
$os{"VERSION"} and $os{"NAME"}
$os{"VERSION"}
$os{"NAME"}
Truth table66%2/3
A and B
A= $os{"VERSION"}B= $os{"NAME"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | $distro = qq{$os{NAME} $os{VERSION}}; | |||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 165 | ▶ | elsif ($os{VERSION} && $os{CODENAME}) { | |||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$os{"VERSION"} and $os{"CODENAME"}
MC/DC100%2/2
$os{"VERSION"} and $os{"CODENAME"}
$os{"VERSION"}
$os{"CODENAME"}
Truth table100%3/3
A and B
A= $os{"VERSION"}B= $os{"CODENAME"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 1 | ▶ | if (my @welcome = grep s{^\s*Welcome\s+to\s+(\S*$distro\S*)\b.*}{$1}i => keys %os) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 1 | $distro = $welcome[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 1 | $distro .= qq{ $os{VERSION}}; | |||||||||||||||||||||||||||||||||||||||||||||
| 170 | 1 | ▶ | $distro =~ m/\b$os{CODENAME}\b/ or | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 171 | $distro .= qq{ ($os{CODENAME})}; | ||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 173 | ▶ | elsif ($os{MAJORVERSION} && defined $os{MINORVERSION}) { | |||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$os{"MAJORVERSION"} and defined $os{"MINORVERSION"}
MC/DC50%1/2
$os{"MAJORVERSION"} and defined $os{"MINORVERSION"}
$os{"MAJORVERSION"}
defined $os{"MINORVERSION"}
Truth table66%2/3
A and B
A= $os{"MAJORVERSION"}B= defined $os{"MINORVERSION"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 11 | ▶ | -d "/usr/syno" || "@dist_file" =~ m{^\S*/VERSION$} and $distro .= "DSM"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
-d "/usr/syno" or join($", @dist_file) =~ m[^\S*/VERSION$]
MC/DC0%0/2
-d "/usr/syno" or join($", @dist_file) =~ m[^\S*/VERSION$]
-d "/usr/syno"
join($", @dist_file) =~ m[^\S*/VERSION$]
Truth table33%1/3
A or B
A= -d "/usr/syno"B= join($", @dist_file) =~ m[^\S*/VERSION$]
| |||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 11 | $distro .= qq{ $os{MAJORVERSION}.$os{MINORVERSION}}; | |||||||||||||||||||||||||||||||||||||||||||||
| 176 | 11 | ▶ | $os{BUILDNUMBER} and $distro .= qq{-$os{BUILDNUMBER}}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 11 | ▶ | $os{SMALLFIXNUMBER} and $distro .= qq{-$os{SMALLFIXNUMBER}}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 179 | ▶ | elsif ($os{DISTRIBVER} && exists $os{NETBSDSRCDIR}) { | |||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$os{"DISTRIBVER"} and exists $os{"NETBSDSRCDIR"}
MC/DC50%1/2
$os{"DISTRIBVER"} and exists $os{"NETBSDSRCDIR"}
$os{"DISTRIBVER"}
exists $os{"NETBSDSRCDIR"}
Truth table66%2/3
A and B
A= $os{"DISTRIBVER"}B= exists $os{"NETBSDSRCDIR"}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 2 | (my $dv = $os{DISTRIBVER}) =~ tr{ ''"";}{}d; | |||||||||||||||||||||||||||||||||||||||||||||
| 181 | 2 | $distro .= qq{ NetBSD $dv}; | |||||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 183 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 184 | # /etc/issue: | ||||||||||||||||||||||||||||||||||||||||||||||
| 185 | # Welcome to SUSE LINUX 10.0 "Prague" (i586) - Kernel \r (\l). | ||||||||||||||||||||||||||||||||||||||||||||||
| 186 | # Welcome to openSUSE 10.1 "Agama Lizard" (i586) - Kernel \r (\l). | ||||||||||||||||||||||||||||||||||||||||||||||
| 187 | # Welcome to openSUSE 10.2 (i586) - Kernel \r (\l). | ||||||||||||||||||||||||||||||||||||||||||||||
| 188 | # Welcome to openSUSE 10.2 "Basilisk Lizard" (X86-64) - Kernel \r (\l). | ||||||||||||||||||||||||||||||||||||||||||||||
| 189 | # Welcome to openSUSE 10.3 (i586) - Kernel \r (\l). | ||||||||||||||||||||||||||||||||||||||||||||||
| 190 | # Welcome to openSUSE 10.3 (X86-64) - Kernel \r (\l). | ||||||||||||||||||||||||||||||||||||||||||||||
| 191 | # Welcome to openSUSE 11.1 - Kernel \r (\l). | ||||||||||||||||||||||||||||||||||||||||||||||
| 192 | # Welcome to openSUSE 11.2 "Emerald" - Kernel \r (\l). | ||||||||||||||||||||||||||||||||||||||||||||||
| 193 | # Welcome to openSUSE 11.3 "Teal" - Kernel \r (\l). | ||||||||||||||||||||||||||||||||||||||||||||||
| 194 | # Welcome to openSUSE 11.4 "Celadon" - Kernel \r (\l). | ||||||||||||||||||||||||||||||||||||||||||||||
| 195 | # Welcome to openSUSE 12.1 "Asparagus" - Kernel \r (\l). | ||||||||||||||||||||||||||||||||||||||||||||||
| 196 | # Welcome to openSUSE 12.2 "Mantis" - Kernel \r (\l). | ||||||||||||||||||||||||||||||||||||||||||||||
| 197 | # Welcome to openSUSE 12.3 "Dartmouth" - Kernel \r (\l). | ||||||||||||||||||||||||||||||||||||||||||||||
| 198 | # Welcome to openSUSE 13.1 "Bottle" - Kernel \r (\l). | ||||||||||||||||||||||||||||||||||||||||||||||
| 199 | # Welcome to openSUSE 13.2 "Harlequin" - Kernel \r (\l). | ||||||||||||||||||||||||||||||||||||||||||||||
| 200 | # Welcome to openSUSE Leap 42.1 - Kernel \r (\l). | ||||||||||||||||||||||||||||||||||||||||||||||
| 201 | # Welcome to openSUSE 20151218 "Tumbleweed" - Kernel \r (\l). | ||||||||||||||||||||||||||||||||||||||||||||||
| 202 | # Welcome to SUSE Linux Enterprise Server 11 SP1 for VMware (x86_64) - Kernel \r (\l). | ||||||||||||||||||||||||||||||||||||||||||||||
| 203 | # Ubuntu 10.04.4 LTS \n \l | ||||||||||||||||||||||||||||||||||||||||||||||
| 204 | # Debian GNU/Linux wheezy/sid \n \l | ||||||||||||||||||||||||||||||||||||||||||||||
| 205 | # Debian GNU/Linux 6.0 \n \l | ||||||||||||||||||||||||||||||||||||||||||||||
| 206 | # CentOS release 6.4 (Final) | ||||||||||||||||||||||||||||||||||||||||||||||
| 207 | # /etc/redhat-release: | ||||||||||||||||||||||||||||||||||||||||||||||
| 208 | # CentOS release 5.7 (Final) | ||||||||||||||||||||||||||||||||||||||||||||||
| 209 | # CentOS release 6.4 (Final) | ||||||||||||||||||||||||||||||||||||||||||||||
| 210 | # Red Hat Enterprise Linux ES release 4 (Nahant Update 2) | ||||||||||||||||||||||||||||||||||||||||||||||
| 211 | # /etc/debian_version: | ||||||||||||||||||||||||||||||||||||||||||||||
| 212 | # 6.0.4 | ||||||||||||||||||||||||||||||||||||||||||||||
| 213 | # wheezy/sid | ||||||||||||||||||||||||||||||||||||||||||||||
| 214 | # squeeze/sid | ||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 17 | my @key = sort keys %os; | |||||||||||||||||||||||||||||||||||||||||||||
| 217 | 17 | s/\s*\\[rln].*// for @key; | |||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 17 | my @vsn = grep m/^[0-9.]+$/ => @key; | |||||||||||||||||||||||||||||||||||||||||||||
| 220 | #$self->{__X__} = { os => \%os, key => \@key, vsn => \@vsn }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 17 | ▶ | if (my @welcome = grep s{^\s*Welcome\s+to\s+}{}i => @key) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 3 | ($distro = $welcome[0]) =~ s/"([^"]+)"/($1)/; | |||||||||||||||||||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 225 | elsif (my @rel = grep m{\brelease\b}i => @key) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 12 | ▶ | @rel > 1 && $rel[0] =~ m/^Enterprise Linux Enterprise/ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
@rel > 1 and $rel[0] =~ /^Enterprise Linux Enterprise/ and $rel[1] =~ /^Oracle Linux/
@rel > 1 and $rel[0] =~ /^Enterprise Linux Enterprise/
MC/DC33%1/3
@rel > 1 and $rel[0] =~ /^Enterprise Linux Enterprise/ and $rel[1] =~ /^Oracle Linux/
@rel > 1
$rel[0] =~ /^Enterprise Linux Enterprise/
$rel[1] =~ /^Oracle Linux/
Truth table50%2/4
A and B and C
A= @rel > 1B= $rel[0] =~ /^Enterprise Linux Enterprise/C= $rel[1] =~ /^Oracle Linux/
| |||||||||||||||||||||||||||||||||||||||||||||||
| 227 | && $rel[1] =~ m/^Oracle Linux/ and shift @rel; | ||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 12 | $distro = $rel[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 229 | 12 | $distro =~ s/ *release//; | |||||||||||||||||||||||||||||||||||||||||||||
| 230 | 12 | $distro =~ s/Red Hat Enterprise Linux/RHEL/; # Too long for subject | |||||||||||||||||||||||||||||||||||||||||||||
| 231 | # RHEL ES 4 (Nahant Update 2) => RHEL Server 4.2 (Nahant) | ||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 12 | $distro =~ s/^RHEL ES (\d+)\s+(.*)\s+Update\s+(\d+)/RHEL Server $1.$3 $2/; | |||||||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 234 | elsif ( my @lnx = grep m{\bLinux\b}i => @key ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 2 | $distro = $lnx[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 237 | ▶ | elsif ( $distro && @vsn ) { | |||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$distro and @vsn
MC/DC0%0/2
$distro and @vsn
$distro
@vsn
Truth table0%0/3
A and B
A= $distroB= @vsn
| |||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | $distro .= "-$vsn[0]"; | |||||||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 240 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | $distro = $key[0]; | |||||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 17 | $distro =~ s/\s+-\s+Kernel.*//i; | |||||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 137 | ▶ | if ($distro =~ s/^\s*(.*\S)\s*$/$1/) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 137 | $self->{__distro} = $distro; | |||||||||||||||||||||||||||||||||||||||||||||
| 247 | 137 | $os .= " [$distro]"; | |||||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 137 | $self->{__release_info} = \%os; | |||||||||||||||||||||||||||||||||||||||||||||
| 250 | 137 | $self->{__os} = $os; | |||||||||||||||||||||||||||||||||||||||||||||
| 251 | } # prepare_os | ||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||
| 253 | =head2 $si->linux_generic | ||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||
| 255 | Check C</proc/cpuinfo> for these keys: | ||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||
| 257 | =over | ||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||
| 259 | =item "processor" (count occurrence for __cpu_count) | ||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||
| 261 | =item "model name" (part of __cpu) | ||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||
| 263 | =item "vendor_id" (part of __cpu) | ||||||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||||||
| 265 | =item "cpu mhz" (part of __cpu) | ||||||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||||||
| 267 | =item "cpu cores" (add values to add to __cpu_count) | ||||||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||||||
| 269 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||||||
| 271 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 272 | |||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 131 | ▶ | sub linux_generic { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
linux_generic: called CC=18 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 131 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 131 | ▶ | my $n_phys_id = $self->count_unique_in_cpuinfo (qr/^physical id\s+:/) || 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->count_unique_in_cpuinfo(qr/^physical id\s+:/) || 0
MC/DC100%1/1
$self->count_unique_in_cpuinfo(qr/^physical id\s+:/) || 0
$self->count_unique_in_cpuinfo(qr/^physical id\s+:/)
Truth table100%2/2
A
A= $self->count_unique_in_cpuinfo(qr/^physical id\s+:/)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 131 | ▶ | my $n_core_id = $self->count_unique_in_cpuinfo (qr/^core id\s+:/) || 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->count_unique_in_cpuinfo(qr/^core id\s+:/) || 0
MC/DC100%1/1
$self->count_unique_in_cpuinfo(qr/^core id\s+:/) || 0
$self->count_unique_in_cpuinfo(qr/^core id\s+:/)
Truth table100%2/2
A
A= $self->count_unique_in_cpuinfo(qr/^core id\s+:/)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 131 | ▶ | my $n_processor = $self->count_unique_in_cpuinfo (qr/^processor\s+:/) || 0; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->count_unique_in_cpuinfo(qr/^processor\s+:/) || 0
MC/DC0%0/1
$self->count_unique_in_cpuinfo(qr/^processor\s+:/) || 0
$self->count_unique_in_cpuinfo(qr/^processor\s+:/)
Truth table50%1/2
A
A= $self->count_unique_in_cpuinfo(qr/^processor\s+:/)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 131 | ▶ | my $n_cpu = $n_phys_id || $n_core_id || $n_processor; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%4/6
$n_phys_id || $n_core_id || $n_processor
$n_phys_id or $n_core_id
MC/DC0%0/3
$n_phys_id || $n_core_id || $n_processor
$n_phys_id
$n_core_id
$n_processor
Truth table50%2/4
A or B || C
A= $n_phys_idB= $n_core_idC= $n_processor
| |||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||
| 281 | # ::diag"Np: $n_phys_id, NC: $n_core_id, NP: $n_processor, NC: $n_cpu"; | ||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 131 | $self->{__cpu_count} = $n_cpu; | |||||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 131 | { my @tags = ("model name", "vendor_id", "cpu mhz"); | |||||||||||||||||||||||||||||||||||||||||||||
| 285 | 131 | my %info = map { ($_ => $self->from_cpuinfo ($_)) } @tags; | |||||||||||||||||||||||||||||||||||||||||||||
| 286 | 131 | ▶ | unless (defined $info{$tags[0]}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 287 | # riscv64 -> rv64imafdc | ||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | $info{$tags[0]} = $self->from_cpuinfo ("isa"); | |||||||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 131 | ▶ | $info{$tags[2]} and $info{$tags[2]} = sprintf "%.0fMHz", $info{$tags[2]}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 131 | my @cpui; | |||||||||||||||||||||||||||||||||||||||||||||
| 292 | 131 | ▶ | if ($info{$tags[0]}) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 131 | push @cpui => $info{shift @tags}; | |||||||||||||||||||||||||||||||||||||||||||||
| 294 | 131 | push @cpui => "(".(join " " => grep { length } @info{@tags}).")"; | |||||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 296 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | push @cpui => grep { length } @info{@tags}; | |||||||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 131 | $self->{__cpu} = join " " => @cpui; | |||||||||||||||||||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 131 | ▶ | if ($n_phys_id) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 303 | $n_processor > $n_phys_id and | ||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 130 | ▶ | $self->{__cpu_count} .= " [$n_processor cores]"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 130 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 1 | ▶ | if ($n_core_id) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 308 | $n_processor > $n_core_id and | ||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | $self->{__cpu_count} .= " [$n_processor cores]"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 1 | my $n_cores = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 314 | 1 | my $core_id = 0; | |||||||||||||||||||||||||||||||||||||||||||||
| 315 | 1 | my %cores; | |||||||||||||||||||||||||||||||||||||||||||||
| 316 | 1 | for my $cores (grep m/(cpu cores|core id)\s*:\s*\d+/ => $self->_proc_cpuinfo) { | |||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | ▶ | my ($tag, $count) = $cores =~ m/^(.*\S)\s*:\s*(\d+)/ or next; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | if ($tag eq "core id") { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | $core_id = $count; | |||||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 321 | else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | $cores{$core_id} = $count; | |||||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 1 | $n_cores += $cores{$_} for keys %cores; | |||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 1 | ▶ | $n_cores > $n_cpu and $self->{__cpu_count} .= " [$n_cores cores]"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 328 | } # _linux_generic | ||||||||||||||||||||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||||||||||||||||||||
| 330 | =head2 $si->linux_arm | ||||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||
| 332 | Check C</proc/cpuinfo> for these keys: | ||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||
| 334 | =over | ||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||
| 336 | =item "processor" (count occurrence for __cpu_count) | ||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||
| 338 | =item "Processor" (part of __cpu) | ||||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||
| 340 | =item "BogoMIPS" (part of __cpu) | ||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||
| 342 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||
| 344 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 3 | ▶ | sub linux_arm { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
linux_arm: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 3 | $self->{__cpu_count} = $self->count_in_cpuinfo (qr/^processor\s+:\s+/i); | |||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 3 | ▶ | my $cpu = $self->from_cpuinfo ("Processor") || | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->from_cpuinfo('Processor') || $self->from_cpuinfo('Model[_ ]name')
MC/DC0%0/2
$self->from_cpuinfo('Processor') || $self->from_cpuinfo('Model[_ ]name')
$self->from_cpuinfo('Processor')
$self->from_cpuinfo('Model[_ ]name')
Truth table66%2/3
A || B
A= $self->from_cpuinfo('Processor')B= $self->from_cpuinfo('Model[_ ]name')
| |||||||||||||||||||||||||||||||||||||||||||||||
| 352 | $self->from_cpuinfo ("Model[_ ]name"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 3 | my $bogo = $self->from_cpuinfo ("BogoMIPS"); | |||||||||||||||||||||||||||||||||||||||||||||
| 354 | 3 | my $mhz = 100 * int (($bogo + 50) / 100); | |||||||||||||||||||||||||||||||||||||||||||||
| 355 | 3 | $cpu =~ s/\s+/ /g; | |||||||||||||||||||||||||||||||||||||||||||||
| 356 | 3 | ▶ | $mhz and $cpu .= " ($mhz MHz)"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 3 | $self->{__cpu} = $cpu; | |||||||||||||||||||||||||||||||||||||||||||||
| 358 | } # _linux_arm | ||||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||||
| 360 | =head2 $si->linux_ppc | ||||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||||
| 362 | Check C</proc/cpuinfo> for these keys: | ||||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||
| 364 | =over | ||||||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||||||
| 366 | =item "processor" (count occurrence for __cpu_count) | ||||||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||||||
| 368 | =item "cpu" (part of __cpu) | ||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||
| 370 | =item "machine" (part of __cpu) | ||||||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||||||
| 372 | =item "clock" (part of __cpu) | ||||||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||||||
| 374 | =item "detected" (alters machine if present) | ||||||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||||||
| 376 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||||||
| 378 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 1 | ▶ | sub linux_ppc { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
linux_ppc: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 1 | $self->{__cpu_count} = $self->count_in_cpuinfo (qr/^processor\s+:\s+/); | |||||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 1 | my @tags = qw( cpu machine clock ); | |||||||||||||||||||||||||||||||||||||||||||||
| 386 | 1 | my %info = map { ($_ => $self->from_cpuinfo ($_)) } @tags; | |||||||||||||||||||||||||||||||||||||||||||||
| 387 | 1 | ▶ | if ($info{detected} = $self->from_cpuinfo ("detected as")){ | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 1 | $info{detected} =~ s/.*(\b.+Mac G\d).*/$1/; | |||||||||||||||||||||||||||||||||||||||||||||
| 389 | 1 | $info{machine} = $info{detected}; | |||||||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 1 | $self->{__cpu} = sprintf "%s %s (%s)", map { $info{$_} } @tags; | |||||||||||||||||||||||||||||||||||||||||||||
| 393 | } # linux_ppc | ||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||
| 395 | =head2 $si->linux_sparc | ||||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||||
| 397 | Check C</proc/cpuinfo> for these keys: | ||||||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||||||
| 399 | =over | ||||||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||||||
| 401 | =item "processor" (count occurrence for __cpu_count) | ||||||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||||||
| 403 | =item "cpu" (part of __cpu) | ||||||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||||||
| 405 | =item "Cpu0ClkTck" (part of __cpu) | ||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||
| 407 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||||||
| 409 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | ▶ | sub linux_sparc { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
linux_sparc: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | $self->{__cpu_count} = $self->from_cpuinfo ("ncpus active"); | |||||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | my @tags = qw( cpu Cpu0ClkTck ); | |||||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | my %info = map { ($_ => $self->from_cpuinfo ($_)) } @tags; | |||||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | my $cpu = $info{cpu}; | |||||||||||||||||||||||||||||||||||||||||||||
| 419 | $info{Cpu0ClkTck} and | ||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | ▶ | $cpu .= sprintf " (%.0fMHz)", hex ($info{Cpu0ClkTck}) / 1_000_000; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | $self->{__cpu} = $cpu; | |||||||||||||||||||||||||||||||||||||||||||||
| 422 | } # linux_sparc | ||||||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||||||
| 424 | =head2 $si->linux_s390x | ||||||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||||||
| 426 | Check C</proc/cpuinfo> for these keys: | ||||||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||||||
| 428 | =over | ||||||||||||||||||||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||||||||||||||||||||
| 430 | =item "processor" (count occurrence for __cpu_count) | ||||||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||||||
| 432 | =item "Processor" (part of __cpu) | ||||||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||||||
| 434 | =item "BogoMIPS" (part of __cpu) | ||||||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||||||
| 436 | =back | ||||||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||||||
| 438 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 2 | ▶ | sub linux_s390x { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
linux_s390x: called CC=4 SCAR=15.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 2 | $self->{__cpu_count} = $self->count_in_cpuinfo (qr/^processor\s+\d+:\s+/i); | |||||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 2 | ▶ | my $cpu = $self->from_cpuinfo ("vendor_id") || | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%2/6
$self->from_cpuinfo('vendor_id') || $self->from_cpuinfo('Processor') || $self->from_cpuinfo('Model[_ ]name')
$self->from_cpuinfo("vendor_id") or $self->from_cpuinfo("Processor")
MC/DC0%0/3
$self->from_cpuinfo('vendor_id') || $self->from_cpuinfo('Processor') || $self->from_cpuinfo('Model[_ ]name')
$self->from_cpuinfo("vendor_id")
$self->from_cpuinfo("Processor")
$self->from_cpuinfo('Model[_ ]name')
Truth table25%1/4
A or B || C
A= $self->from_cpuinfo("vendor_id")B= $self->from_cpuinfo("Processor")C= $self->from_cpuinfo('Model[_ ]name')
| |||||||||||||||||||||||||||||||||||||||||||||||
| 446 | $self->from_cpuinfo ("Processor") || | ||||||||||||||||||||||||||||||||||||||||||||||
| 447 | $self->from_cpuinfo ("Model[_ ]name"); | ||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 2 | my $bogo = $self->from_cpuinfo (qr{BogoMIPS(?:\s*per[ _]CPU)?}i); | |||||||||||||||||||||||||||||||||||||||||||||
| 449 | 2 | my $mhz = 100 * int (($bogo + 50) / 100); | |||||||||||||||||||||||||||||||||||||||||||||
| 450 | 2 | $cpu =~ s/\s+/ /g; | |||||||||||||||||||||||||||||||||||||||||||||
| 451 | 2 | ▶ | $mhz and $cpu .= " ($mhz MHz)"; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 2 | $self->{__cpu} = $cpu; | |||||||||||||||||||||||||||||||||||||||||||||
| 453 | } # _linux_s390x | ||||||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||||||
| 455 | =head2 $si->prepare_proc_cpuinfo | ||||||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||||||
| 457 | Read the complete C<< /proc/cpuinfo >>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||||||
| 459 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 137 | ▶ | sub prepare_proc_cpuinfo { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prepare_proc_cpuinfo: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 137 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 137 | ▶ | if (open my $pci, "<", "/proc/cpuinfo") { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 137 | chomp (my @pci = <$pci>); | |||||||||||||||||||||||||||||||||||||||||||||
| 466 | 137 | s/[\s\xa0]+/ /g for @pci; | |||||||||||||||||||||||||||||||||||||||||||||
| 467 | 137 | s/ $// for @pci; | |||||||||||||||||||||||||||||||||||||||||||||
| 468 | 137 | $self->{__proc_cpuinfo} = \@pci; | |||||||||||||||||||||||||||||||||||||||||||||
| 469 | 137 | close $pci; | |||||||||||||||||||||||||||||||||||||||||||||
| 470 | 137 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 472 | } # prepare_proc_cpuinfo | ||||||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||||||
| 474 | =head2 $si->count_in_cpuinfo ($regex) | ||||||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||||||
| 476 | Returns the number of lines $regex matches for. | ||||||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||||||
| 478 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 6 | ▶ | sub count_in_cpuinfo { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
count_in_cpuinfo: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 6 | my ($self, $regex) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 6 | return scalar grep /$regex/, $self->_proc_cpuinfo; | |||||||||||||||||||||||||||||||||||||||||||||
| 484 | } # count_in_cpuinfo | ||||||||||||||||||||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||||||||||||||||||||
| 486 | =head2 $si->count_unique_in_cpuinfo ($regex) | ||||||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||||||
| 488 | Returns the number of lines $regex matches for. | ||||||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||||||
| 490 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 393 | ▶ | sub count_unique_in_cpuinfo { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
count_unique_in_cpuinfo: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 393 | my ($self, $regex) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 393 | my %match = map { $_ => 1 } grep /$regex/ => $self->_proc_cpuinfo; | |||||||||||||||||||||||||||||||||||||||||||||
| 496 | 393 | return scalar keys %match; | |||||||||||||||||||||||||||||||||||||||||||||
| 497 | } # count_unique_in_cpuinfo | ||||||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||||||
| 499 | =head2 $si->from_cpuinfo ($key) | ||||||||||||||||||||||||||||||||||||||||||||||
| 500 | |||||||||||||||||||||||||||||||||||||||||||||||
| 501 | Returns the first value of that key in C<< /proc/cpuinfo >>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||||||
| 503 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 408 | ▶ | sub from_cpuinfo { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
from_cpuinfo: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 408 | my ($self, $key) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 408 | my ($first) = grep m/^\s*$key\s*[:=]\s*/i => $self->_proc_cpuinfo; | |||||||||||||||||||||||||||||||||||||||||||||
| 509 | 408 | ▶ | defined $first or $first = ""; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 408 | $first =~ s/^\s*$key\s*[:=]\s*//i; | |||||||||||||||||||||||||||||||||||||||||||||
| 511 | 408 | return $first; | |||||||||||||||||||||||||||||||||||||||||||||
| 512 | } # from_cpuinfo | ||||||||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||||||
| 516 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||