summaryrefslogtreecommitdiff
path: root/mysql-test/lib/My/SysInfo.pm
diff options
context:
space:
mode:
authorunknown <msvensson@pilot.(none)>2008-05-04 16:35:16 +0200
committerunknown <msvensson@pilot.(none)>2008-05-04 16:35:16 +0200
commit67ea77eaee2c9bb2d3b809e54b2207ab3b5b7d6b (patch)
tree9372bff306c1c516f8b517086d3a46aa4e21bc70 /mysql-test/lib/My/SysInfo.pm
parentf2b57ac042e74695d6fba40de1bbaca3e6173ff1 (diff)
downloadmariadb-git-67ea77eaee2c9bb2d3b809e54b2207ab3b5b7d6b.tar.gz
Always set bogomips unless already set
Return undef only in case kstat works Cpus reported once, but with 'cpu_count' set to the actual number
Diffstat (limited to 'mysql-test/lib/My/SysInfo.pm')
-rw-r--r--mysql-test/lib/My/SysInfo.pm30
1 files changed, 23 insertions, 7 deletions
diff --git a/mysql-test/lib/My/SysInfo.pm b/mysql-test/lib/My/SysInfo.pm
index b764b4548f7..87f768f4866 100644
--- a/mysql-test/lib/My/SysInfo.pm
+++ b/mysql-test/lib/My/SysInfo.pm
@@ -21,7 +21,7 @@ use strict;
use Carp;
use My::Platform;
-
+use constant DEFAULT_BOGO_MIPS => 2000;
sub _cpuinfo {
my ($self)= @_;
@@ -59,7 +59,14 @@ sub _cpuinfo {
}
}
- push(@{$self->{cpus}}, $cpuinfo);
+ # Make sure bogomips is set to some value
+ $cpuinfo->{bogomips} |= DEFAULT_BOGO_MIPS;
+
+ # Cpus reported once, but with 'cpu_count' set to the actual number
+ my $cpu_count= $cpuinfo->{cpu_count} || 1;
+ for(1..$cpu_count){
+ push(@{$self->{cpus}}, $cpuinfo);
+ }
}
$F= undef; # Close file
return $self;
@@ -71,7 +78,7 @@ sub _kstat {
while (1){
my $instance_num= $self->{cpus} ? @{$self->{cpus}} : 0;
my $list= `kstat -p -m cpu_info -i $instance_num`;
- my @lines= split('\n', $list) or return undef;
+ my @lines= split('\n', $list) or last; # Break loop
my $cpuinfo= {};
foreach my $line (@lines)
@@ -82,14 +89,19 @@ sub _kstat {
$cpuinfo->{$statistic}= $value;
}
- # Default value, the actual cpu values can be used to decrease it
+ # Default value, the actual cpu values can be used to decrease this
# on slower cpus
- $cpuinfo->{bogomips}= 2000;
+ $cpuinfo->{bogomips}= DEFAULT_BOGO_MIPS;
push(@{$self->{cpus}}, $cpuinfo);
}
- return $self;
+ # At least one cpu should have been found
+ # if this method worked
+ if ( $self->{cpus} ) {
+ return $self;
+ }
+ return undef;
}
@@ -122,7 +134,11 @@ sub new {
}
# Push a dummy cpu
- push(@{$self->{cpus}}, {bogomips => 2000, model_name => "unknown"});
+ push(@{$self->{cpus}},
+ {
+ bogomips => DEFAULT_BOGO_MIPS,
+ model_name => "unknown",
+ });
return $self;
}