facter 1.6.4 → 1.6.5
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of facter might be problematic. Click here for more details.
- data/CHANGELOG +33 -1
- data/conf/redhat/facter.spec +2 -1
- data/install.rb +25 -23
- data/lib/facter.rb +2 -1
- data/lib/facter/domain.rb +4 -4
- data/lib/facter/ec2.rb +6 -28
- data/lib/facter/hardwareisa.rb +0 -1
- data/lib/facter/hardwaremodel.rb +1 -1
- data/lib/facter/lsbmajdistrelease.rb +1 -1
- data/lib/facter/macaddress.rb +1 -1
- data/lib/facter/memory.rb +15 -4
- data/lib/facter/operatingsystem.rb +8 -4
- data/lib/facter/osfamily.rb +1 -1
- data/lib/facter/uniqueid.rb +1 -1
- data/lib/facter/util/collection.rb +2 -3
- data/lib/facter/util/config.rb +3 -3
- data/lib/facter/util/ec2.rb +49 -0
- data/lib/facter/util/fact.rb +12 -7
- data/lib/facter/util/monkey_patches.rb +7 -0
- data/lib/facter/util/uptime.rb +2 -2
- data/lib/facter/util/virtual.rb +1 -1
- data/lib/facter/virtual.rb +11 -1
- data/spec/{unit/data → fixtures/unit/selinux}/selinux_sestatus +0 -0
- data/spec/fixtures/unit/util/ec2/linux-arp-ec2.out +1 -0
- data/spec/fixtures/unit/util/ec2/linux-arp-not-ec2.out +5 -0
- data/spec/fixtures/unit/util/ec2/windows-2008-arp-a-not-ec2.out +6 -0
- data/spec/fixtures/unit/util/ec2/windows-2008-arp-a.out +10 -0
- data/spec/{unit/data → fixtures/unit/util/ip}/6.0-STABLE_FreeBSD_ifconfig +0 -0
- data/spec/{unit/data → fixtures/unit/util/ip}/Mac_OS_X_10.5.5_ifconfig +0 -0
- data/spec/{unit/data → fixtures/unit/util/ip}/darwin_ifconfig_all_with_multiple_interfaces +0 -0
- data/spec/{unit/data → fixtures/unit/util/ip}/darwin_ifconfig_single_interface +0 -0
- data/spec/{unit/data → fixtures/unit/util/ip}/debian_kfreebsd_ifconfig +0 -0
- data/spec/{unit/data → fixtures/unit/util/ip}/hpux_ifconfig_single_interface +0 -0
- data/spec/{unit/data → fixtures/unit/util/ip}/hpux_netstat_all_interfaces +0 -0
- data/spec/{unit/data → fixtures/unit/util/ip}/linux_ifconfig_all_with_single_interface +0 -0
- data/spec/{unit/data → fixtures/unit/util/ip}/solaris_ifconfig_all_with_multiple_interfaces +0 -0
- data/spec/{unit/data → fixtures/unit/util/ip}/solaris_ifconfig_single_interface +0 -0
- data/spec/{unit/data → fixtures/unit/util/ip}/windows_netsh_all_interfaces +0 -0
- data/spec/{unit/data → fixtures/unit/util/ip}/windows_netsh_single_interface +0 -0
- data/spec/{unit/data → fixtures/unit/util/ip}/windows_netsh_single_interface6 +0 -0
- data/spec/{unit/data → fixtures/unit/util/manufacturer}/freebsd_dmidecode +0 -0
- data/spec/{unit/data → fixtures/unit/util/manufacturer}/linux_dmidecode_with_spaces +0 -0
- data/spec/{unit/data → fixtures/unit/util/manufacturer}/opensolaris_smbios +0 -0
- data/spec/fixtures/{uptime → unit/util/uptime}/kstat_boot_time +0 -0
- data/spec/fixtures/unit/util/uptime/sysctl_kern_boottime_darwin +1 -0
- data/spec/fixtures/unit/util/uptime/sysctl_kern_boottime_openbsd +1 -0
- data/spec/fixtures/{uptime → unit/util/uptime}/ubuntu_proc_uptime +0 -0
- data/spec/fixtures/{uptime → unit/util/uptime}/who_b_boottime +0 -0
- data/spec/{unit/data → fixtures/unit/util/vlans}/linux_vlan_config +0 -0
- data/spec/{unit/data → fixtures/unit/util/xendomains}/xendomains +0 -0
- data/spec/integration/facter_spec.rb +2 -2
- data/spec/puppetlabs_spec/files.rb +57 -0
- data/spec/puppetlabs_spec/fixtures.rb +49 -0
- data/spec/puppetlabs_spec/matchers.rb +87 -0
- data/spec/puppetlabs_spec_helper.rb +25 -0
- data/spec/spec_helper.rb +9 -12
- data/spec/unit/architecture_spec.rb +2 -4
- data/spec/unit/domain_spec.rb +3 -1
- data/spec/unit/ec2_spec.rb +140 -0
- data/spec/unit/facter_spec.rb +2 -2
- data/spec/unit/hardwareisa_spec.rb +34 -0
- data/spec/unit/hostname_spec.rb +3 -1
- data/spec/unit/id_spec.rb +2 -2
- data/spec/unit/interfaces_spec.rb +2 -4
- data/spec/unit/ipaddress6_spec.rb +4 -7
- data/spec/unit/lsbmajdistrelease_spec.rb +13 -0
- data/spec/unit/macaddress_spec.rb +4 -7
- data/spec/unit/memory_spec.rb +11 -6
- data/spec/unit/operatingsystem_spec.rb +101 -69
- data/spec/unit/operatingsystemrelease_spec.rb +2 -4
- data/spec/unit/physicalprocessorcount_spec.rb +1 -1
- data/spec/unit/processor_spec.rb +32 -35
- data/spec/unit/selinux_spec.rb +5 -10
- data/spec/unit/uniqueid_spec.rb +27 -0
- data/spec/unit/uptime_spec.rb +2 -4
- data/spec/unit/util/collection_spec.rb +12 -3
- data/spec/unit/util/config_spec.rb +24 -0
- data/spec/unit/util/confine_spec.rb +2 -3
- data/spec/unit/util/ec2_spec.rb +112 -0
- data/spec/unit/util/fact_spec.rb +2 -3
- data/spec/unit/util/ip_spec.rb +27 -55
- data/spec/unit/util/loader_spec.rb +2 -4
- data/spec/unit/util/macaddress_spec.rb +4 -5
- data/spec/unit/util/macosx_spec.rb +2 -3
- data/spec/unit/util/manufacturer_spec.rb +8 -9
- data/spec/unit/util/processor_spec.rb +8 -10
- data/spec/unit/util/resolution_spec.rb +2 -3
- data/spec/unit/util/uptime_spec.rb +15 -14
- data/spec/unit/util/virtual_spec.rb +10 -2
- data/spec/unit/util/vlans_spec.rb +3 -5
- data/spec/unit/util/wmi_spec.rb +2 -3
- data/spec/unit/util/xendomains_spec.rb +3 -5
- data/spec/unit/virtual_spec.rb +48 -18
- metadata +44 -28
- data/spec/fixtures/uptime/sysctl_kern_boottime_big_endian +0 -0
- data/spec/fixtures/uptime/sysctl_kern_boottime_little_endian +0 -0
data/spec/unit/util/fact_spec.rb
CHANGED
data/spec/unit/util/ip_spec.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
#!/usr/bin/env
|
2
|
-
|
3
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
1
|
+
#!/usr/bin/env rspec
|
4
2
|
|
3
|
+
require 'spec_helper'
|
5
4
|
require 'facter/util/ip'
|
6
5
|
|
7
6
|
describe Facter::Util::IP do
|
@@ -26,44 +25,38 @@ describe Facter::Util::IP do
|
|
26
25
|
end
|
27
26
|
|
28
27
|
it "should return a list with a single interface and the loopback interface on Linux with a single interface" do
|
29
|
-
|
30
|
-
linux_ifconfig = File.read(sample_output_file)
|
28
|
+
linux_ifconfig = my_fixture_read("linux_ifconfig_all_with_single_interface")
|
31
29
|
Facter::Util::IP.stubs(:get_all_interface_output).returns(linux_ifconfig)
|
32
30
|
Facter::Util::IP.get_interfaces().should == ["eth0", "lo"]
|
33
31
|
end
|
34
32
|
|
35
33
|
it "should return a list two interfaces on Darwin with two interfaces" do
|
36
|
-
|
37
|
-
darwin_ifconfig = File.read(sample_output_file)
|
34
|
+
darwin_ifconfig = my_fixture_read("darwin_ifconfig_all_with_multiple_interfaces")
|
38
35
|
Facter::Util::IP.stubs(:get_all_interface_output).returns(darwin_ifconfig)
|
39
36
|
Facter::Util::IP.get_interfaces().should == ["lo0", "en0"]
|
40
37
|
end
|
41
38
|
|
42
39
|
it "should return a list two interfaces on Solaris with two interfaces multiply reporting" do
|
43
|
-
|
44
|
-
solaris_ifconfig = File.read(sample_output_file)
|
40
|
+
solaris_ifconfig = my_fixture_read("solaris_ifconfig_all_with_multiple_interfaces")
|
45
41
|
Facter::Util::IP.stubs(:get_all_interface_output).returns(solaris_ifconfig)
|
46
42
|
Facter::Util::IP.get_interfaces().should == ["lo0", "e1000g0"]
|
47
43
|
end
|
48
44
|
|
49
45
|
it "should return a list three interfaces on HP-UX with three interfaces multiply reporting" do
|
50
|
-
|
51
|
-
hpux_netstat = File.read(sample_output_file)
|
46
|
+
hpux_netstat = my_fixture_read("hpux_netstat_all_interfaces")
|
52
47
|
Facter::Util::IP.stubs(:get_all_interface_output).returns(hpux_netstat)
|
53
48
|
Facter::Util::IP.get_interfaces().should == ["lan1", "lan0", "lo0"]
|
54
49
|
end
|
55
50
|
|
56
51
|
it "should return a list of six interfaces on a GNU/kFreeBSD with six interfaces" do
|
57
|
-
|
58
|
-
kfreebsd_ifconfig = File.read(sample_output_file)
|
52
|
+
kfreebsd_ifconfig = my_fixture_read("debian_kfreebsd_ifconfig")
|
59
53
|
Facter::Util::IP.stubs(:get_all_interface_output).returns(kfreebsd_ifconfig)
|
60
54
|
Facter::Util::IP.get_interfaces().should == ["em0", "em1", "bge0", "bge1", "lo0", "vlan0"]
|
61
55
|
end
|
62
56
|
|
63
57
|
it "should return a list of only connected interfaces on Windows" do
|
64
58
|
Facter.fact(:kernel).stubs(:value).returns("windows")
|
65
|
-
|
66
|
-
windows_netsh = File.read(sample_output_file)
|
59
|
+
windows_netsh = my_fixture_read("windows_netsh_all_interfaces")
|
67
60
|
Facter::Util::IP.stubs(:get_all_interface_output).returns(windows_netsh)
|
68
61
|
Facter::Util::IP.get_interfaces().should == ["Loopback Pseudo-Interface 1", "Local Area Connection", "Teredo Tunneling Pseudo-Interface"]
|
69
62
|
end
|
@@ -78,8 +71,7 @@ describe Facter::Util::IP do
|
|
78
71
|
end
|
79
72
|
|
80
73
|
it "should return ipaddress information for Solaris" do
|
81
|
-
|
82
|
-
solaris_ifconfig_interface = File.read(sample_output_file)
|
74
|
+
solaris_ifconfig_interface = my_fixture_read("solaris_ifconfig_single_interface")
|
83
75
|
|
84
76
|
Facter::Util::IP.expects(:get_single_interface_output).with("e1000g0").returns(solaris_ifconfig_interface)
|
85
77
|
Facter.stubs(:value).with(:kernel).returns("SunOS")
|
@@ -88,8 +80,7 @@ describe Facter::Util::IP do
|
|
88
80
|
end
|
89
81
|
|
90
82
|
it "should return netmask information for Solaris" do
|
91
|
-
|
92
|
-
solaris_ifconfig_interface = File.read(sample_output_file)
|
83
|
+
solaris_ifconfig_interface = my_fixture_read("solaris_ifconfig_single_interface")
|
93
84
|
|
94
85
|
Facter::Util::IP.expects(:get_single_interface_output).with("e1000g0").returns(solaris_ifconfig_interface)
|
95
86
|
Facter.stubs(:value).with(:kernel).returns("SunOS")
|
@@ -98,8 +89,7 @@ describe Facter::Util::IP do
|
|
98
89
|
end
|
99
90
|
|
100
91
|
it "should return calculated network information for Solaris" do
|
101
|
-
|
102
|
-
solaris_ifconfig_interface = File.read(sample_output_file)
|
92
|
+
solaris_ifconfig_interface = my_fixture_read("solaris_ifconfig_single_interface")
|
103
93
|
|
104
94
|
Facter::Util::IP.stubs(:get_single_interface_output).with("e1000g0").returns(solaris_ifconfig_interface)
|
105
95
|
Facter.stubs(:value).with(:kernel).returns("SunOS")
|
@@ -108,8 +98,7 @@ describe Facter::Util::IP do
|
|
108
98
|
end
|
109
99
|
|
110
100
|
it "should return ipaddress information for HP-UX" do
|
111
|
-
|
112
|
-
hpux_ifconfig_interface = File.read(sample_output_file)
|
101
|
+
hpux_ifconfig_interface = my_fixture_read("hpux_ifconfig_single_interface")
|
113
102
|
|
114
103
|
Facter::Util::IP.expects(:get_single_interface_output).with("lan0").returns(hpux_ifconfig_interface)
|
115
104
|
Facter.stubs(:value).with(:kernel).returns("HP-UX")
|
@@ -118,8 +107,7 @@ describe Facter::Util::IP do
|
|
118
107
|
end
|
119
108
|
|
120
109
|
it "should return macaddress information for HP-UX" do
|
121
|
-
|
122
|
-
hpux_ifconfig_interface = File.read(sample_output_file)
|
110
|
+
hpux_ifconfig_interface = my_fixture_read("hpux_ifconfig_single_interface")
|
123
111
|
|
124
112
|
Facter::Util::IP.expects(:get_single_interface_output).with("lan0").returns(hpux_ifconfig_interface)
|
125
113
|
Facter.stubs(:value).with(:kernel).returns("HP-UX")
|
@@ -128,8 +116,7 @@ describe Facter::Util::IP do
|
|
128
116
|
end
|
129
117
|
|
130
118
|
it "should return macaddress with leading zeros stripped off for GNU/kFreeBSD" do
|
131
|
-
|
132
|
-
kfreebsd_ifconfig = File.read(sample_output_file)
|
119
|
+
kfreebsd_ifconfig = my_fixture_read("debian_kfreebsd_ifconfig")
|
133
120
|
|
134
121
|
Facter::Util::IP.expects(:get_single_interface_output).with("em0").returns(kfreebsd_ifconfig)
|
135
122
|
Facter.stubs(:value).with(:kernel).returns("GNU/kFreeBSD")
|
@@ -138,8 +125,7 @@ describe Facter::Util::IP do
|
|
138
125
|
end
|
139
126
|
|
140
127
|
it "should return netmask information for HP-UX" do
|
141
|
-
|
142
|
-
hpux_ifconfig_interface = File.read(sample_output_file)
|
128
|
+
hpux_ifconfig_interface = my_fixture_read("hpux_ifconfig_single_interface")
|
143
129
|
|
144
130
|
Facter::Util::IP.expects(:get_single_interface_output).with("lan0").returns(hpux_ifconfig_interface)
|
145
131
|
Facter.stubs(:value).with(:kernel).returns("HP-UX")
|
@@ -148,8 +134,7 @@ describe Facter::Util::IP do
|
|
148
134
|
end
|
149
135
|
|
150
136
|
it "should return calculated network information for HP-UX" do
|
151
|
-
|
152
|
-
hpux_ifconfig_interface = File.read(sample_output_file)
|
137
|
+
hpux_ifconfig_interface = my_fixture_read("hpux_ifconfig_single_interface")
|
153
138
|
|
154
139
|
Facter::Util::IP.stubs(:get_single_interface_output).with("lan0").returns(hpux_ifconfig_interface)
|
155
140
|
Facter.stubs(:value).with(:kernel).returns("HP-UX")
|
@@ -158,8 +143,7 @@ describe Facter::Util::IP do
|
|
158
143
|
end
|
159
144
|
|
160
145
|
it "should return interface information for FreeBSD supported via an alias" do
|
161
|
-
|
162
|
-
ifconfig_interface = File.read(sample_output_file)
|
146
|
+
ifconfig_interface = my_fixture_read("6.0-STABLE_FreeBSD_ifconfig")
|
163
147
|
|
164
148
|
Facter::Util::IP.expects(:get_single_interface_output).with("fxp0").returns(ifconfig_interface)
|
165
149
|
Facter.stubs(:value).with(:kernel).returns("FreeBSD")
|
@@ -168,8 +152,7 @@ describe Facter::Util::IP do
|
|
168
152
|
end
|
169
153
|
|
170
154
|
it "should return macaddress information for OS X" do
|
171
|
-
|
172
|
-
ifconfig_interface = File.read(sample_output_file)
|
155
|
+
ifconfig_interface = my_fixture_read("Mac_OS_X_10.5.5_ifconfig")
|
173
156
|
|
174
157
|
Facter::Util::IP.expects(:get_single_interface_output).with("en1").returns(ifconfig_interface)
|
175
158
|
Facter.stubs(:value).with(:kernel).returns("Darwin")
|
@@ -178,8 +161,7 @@ describe Facter::Util::IP do
|
|
178
161
|
end
|
179
162
|
|
180
163
|
it "should return all interfaces correctly on OS X" do
|
181
|
-
|
182
|
-
ifconfig_interface = File.read(sample_output_file)
|
164
|
+
ifconfig_interface = my_fixture_read("Mac_OS_X_10.5.5_ifconfig")
|
183
165
|
|
184
166
|
Facter::Util::IP.expects(:get_all_interface_output).returns(ifconfig_interface)
|
185
167
|
Facter.stubs(:value).with(:kernel).returns("Darwin")
|
@@ -188,8 +170,7 @@ describe Facter::Util::IP do
|
|
188
170
|
end
|
189
171
|
|
190
172
|
it "should return a human readable netmask on Solaris" do
|
191
|
-
|
192
|
-
solaris_ifconfig_interface = File.read(sample_output_file)
|
173
|
+
solaris_ifconfig_interface = my_fixture_read("solaris_ifconfig_single_interface")
|
193
174
|
|
194
175
|
Facter::Util::IP.expects(:get_single_interface_output).with("e1000g0").returns(solaris_ifconfig_interface)
|
195
176
|
Facter.stubs(:value).with(:kernel).returns("SunOS")
|
@@ -198,8 +179,7 @@ describe Facter::Util::IP do
|
|
198
179
|
end
|
199
180
|
|
200
181
|
it "should return a human readable netmask on HP-UX" do
|
201
|
-
|
202
|
-
hpux_ifconfig_interface = File.read(sample_output_file)
|
182
|
+
hpux_ifconfig_interface = my_fixture_read("hpux_ifconfig_single_interface")
|
203
183
|
|
204
184
|
Facter::Util::IP.expects(:get_single_interface_output).with("lan0").returns(hpux_ifconfig_interface)
|
205
185
|
Facter.stubs(:value).with(:kernel).returns("HP-UX")
|
@@ -208,9 +188,7 @@ describe Facter::Util::IP do
|
|
208
188
|
end
|
209
189
|
|
210
190
|
it "should return a human readable netmask on Darwin" do
|
211
|
-
|
212
|
-
|
213
|
-
darwin_ifconfig_interface = File.read(sample_output_file)
|
191
|
+
darwin_ifconfig_interface = my_fixture_read("darwin_ifconfig_single_interface")
|
214
192
|
|
215
193
|
Facter::Util::IP.expects(:get_single_interface_output).with("en1").returns(darwin_ifconfig_interface)
|
216
194
|
Facter.stubs(:value).with(:kernel).returns("Darwin")
|
@@ -219,9 +197,7 @@ describe Facter::Util::IP do
|
|
219
197
|
end
|
220
198
|
|
221
199
|
it "should return a human readable netmask on GNU/kFreeBSD" do
|
222
|
-
|
223
|
-
|
224
|
-
kfreebsd_ifconfig = File.read(sample_output_file)
|
200
|
+
kfreebsd_ifconfig = my_fixture_read("debian_kfreebsd_ifconfig")
|
225
201
|
|
226
202
|
Facter::Util::IP.expects(:get_single_interface_output).with("em1").returns(kfreebsd_ifconfig)
|
227
203
|
Facter.stubs(:value).with(:kernel).returns("GNU/kFreeBSD")
|
@@ -260,8 +236,7 @@ describe Facter::Util::IP do
|
|
260
236
|
end
|
261
237
|
|
262
238
|
it "should return ipaddress information" do
|
263
|
-
|
264
|
-
windows_netsh = File.read(sample_output_file)
|
239
|
+
windows_netsh = my_fixture_read("windows_netsh_single_interface")
|
265
240
|
|
266
241
|
Facter::Util::IP.expects(:get_output_for_interface_and_label).with("Local Area Connection", "ipaddress").returns(windows_netsh)
|
267
242
|
|
@@ -269,8 +244,7 @@ describe Facter::Util::IP do
|
|
269
244
|
end
|
270
245
|
|
271
246
|
it "should return a human readable netmask" do
|
272
|
-
|
273
|
-
windows_netsh = File.read(sample_output_file)
|
247
|
+
windows_netsh = my_fixture_read("windows_netsh_single_interface")
|
274
248
|
|
275
249
|
Facter::Util::IP.expects(:get_output_for_interface_and_label).with("Local Area Connection", "netmask").returns(windows_netsh)
|
276
250
|
|
@@ -278,8 +252,7 @@ describe Facter::Util::IP do
|
|
278
252
|
end
|
279
253
|
|
280
254
|
it "should return network information" do
|
281
|
-
|
282
|
-
windows_netsh = File.read(sample_output_file)
|
255
|
+
windows_netsh = my_fixture_read("windows_netsh_single_interface")
|
283
256
|
|
284
257
|
Facter::Util::IP.stubs(:get_output_for_interface_and_label).with("Local Area Connection", "ipaddress").returns(windows_netsh)
|
285
258
|
Facter::Util::IP.stubs(:get_output_for_interface_and_label).with("Local Area Connection", "netmask").returns(windows_netsh)
|
@@ -288,8 +261,7 @@ describe Facter::Util::IP do
|
|
288
261
|
end
|
289
262
|
|
290
263
|
it "should return ipaddress6 information" do
|
291
|
-
|
292
|
-
windows_netsh = File.read(sample_output_file)
|
264
|
+
windows_netsh = my_fixture_read("windows_netsh_single_interface6")
|
293
265
|
|
294
266
|
Facter::Util::IP.expects(:get_output_for_interface_and_label).with("Teredo Tunneling Pseudo-Interface", "ipaddress6").returns(windows_netsh)
|
295
267
|
|
@@ -1,10 +1,8 @@
|
|
1
|
-
#!/usr/bin/env
|
2
|
-
|
3
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
1
|
+
#!/usr/bin/env rspec
|
4
2
|
|
3
|
+
require 'spec_helper'
|
5
4
|
require 'facter/util/loader'
|
6
5
|
|
7
|
-
|
8
6
|
# loader subclass for making assertions about file/directory ordering
|
9
7
|
class TestLoader < Facter::Util::Loader
|
10
8
|
def loaded_files
|
@@ -1,7 +1,6 @@
|
|
1
|
-
#!/usr/bin/env
|
2
|
-
|
3
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
1
|
+
#!/usr/bin/env rspec
|
4
2
|
|
3
|
+
require 'spec_helper'
|
5
4
|
require 'facter/util/macaddress'
|
6
5
|
|
7
6
|
describe "standardized MAC address" do
|
@@ -29,8 +28,8 @@ describe "Darwin", :unless => Facter.value(:operatingsystem) == 'windows' do
|
|
29
28
|
]
|
30
29
|
|
31
30
|
test_cases.each do |version, default_iface, macaddress, fallback_macaddress|
|
32
|
-
netstat_file =
|
33
|
-
ifconfig_file_no_iface =
|
31
|
+
netstat_file = fixtures("netstat", "darwin_#{version.tr('.', '_')}")
|
32
|
+
ifconfig_file_no_iface = fixtures("ifconfig", "darwin_#{version.tr('.', '_')}")
|
34
33
|
ifconfig_file = "#{ifconfig_file_no_iface}_#{default_iface}"
|
35
34
|
|
36
35
|
describe "version #{version}" do
|
@@ -1,5 +1,6 @@
|
|
1
|
-
|
1
|
+
#!/usr/bin/env rspec
|
2
2
|
|
3
|
+
require 'spec_helper'
|
3
4
|
require 'facter/util/manufacturer'
|
4
5
|
|
5
6
|
describe Facter::Manufacturer do
|
@@ -17,14 +18,14 @@ describe Facter::Manufacturer do
|
|
17
18
|
end
|
18
19
|
|
19
20
|
it "should parse prtdiag output on a sunfire v120" do
|
20
|
-
Facter::Util::Resolution.stubs(:exec).returns(
|
21
|
+
Facter::Util::Resolution.stubs(:exec).returns(my_fixture_read("solaris_sunfire_v120_prtdiag"))
|
21
22
|
Facter::Manufacturer.prtdiag_sparc_find_system_info()
|
22
23
|
Facter.value(:manufacturer).should == "Sun Microsystems"
|
23
24
|
Facter.value(:productname).should == "Sun Fire V120 (UltraSPARC-IIe 648MHz)"
|
24
25
|
end
|
25
26
|
|
26
27
|
it "should parse prtdiag output on a t5220" do
|
27
|
-
Facter::Util::Resolution.stubs(:exec).returns(
|
28
|
+
Facter::Util::Resolution.stubs(:exec).returns(my_fixture_read("solaris_t5220_prtdiag"))
|
28
29
|
Facter::Manufacturer.prtdiag_sparc_find_system_info()
|
29
30
|
Facter.value(:manufacturer).should == "Sun Microsystems"
|
30
31
|
Facter.value(:productname).should == "SPARC Enterprise T5220"
|
@@ -41,8 +42,7 @@ describe Facter::Manufacturer do
|
|
41
42
|
end
|
42
43
|
|
43
44
|
it "should strip white space on dmi output with spaces" do
|
44
|
-
|
45
|
-
dmidecode_output = File.new(sample_output_file).read()
|
45
|
+
dmidecode_output = my_fixture_read("linux_dmidecode_with_spaces")
|
46
46
|
Facter::Manufacturer.expects(:get_dmi_table).returns(dmidecode_output)
|
47
47
|
Facter.fact(:kernel).stubs(:value).returns("Linux")
|
48
48
|
|
@@ -53,8 +53,7 @@ describe Facter::Manufacturer do
|
|
53
53
|
end
|
54
54
|
|
55
55
|
it "should handle output from smbios when run under sunos" do
|
56
|
-
|
57
|
-
smbios_output = File.new(sample_output_file).read()
|
56
|
+
smbios_output = my_fixture_read("opensolaris_smbios")
|
58
57
|
Facter::Manufacturer.expects(:get_dmi_table).returns(smbios_output)
|
59
58
|
Facter.fact(:kernel).stubs(:value).returns("SunOS")
|
60
59
|
|
@@ -126,8 +125,8 @@ Handle 0x001F
|
|
126
125
|
|
127
126
|
def find_product_name(os)
|
128
127
|
output_file = case os
|
129
|
-
when "FreeBSD" then
|
130
|
-
when "SunOS" then
|
128
|
+
when "FreeBSD" then my_fixture("freebsd_dmidecode")
|
129
|
+
when "SunOS" then my_fixture("opensolaris_smbios")
|
131
130
|
end
|
132
131
|
|
133
132
|
output = File.new(output_file).read()
|
@@ -1,12 +1,10 @@
|
|
1
|
-
#!/usr/bin/env
|
2
|
-
|
3
|
-
$basedir = File.expand_path(File.dirname(__FILE__) + '/../..')
|
4
|
-
require File.join($basedir, 'spec_helper')
|
1
|
+
#!/usr/bin/env rspec
|
5
2
|
|
3
|
+
require 'spec_helper'
|
6
4
|
require 'facter/util/processor'
|
7
5
|
|
8
6
|
def cpuinfo_fixture(filename)
|
9
|
-
|
7
|
+
File.open(fixtures('cpuinfo', filename)).readlines
|
10
8
|
end
|
11
9
|
|
12
10
|
describe Facter::Util::Processor do
|
@@ -15,7 +13,7 @@ describe Facter::Util::Processor do
|
|
15
13
|
Facter.fact(:architecture).stubs(:value).returns("amd64")
|
16
14
|
File.stubs(:exists?).with("/proc/cpuinfo").returns(true)
|
17
15
|
File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture("amd64solo"))
|
18
|
-
|
16
|
+
|
19
17
|
Facter::Util::Processor.enum_cpuinfo[0].should == "Intel(R) Core(TM)2 Duo CPU P8700 @ 2.53GHz"
|
20
18
|
end
|
21
19
|
|
@@ -24,22 +22,22 @@ describe Facter::Util::Processor do
|
|
24
22
|
Facter.fact(:architecture).stubs(:value).returns("amd64")
|
25
23
|
File.stubs(:exists?).with("/proc/cpuinfo").returns(true)
|
26
24
|
File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture("amd64dual"))
|
27
|
-
|
25
|
+
|
28
26
|
Facter::Util::Processor.enum_cpuinfo[0].should == "Intel(R) Core(TM)2 Duo CPU P8700 @ 2.53GHz"
|
29
27
|
Facter::Util::Processor.enum_cpuinfo[1].should == "Intel(R) Core(TM)2 Duo CPU P8700 @ 2.53GHz"
|
30
28
|
end
|
31
|
-
|
29
|
+
|
32
30
|
it "should get the processor descriptions from the amd64tri fixture" do
|
33
31
|
Facter.fact(:kernel).stubs(:value).returns("Linux")
|
34
32
|
Facter.fact(:architecture).stubs(:value).returns("amd64")
|
35
33
|
File.stubs(:exists?).with("/proc/cpuinfo").returns(true)
|
36
34
|
File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture("amd64tri"))
|
37
|
-
|
35
|
+
|
38
36
|
Facter::Util::Processor.enum_cpuinfo[0].should == "Intel(R) Core(TM)2 Duo CPU P8700 @ 2.53GHz"
|
39
37
|
Facter::Util::Processor.enum_cpuinfo[1].should == "Intel(R) Core(TM)2 Duo CPU P8700 @ 2.53GHz"
|
40
38
|
Facter::Util::Processor.enum_cpuinfo[2].should == "Intel(R) Core(TM)2 Duo CPU P8700 @ 2.53GHz"
|
41
39
|
end
|
42
|
-
|
40
|
+
|
43
41
|
it "should get the processor descriptions from the amd64quad fixture" do
|
44
42
|
Facter.fact(:kernel).stubs(:value).returns("Linux")
|
45
43
|
Facter.fact(:architecture).stubs(:value).returns("amd64")
|
@@ -1,7 +1,6 @@
|
|
1
|
-
#!/usr/bin/env
|
2
|
-
|
3
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
1
|
+
#!/usr/bin/env rspec
|
4
2
|
|
3
|
+
require 'spec_helper'
|
5
4
|
require 'facter/util/uptime'
|
6
5
|
|
7
6
|
describe Facter::Util::Uptime do
|
@@ -9,7 +8,7 @@ describe Facter::Util::Uptime do
|
|
9
8
|
describe ".get_uptime_seconds_unix", :unless => Facter.value(:operatingsystem) == 'windows' do
|
10
9
|
describe "when /proc/uptime is available" do
|
11
10
|
before do
|
12
|
-
uptime_file =
|
11
|
+
uptime_file = my_fixture("ubuntu_proc_uptime")
|
13
12
|
Facter::Util::Uptime.stubs(:uptime_file).returns("\"#{uptime_file}\"")
|
14
13
|
end
|
15
14
|
|
@@ -26,15 +25,17 @@ describe Facter::Util::Uptime do
|
|
26
25
|
Facter::Util::Uptime.stubs(:uptime_file).returns(@nonexistent_file)
|
27
26
|
end
|
28
27
|
|
29
|
-
it "should use 'sysctl kern.boottime'" do
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
28
|
+
it "should use 'sysctl -n kern.boottime' on OpenBSD" do
|
29
|
+
sysctl_output_file = my_fixture('sysctl_kern_boottime_openbsd') # Dec 09 21:11:46 +0000 2011
|
30
|
+
Facter::Util::Uptime.stubs(:uptime_sysctl_cmd).returns("cat \"#{sysctl_output_file}\"")
|
31
|
+
Time.stubs(:now).returns Time.parse("Dec 09 22:11:46 +0000 2011") # one hour later
|
32
|
+
Facter::Util::Uptime.get_uptime_seconds_unix.should == 60 * 60
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should use 'sysctl -n kern.boottime' on Darwin, etc." do
|
36
|
+
sysctl_output_file = my_fixture('sysctl_kern_boottime_darwin') # Oct 30 21:52:27 +0000 2011
|
36
37
|
Facter::Util::Uptime.stubs(:uptime_sysctl_cmd).returns("cat \"#{sysctl_output_file}\"")
|
37
|
-
Time.stubs(:now).returns Time.parse("
|
38
|
+
Time.stubs(:now).returns Time.parse("Oct 30 22:52:27 +0000 2011") # one hour later
|
38
39
|
Facter::Util::Uptime.get_uptime_seconds_unix.should == 60 * 60
|
39
40
|
end
|
40
41
|
|
@@ -44,7 +45,7 @@ describe Facter::Util::Uptime do
|
|
44
45
|
end
|
45
46
|
|
46
47
|
it "should use 'kstat -p unix:::boot_time'" do
|
47
|
-
kstat_output_file =
|
48
|
+
kstat_output_file = my_fixture('kstat_boot_time') # unix:0:system_misc:boot_time 1236919980
|
48
49
|
Facter::Util::Uptime.stubs(:uptime_kstat_cmd).returns("cat \"#{kstat_output_file}\"")
|
49
50
|
Time.stubs(:now).returns Time.at(1236923580) #one hour later
|
50
51
|
Facter::Util::Uptime.get_uptime_seconds_unix.should == 60 * 60
|
@@ -56,7 +57,7 @@ describe Facter::Util::Uptime do
|
|
56
57
|
end
|
57
58
|
|
58
59
|
it "should use 'who -b'" do
|
59
|
-
who_b_output_file =
|
60
|
+
who_b_output_file = my_fixture('who_b_boottime') # Aug 1 14:13
|
60
61
|
Facter::Util::Uptime.stubs(:uptime_who_cmd).returns("cat \"#{who_b_output_file}\"")
|
61
62
|
Time.stubs(:now).returns Time.parse("Aug 01 15:13") # one hour later
|
62
63
|
Facter::Util::Uptime.get_uptime_seconds_unix.should == 60 * 60
|