Info/HPUX.pm

filter: Statementstmt 16.9% 11 / 65 Branchbran 0.0% 0 / 48 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 60.0% 3 / 5 Podpod 100% 1 / 1 totaltotal 11.1% 15 / 134 CC 29 SCAR 65.4
CC
29
Cov
9%
_prepare_cpu_type
812.0
prepare_sysinfo
6.0
BEGIN
1.0
CRAP 689.4
↑ Summary Info/Linux.pm »
1 package System::Info::HPUX;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use base "System::Info::Base";
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 our $VERSION = "0.051";
9  
10 =head1 NAME
11  
12 System::Info::HPUX - Object for specific HP-UX 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 0 ▶sub prepare_sysinfo {
Subroutine prepare_sysinfo: not called CC=2 SCAR=17.9
Pod documented
23 0 my $self = shift;
24 0 $self->SUPER::prepare_sysinfo;
25  
26 0 $self->{__os} =~ s/hp-ux/HP-UX/;
27 0 chomp (my $k64 = `/usr/bin/getconf KERNEL_BITS 2>/dev/null`);
28 0 ▶ length $k64 and $self->{__os} .= "/$k64";
Branch: 1 branch
BranchTrueFalseTotal
length $k64 and $self->{"__os"} .= "/$k64" 0 0 0
29  
30 # ioscan is always available
31 0 $self->{__cpu_count} = grep m/^processor/ => `/usr/sbin/ioscan -knfCprocessor`;
32  
33 0 $self->_prepare_cpu_type;
34 0 return $self;
35 } # prepare_sysinfo
36  
37 0 ▶sub _prepare_cpu_type {
Subroutine _prepare_cpu_type: not called CC=28 SCAR=67.0
38 0 my $self = shift;
39  
40 0 my $parisc = 0;
41 # For now, unknown cpu_types are set as the Generic
42 0 chomp (my $cv = `/usr/bin/getconf CPU_VERSION 2>/dev/null`);
43  
44 # see /usr/include/sys/unistd.h for hex values
45 0 ▶ if ($cv < 0x20B) {
Branch: 4 branches
BranchTrueFalseTotal
if ($cv < 523) { } 0 0 0
elsif ($cv >= 524 and $cv <= 526) { } 0 0 0
elsif ($cv <= 767) { } 0 0 0
elsif ($cv == 768) { } 0 0 0
46 # $self->{__cpu_type} = sprintf("Unknown CPU_VERSION 0x%x", $cv);
47 }
48 ▶ elsif ($cv >= 0x20C && $cv <= 0x20E) {
Condition0%0/3
$cv >= 524 and $cv <= 526
!ll&&!rl&&r
000
MC/DC0%0/2
$cv >= 524 and $cv <= 526
$cv >= 524 $cv <= 526
Truth table0%0/3
A and B
A= $cv >= 524B= $cv <= 526
ABresult
0X0
100
111
49 0 $self->{__cpu_type} = "Motorola"; # You have an antique
50 }
51 elsif ($cv <= 0x2FF) {
52 0 $self->{__cpu_type} = "PA-RISC";
53 0 ▶ $self->{__cpu_type} = "PA-RISC1.0" if $cv == 0x20B;
Branch: 1 branch
BranchTrueFalseTotal
if $cv == 523 0 0 0
54 0 ▶ $self->{__cpu_type} = "PA-RISC1.1" if $cv == 0x210;
Branch: 1 branch
BranchTrueFalseTotal
if $cv == 528 0 0 0
55 0 ▶ $self->{__cpu_type} = "PA-RISC1.2" if $cv == 0x211;
Branch: 1 branch
BranchTrueFalseTotal
if $cv == 529 0 0 0
56 0 ▶ $self->{__cpu_type} = "PA-RISC2.0" if $cv == 0x214;
Branch: 1 branch
BranchTrueFalseTotal
if $cv == 532 0 0 0
57 0 $parisc++;
58 }
59 elsif ($cv == 0x300) {
60 0 $self->{__cpu_type} = "ia64";
61 }
62 else {
63 # $self->{__cpu_type} = sprintf("Unknown CPU_VERSION 0x%x", $cv);
64 }
65 0 ▶ if ($parisc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parisc) { } 0 0 0
66 0 my (@cpu, $lst);
67 0 chomp (my $model = `model`);
68 0 (my $m = $model) =~ s{.*/}{};
69 0 foreach my $f (qw( /usr/sam/lib/mo/sched.models
70 /opt/langtools/lib/sched.models )) {
71 0 ▶ if (open my $fh, "<", $f) {
Branch: 1 branch
BranchTrueFalseTotal
if (open my $fh, "<", $f) 0 0 0
72 0 @cpu = grep m/$m/i => <$fh>;
73 0 close $fh;
74 0 ▶ @cpu and last;
Branch: 1 branch
BranchTrueFalseTotal
@cpu and last 0 0 0
75 }
76 }
77 0 ▶ if (@cpu == 0 && open my $lst,
Branch: 1 branch
BranchTrueFalseTotal
if (@cpu == 0 and open my $lst, "echo 'sc product cpu;il' | /usr/sbin/cstm |") 0 0 0
Condition0%0/3
@cpu == 0 and open my $lst, "echo 'sc product cpu;il' | /usr/sbin/cstm |"
!ll&&!rl&&r
000
MC/DC0%0/2
@cpu == 0 and open my $lst, "echo 'sc product cpu;il' | /usr/sbin/cstm |"
@cpu == 0 open my $lst, "echo 'sc product cpu;il' | /usr/sbin/cstm |"
Truth table0%0/3
A and B
A= @cpu == 0B= open my $lst, "echo 'sc product cpu;il' | /usr/sbin/cstm |"
ABresult
0X0
100
111
78 "echo 'sc product cpu;il' | /usr/sbin/cstm |") {
79 0 ▶ while (<$lst>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $lst)) 0 0 0
80 0 ▶ s/^\s*(PA)\s*(\d+)\s+CPU Module.*/$m 1.1 $1$2/ or next;
Branch: 1 branch
BranchTrueFalseTotal
s/^\s*(PA)\s*(\d+)\s+CPU Module.*/$m 1.1 $1$2/ or next 0 0 0
81 0 ▶ $2 =~ m/^8/ and s/ 1.1 / 2.0 /;
Branch: 1 branch
BranchTrueFalseTotal
$2 =~ /^8/ and s/ 1.1 / 2.0 / 0 0 0
82 0 push @cpu, $_;
83 }
84 }
85 0 ▶ if (@cpu and $cpu[0] =~ m/^\S+\s+(\d+\.\d+[a-z]?)\s+(\S+)/) {
Branch: 1 branch
BranchTrueFalseTotal
if (@cpu and $cpu[0] =~ /^\S+\s+(\d+\.\d+[a-z]?)\s+(\S+)/) 0 0 0
Condition0%0/3
@cpu and $cpu[0] =~ /^\S+\s+(\d+\.\d+[a-z]?)\s+(\S+)/
!ll&&!rl&&r
000
MC/DC0%0/2
@cpu and $cpu[0] =~ /^\S+\s+(\d+\.\d+[a-z]?)\s+(\S+)/
@cpu $cpu[0] =~ /^\S+\s+(\d+\.\d+[a-z]?)\s+(\S+)/
Truth table0%0/3
A and B
A= @cpuB= $cpu[0] =~ /^\S+\s+(\d+\.\d+[a-z]?)\s+(\S+)/
ABresult
0X0
100
111
86 0 my ($arch, $cpu) = ("PA-RISC$1", $2);
87 0 $self->{__cpu} = $cpu;
88 0 chomp (my $hw3264 =
89 `/usr/bin/getconf HW_32_64_CAPABLE 2>/dev/null`);
90 0 (my $osvers = $self->{__os}) =~ s/.*[AB]\.//;
91 0 $osvers =~ s{/.*}{};
92 0 ▶ $osvers <= 10.20 and $hw3264 = 0;
Branch: 1 branch
BranchTrueFalseTotal
$osvers <= "10.2" and $hw3264 = 0 0 0 0
93 0 ▶ if ($hw3264 == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if ($hw3264 == 1) { } 0 0 0
elsif ($hw3264 == 0) { } 0 0 0
94 0 $self->{__cpu_type} = $arch . "/64";
95 }
96 elsif ($hw3264 == 0) {
97 0 $self->{__cpu_type} = $arch . "/32";
98 }
99 }
100 }
101 else {
102 0 my $machinfo = `/usr/contrib/bin/machinfo`;
103 0 ▶ if ($machinfo =~ m/processor model:\s+(\d+)\s+(.*)/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($machinfo =~ /processor model:\s+(\d+)\s+(.*)/) { } 0 0 0
elsif ($machinfo =~ /\s*[0-9]+\s+(intel.r.*processor)\s*\(([0-9.]+)\s*([GM])Hz.*/im) { } 0 0 0
104 0 $self->{__cpu} = $2;
105 }
106 elsif ($machinfo =~ m{\s*[0-9]+\s+(intel.r.*processor)\s*\(([0-9.]+)\s*([GM])Hz.*}mi) {
107 0 my ($m, $s, $h) = ($1, $2, $3);
108 0 $m =~ s{ series processor}{};
109 0 ▶ $h eq "G" and $s = int ($s * 1024);
Branch: 1 branch
BranchTrueFalseTotal
$h eq "G" and $s = int $s * 1024 0 0 0
110 0 $self->{__cpu} = "$m/$s";
111 }
112 $machinfo =~ m/Clock\s+speed\s+=\s+(.*)/ and
113 0 ▶ $self->{__cpu} .= "/$1";
Branch: 1 branch
BranchTrueFalseTotal
$machinfo =~ /Clock\s+speed\s+=\s+(.*)/ and $self->{"__cpu"} .= "/$1" 0 0 0
114 }
115  
116 0 (my $v = $self->{__osvers}) =~ s/^[A-Z]+\.//;
117 0 $self->{__distro} = "HP-UX $v";
118 } # _prepare_cpu_type
119  
120 2 1;
121  
122 __END__
↑ Summary Info/Linux.pm »