Skip to content

Commit

Permalink
Update Virtualbox guest test for the dmidecode detection
Browse files Browse the repository at this point in the history
  • Loading branch information
tas50 authored and btm committed Nov 4, 2013
1 parent 0b9b6c5 commit 3dfa00e
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions spec/unit/plugins/linux/virtualization_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,6 @@
@plugin[:virtualization][:role].should == "host"
end

it "should set vbox guest if /proc/modules contains vboxguest" do
File.should_receive(:exists?).with("/proc/modules").and_return(true)
File.stub(:read).with("/proc/modules").and_return("vboxguest 177749 2 vboxsf")
@plugin.run
@plugin[:virtualization][:system].should == "vbox"
@plugin[:virtualization][:role].should == "guest"
end

it "should not set virtualization if vbox isn't there" do
File.should_receive(:exists?).at_least(:once).and_return(false)
@plugin.run
Expand Down Expand Up @@ -156,6 +148,26 @@
@plugin[:virtualization][:role].should == "guest"
end

it "should set vbox guest if dmidecode detects Oracle Corporation" do
vbox_dmidecode=<<-VBOX
Base Board Information
Manufacturer: Oracle Corporation
Product Name: VirtualBox
Version: 1.2
Serial Number: 0
Asset Tag: Not Specified
Features:
Board is a hosting board
Location In Chasis: Not Specified
Type: Motherboard
Contained Object Handles: 0
VBOX
@plugin.stub(:shell_out).with("dmidecode").and_return(mock_shell_out(0, vbox_dmidecode, ""))
@plugin.run
@plugin[:virtualization][:system].should == "vbox"
@plugin[:virtualization][:role].should == "guest"
end

it "should run dmidecode and not set virtualization if nothing is detected" do
@plugin.stub(:shell_out).with("dmidecode").and_return(mock_shell_out(0, "", ""))
@plugin.run
Expand Down

0 comments on commit 3dfa00e

Please sign in to comment.