summaryrefslogtreecommitdiffstats
path: root/spec/unit/virtual_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/virtual_spec.rb')
-rw-r--r--spec/unit/virtual_spec.rb38
1 files changed, 34 insertions, 4 deletions
diff --git a/spec/unit/virtual_spec.rb b/spec/unit/virtual_spec.rb
index 7e50847..f69c898 100644
--- a/spec/unit/virtual_spec.rb
+++ b/spec/unit/virtual_spec.rb
@@ -73,6 +73,7 @@ describe "Virtual fact" do
before do
FileTest.expects(:exists?).with("/usr/lib/vmware/bin/vmware-vmx").returns false
+ Facter.fact(:operatingsystem).stubs(:value).returns(true)
Facter.fact(:architecture).stubs(:value).returns(true)
end
@@ -94,6 +95,12 @@ describe "Virtual fact" do
Facter.fact(:virtual).value.should == "vmware"
end
+ it "should be virtualbox with VirtualBox vendor name from lspci" do
+ Facter.fact(:kernel).stubs(:value).returns("Linux")
+ Facter::Util::Resolution.stubs(:exec).with('lspci').returns("00:02.0 VGA compatible controller: InnoTek Systemberatung GmbH VirtualBox Graphics Adapter")
+ Facter.fact(:virtual).value.should == "virtualbox"
+ end
+
it "should be vmware with VMWare vendor name from dmidecode" do
Facter.fact(:kernel).stubs(:value).returns("Linux")
Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
@@ -108,21 +115,38 @@ describe "Virtual fact" do
Facter.fact(:virtual).value.should == "parallels"
end
- it "should be vmware with VMWare vendor name from prtdiag" do
+ it "should be virtualbox with VirtualBox 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("BIOS Information\nVendor: innotek GmbH\nVersion: VirtualBox\n\nSystem Information\nManufacturer: innotek GmbH\nProduct Name: VirtualBox\nFamily: Virtual Machine")
+ Facter.fact(:virtual).value.should == "virtualbox"
+ end
+
+ end
+ describe "on Solaris" do
+ 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').returns("System Configuration: VMware, Inc. VMware Virtual Platform")
+ Facter::Util::Resolution.stubs(:exec).with('prtdiag', '/bin/sh').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("Linux")
+ 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').returns("System Configuration: Parallels Virtual Platform")
+ Facter::Util::Resolution.stubs(:exec).with('prtdiag', '/bin/sh').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.fact(:virtual).value.should == "virtualbox"
+ end
end
end
@@ -152,6 +176,12 @@ describe "is_virtual fact" do
Facter.fact(:is_virtual).value.should == "true"
end
+ it "should be true when running on virtualbox" do
+ 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
Facter.fact(:kernel).stubs(:value).returns("Linux")
Facter.fact(:virtual).stubs(:value).returns("openvzve")