[Pkg-puppet-devel] [facter] 03/61: (#20989) x86 windows hardware model show i686 not i1586
Stig Sandbeck Mathisen
ssm at debian.org
Mon Nov 4 15:01:36 UTC 2013
This is an automated email from the git hooks/post-receive script.
ssm pushed a commit to branch master
in repository facter.
commit 0cb1ff1e49522ed6d4a7d6ca564e4a46cd78b1a8
Author: Rob Reynolds <ferventcoder at gmail.com>
Date: Wed Jul 3 13:56:49 2013 -0500
(#20989) x86 windows hardware model show i686 not i1586
Currently hardware model uses the cpu level when
using 32 bit windows on x64 capable hardware. The
actual architecture is i686 even though it might be
showing as i1586 if the cpu level is 15.
Based on my research on this, all levels above 6
should show the i686 hardware model. i1586 or i1186
would be a misnomer.
This fix adds a check to determine if the cpu level
is over 6 and then responds by setting the
architecture_level (new) to 6, otherwise it uses the
cpu level coming back from the windows processor
query.
Note this only affects windows hardware.
---
lib/facter/hardwaremodel.rb | 9 +++++++--
spec/unit/hardwaremodel_spec.rb | 17 ++++++++++++++++-
2 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/lib/facter/hardwaremodel.rb b/lib/facter/hardwaremodel.rb
index adfda48..48a1b93 100644
--- a/lib/facter/hardwaremodel.rb
+++ b/lib/facter/hardwaremodel.rb
@@ -32,17 +32,22 @@ Facter.add(:hardwaremodel) do
# http://source.winehq.org/source/include/winnt.h#L568
# http://msdn.microsoft.com/en-us/library/windows/desktop/aa394373(v=vs.85).aspx
# http://msdn.microsoft.com/en-us/library/windows/desktop/windows.system.processorarchitecture.aspx
+ # http://linux.derkeiler.com/Mailing-Lists/Kernel/2008-05/msg12924.html (anything over 6 is still i686)
# Also, arm and neutral are included because they are valid for the upcoming
# windows 8 release. --jeffweiss 23 May 2012
require 'facter/util/wmi'
model = ""
+ architecture_level = nil
+
Facter::Util::WMI.execquery("select Architecture, Level, AddressWidth from Win32_Processor").each do |cpu|
+ architecture_level = (cpu.Level > 5) ? 6 : cpu.Level;
+
model =
case cpu.Architecture
when 11 then 'neutral' # PROCESSOR_ARCHITECTURE_NEUTRAL
when 10 then 'i686' # PROCESSOR_ARCHITECTURE_IA32_ON_WIN64
when 9 then # PROCESSOR_ARCHITECTURE_AMD64
- cpu.AddressWidth == 32 ? "i#{cpu.Level}86" : 'x64' # 32 bit OS on 64 bit CPU
+ cpu.AddressWidth == 32 ? "i#{architecture_level}86" : 'x64' # 32 bit OS on 64 bit CPU
when 8 then 'msil' # PROCESSOR_ARCHITECTURE_MSIL
when 7 then 'alpha64' # PROCESSOR_ARCHITECTURE_ALPHA64
when 6 then 'ia64' # PROCESSOR_ARCHITECTURE_IA64
@@ -51,7 +56,7 @@ Facter.add(:hardwaremodel) do
when 3 then 'powerpc' # PROCESSOR_ARCHITECTURE_PPC
when 2 then 'alpha' # PROCESSOR_ARCHITECTURE_ALPHA
when 1 then 'mips' # PROCESSOR_ARCHITECTURE_MIPS
- when 0 then "i#{cpu.Level}86" # PROCESSOR_ARCHITECTURE_INTEL
+ when 0 then "i#{architecture_level}86" # PROCESSOR_ARCHITECTURE_INTEL
else 'unknown' # PROCESSOR_ARCHITECTURE_UNKNOWN
end
break
diff --git a/spec/unit/hardwaremodel_spec.rb b/spec/unit/hardwaremodel_spec.rb
index a168c11..29c893d 100644
--- a/spec/unit/hardwaremodel_spec.rb
+++ b/spec/unit/hardwaremodel_spec.rb
@@ -17,6 +17,14 @@ describe "Hardwaremodel fact" do
Facter.fact(:kernel).stubs(:value).returns("windows")
end
+ it "should detect i486" do
+ cpu = mock('cpu', :Architecture => 0)
+ cpu.expects(:Level).returns(4).twice
+ Facter::Util::WMI.expects(:execquery).returns([cpu])
+
+ Facter.fact(:hardwaremodel).value.should == "i486"
+ end
+
it "should detect i686" do
cpu = mock('cpu', :Architecture => 0, :Level => 6)
Facter::Util::WMI.expects(:execquery).returns([cpu])
@@ -25,7 +33,7 @@ describe "Hardwaremodel fact" do
end
it "should detect x64" do
- cpu = mock('cpu', :Architecture => 9, :AddressWidth => 64)
+ cpu = mock('cpu', :Architecture => 9, :AddressWidth => 64, :Level => 6)
Facter::Util::WMI.expects(:execquery).returns([cpu])
Facter.fact(:hardwaremodel).value.should == "x64"
@@ -37,5 +45,12 @@ describe "Hardwaremodel fact" do
Facter.fact(:hardwaremodel).value.should == "i686"
end
+
+ it "(#20989) should report i686 when a 32 bit OS is running on a 64 bit CPU and when level is greater than 6 (and not something like i1586)" do
+ cpu = mock('cpu', :Architecture => 9, :AddressWidth => 32, :Level => 15)
+ Facter::Util::WMI.expects(:execquery).returns([cpu])
+
+ Facter.fact(:hardwaremodel).value.should == "i686"
+ end
end
end
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-puppet/facter.git
More information about the Pkg-puppet-devel
mailing list