diff options
Diffstat (limited to 'spec/unit')
-rw-r--r-- | spec/unit/util/virtual.rb | 16 | ||||
-rw-r--r-- | spec/unit/virtual.rb | 13 |
2 files changed, 29 insertions, 0 deletions
diff --git a/spec/unit/util/virtual.rb b/spec/unit/util/virtual.rb index de339b8..5b59cf9 100644 --- a/spec/unit/util/virtual.rb +++ b/spec/unit/util/virtual.rb @@ -100,4 +100,20 @@ describe Facter::Util::Virtual do Facter::Util::Virtual.should be_kvm end + it "should detect kvm on FreeBSD" do + Facter.fact(:kernel).stubs(:value).returns("FreeBSD") + Facter::Util::Resolution.stubs(:exec).with("/sbin/sysctl -n hw.model").returns("QEMU Virtual CPU version 0.12.4") + Facter::Util::Virtual.should be_kvm + end + + it "should identify FreeBSD jail when in jail" do + Facter::Util::Resolution.stubs(:exec).with("/sbin/sysctl -n security.jail.jailed").returns("1") + Facter::Util::Virtual.should be_jail + end + + it "should not identify FreeBSD jail when not in jail" do + Facter::Util::Resolution.stubs(:exec).with("/sbin/sysctl -n security.jail.jailed").returns("0") + Facter::Util::Virtual.should_not be_jail + end + end diff --git a/spec/unit/virtual.rb b/spec/unit/virtual.rb index 7dbd146..8ee843b 100644 --- a/spec/unit/virtual.rb +++ b/spec/unit/virtual.rb @@ -17,6 +17,13 @@ describe "Virtual fact" do Facter.fact(:virtual).value.should == "zone" end + it "should be jail on FreeBSD when a jail in kvm" do + Facter.fact(:kernel).stubs(:value).returns("FreeBSD") + Facter::Util::Virtual.stubs(:jail?).returns(true) + Facter::Util::Virtual.stubs(:kvm?).returns(true) + Facter.fact(:virtual).value.should == "jail" + end + end describe "is_virtual fact" do @@ -55,4 +62,10 @@ describe "is_virtual fact" do Facter.fact(:is_virtual).value.should == true end + it "should be true when running in jail" do + Facter.fact(:kernel).stubs(:value).returns("FreeBSD") + Facter.fact(:virtual).stubs(:value).returns("jail") + Facter.fact(:is_virtual).value.should == true + end + end |