spec/ohai/plugins/linux/virtualization_spec.rb in ohai-0.6.6 vs spec/ohai/plugins/linux/virtualization_spec.rb in ohai-0.6.8.rc.0
- old
+ new
@@ -24,30 +24,37 @@
@ohai[:os] = "linux"
@ohai.stub!(:require_plugin).and_return(true)
@ohai.extend(SimpleFromFile)
# default to all requested Files not existing
- File.stub(:exists?).with("/proc/xen").and_return(false)
- File.stub(:exists?).with("/dev/xen/evtchn").and_return(false)
+ File.stub!(:exists?).with("/proc/xen/capabilities").and_return(false)
+ File.stub!(:exists?).with("/proc/sys/xen/independent_wallclock").and_return(false)
File.stub!(:exists?).with("/proc/modules").and_return(false)
File.stub!(:exists?).with("/proc/cpuinfo").and_return(false)
File.stub!(:exists?).with("/usr/sbin/dmidecode").and_return(false)
File.stub!(:exists?).with("/proc/self/status").and_return(false)
File.stub!(:exists?).with("/proc/user_beancounters").and_return(false)
end
describe "when we are checking for xen" do
- it "should set xen host if /proc/xen " do
- File.should_receive(:exists?).with("/proc/xen").and_return(true)
- File.should_receive(:exists?).with("/dev/xen/evtchn").and_return(true)
+ it "should set xen host if /proc/xen/capabilities contains control_d " do
+ File.should_receive(:exists?).with("/proc/xen/capabilities").and_return(true)
+ File.stub!(:read).with("/proc/xen/capabilities").and_return("control_d")
@ohai._require_plugin("linux::virtualization")
@ohai[:virtualization][:system].should == "xen"
@ohai[:virtualization][:role].should == "host"
end
- it "should set xen guest if no /dev/xen/evtchn" do
- File.should_receive(:exists?).with("/proc/xen").and_return(true)
- File.should_receive(:exists?).with("/dev/xen/evtchn").and_return(false)
+ it "should set xen guest if /proc/xen/capabilities exists but is empty" do
+ File.should_receive(:exists?).with("/proc/xen/capabilities").and_return(true)
+ File.stub!(:read).with("/proc/xen/capabilities").and_return("")
+ @ohai._require_plugin("linux::virtualization")
+ @ohai[:virtualization][:system].should == "xen"
+ @ohai[:virtualization][:role].should == "guest"
+ end
+
+ it "should set xen guest if /proc/sys/xen/independent_wallclock exists" do
+ File.should_receive(:exists?).with("/proc/sys/xen/independent_wallclock").and_return(true)
@ohai._require_plugin("linux::virtualization")
@ohai[:virtualization][:system].should == "xen"
@ohai[:virtualization][:role].should == "guest"
end