summaryrefslogtreecommitdiffstats
path: root/spec/unit
diff options
context:
space:
mode:
authorPaul Nasrat <pnasrat@googlemail.com>2009-09-05 06:45:50 +0100
committerPaul Nasrat <pnasrat@googlemail.com>2009-09-09 07:04:44 +0100
commit49470cf776f2c23cabec00b68b85a1264a3f7b48 (patch)
treebd1dd2d50d79836569451658a12cee4c89dc199a /spec/unit
parent9515a403b2a3350b3b6eb2c1578c5871e9588ac2 (diff)
downloadfacter-49470cf776f2c23cabec00b68b85a1264a3f7b48.tar.gz
facter-49470cf776f2c23cabec00b68b85a1264a3f7b48.tar.xz
facter-49470cf776f2c23cabec00b68b85a1264a3f7b48.zip
Fix broken solaris zone tests on EC2
This cleans up xen and vserver detection to enable us to stub out so when we happen to be running tests on xen we don't report as that. More cleanup is needed in this area but this should give us a green build. This renames the tests to be consistent with current naming convention
Diffstat (limited to 'spec/unit')
-rw-r--r--spec/unit/util/virtual.rb (renamed from spec/unit/util/virtual_spec.rb)36
-rw-r--r--spec/unit/virtual.rb (renamed from spec/unit/virtual_spec.rb)2
2 files changed, 38 insertions, 0 deletions
diff --git a/spec/unit/util/virtual_spec.rb b/spec/unit/util/virtual.rb
index 3552c45..1f1c0f8 100644
--- a/spec/unit/util/virtual_spec.rb
+++ b/spec/unit/util/virtual.rb
@@ -57,4 +57,40 @@ describe Facter::Util::Virtual do
Facter::Util::Virtual.should_not be_vserver
end
+ it "should identify vserver_host when /proc/virtual exists" do
+ Facter::Util::Virtual.expects(:vserver?).returns(true)
+ FileTest.stubs(:exists?).with("/proc/virtual").returns(true)
+ Facter::Util::Virtual.vserver_type().should == "vserver_host"
+ end
+
+ it "should identify vserver_type as vserver when /proc/virtual does not exist" do
+ Facter::Util::Virtual.expects(:vserver?).returns(true)
+ FileTest.stubs(:exists?).with("/proc/virtual").returns(false)
+ Facter::Util::Virtual.vserver_type().should == "vserver"
+ end
+
+ it "should detect xen when /proc/sys/xen exists" do
+ FileTest.expects(:exists?).with("/proc/sys/xen").returns(true)
+ Facter::Util::Virtual.should be_xen
+ end
+
+ it "should detect xen when /sys/bus/xen exists" do
+ FileTest.expects(:exists?).with("/proc/sys/xen").returns(false)
+ FileTest.expects(:exists?).with("/sys/bus/xen").returns(true)
+ Facter::Util::Virtual.should be_xen
+ end
+
+ it "should detect xen when /proc/xen exists" do
+ FileTest.expects(:exists?).with("/proc/sys/xen").returns(false)
+ FileTest.expects(:exists?).with("/sys/bus/xen").returns(false)
+ FileTest.expects(:exists?).with("/proc/xen").returns(true)
+ Facter::Util::Virtual.should be_xen
+ end
+
+ it "should not detect xen when no sysfs/proc xen directories exist" do
+ FileTest.expects(:exists?).with("/proc/sys/xen").returns(false)
+ FileTest.expects(:exists?).with("/sys/bus/xen").returns(false)
+ FileTest.expects(:exists?).with("/proc/xen").returns(false)
+ Facter::Util::Virtual.should_not be_xen
+ end
end
diff --git a/spec/unit/virtual_spec.rb b/spec/unit/virtual.rb
index 68cd258..cc72ffc 100644
--- a/spec/unit/virtual_spec.rb
+++ b/spec/unit/virtual.rb
@@ -12,6 +12,8 @@ describe "Virtual fact" do
it "should be zone on Solaris when a zone" do
Facter.fact(:kernel).stubs(:value).returns("SunOS")
Facter::Util::Virtual.stubs(:zone?).returns(true)
+ Facter::Util::Virtual.stubs(:vserver?).returns(false)
+ Facter::Util::Virtual.stubs(:xen?).returns(false)
Facter.fact(:virtual).value.should == "zone"
end