spec/unit/util/virtual_spec.rb in facter-1.6.1 vs spec/unit/util/virtual_spec.rb in facter-1.6.2
- old
+ new
@@ -7,23 +7,44 @@
after do
Facter.clear
end
it "should detect openvz" do
FileTest.stubs(:directory?).with("/proc/vz").returns(true)
- FileTest.stubs(:exists?).with("/proc/vz/veinfo").returns(true)
+ Dir.stubs(:glob).with("/proc/vz/*").returns(['vzquota'])
Facter::Util::Virtual.should be_openvz
end
- it "should identify openvzhn when version file exists" do
+ it "should not detect openvz when /proc/lve/list is present" do
+ FileTest.stubs(:file?).with("/proc/lve/list").returns(true)
+ Facter::Util::Virtual.should_not be_openvz
+ end
+
+ it "should not detect openvz when /proc/vz/ is empty" do
+ FileTest.stubs(:file?).with("/proc/lve/list").returns(false)
+ FileTest.stubs(:directory?).with("/proc/vz").returns(true)
+ Dir.stubs(:glob).with("/proc/vz/*").returns([])
+ Facter::Util::Virtual.should_not be_openvz
+ end
+
+ it "should identify openvzhn when /proc/self/status has envID of 0" do
Facter::Util::Virtual.stubs(:openvz?).returns(true)
- FileTest.stubs(:exists?).with("/proc/vz/version").returns(true)
+ FileTest.stubs(:exists?).with("/proc/self/status").returns(true)
+ Facter::Util::Resolution.stubs(:exec).with('grep "envID" /proc/self/status').returns("envID: 0")
Facter::Util::Virtual.openvz_type().should == "openvzhn"
end
- it "should identify openvzve when no version file exists" do
+ it "should identify openvzve when /proc/self/status has envID of 0" do
Facter::Util::Virtual.stubs(:openvz?).returns(true)
- FileTest.stubs(:exists?).with("/proc/vz/version").returns(false)
+ FileTest.stubs(:exists?).with('/proc/self/status').returns(true)
+ Facter::Util::Resolution.stubs(:exec).with('grep "envID" /proc/self/status').returns("envID: 666")
Facter::Util::Virtual.openvz_type().should == "openvzve"
+ end
+
+ it "should not attempt to identify openvz when /proc/self/status has no envID" do
+ Facter::Util::Virtual.stubs(:openvz?).returns(true)
+ FileTest.stubs(:exists?).with('/proc/self/status').returns(true)
+ Facter::Util::Resolution.stubs(:exec).with('grep "envID" /proc/self/status').returns("")
+ Facter::Util::Virtual.openvz_type().should be_nil
end
it "should identify Solaris zones when non-global zone" do
Facter::Util::Resolution.stubs(:exec).with("/sbin/zonename").returns("somezone")
Facter::Util::Virtual.should be_zone