summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2015-11-03 10:37:05 -0800
committerTim Smith <tsmith84@gmail.com>2015-11-03 10:37:05 -0800
commit641b3872b614331aceb9a8c7b49734ca8a711166 (patch)
tree676137d29a31b9f0bf55fae6d94725abe7831f4c
parent8e52ccb86ae76ec00effeee43a61d40b78a721c4 (diff)
downloadohai-641b3872b614331aceb9a8c7b49734ca8a711166.tar.gz
Convert hex CPU data to ints
Make sure to keep the data as a string so that the format matches the format we use on Linux.
-rw-r--r--lib/ohai/plugins/freebsd/cpu.rb6
-rw-r--r--spec/unit/plugins/freebsd/cpu_spec.rb5
2 files changed, 7 insertions, 4 deletions
diff --git a/lib/ohai/plugins/freebsd/cpu.rb b/lib/ohai/plugins/freebsd/cpu.rb
index 0eb8a510..a1d4ec51 100644
--- a/lib/ohai/plugins/freebsd/cpu.rb
+++ b/lib/ohai/plugins/freebsd/cpu.rb
@@ -1,5 +1,6 @@
#
# Author:: Bryan McLellan (btm@loftninjas.org)
+# Author:: Tim Smith (tsmith@chef.io)
# Copyright:: Copyright (c) 2008 Bryan McLellan
# License:: Apache License, Version 2.0
#
@@ -43,8 +44,9 @@ Ohai.plugin(:CPU) do
cpuinfo["mhz"] = $2
when /Origin.*"(.*)".*Family.*0x(\S+).*Model.*0x(\S+).*Stepping.*(\S+)/
cpuinfo["vendor_id"] = $1
- cpuinfo["family"] = $2
- cpuinfo["model"] = $3
+ # convert from hex value to int, but keep a string to match Linux ohai
+ cpuinfo["family"] = $2.to_i(16).to_s
+ cpuinfo["model"] = $3.to_i(16).to_s
cpuinfo["stepping"] = $4
# These _should_ match /AMD Features2?/ lines as well
when /Features=.+<(.+)>/
diff --git a/spec/unit/plugins/freebsd/cpu_spec.rb b/spec/unit/plugins/freebsd/cpu_spec.rb
index 93b173d2..2d2b2229 100644
--- a/spec/unit/plugins/freebsd/cpu_spec.rb
+++ b/spec/unit/plugins/freebsd/cpu_spec.rb
@@ -63,7 +63,7 @@ describe Ohai::System, "FreeBSD cpu plugin on FreeBSD >=10.2" do
it "detects CPU model" do
@plugin.run
- expect(@plugin[:cpu][:model]).to eq("46")
+ expect(@plugin[:cpu][:model]).to eq("70")
end
it "detects CPU stepping" do
@@ -102,7 +102,8 @@ describe Ohai::System, "FreeBSD cpu plugin on FreeBSD <=10.1" do
it "detects CPU model" do
@plugin.run
- expect(@plugin[:cpu][:model]).to eq("1c")
+
+ expect(@plugin[:cpu][:model]).to eq("28")
end
it "detects CPU stepping" do