diff options
author | Paul Nasrat <pnasrat@googlemail.com> | 2010-01-17 17:02:38 +0000 |
---|---|---|
committer | Paul Nasrat <pnasrat@googlemail.com> | 2010-01-30 08:26:13 +0000 |
commit | 7750f036539afa4ad04aef676ab27c551e97ad3e (patch) | |
tree | 35b22b569d20dd8f8f360313de1fe1d6df21ca62 | |
parent | f4269d90316b32334cc3bc972737acde379e6262 (diff) | |
download | facter-7750f036539afa4ad04aef676ab27c551e97ad3e.tar.gz facter-7750f036539afa4ad04aef676ab27c551e97ad3e.tar.xz facter-7750f036539afa4ad04aef676ab27c551e97ad3e.zip |
Fix #2341 - stricter handling of dmidecode split
This adds a test to ensure we are not prematurely splitting on Handle
-rw-r--r-- | lib/facter/util/manufacturer.rb | 2 | ||||
-rw-r--r-- | spec/unit/util/manufacturer.rb | 22 |
2 files changed, 23 insertions, 1 deletions
diff --git a/lib/facter/util/manufacturer.rb b/lib/facter/util/manufacturer.rb index d015226..baf24bc 100644 --- a/lib/facter/util/manufacturer.rb +++ b/lib/facter/util/manufacturer.rb @@ -28,7 +28,7 @@ module Facter::Manufacturer end def self.dmi_find_system_info(name) - splitstr= Facter.value(:kernel) == 'SunOS' ? "ID SIZE TYPE" : "Handle" + splitstr= Facter.value(:kernel) == 'SunOS' ? "ID SIZE TYPE" : "/^Handle/" output = self.get_dmi_table() return if output.nil? name.each_pair do |key,v| diff --git a/spec/unit/util/manufacturer.rb b/spec/unit/util/manufacturer.rb index 47a0c98..11d207d 100644 --- a/spec/unit/util/manufacturer.rb +++ b/spec/unit/util/manufacturer.rb @@ -23,4 +23,26 @@ describe Facter::Manufacturer do Facter::Manufacturer.dmi_find_system_info(query) Facter.value(:productname).should == "MS-6754" end + + it "should not split on dmi keys containing the string Handle" do + dmidecode_output = <<-eos +Handle 0x1000, DMI type 16, 15 bytes +Physical Memory Array + Location: System Board Or Motherboard + Use: System Memory + Error Correction Type: None + Maximum Capacity: 4 GB + Error Information Handle: Not Provided + Number Of Devices: 2 + +Handle 0x001F + DMI type 127, 4 bytes. + End Of Table + eos + Facter::Manufacturer.expects(:get_dmi_table).returns(dmidecode_output) + Facter.fact(:kernel).stubs(:value).returns("Linux") + query = { 'Physical Memory Array' => [ { 'Number Of Devices:' => 'ramslots'}]} + Facter::Manufacturer.dmi_find_system_info(query) + Facter.value(:ramslots).should == "2" + end end
\ No newline at end of file |