Info/BSD.pm

filter: Statementstmt 39.2% 11 / 28 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 60.0% 3 / 5 Podpod 100% 1 / 1 totaltotal 32.6% 15 / 46 CC 7 SCAR 28.4
CC
7
Cov
28%
prepare_sysinfo
30.0
__get_sysctl
12.0
BEGIN
1.0
CRAP 17.2
« Info/Solaris.pm ↑ Summary Info/Darwin.pm »
1 package System::Info::BSD;
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.051";
9  
10 =head1 NAME
11  
12 System::Info::BSD - Object for specific BSD 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=5 SCAR=34.0
Pod documented
23 0 my $self = shift;
24 0 $self->SUPER::prepare_sysinfo;
25  
26 0 my $sysctl = __get_sysctl ();
27 0 $self->{__sysctl} = $sysctl;
28  
29 0 my $cpu = $sysctl->{model};
30  
31 0 ▶ if (exists $sysctl->{cpuspeed}) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $sysctl->{'cpuspeed'}) { } 0 0 0
elsif (exists $sysctl->{'cpufrequency'}) { } 0 0 0
32 0 $cpu .= sprintf " (%.0f MHz)", $sysctl->{cpuspeed};
33 }
34 elsif (exists $sysctl->{cpufrequency}) {
35 0 $cpu .= sprintf " (%.0f MHz)", $sysctl->{cpufrequency}/1_000_000;
36 }
37  
38 0 ▶ $self->{__cpu_type} = $sysctl->{machine} if $sysctl->{machine};
Branch: 1 branch
BranchTrueFalseTotal
if $sysctl->{"machine"} 0 0 0
39 0 ▶ $self->{__cpu} = $cpu if $cpu;
Branch: 1 branch
BranchTrueFalseTotal
if $cpu 0 0 0
40 0 $self->{__cpu_count} = $sysctl->{ncpu};
41  
42 0 return $self;
43 } # prepare_sysinfo
44  
45 0 ▶sub __get_sysctl {
Subroutine __get_sysctl: not called CC=3 SCAR=24.8
46 0 ▶ my $sysctl_cmd = -x "/sbin/sysctl" ? "/sbin/sysctl" : "sysctl";
Branch: 1 branch
BranchTrueFalseTotal
-x '/sbin/sysctl' ? : 0 0 0
47  
48 0 chomp (my @sysctl = `$sysctl_cmd -a hw`);
49 0 my %sysctl = map m/^hw\.([\w.]+)\s*[:=]\s*(.*)$/ => @sysctl;
50 0 ▶ $sysctl{machine} and $sysctl{machine} =~ s/Power Macintosh/macppc/;
Branch: 1 branch
BranchTrueFalseTotal
$sysctl{"machine"} and $sysctl{"machine"} =~ s/Power Macintosh/macppc/ 0 0 0
51  
52 0 return \%sysctl;
53 } # __get_sysctl
54  
55 3 1;
56  
57 __END__
« Info/Solaris.pm ↑ Summary Info/Darwin.pm »