~gandelman-a/ubuntu/precise/facter/merge922788

« back to all changes in this revision

Viewing changes to spec/unit/virtual_spec.rb

  • Committer: Package Import Robot
  • Author(s): Adam Gandelman
  • Date: 2011-10-18 10:32:42 UTC
  • mfrom: (1.3.3 upstream)
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: package-import@ubuntu.com-20111018103242-ag8i8vejfp8v7b1b
Tags: upstream-1.6.1
ImportĀ upstreamĀ versionĀ 1.6.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
72
72
  describe "on Linux" do
73
73
 
74
74
      before do
75
 
        FileTest.expects(:exists?).with("/usr/lib/vmware/bin/vmware-vmx").returns false
 
75
        Facter::Util::Resolution.expects(:exec).with("vmware -v").returns false
 
76
        Facter.fact(:operatingsystem).stubs(:value).returns(true)
76
77
        Facter.fact(:architecture).stubs(:value).returns(true)
77
78
      end
78
79
 
94
95
          Facter.fact(:virtual).value.should == "vmware"
95
96
      end
96
97
 
 
98
      it "should be virtualbox with VirtualBox vendor name from lspci" do
 
99
          Facter.fact(:kernel).stubs(:value).returns("Linux")
 
100
          Facter::Util::Resolution.stubs(:exec).with('lspci').returns("00:02.0 VGA compatible controller: InnoTek Systemberatung GmbH VirtualBox Graphics Adapter")
 
101
          Facter.fact(:virtual).value.should == "virtualbox"
 
102
      end
 
103
 
97
104
      it "should be vmware with VMWare vendor name from dmidecode" do
98
105
          Facter.fact(:kernel).stubs(:value).returns("Linux")
99
106
          Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
101
108
          Facter.fact(:virtual).value.should == "vmware"
102
109
      end
103
110
 
 
111
      it "should be xenhvm with Xen HVM vendor name from lspci" do
 
112
          Facter.fact(:kernel).stubs(:value).returns("Linux")
 
113
          Facter::Util::Resolution.stubs(:exec).with('lspci').returns("00:03.0 Unassigned class [ff80]: XenSource, Inc. Xen Platform Device (rev 01)")
 
114
          Facter.fact(:virtual).value.should == "xenhvm"
 
115
      end
 
116
 
 
117
      it "should be xenhvm with Xen HVM vendor name from dmidecode" do
 
118
          Facter.fact(:kernel).stubs(:value).returns("Linux")
 
119
          Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
 
120
          Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns("System Information\nManufacturer: Xen\nProduct Name: HVM domU")
 
121
          Facter.fact(:virtual).value.should == "xenhvm"
 
122
      end
 
123
 
104
124
      it "should be parallels with Parallels vendor name from dmidecode" do
105
125
          Facter.fact(:kernel).stubs(:value).returns("Linux")
106
126
          Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
108
128
          Facter.fact(:virtual).value.should == "parallels"
109
129
      end
110
130
 
 
131
      it "should be virtualbox with VirtualBox vendor name from dmidecode" do
 
132
          Facter.fact(:kernel).stubs(:value).returns("Linux")
 
133
          Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
 
134
          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")
 
135
          Facter.fact(:virtual).value.should == "virtualbox"
 
136
      end
 
137
 
 
138
  end
 
139
  describe "on Solaris" do
 
140
      before(:each) do
 
141
          Facter::Util::Resolution.expects(:exec).with("vmware -v").returns false
 
142
      end
 
143
 
111
144
      it "should be vmware with VMWare vendor name from prtdiag" do
112
 
          Facter.fact(:kernel).stubs(:value).returns("Linux")
 
145
          Facter.fact(:kernel).stubs(:value).returns("SunOS")
113
146
          Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
114
147
          Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns(nil)
115
148
          Facter::Util::Resolution.stubs(:exec).with('prtdiag').returns("System Configuration: VMware, Inc. VMware Virtual Platform")
117
150
      end
118
151
 
119
152
      it "should be parallels with Parallels vendor name from prtdiag" do
120
 
          Facter.fact(:kernel).stubs(:value).returns("Linux")
 
153
          Facter.fact(:kernel).stubs(:value).returns("SunOS")
121
154
          Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
122
155
          Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns(nil)
123
156
          Facter::Util::Resolution.stubs(:exec).with('prtdiag').returns("System Configuration: Parallels Virtual Platform")
124
157
          Facter.fact(:virtual).value.should == "parallels"
125
158
      end
 
159
 
 
160
      it "should be virtualbox with VirtualBox vendor name from prtdiag" do
 
161
          Facter.fact(:kernel).stubs(:value).returns("SunOS")
 
162
          Facter::Util::Resolution.stubs(:exec).with('lspci').returns(nil)
 
163
          Facter::Util::Resolution.stubs(:exec).with('dmidecode').returns(nil)
 
164
          Facter::Util::Resolution.stubs(:exec).with('prtdiag').returns("System Configuration: innotek GmbH VirtualBox")
 
165
          Facter.fact(:virtual).value.should == "virtualbox"
 
166
      end
126
167
  end
127
168
end
128
169
 
140
181
       Facter.fact(:is_virtual).value.should == "false"
141
182
    end
142
183
 
 
184
    it "should be true when running on xenhvm" do
 
185
       Facter.fact(:kernel).stubs(:value).returns("Linux")
 
186
       Facter.fact(:virtual).stubs(:value).returns("xenhvm")
 
187
       Facter.fact(:is_virtual).value.should == "true"
 
188
    end
 
189
 
143
190
    it "should be false when running on physical" do
144
191
       Facter.fact(:kernel).stubs(:value).returns("Linux")
145
192
       Facter.fact(:virtual).stubs(:value).returns("physical")
152
199
        Facter.fact(:is_virtual).value.should == "true"
153
200
    end
154
201
 
155
 
    it "should be true when running on openvz" do
 
202
    it "should be true when running on virtualbox" do
 
203
        Facter.fact(:kernel).stubs(:value).returns("Linux")
 
204
        Facter.fact(:virtual).stubs(:value).returns("virtualbox")
 
205
        Facter.fact(:is_virtual).value.should == "true"
 
206
    end
 
207
 
 
208
    it "should be true when running on openvzve" do
156
209
        Facter.fact(:kernel).stubs(:value).returns("Linux")
157
210
        Facter.fact(:virtual).stubs(:value).returns("openvzve")
158
211
        Facter.fact(:is_virtual).value.should == "true"
184
237
 
185
238
    it "should be true when running on S390" do
186
239
        Facter.fact(:architecture).stubs(:value).returns("s390x")
 
240
        Facter.fact(:kernel).stubs(:value).returns("Linux")
187
241
        Facter.fact(:virtual).stubs(:value).returns("zlinux")
188
242
        Facter.fact(:is_virtual).value.should == "true"
189
243
    end
193
247
        Facter.fact(:virtual).stubs(:value).returns("parallels")
194
248
        Facter.fact(:is_virtual).value.should == "true"
195
249
    end
 
250
 
 
251
    it "should be false on vmware_server" do
 
252
        Facter.fact(:kernel).stubs(:value).returns("Linux")
 
253
        Facter.fact(:virtual).stubs(:value).returns("vmware_server")
 
254
        Facter.fact(:is_virtual).value.should == "false"
 
255
    end
 
256
 
 
257
    it "should be false on openvz host nodes" do
 
258
        Facter.fact(:kernel).stubs(:value).returns("Linux")
 
259
        Facter.fact(:virtual).stubs(:value).returns("openvzhn")
 
260
        Facter.fact(:is_virtual).value.should == "false"
 
261
    end
196
262
end