summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorTim Smith <tsmith@llnw.com>2014-04-30 00:09:06 -0700
committerBryan McLellan <btm@getchef.com>2014-05-15 08:21:41 -0700
commitb57679327467ee0250e6ea6e16e1276b9a3b4a54 (patch)
tree9a72ec749e536ab862b83626d4b8a9261dbb054c /spec
parent5ca79f0bb48875c71686314169a71fd8b07508a7 (diff)
downloadohai-b57679327467ee0250e6ea6e16e1276b9a3b4a54.tar.gz
Add addition Freebsd CPU unit tests
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/plugins/freebsd/cpu_spec.rb38
1 files changed, 32 insertions, 6 deletions
diff --git a/spec/unit/plugins/freebsd/cpu_spec.rb b/spec/unit/plugins/freebsd/cpu_spec.rb
index 65234ac5..100c95f3 100644
--- a/spec/unit/plugins/freebsd/cpu_spec.rb
+++ b/spec/unit/plugins/freebsd/cpu_spec.rb
@@ -22,15 +22,16 @@ describe Ohai::System, "FreeBSD cpu plugin" do
before(:each) do
@plugin = get_plugin("freebsd/cpu")
@plugin.stub(:collect_os).and_return(:freebsd)
+ @plugin.stub(:shell_out).with("sysctl -n hw.ncpu").and_return(mock_shell_out(0, "2", ""))
@double_file = double("/var/run/dmesg.boot")
@double_file.stub(:each).
- and_yield("CPU: Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz (3516.61-MHz K8-class CPU)").
+ and_yield('CPU: Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz (3516.61-MHz K8-class CPU)').
and_yield(' Origin = "GenuineIntel" Id = 0x306a9 Family = 6 Model = 3a Stepping = 9').
- and_yield(" Features=0x783fbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,MMX,FXSR,SSE,SSE2>").
- and_yield(" Features2=0x209<SSE3,MON,SSSE3>").
- and_yield(" AMD Features=0x28100800<SYSCALL,NX,RDTSCP,LM>").
- and_yield(" AMD Features2=0x1<LAHF>").
- and_yield(" TSC: P-state invariant")
+ and_yield(' Features=0x783fbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,MMX,FXSR,SSE,SSE2>').
+ and_yield(' Features2=0x209<SSE3,MON,SSSE3>').
+ and_yield(' AMD Features=0x28100800<SYSCALL,NX,RDTSCP,LM>').
+ and_yield(' AMD Features2=0x1<LAHF>').
+ and_yield(' TSC: P-state invariant')
File.stub(:open).with("/var/run/dmesg.boot").and_return(@double_file)
end
@@ -39,4 +40,29 @@ describe Ohai::System, "FreeBSD cpu plugin" do
@plugin[:cpu][:flags].should == %w{fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 mmx fxsr sse sse2 sse3 mon ssse3 syscall nx rdtscp lm lahf}
end
+ it "detects all CPU model_name" do
+ @plugin.run
+ @plugin[:cpu][:model_name].should == "Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz"
+ end
+
+ it "detects all CPU mhz" do
+ @plugin.run
+ @plugin[:cpu][:mhz].should == "3516.61"
+ end
+
+ it "detects all CPU vendor_id" do
+ @plugin.run
+ @plugin[:cpu][:vendor_id].should == "GenuineIntel"
+ end
+
+ it "detects all CPU stepping" do
+ @plugin.run
+ @plugin[:cpu][:stepping].should == "9"
+ end
+
+ it "detects all CPU total" do
+ @plugin.run
+ @plugin[:cpu][:total].should == "2"
+ end
+
end