spec/unit/virtual_spec.rb in facter-1.6.0 vs spec/unit/virtual_spec.rb in facter-1.6.1
- old
+ new
@@ -70,11 +70,11 @@
end
describe "on Linux" do
before do
- FileTest.expects(:exists?).with("/usr/lib/vmware/bin/vmware-vmx").returns false
+ Facter::Util::Resolution.expects(:exec).with("vmware -v").returns false
Facter.fact(:operatingsystem).stubs(:value).returns(true)
Facter.fact(:architecture).stubs(:value).returns(true)
end
it "should be parallels with Parallels vendor id from lspci" do
@@ -106,10 +106,23 @@
Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns("On Board Device 1 Information\nType: Video\nStatus: Disabled\nDescription: VMware SVGA II")
Facter.fact(:virtual).value.should == "vmware"
end
+ it "should be xenhvm with Xen HVM vendor name from lspci" do
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
+ Facter::Util::Resolution.stubs(:exec).with('lspci').returns("00:03.0 Unassigned class [ff80]: XenSource, Inc. Xen Platform Device (rev 01)")
+ Facter.fact(:virtual).value.should == "xenhvm"
+ end
+
+ it "should be xenhvm with Xen HVM vendor name from dmidecode" do
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
+ Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
+ Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns("System Information\nManufacturer: Xen\nProduct Name: HVM domU")
+ Facter.fact(:virtual).value.should == "xenhvm"
+ end
+
it "should be parallels with Parallels vendor name from dmidecode" do
Facter.fact(:kernel).stubs(:value).returns("Linux")
Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns("On Board Device Information\nType: Video\nStatus: Disabled\nDescription: Parallels Video Adapter")
Facter.fact(:virtual).value.should == "parallels"
@@ -122,31 +135,35 @@
Facter.fact(:virtual).value.should == "virtualbox"
end
end
describe "on Solaris" do
+ before(:each) do
+ Facter::Util::Resolution.expects(:exec).with("vmware -v").returns false
+ end
+
it "should be vmware with VMWare vendor name from prtdiag" do
Facter.fact(:kernel).stubs(:value).returns("SunOS")
Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns(nil)
- Facter::Util::Resolution.stubs(:exec).with('prtdiag', '/bin/sh').returns("System Configuration: VMware, Inc. VMware Virtual Platform")
+ Facter::Util::Resolution.stubs(:exec).with('prtdiag').returns("System Configuration: VMware, Inc. VMware Virtual Platform")
Facter.fact(:virtual).value.should == "vmware"
end
it "should be parallels with Parallels vendor name from prtdiag" do
Facter.fact(:kernel).stubs(:value).returns("SunOS")
Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns(nil)
- Facter::Util::Resolution.stubs(:exec).with('prtdiag', '/bin/sh').returns("System Configuration: Parallels Virtual Platform")
+ Facter::Util::Resolution.stubs(:exec).with('prtdiag').returns("System Configuration: Parallels Virtual Platform")
Facter.fact(:virtual).value.should == "parallels"
end
it "should be virtualbox with VirtualBox vendor name from prtdiag" do
Facter.fact(:kernel).stubs(:value).returns("SunOS")
Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns(nil)
- Facter::Util::Resolution.stubs(:exec).with('prtdiag', '/bin/sh').returns("System Configuration: innotek GmbH VirtualBox")
+ Facter::Util::Resolution.stubs(:exec).with('prtdiag').returns("System Configuration: innotek GmbH VirtualBox")
Facter.fact(:virtual).value.should == "virtualbox"
end
end
end
@@ -162,10 +179,16 @@
Facter.fact(:kernel).stubs(:value).returns("Linux")
Facter.fact(:virtual).stubs(:value).returns("xen0")
Facter.fact(:is_virtual).value.should == "false"
end
+ it "should be true when running on xenhvm" do
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
+ Facter.fact(:virtual).stubs(:value).returns("xenhvm")
+ Facter.fact(:is_virtual).value.should == "true"
+ end
+
it "should be false when running on physical" do
Facter.fact(:kernel).stubs(:value).returns("Linux")
Facter.fact(:virtual).stubs(:value).returns("physical")
Facter.fact(:is_virtual).value.should == "false"
end
@@ -180,11 +203,11 @@
Facter.fact(:kernel).stubs(:value).returns("Linux")
Facter.fact(:virtual).stubs(:value).returns("virtualbox")
Facter.fact(:is_virtual).value.should == "true"
end
- it "should be true when running on openvz" do
+ it "should be true when running on openvzve" do
Facter.fact(:kernel).stubs(:value).returns("Linux")
Facter.fact(:virtual).stubs(:value).returns("openvzve")
Facter.fact(:is_virtual).value.should == "true"
end
@@ -212,15 +235,28 @@
Facter.fact(:is_virtual).value.should == "true"
end
it "should be true when running on S390" do
Facter.fact(:architecture).stubs(:value).returns("s390x")
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
Facter.fact(:virtual).stubs(:value).returns("zlinux")
Facter.fact(:is_virtual).value.should == "true"
end
it "should be true when running on parallels" do
Facter.fact(:kernel).stubs(:value).returns("Darwin")
Facter.fact(:virtual).stubs(:value).returns("parallels")
Facter.fact(:is_virtual).value.should == "true"
+ end
+
+ it "should be false on vmware_server" do
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
+ Facter.fact(:virtual).stubs(:value).returns("vmware_server")
+ Facter.fact(:is_virtual).value.should == "false"
+ end
+
+ it "should be false on openvz host nodes" do
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
+ Facter.fact(:virtual).stubs(:value).returns("openvzhn")
+ Facter.fact(:is_virtual).value.should == "false"
end
end