Merge lp:~gandelman-a/ubuntu/precise/facter/merge922788 into lp:ubuntu/precise/facter
- Precise (12.04)
- merge922788
- Merge into precise
Proposed by
Adam Gandelman
Status: | Merged |
---|---|
Merge reported by: | Jamie Strandboge |
Merged at revision: | not available |
Proposed branch: | lp:~gandelman-a/ubuntu/precise/facter/merge922788 |
Merge into: | lp:ubuntu/precise/facter |
Diff against target: |
6642 lines (+3054/-2736) 64 files modified
CHANGELOG (+18/-0) LICENSE (+1/-1) conf/osx/createpackage.sh (+1/-1) conf/redhat/facter.spec (+13/-6) conf/solaris/pkginfo (+1/-1) debian/changelog (+35/-0) debian/control (+1/-1) debian/facter.dirs (+0/-1) install.rb (+14/-17) lib/facter.rb (+2/-2) lib/facter/architecture.rb (+1/-2) lib/facter/augeasversion.rb (+1/-2) lib/facter/domain.rb (+3/-3) lib/facter/hardwareisa.rb (+1/-1) lib/facter/ipaddress.rb (+2/-2) lib/facter/lsbmajdistrelease.rb (+1/-1) lib/facter/macaddress.rb (+2/-2) lib/facter/manufacturer.rb (+6/-1) lib/facter/netmask.rb (+0/-3) lib/facter/network.rb (+2/-3) lib/facter/operatingsystem.rb (+5/-2) lib/facter/operatingsystemrelease.rb (+3/-3) lib/facter/osfamily.rb (+1/-1) lib/facter/processor.rb (+2/-2) lib/facter/selinux.rb (+3/-3) lib/facter/uniqueid.rb (+1/-1) lib/facter/uptime_days.rb (+0/-1) lib/facter/uptime_hours.rb (+0/-1) lib/facter/util/macaddress.rb (+1/-0) lib/facter/util/manufacturer.rb (+2/-3) lib/facter/util/processor.rb (+3/-3) lib/facter/util/resolution.rb (+3/-3) lib/facter/util/values.rb (+1/-1) lib/facter/virtual.rb (+2/-2) lib/facter/vlans.rb (+1/-2) lib/facter/xendomains.rb (+0/-1) spec/fixtures/ifconfig/linux_ifconfig_no_mac (+8/-0) spec/fixtures/ifconfig/linux_ifconfig_venet (+24/-0) spec/fixtures/unit/util/manufacturer/solaris_sunfire_v120_prtdiag (+33/-0) spec/fixtures/unit/util/manufacturer/solaris_t5220_prtdiag (+136/-0) spec/spec_helper.rb (+5/-0) spec/unit/architecture_spec.rb (+44/-44) spec/unit/facter_spec.rb (+266/-264) spec/unit/id_spec.rb (+21/-21) spec/unit/interfaces_spec.rb (+6/-6) spec/unit/macaddress_spec.rb (+36/-12) spec/unit/memory_spec.rb (+137/-137) spec/unit/operatingsystem_spec.rb (+82/-73) spec/unit/operatingsystemrelease_spec.rb (+50/-49) spec/unit/processor_spec.rb (+2/-2) spec/unit/selinux_spec.rb (+80/-80) spec/unit/util/collection_spec.rb (+247/-247) spec/unit/util/confine_spec.rb (+129/-129) spec/unit/util/fact_spec.rb (+121/-121) spec/unit/util/ip_spec.rb (+290/-290) spec/unit/util/loader_spec.rb (+265/-265) spec/unit/util/macaddress_spec.rb (+6/-1) spec/unit/util/macosx_spec.rb (+73/-73) spec/unit/util/manufacturer_spec.rb (+123/-106) spec/unit/util/resolution_spec.rb (+291/-291) spec/unit/util/virtual_spec.rb (+168/-168) spec/unit/util/vlans_spec.rb (+6/-6) spec/unit/virtual_spec.rb (+271/-271) spec/watchr.rb (+1/-1) |
To merge this branch: | bzr merge lp:~gandelman-a/ubuntu/precise/facter/merge922788 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ubuntu branches | Pending | ||
Review via email: mp+90519@code.launchpad.net |
Commit message
Description of the change
facter (1.6.4-2ubuntu1) precise; urgency=low
* Merge from Debian testing (LP: #922788). Remaining changes:
- debian/rules: use what we had in natty; we don't want ruby-pkg-tools
in main. (LP: #408402)
- debian/control: Continue using ruby + libopenssl-ruby as Build-Depends
even tho Debian has moved to gem2deb (not in main). Move ruby-json to
Suggests.
- debian/rules: Use dh_prep instead of dh_clean, add build-arch +
build-indep targets
- debian/control: Make binary package depend on ruby1.8 explicitly.
* Dropped changes:
- debian/control: Update debhelper Build-Depends to 8 (Updated in Debian)
-- Adam Gandelman <email address hidden> Fri, 27 Jan 2012 11:05:12 -0800
To post a comment you must log in.
Revision history for this message
Jamie Strandboge (jdstrand) wrote : | # |
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'CHANGELOG' |
2 | --- CHANGELOG 2011-11-10 10:11:05 +0000 |
3 | +++ CHANGELOG 2012-01-27 20:04:26 +0000 |
4 | @@ -1,3 +1,21 @@ |
5 | +1.6.4 |
6 | +=== |
7 | +6406c8f (##11041) Add dmidecode as a requirement for rpm |
8 | +ed81492 (#10444) Add identification of system boards to Facter |
9 | +bdbb2da (#10885) Malformed facter.bat when ruby dir contains backreferences |
10 | +0bad18b (#10490) Handle case where no macaddress can be found |
11 | + |
12 | +1.6.3 |
13 | +=== |
14 | +b2a66a9 (#7038) Validate prtdiag output in manufacturer |
15 | +c9db305 (#10228) Ascendos OS support for various facts. |
16 | +6efadbb (#10233) Adds support for Parallels Server Bare Metal to Facter |
17 | +ce8f572 (#10079) Remove trailing whitespace |
18 | +e89758d Updated CHANGELOG for 1.6.2 |
19 | +7b14b77 (#9928) Correct readlines stubbing to return an array instead of an empty string. |
20 | +0d6df28 (#9904) Remove windows rspec warning. |
21 | +f0ccb5e (#9555) Spec tests: Change all cases of tabs and 4 space indentation to 2 space indentation. |
22 | + |
23 | 1.6.2 |
24 | === |
25 | d7c00f6 (#9852) Fixing watchr on facter |
26 | |
27 | === modified file 'LICENSE' |
28 | --- LICENSE 2011-06-24 10:04:12 +0000 |
29 | +++ LICENSE 2012-01-27 20:04:26 +0000 |
30 | @@ -11,5 +11,5 @@ |
31 | Unless required by applicable law or agreed to in writing, software |
32 | distributed under the License is distributed on an "AS IS" BASIS, |
33 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
34 | -See the License for the specific language governing permissions and |
35 | +See the License for the specific language governing permissions and |
36 | limitations under the License. |
37 | |
38 | === modified file 'conf/osx/createpackage.sh' |
39 | --- conf/osx/createpackage.sh 2010-12-01 16:02:13 +0000 |
40 | +++ conf/osx/createpackage.sh 2012-01-27 20:04:26 +0000 |
41 | @@ -56,7 +56,7 @@ |
42 | |
43 | function install_docs() { |
44 | echo "Installing docs to ${pkgroot}" |
45 | - docdir="${pkgroot}/usr/share/doc/facter" |
46 | + docdir="${pkgroot}/usr/share/doc/facter" |
47 | mkdir -p "${docdir}" |
48 | for docfile in ChangeLog COPYING LICENSE README README.rst TODO; do |
49 | install -m 0644 "${facter_root}/${docfile}" "${docdir}" |
50 | |
51 | === modified file 'conf/redhat/facter.spec' |
52 | --- conf/redhat/facter.spec 2011-10-12 11:29:53 +0000 |
53 | +++ conf/redhat/facter.spec 2012-01-27 20:04:26 +0000 |
54 | @@ -2,17 +2,17 @@ |
55 | |
56 | %define has_ruby_abi 0%{?fedora} || 0%{?rhel} >= 5 |
57 | %define has_ruby_noarch %has_ruby_abi |
58 | -%global _ver 1.6.2 |
59 | +%global _ver 1.6.4 |
60 | |
61 | Summary: Ruby module for collecting simple facts about a host operating system |
62 | Name: facter |
63 | -Version: 1.6.2 |
64 | -Release: 1%{?dist} |
65 | +Version: 1.6.4 |
66 | +Release: 0.1rc1%{?dist} |
67 | License: Apache 2.0 |
68 | Group: System Environment/Base |
69 | URL: http://www.puppetlabs.com/puppet/related-projects/%{name}/ |
70 | -Source0: http://puppetlabs.com/downloads/%{name}/%{name}-%{_ver}.tar.gz |
71 | -#Source1: http://puppetlabs.com/downloads/%{name}/%{name}-%{version}.tar.gz.sign |
72 | +Source0: http://puppetlabs.com/downloads/%{name}/%{name}-%{version}rc1.tar.gz |
73 | +#Source1: http://puppetlabs.com/downloads/%{name}/%{name}-%{version}rc1.tar.gz.asc |
74 | |
75 | BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) |
76 | %if %has_ruby_noarch |
77 | @@ -21,6 +21,7 @@ |
78 | |
79 | Requires: ruby >= 1.8.1 |
80 | Requires: which |
81 | +Requires: dmidecode |
82 | %if %has_ruby_abi |
83 | Requires: ruby(abi) = 1.8 |
84 | %endif |
85 | @@ -32,7 +33,7 @@ |
86 | operating system. Additional facts can be added through simple Ruby scripts |
87 | |
88 | %prep |
89 | -%setup -q -n %{name}-%{_ver} |
90 | +%setup -q -n %{name}-%{version}rc1 |
91 | |
92 | %build |
93 | |
94 | @@ -53,6 +54,12 @@ |
95 | |
96 | |
97 | %changelog |
98 | +* Wed Nov 30 2011 Matthaus Litteken <matthaus@puppetlabs.com> - 1.6.4-0.1rc1 |
99 | +- 1.6.4 rc1 |
100 | + |
101 | +* Mon Oct 31 2011 Michael Stahnke <stahnma@puppetlabs.com> - 1.6.3-0.1rc1 |
102 | +- 1.6.3 rc1 |
103 | + |
104 | * Mon Oct 10 2011 Michael Stahnke <stahnma@puppetlabs.com> - 1.6.2-1 |
105 | - Update to 1.6.2 |
106 | |
107 | |
108 | === modified file 'conf/solaris/pkginfo' |
109 | --- conf/solaris/pkginfo 2011-10-12 11:29:53 +0000 |
110 | +++ conf/solaris/pkginfo 2012-01-27 20:04:26 +0000 |
111 | @@ -1,6 +1,6 @@ |
112 | PKG=CSWfacter |
113 | NAME=facter - System Fact Gatherer |
114 | -VERSION=1.6.2 |
115 | +VERSION=1.6.3rc1 |
116 | CATEGORY=application |
117 | VENDOR=http://www.puppetlabs.com/puppet/related-projects/facter |
118 | HOTLINE=http://puppetlabs.com/cgi-bin/facter.cgi |
119 | |
120 | === modified file 'debian/changelog' |
121 | --- debian/changelog 2011-11-10 10:11:05 +0000 |
122 | +++ debian/changelog 2012-01-27 20:04:26 +0000 |
123 | @@ -1,3 +1,38 @@ |
124 | +facter (1.6.4-2ubuntu1) precise; urgency=low |
125 | + |
126 | + * Merge from Debian testing (LP: #922788). Remaining changes: |
127 | + - debian/rules: use what we had in natty; we don't want ruby-pkg-tools |
128 | + in main. (LP: #408402) |
129 | + - debian/control: Continue using ruby + libopenssl-ruby as Build-Depends |
130 | + even tho Debian has moved to gem2deb (not in main). Move ruby-json to |
131 | + Suggests. |
132 | + - debian/rules: Use dh_prep instead of dh_clean, add build-arch + |
133 | + build-indep targets |
134 | + - debian/control: Make binary package depend on ruby1.8 explicitly. |
135 | + * Dropped changes: |
136 | + - debian/control: Update debhelper Build-Depends to 8 (Updated in Debian) |
137 | + |
138 | + -- Adam Gandelman <adamg@canonical.com> Fri, 27 Jan 2012 11:05:12 -0800 |
139 | + |
140 | +facter (1.6.4-2) unstable; urgency=low |
141 | + |
142 | + * Move dmidecode from Depends to Recommends (Closes: #651501) |
143 | + |
144 | + -- Stig Sandbeck Mathisen <ssm@debian.org> Fri, 09 Dec 2011 09:40:16 +0100 |
145 | + |
146 | +facter (1.6.4-1) unstable; urgency=low |
147 | + |
148 | + * New upstream release |
149 | + * Add dependency on dmidecode |
150 | + |
151 | + -- Stig Sandbeck Mathisen <ssm@debian.org> Thu, 08 Dec 2011 01:19:09 +0100 |
152 | + |
153 | +facter (1.6.3-1) unstable; urgency=low |
154 | + |
155 | + * New upstream release |
156 | + |
157 | + -- Stig Sandbeck Mathisen <ssm@debian.org> Tue, 22 Nov 2011 21:44:38 +0100 |
158 | + |
159 | facter (1.6.2-1ubuntu1) precise; urgency=low |
160 | |
161 | * Merge from Debian testing (LP: #888671). Remaining changes: |
162 | |
163 | === modified file 'debian/control' |
164 | --- debian/control 2011-11-10 10:11:05 +0000 |
165 | +++ debian/control 2012-01-27 20:04:26 +0000 |
166 | @@ -15,7 +15,7 @@ |
167 | Architecture: all |
168 | XB-Ruby-Versions: ${ruby:Versions} |
169 | Depends: ${misc:Depends}, ruby1.8, net-tools, bind9-host | host |
170 | -Recommends: pciutils |
171 | +Recommends: pciutils, dmidecode |
172 | Suggests: ruby-json |
173 | Description: collect and display facts about the system |
174 | A cross-platform Ruby library for retrieving facts from operating systems. |
175 | |
176 | === removed file 'debian/facter.dirs' |
177 | --- debian/facter.dirs 2010-01-29 09:57:40 +0000 |
178 | +++ debian/facter.dirs 1970-01-01 00:00:00 +0000 |
179 | @@ -1,1 +0,0 @@ |
180 | -usr/lib/ruby/1.8 |
181 | |
182 | === modified file 'install.rb' |
183 | --- install.rb 2011-11-10 10:11:05 +0000 |
184 | +++ install.rb 2012-01-27 20:04:26 +0000 |
185 | @@ -101,7 +101,7 @@ |
186 | end |
187 | |
188 | def do_man(man, strip = 'man/') |
189 | - if (InstallOptions.man == true) |
190 | + if (InstallOptions.man == true) |
191 | man.each do |mf| |
192 | omf = File.join(InstallOptions.man_dir, mf.gsub(/#{strip}/, '')) |
193 | om = File.dirname(omf) |
194 | @@ -418,29 +418,26 @@ |
195 | if not installed_wrapper |
196 | tmp_file2 = File.join(tmp_dir, '_tmp_wrapper') |
197 | cwn = File.join(Config::CONFIG['bindir'], op_file) |
198 | - cwv = CMD_WRAPPER.gsub('<ruby>', ruby.gsub(%r{/}) { "\\" }).gsub!('<command>', cwn.gsub(%r{/}) { "\\" } ) |
199 | - |
200 | - File.open(tmp_file2, "wb") { |cw| cw.puts cwv } |
201 | - FileUtils.install(tmp_file2, File.join(target, "#{op_file}.bat"), :mode => 0755, :verbose => true) |
202 | - |
203 | - File.unlink(tmp_file2) |
204 | - installed_wrapper = true |
205 | - end |
206 | - end |
207 | - FileUtils.install(tmp_file, File.join(target, op_file), :mode => 0755, :verbose => true) |
208 | - File.unlink(tmp_file) |
209 | -end |
210 | - |
211 | -CMD_WRAPPER = <<-EOS |
212 | + cwv = <<-EOS |
213 | @echo off |
214 | if "%OS%"=="Windows_NT" goto WinNT |
215 | -<ruby> -x "<command>" %1 %2 %3 %4 %5 %6 %7 %8 %9 |
216 | +#{ruby} -x "#{cwn}" %1 %2 %3 %4 %5 %6 %7 %8 %9 |
217 | goto done |
218 | :WinNT |
219 | -<ruby> -x "<command>" %* |
220 | +#{ruby} -x "#{cwn}" %* |
221 | goto done |
222 | :done |
223 | EOS |
224 | + File.open(tmp_file2, "w") { |cw| cw.puts cwv } |
225 | + FileUtils.install(tmp_file2, File.join(target, "#{op_file}.bat"), :mode => 0755, :verbose => true) |
226 | + |
227 | + File.unlink(tmp_file2) |
228 | + installed_wrapper = true |
229 | + end |
230 | + end |
231 | + FileUtils.install(tmp_file, File.join(target, op_file), :mode => 0755, :verbose => true) |
232 | + File.unlink(tmp_file) |
233 | +end |
234 | |
235 | check_prereqs |
236 | prepare_installation |
237 | |
238 | === modified file 'lib/facter.rb' |
239 | --- lib/facter.rb 2011-11-10 10:11:05 +0000 |
240 | +++ lib/facter.rb 2012-01-27 20:04:26 +0000 |
241 | @@ -11,7 +11,7 @@ |
242 | # Unless required by applicable law or agreed to in writing, software |
243 | # distributed under the License is distributed on an "AS IS" BASIS, |
244 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
245 | -# See the License for the specific language governing permissions and |
246 | +# See the License for the specific language governing permissions and |
247 | # limitations under the License. |
248 | |
249 | module Facter |
250 | @@ -24,7 +24,7 @@ |
251 | include Comparable |
252 | include Enumerable |
253 | |
254 | - FACTERVERSION = '1.6.2' |
255 | + FACTERVERSION = '1.6.4' |
256 | # = Facter |
257 | # Functions as a hash of 'facts' you might care about about your |
258 | # system, such as mac address, IP address, Video card, etc. |
259 | |
260 | === modified file 'lib/facter/architecture.rb' |
261 | --- lib/facter/architecture.rb 2011-10-12 11:29:53 +0000 |
262 | +++ lib/facter/architecture.rb 2012-01-27 20:04:26 +0000 |
263 | @@ -2,7 +2,7 @@ |
264 | # |
265 | # Purpose: |
266 | # Return the CPU hardware architecture. |
267 | -# |
268 | +# |
269 | # Resolution: |
270 | # On OpenBSD, Linux and Debian's kfreebsd, use the hardwaremodel fact. |
271 | # Gentoo and Debian call "x86_86" "amd64". |
272 | @@ -35,4 +35,3 @@ |
273 | end |
274 | end |
275 | end |
276 | - |
277 | |
278 | === modified file 'lib/facter/augeasversion.rb' |
279 | --- lib/facter/augeasversion.rb 2011-10-06 10:48:30 +0000 |
280 | +++ lib/facter/augeasversion.rb 2012-01-27 20:04:26 +0000 |
281 | @@ -7,7 +7,7 @@ |
282 | # the underlying Augeas library. |
283 | # |
284 | # Caveats: |
285 | -# The library version may not indicate the presence of certain lenses, |
286 | +# The library version may not indicate the presence of certain lenses, |
287 | # depending on the system packages updated, nor the version of ruby-augeas |
288 | # which may affect support for the Puppet Augeas provider. |
289 | # Versions prior to 0.3.6 cannot be interrogated for their version. |
290 | @@ -26,4 +26,3 @@ |
291 | end |
292 | end |
293 | end |
294 | - |
295 | |
296 | === modified file 'lib/facter/domain.rb' |
297 | --- lib/facter/domain.rb 2011-10-12 11:29:53 +0000 |
298 | +++ lib/facter/domain.rb 2012-01-27 20:04:26 +0000 |
299 | @@ -2,7 +2,7 @@ |
300 | # |
301 | # Purpose: |
302 | # Return the host's primary DNS domain name. |
303 | -# |
304 | +# |
305 | # Resolution: |
306 | # On UNIX (excluding Darwin), first try and use the hostname fact, |
307 | # which uses the hostname system command, and then parse the output |
308 | @@ -23,11 +23,11 @@ |
309 | # Get the domain from various sources; the order of these |
310 | # steps is important |
311 | |
312 | - if name = Facter::Util::Resolution.exec('hostname') and |
313 | + if name = Facter::Util::Resolution.exec('hostname') and |
314 | name =~ /.*?\.(.+$)/ |
315 | |
316 | $1 |
317 | - elsif domain = Facter::Util::Resolution.exec('dnsdomainname') and |
318 | + elsif domain = Facter::Util::Resolution.exec('dnsdomainname') and |
319 | domain =~ /.+\..+/ |
320 | |
321 | domain |
322 | |
323 | === modified file 'lib/facter/hardwareisa.rb' |
324 | --- lib/facter/hardwareisa.rb 2011-10-12 11:29:53 +0000 |
325 | +++ lib/facter/hardwareisa.rb 2012-01-27 20:04:26 +0000 |
326 | @@ -12,5 +12,5 @@ |
327 | |
328 | Facter.add(:hardwareisa) do |
329 | setcode 'uname -p' |
330 | - confine :operatingsystem => %w{Solaris Linux Fedora RedHat CentOS Scientific SLC SuSE SLES Debian Ubuntu Gentoo FreeBSD OpenBSD NetBSD DragonFly OEL OracleLinux OVS GNU/kFreeBSD} |
331 | + confine :operatingsystem => %w{Solaris Linux Fedora RedHat CentOS Scientific PSBM SLC Ascendos SuSE SLES Debian Ubuntu Gentoo FreeBSD OpenBSD NetBSD DragonFly OEL OracleLinux OVS GNU/kFreeBSD} |
332 | end |
333 | |
334 | === modified file 'lib/facter/ipaddress.rb' |
335 | --- lib/facter/ipaddress.rb 2011-10-12 11:29:53 +0000 |
336 | +++ lib/facter/ipaddress.rb 2012-01-27 20:04:26 +0000 |
337 | @@ -117,13 +117,13 @@ |
338 | else |
339 | require 'resolv' |
340 | end |
341 | - |
342 | + |
343 | begin |
344 | if hostname = Facter.value(:hostname) |
345 | if Facter.value(:kernel) == 'windows' |
346 | ip = Win32::Resolv.get_resolv_info.last[0] |
347 | else |
348 | - ip = Resolv.getaddress(hostname) |
349 | + ip = Resolv.getaddress(hostname) |
350 | end |
351 | unless ip == "127.0.0.1" |
352 | ip |
353 | |
354 | === modified file 'lib/facter/lsbmajdistrelease.rb' |
355 | --- lib/facter/lsbmajdistrelease.rb 2011-10-12 11:29:53 +0000 |
356 | +++ lib/facter/lsbmajdistrelease.rb 2012-01-27 20:04:26 +0000 |
357 | @@ -15,7 +15,7 @@ |
358 | require 'facter' |
359 | |
360 | Facter.add("lsbmajdistrelease") do |
361 | - confine :operatingsystem => %w{Linux Fedora RedHat CentOS Scientific SLC SuSE SLES Debian Ubuntu Gentoo OEL OracleLinux OVS GNU/kFreeBSD} |
362 | + confine :operatingsystem => %w{Linux Fedora RedHat CentOS Scientific PSBM SLC Ascendos SuSE SLES Debian Ubuntu Gentoo OEL OracleLinux OVS GNU/kFreeBSD} |
363 | setcode do |
364 | if /(\d*)\./i =~ Facter.value(:lsbdistrelease) |
365 | result=$1 |
366 | |
367 | === modified file 'lib/facter/macaddress.rb' |
368 | --- lib/facter/macaddress.rb 2011-10-12 11:29:53 +0000 |
369 | +++ lib/facter/macaddress.rb 2012-01-27 20:04:26 +0000 |
370 | @@ -1,6 +1,6 @@ |
371 | # Fact: macaddress |
372 | # |
373 | -# Purpose: |
374 | +# Purpose: |
375 | # |
376 | # Resolution: |
377 | # |
378 | @@ -10,7 +10,7 @@ |
379 | require 'facter/util/macaddress' |
380 | |
381 | Facter.add(:macaddress) do |
382 | - confine :operatingsystem => %w{Solaris Linux Fedora RedHat CentOS Scientific SLC SuSE SLES Debian Gentoo Ubuntu OEL OracleLinux OVS GNU/kFreeBSD} |
383 | + confine :operatingsystem => %w{Solaris Linux Fedora RedHat CentOS Scientific PSBM SLC Ascendos SuSE SLES Debian Gentoo Ubuntu OEL OracleLinux OVS GNU/kFreeBSD} |
384 | setcode do |
385 | ether = [] |
386 | output = Facter::Util::Resolution.exec("/sbin/ifconfig -a") |
387 | |
388 | === modified file 'lib/facter/manufacturer.rb' |
389 | --- lib/facter/manufacturer.rb 2011-11-10 10:11:05 +0000 |
390 | +++ lib/facter/manufacturer.rb 2012-01-27 20:04:26 +0000 |
391 | @@ -26,7 +26,7 @@ |
392 | } |
393 | |
394 | Facter::Manufacturer.sysctl_find_system_info(mfg_keys) |
395 | -elsif Facter.value(:kernel) == "Darwin" |
396 | +elsif Facter.value(:kernel) == "Darwin" |
397 | mfg_keys = { |
398 | 'hw.model' => 'productname' |
399 | } |
400 | @@ -42,6 +42,11 @@ |
401 | Facter::Manufacturer.win32_find_system_info(win32_keys) |
402 | else |
403 | query = { |
404 | + '[Bb]ase [Bb]oard [Ii]nformation' => [ |
405 | + { 'Manufacturer:' => 'boardmanufacturer' }, |
406 | + { 'Product(?: Name)?:' => 'boardproductname' }, |
407 | + { 'Serial Number:' => 'boardserialnumber' } |
408 | + ], |
409 | '[Ss]ystem [Ii]nformation' => [ |
410 | { 'Manufacturer:' => 'manufacturer' }, |
411 | { 'Product(?: Name)?:' => 'productname' }, |
412 | |
413 | === modified file 'lib/facter/netmask.rb' |
414 | --- lib/facter/netmask.rb 2011-10-12 11:29:53 +0000 |
415 | +++ lib/facter/netmask.rb 2012-01-27 20:04:26 +0000 |
416 | @@ -6,7 +6,6 @@ |
417 | # |
418 | # Caveats: |
419 | # |
420 | - |
421 | # netmask.rb |
422 | # Find the netmask of the primary ipaddress |
423 | # Copyright (C) 2007 David Schmitt <david@schmitt.edv-bus.at> |
424 | @@ -14,7 +13,6 @@ |
425 | # |
426 | # idea and originial source by Mark 'phips' Phillips |
427 | # |
428 | - |
429 | require 'facter/util/netmask' |
430 | |
431 | Facter.add("netmask") do |
432 | @@ -23,4 +21,3 @@ |
433 | Facter::NetMask.get_netmask |
434 | end |
435 | end |
436 | - |
437 | |
438 | === modified file 'lib/facter/network.rb' |
439 | --- lib/facter/network.rb 2011-10-12 11:29:53 +0000 |
440 | +++ lib/facter/network.rb 2012-01-27 20:04:26 +0000 |
441 | @@ -9,13 +9,12 @@ |
442 | # |
443 | # Caveats: |
444 | # |
445 | - |
446 | require 'facter/util/ip' |
447 | |
448 | Facter::Util::IP.get_interfaces.each do |interface| |
449 | Facter.add("network_" + Facter::Util::IP.alphafy(interface)) do |
450 | setcode do |
451 | Facter::Util::IP.get_network_value(interface) |
452 | - end |
453 | - end |
454 | + end |
455 | + end |
456 | end |
457 | |
458 | === modified file 'lib/facter/operatingsystem.rb' |
459 | --- lib/facter/operatingsystem.rb 2011-10-12 11:29:53 +0000 |
460 | +++ lib/facter/operatingsystem.rb 2012-01-27 20:04:26 +0000 |
461 | @@ -10,7 +10,6 @@ |
462 | # |
463 | # Caveats: |
464 | # |
465 | - |
466 | require 'facter/lsb' |
467 | |
468 | Facter.add(:operatingsystem) do |
469 | @@ -55,10 +54,14 @@ |
470 | "CentOS" |
471 | elsif txt =~ /CERN/ |
472 | "SLC" |
473 | - elsif txt =~ /scientific/i |
474 | + elsif txt =~ /scientific/i |
475 | "Scientific" |
476 | elsif txt =~ /^cloudlinux/i |
477 | "CloudLinux" |
478 | + elsif txt =~ /^Parallels Server Bare Metal/i |
479 | + "PSBM" |
480 | + elsif txt =~ /Ascendos/i |
481 | + "Ascendos" |
482 | else |
483 | "RedHat" |
484 | end |
485 | |
486 | === modified file 'lib/facter/operatingsystemrelease.rb' |
487 | --- lib/facter/operatingsystemrelease.rb 2011-10-12 11:29:53 +0000 |
488 | +++ lib/facter/operatingsystemrelease.rb 2012-01-27 20:04:26 +0000 |
489 | @@ -10,17 +10,17 @@ |
490 | # information. |
491 | # On Slackware, parses '/etc/slackware-version'. |
492 | # On Amazon Linux, returns the 'lsbdistrelease' value. |
493 | -# |
494 | +# |
495 | # On all remaining systems, returns the 'kernelrelease' value. |
496 | # |
497 | # Caveats: |
498 | # |
499 | |
500 | Facter.add(:operatingsystemrelease) do |
501 | - confine :operatingsystem => %w{CentOS Fedora oel ovs OracleLinux RedHat MeeGo Scientific SLC CloudLinux} |
502 | + confine :operatingsystem => %w{CentOS Fedora oel ovs OracleLinux RedHat MeeGo Scientific SLC Ascendos CloudLinux PSBM} |
503 | setcode do |
504 | case Facter.value(:operatingsystem) |
505 | - when "CentOS", "RedHat", "Scientific", "SLC", "CloudLinux" |
506 | + when "CentOS", "RedHat", "Scientific", "SLC", "Ascendos", "CloudLinux", "PSBM" |
507 | releasefile = "/etc/redhat-release" |
508 | when "Fedora" |
509 | releasefile = "/etc/fedora-release" |
510 | |
511 | === modified file 'lib/facter/osfamily.rb' |
512 | --- lib/facter/osfamily.rb 2011-10-12 11:29:53 +0000 |
513 | +++ lib/facter/osfamily.rb 2012-01-27 20:04:26 +0000 |
514 | @@ -16,7 +16,7 @@ |
515 | |
516 | setcode do |
517 | case Facter.value(:operatingsystem) |
518 | - when "RedHat", "Fedora", "CentOS", "Scientific", "SLC", "CloudLinux", "OracleLinux", "OVS", "OEL" |
519 | + when "RedHat", "Fedora", "CentOS", "Scientific", "SLC", "Ascendos", "CloudLinux", "PSBM", "OracleLinux", "OVS", "OEL" |
520 | "RedHat" |
521 | when "Ubuntu", "Debian" |
522 | "Debian" |
523 | |
524 | === modified file 'lib/facter/processor.rb' |
525 | --- lib/facter/processor.rb 2011-10-12 11:29:53 +0000 |
526 | +++ lib/facter/processor.rb 2012-01-27 20:04:26 +0000 |
527 | @@ -25,7 +25,7 @@ |
528 | confine :kernel => [ :linux, :"gnu/kfreebsd" ] |
529 | setcode do |
530 | processor_list = Facter::Util::Processor.enum_cpuinfo |
531 | - |
532 | + |
533 | ## If this returned nothing, then don't resolve the fact |
534 | if processor_list.length != 0 |
535 | processor_list.length.to_s |
536 | @@ -51,7 +51,7 @@ |
537 | confine :kernel => :aix |
538 | setcode do |
539 | processor_list = Facter::Util::Processor.enum_lsdev |
540 | - |
541 | + |
542 | processor_list.length.to_s |
543 | end |
544 | end |
545 | |
546 | === modified file 'lib/facter/selinux.rb' |
547 | --- lib/facter/selinux.rb 2011-10-06 10:48:30 +0000 |
548 | +++ lib/facter/selinux.rb 2012-01-27 20:04:26 +0000 |
549 | @@ -12,7 +12,7 @@ |
550 | |
551 | sestatus_cmd = '/usr/sbin/sestatus' |
552 | |
553 | -# This supports the fact that the selinux mount point is not always in the |
554 | +# This supports the fact that the selinux mount point is not always in the |
555 | # same location -- the selinux mount point is operating system specific. |
556 | def selinux_mount_point |
557 | if FileTest.exists?('/proc/self/mountinfo') |
558 | @@ -29,7 +29,7 @@ |
559 | Facter.add("selinux") do |
560 | confine :kernel => :linux |
561 | setcode do |
562 | - result = "false" |
563 | + result = "false" |
564 | if FileTest.exists?("#{selinux_mount_point}/enforce") |
565 | if FileTest.exists?("/proc/self/attr/current") |
566 | if (File.read("/proc/self/attr/current") != "kernel\0") |
567 | @@ -90,7 +90,7 @@ |
568 | end |
569 | end |
570 | |
571 | -# This is a legacy fact which returns the old selinux_mode fact value to prevent |
572 | +# This is a legacy fact which returns the old selinux_mode fact value to prevent |
573 | # breakages of existing manifests. It should be removed at the next major release. |
574 | # See ticket #6677. |
575 | |
576 | |
577 | === modified file 'lib/facter/uniqueid.rb' |
578 | --- lib/facter/uniqueid.rb 2011-10-12 11:29:53 +0000 |
579 | +++ lib/facter/uniqueid.rb 2012-01-27 20:04:26 +0000 |
580 | @@ -1,4 +1,4 @@ |
581 | Facter.add(:uniqueid) do |
582 | setcode 'hostid' |
583 | - confine :operatingsystem => %w{Solaris Linux Fedora RedHat CentOS Scientific SLC SuSE SLES Debian Ubuntu Gentoo AIX OEL OracleLinux OVS GNU/kFreeBSD} |
584 | + confine :operatingsystem => %w{Solaris Linux Fedora RedHat CentOS Scientific PSBM SLC Ascendos SuSE SLES Debian Ubuntu Gentoo AIX OEL OracleLinux OVS GNU/kFreeBSD} |
585 | end |
586 | |
587 | === modified file 'lib/facter/uptime_days.rb' |
588 | --- lib/facter/uptime_days.rb 2011-06-24 10:04:12 +0000 |
589 | +++ lib/facter/uptime_days.rb 2012-01-27 20:04:26 +0000 |
590 | @@ -13,4 +13,3 @@ |
591 | hours && hours / 24 # hours in day |
592 | end |
593 | end |
594 | - |
595 | |
596 | === modified file 'lib/facter/uptime_hours.rb' |
597 | --- lib/facter/uptime_hours.rb 2011-06-24 10:04:12 +0000 |
598 | +++ lib/facter/uptime_hours.rb 2012-01-27 20:04:26 +0000 |
599 | @@ -13,4 +13,3 @@ |
600 | seconds && seconds / (60 * 60) # seconds in hour |
601 | end |
602 | end |
603 | - |
604 | |
605 | === modified file 'lib/facter/util/macaddress.rb' |
606 | --- lib/facter/util/macaddress.rb 2011-10-06 10:48:30 +0000 |
607 | +++ lib/facter/util/macaddress.rb 2012-01-27 20:04:26 +0000 |
608 | @@ -3,6 +3,7 @@ |
609 | module Facter::Util::Macaddress |
610 | |
611 | def self.standardize(macaddress) |
612 | + return nil unless macaddress |
613 | macaddress.split(":").map{|x| "0#{x}"[-2..-1]}.join(":") |
614 | end |
615 | |
616 | |
617 | === modified file 'lib/facter/util/manufacturer.rb' |
618 | --- lib/facter/util/manufacturer.rb 2011-10-12 11:29:53 +0000 |
619 | +++ lib/facter/util/manufacturer.rb 2012-01-27 20:04:26 +0000 |
620 | @@ -63,11 +63,10 @@ |
621 | |
622 | def self.prtdiag_sparc_find_system_info() |
623 | # Parses prtdiag for a SPARC architecture string, won't work with Solaris x86 |
624 | - output = Facter::Util::Resolution.exec('/usr/sbin/prtdiag') |
625 | + output = Facter::Util::Resolution.exec('/usr/sbin/prtdiag 2>/dev/null') |
626 | |
627 | # System Configuration: Sun Microsystems sun4u Sun SPARC Enterprise M3000 Server |
628 | - sysconfig = output.split("\n")[0] |
629 | - if sysconfig =~ /^System Configuration:\s+(.+?)\s+(sun\d+\S+)\s+(.+)/ then |
630 | + if output and output =~ /^System Configuration:\s+(.+?)\s+(sun\d+\S+)\s+(.+)/ |
631 | Facter.add('manufacturer') do |
632 | setcode do |
633 | $1 |
634 | |
635 | === modified file 'lib/facter/util/processor.rb' |
636 | --- lib/facter/util/processor.rb 2011-10-12 11:29:53 +0000 |
637 | +++ lib/facter/util/processor.rb 2012-01-27 20:04:26 +0000 |
638 | @@ -21,7 +21,7 @@ |
639 | end |
640 | end |
641 | end |
642 | - |
643 | + |
644 | when "ppc64" |
645 | Thread::exclusive do |
646 | File.readlines(cpuinfo).each do |l| |
647 | @@ -33,7 +33,7 @@ |
648 | end |
649 | end |
650 | end |
651 | - |
652 | + |
653 | when /arm/ |
654 | Thread::exclusive do |
655 | File.readlines(cpuinfo).each do |l| |
656 | @@ -63,7 +63,7 @@ |
657 | end |
658 | processor_list |
659 | end |
660 | - |
661 | + |
662 | def self.enum_lsdev |
663 | processor_num = -1 |
664 | processor_list = {} |
665 | |
666 | === modified file 'lib/facter/util/resolution.rb' |
667 | --- lib/facter/util/resolution.rb 2011-10-12 11:29:53 +0000 |
668 | +++ lib/facter/util/resolution.rb 2012-01-27 20:04:26 +0000 |
669 | @@ -36,12 +36,12 @@ |
670 | # Try to guess whether the specified code can be executed by looking at the |
671 | # first word. If it cannot be found on the PATH defer on resolving the fact |
672 | # by returning nil. |
673 | - # This only fails on shell built-ins, most of which are masked by stuff in |
674 | + # This only fails on shell built-ins, most of which are masked by stuff in |
675 | # /bin or of dubious value anyways. In the worst case, "sh -c 'builtin'" can |
676 | # be used to work around this limitation |
677 | # |
678 | - # Windows' %x{} throws Errno::ENOENT when the command is not found, so we |
679 | - # can skip the check there. This is good, since builtins cannot be found |
680 | + # Windows' %x{} throws Errno::ENOENT when the command is not found, so we |
681 | + # can skip the check there. This is good, since builtins cannot be found |
682 | # elsewhere. |
683 | if have_which and !Facter::Util::Config.is_windows? |
684 | path = nil |
685 | |
686 | === modified file 'lib/facter/util/values.rb' |
687 | --- lib/facter/util/values.rb 2011-10-12 11:29:53 +0000 |
688 | +++ lib/facter/util/values.rb 2012-01-27 20:04:26 +0000 |
689 | @@ -8,7 +8,7 @@ |
690 | value = value.to_s if value.is_a?(Symbol) |
691 | value = value.downcase if value.is_a?(String) |
692 | value |
693 | - end |
694 | + end |
695 | end |
696 | end |
697 | end |
698 | |
699 | === modified file 'lib/facter/virtual.rb' |
700 | --- lib/facter/virtual.rb 2011-10-12 11:29:53 +0000 |
701 | +++ lib/facter/virtual.rb 2012-01-27 20:04:26 +0000 |
702 | @@ -133,7 +133,7 @@ |
703 | end |
704 | end |
705 | end |
706 | - |
707 | + |
708 | if output = Facter::Util::Resolution.exec("vmware -v") |
709 | result = output.sub(/(\S+)\s+(\S+).*/) { | text | "#{$1}_#{$2}"}.downcase |
710 | end |
711 | @@ -148,7 +148,7 @@ |
712 | # Purpose: returning true or false for if a machine is virtualised or not. |
713 | # |
714 | # Resolution: Hypervisors and the like may be detected as a virtual type, but |
715 | -# are not actual virtual machines, or should not be treated as such. This |
716 | +# are not actual virtual machines, or should not be treated as such. This |
717 | # determines if the host is actually virtualized. |
718 | # |
719 | # Caveats: |
720 | |
721 | === modified file 'lib/facter/vlans.rb' |
722 | --- lib/facter/vlans.rb 2011-10-12 11:29:53 +0000 |
723 | +++ lib/facter/vlans.rb 2012-01-27 20:04:26 +0000 |
724 | @@ -7,9 +7,8 @@ |
725 | # |
726 | # Caveats: |
727 | # |
728 | +require 'facter/util/vlans' |
729 | |
730 | -require 'facter/util/vlans' |
731 | - |
732 | Facter.add("vlans") do |
733 | confine :kernel => :linux |
734 | setcode do |
735 | |
736 | === modified file 'lib/facter/xendomains.rb' |
737 | --- lib/facter/xendomains.rb 2011-06-24 10:04:12 +0000 |
738 | +++ lib/facter/xendomains.rb 2012-01-27 20:04:26 +0000 |
739 | @@ -8,7 +8,6 @@ |
740 | # |
741 | # Caveats: |
742 | # |
743 | - |
744 | require 'facter/util/xendomains' |
745 | |
746 | Facter.add("xendomains") do |
747 | |
748 | === added file 'spec/fixtures/ifconfig/linux_ifconfig_no_mac' |
749 | --- spec/fixtures/ifconfig/linux_ifconfig_no_mac 1970-01-01 00:00:00 +0000 |
750 | +++ spec/fixtures/ifconfig/linux_ifconfig_no_mac 2012-01-27 20:04:26 +0000 |
751 | @@ -0,0 +1,8 @@ |
752 | +lo Link encap:Local Loopback |
753 | + inet addr:127.0.0.1 Mask:255.0.0.0 |
754 | + UP LOOPBACK RUNNING MTU:16436 Metric:1 |
755 | + RX packets:0 errors:0 dropped:0 overruns:0 frame:0 |
756 | + TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 |
757 | + collisions:0 txqueuelen:0 |
758 | + RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) |
759 | + |
760 | |
761 | === added file 'spec/fixtures/ifconfig/linux_ifconfig_venet' |
762 | --- spec/fixtures/ifconfig/linux_ifconfig_venet 1970-01-01 00:00:00 +0000 |
763 | +++ spec/fixtures/ifconfig/linux_ifconfig_venet 2012-01-27 20:04:26 +0000 |
764 | @@ -0,0 +1,24 @@ |
765 | +lo Link encap:Local Loopback |
766 | + inet addr:127.0.0.1 Mask:255.0.0.0 |
767 | + inet6 addr: ::1/128 Scope:Host |
768 | + UP LOOPBACK RUNNING MTU:16436 Metric:1 |
769 | + RX packets:334 errors:0 dropped:0 overruns:0 frame:0 |
770 | + TX packets:334 errors:0 dropped:0 overruns:0 carrier:0 |
771 | + collisions:0 txqueuelen:0 |
772 | + RX bytes:16700 (16.7 KB) TX bytes:16700 (16.7 KB) |
773 | + |
774 | +venet0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 |
775 | + inet addr:127.0.0.1 P-t-P:127.0.0.1 Bcast:0.0.0.0 Mask:255.255.255.255 |
776 | + UP BROADCAST POINTOPOINT RUNNING NOARP MTU:1500 Metric:1 |
777 | + RX packets:7622207 errors:0 dropped:0 overruns:0 frame:0 |
778 | + TX packets:8183436 errors:0 dropped:1 overruns:0 carrier:0 |
779 | + collisions:0 txqueuelen:0 |
780 | + RX bytes:2102750761 (2.1 GB) TX bytes:2795213667 (2.7 GB) |
781 | + |
782 | +venet0:0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 |
783 | + inet addr:XXX.XXX.XXX.XX1 P-t-P:XXX.XXX.XXX.XX1 Bcast:0.0.0.0 Mask:255.255.255.255 |
784 | + UP BROADCAST POINTOPOINT RUNNING NOARP MTU:1500 Metric:1 |
785 | + |
786 | +venet0:1 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 |
787 | + inet addr:XXX.XXX.XXX.XX2 P-t-P:XXX.XXX.XXX.XX2 Bcast:0.0.0.0 Mask:255.255.255.255 |
788 | + UP BROADCAST POINTOPOINT RUNNING NOARP MTU:1500 Metric:1 |
789 | |
790 | === added directory 'spec/fixtures/unit/util/manufacturer' |
791 | === added file 'spec/fixtures/unit/util/manufacturer/solaris_sunfire_v120_prtdiag' |
792 | --- spec/fixtures/unit/util/manufacturer/solaris_sunfire_v120_prtdiag 1970-01-01 00:00:00 +0000 |
793 | +++ spec/fixtures/unit/util/manufacturer/solaris_sunfire_v120_prtdiag 2012-01-27 20:04:26 +0000 |
794 | @@ -0,0 +1,33 @@ |
795 | +System Configuration: Sun Microsystems sun4u Sun Fire V120 (UltraSPARC-IIe 648MHz) |
796 | +System clock frequency: 100 MHz |
797 | +Memory size: 2048 Megabytes |
798 | + |
799 | +========================= CPUs ========================= |
800 | + |
801 | + Run Ecache CPU CPU |
802 | +Brd CPU Module MHz MB Impl. Mask |
803 | +--- --- ------- ----- ------ ------ ---- |
804 | + 0 0 0 648 0.5 13 3.3 |
805 | + |
806 | + |
807 | +========================= IO Cards ========================= |
808 | + |
809 | + Bus# Freq |
810 | +Brd Type MHz Slot Name Model |
811 | +--- ---- ---- ---- -------------------------------- ---------------------- |
812 | + 0 PCI-1 33 12 ebus |
813 | + 0 PCI-1 33 3 pmu-pci10b9,7101 |
814 | + 0 PCI-1 33 3 lomp |
815 | + 0 PCI-1 33 7 isa |
816 | + 0 PCI-1 33 12 network-pci108e,1101 SUNW,pci-eri |
817 | + 0 PCI-1 33 12 usb-pci108e,1103.1 |
818 | + 0 PCI-1 33 13 ide-pci10b9,5229 |
819 | + 0 PCI-1 33 5 network-pci108e,1101 SUNW,pci-eri |
820 | + 0 PCI-1 33 5 usb-pci108e,1103.1 |
821 | + 0 PCI-2 33 8 scsi-glm Symbios,53C896 |
822 | + 0 PCI-2 33 8 scsi-glm Symbios,53C896 |
823 | + 0 PCI-2 33 5 network-pci108e,2bad SUNW,pci-gem |
824 | + |
825 | + |
826 | +No failures found in System |
827 | +=========================== |
828 | |
829 | === added file 'spec/fixtures/unit/util/manufacturer/solaris_t5220_prtdiag' |
830 | --- spec/fixtures/unit/util/manufacturer/solaris_t5220_prtdiag 1970-01-01 00:00:00 +0000 |
831 | +++ spec/fixtures/unit/util/manufacturer/solaris_t5220_prtdiag 2012-01-27 20:04:26 +0000 |
832 | @@ -0,0 +1,136 @@ |
833 | +System Configuration: Sun Microsystems sun4v SPARC Enterprise T5220 |
834 | +Memory size: 32640 Megabytes |
835 | + |
836 | +================================ Virtual CPUs ================================ |
837 | + |
838 | + |
839 | +CPU ID Frequency Implementation Status |
840 | +------ --------- ---------------------- ------- |
841 | +0 1165 MHz SUNW,UltraSPARC-T2 on-line |
842 | +1 1165 MHz SUNW,UltraSPARC-T2 on-line |
843 | +2 1165 MHz SUNW,UltraSPARC-T2 on-line |
844 | +3 1165 MHz SUNW,UltraSPARC-T2 on-line |
845 | +4 1165 MHz SUNW,UltraSPARC-T2 on-line |
846 | +5 1165 MHz SUNW,UltraSPARC-T2 on-line |
847 | +6 1165 MHz SUNW,UltraSPARC-T2 on-line |
848 | +7 1165 MHz SUNW,UltraSPARC-T2 on-line |
849 | +8 1165 MHz SUNW,UltraSPARC-T2 on-line |
850 | +9 1165 MHz SUNW,UltraSPARC-T2 on-line |
851 | +10 1165 MHz SUNW,UltraSPARC-T2 on-line |
852 | +11 1165 MHz SUNW,UltraSPARC-T2 on-line |
853 | +12 1165 MHz SUNW,UltraSPARC-T2 on-line |
854 | +13 1165 MHz SUNW,UltraSPARC-T2 on-line |
855 | +14 1165 MHz SUNW,UltraSPARC-T2 on-line |
856 | +15 1165 MHz SUNW,UltraSPARC-T2 on-line |
857 | +16 1165 MHz SUNW,UltraSPARC-T2 on-line |
858 | +17 1165 MHz SUNW,UltraSPARC-T2 on-line |
859 | +18 1165 MHz SUNW,UltraSPARC-T2 on-line |
860 | +19 1165 MHz SUNW,UltraSPARC-T2 on-line |
861 | +20 1165 MHz SUNW,UltraSPARC-T2 on-line |
862 | +21 1165 MHz SUNW,UltraSPARC-T2 on-line |
863 | +22 1165 MHz SUNW,UltraSPARC-T2 on-line |
864 | +23 1165 MHz SUNW,UltraSPARC-T2 on-line |
865 | +24 1165 MHz SUNW,UltraSPARC-T2 on-line |
866 | +25 1165 MHz SUNW,UltraSPARC-T2 on-line |
867 | +26 1165 MHz SUNW,UltraSPARC-T2 on-line |
868 | +27 1165 MHz SUNW,UltraSPARC-T2 on-line |
869 | +28 1165 MHz SUNW,UltraSPARC-T2 on-line |
870 | +29 1165 MHz SUNW,UltraSPARC-T2 on-line |
871 | +30 1165 MHz SUNW,UltraSPARC-T2 on-line |
872 | +31 1165 MHz SUNW,UltraSPARC-T2 on-line |
873 | +32 1165 MHz SUNW,UltraSPARC-T2 on-line |
874 | +33 1165 MHz SUNW,UltraSPARC-T2 on-line |
875 | +34 1165 MHz SUNW,UltraSPARC-T2 on-line |
876 | +35 1165 MHz SUNW,UltraSPARC-T2 on-line |
877 | +36 1165 MHz SUNW,UltraSPARC-T2 on-line |
878 | +37 1165 MHz SUNW,UltraSPARC-T2 on-line |
879 | +38 1165 MHz SUNW,UltraSPARC-T2 on-line |
880 | +39 1165 MHz SUNW,UltraSPARC-T2 on-line |
881 | +40 1165 MHz SUNW,UltraSPARC-T2 on-line |
882 | +41 1165 MHz SUNW,UltraSPARC-T2 on-line |
883 | +42 1165 MHz SUNW,UltraSPARC-T2 on-line |
884 | +43 1165 MHz SUNW,UltraSPARC-T2 on-line |
885 | +44 1165 MHz SUNW,UltraSPARC-T2 on-line |
886 | +45 1165 MHz SUNW,UltraSPARC-T2 on-line |
887 | +46 1165 MHz SUNW,UltraSPARC-T2 on-line |
888 | +47 1165 MHz SUNW,UltraSPARC-T2 on-line |
889 | +48 1165 MHz SUNW,UltraSPARC-T2 on-line |
890 | +49 1165 MHz SUNW,UltraSPARC-T2 on-line |
891 | +50 1165 MHz SUNW,UltraSPARC-T2 on-line |
892 | +51 1165 MHz SUNW,UltraSPARC-T2 on-line |
893 | +52 1165 MHz SUNW,UltraSPARC-T2 on-line |
894 | +53 1165 MHz SUNW,UltraSPARC-T2 on-line |
895 | +54 1165 MHz SUNW,UltraSPARC-T2 on-line |
896 | +55 1165 MHz SUNW,UltraSPARC-T2 on-line |
897 | +56 1165 MHz SUNW,UltraSPARC-T2 on-line |
898 | +57 1165 MHz SUNW,UltraSPARC-T2 on-line |
899 | +58 1165 MHz SUNW,UltraSPARC-T2 on-line |
900 | +59 1165 MHz SUNW,UltraSPARC-T2 on-line |
901 | +60 1165 MHz SUNW,UltraSPARC-T2 on-line |
902 | +61 1165 MHz SUNW,UltraSPARC-T2 on-line |
903 | +62 1165 MHz SUNW,UltraSPARC-T2 on-line |
904 | +63 1165 MHz SUNW,UltraSPARC-T2 on-line |
905 | + |
906 | +======================= Physical Memory Configuration ======================== |
907 | +Segment Table: |
908 | +-------------------------------------------------------------- |
909 | +Base Segment Interleave Bank Contains |
910 | +Address Size Factor Size Modules |
911 | +-------------------------------------------------------------- |
912 | +0x0 32 GB 8 4 GB MB/CMP0/BR0/CH0/D0 |
913 | + MB/CMP0/BR0/CH1/D0 |
914 | + 4 GB MB/CMP0/BR0/CH0/D1 |
915 | + MB/CMP0/BR0/CH1/D1 |
916 | + 4 GB MB/CMP0/BR1/CH0/D0 |
917 | + MB/CMP0/BR1/CH1/D0 |
918 | + 4 GB MB/CMP0/BR1/CH0/D1 |
919 | + MB/CMP0/BR1/CH1/D1 |
920 | + 4 GB MB/CMP0/BR2/CH0/D0 |
921 | + MB/CMP0/BR2/CH1/D0 |
922 | + 4 GB MB/CMP0/BR2/CH0/D1 |
923 | + MB/CMP0/BR2/CH1/D1 |
924 | + 4 GB MB/CMP0/BR3/CH0/D0 |
925 | + MB/CMP0/BR3/CH1/D0 |
926 | + 4 GB MB/CMP0/BR3/CH0/D1 |
927 | + MB/CMP0/BR3/CH1/D1 |
928 | + |
929 | + |
930 | +================================ IO Devices ================================ |
931 | +Slot + Bus Name + Model |
932 | +Status Type Path |
933 | +---------------------------------------------------------------------------- |
934 | +MB/NET0 PCIE network-pciex8086,105e |
935 | + /pci@0/pci@0/pci@1/pci@0/pci@2/network@0 |
936 | +MB/NET1 PCIE network-pciex8086,105e |
937 | + /pci@0/pci@0/pci@1/pci@0/pci@2/network@0,1 |
938 | +MB/NET2 PCIE network-pciex8086,105e |
939 | + /pci@0/pci@0/pci@1/pci@0/pci@3/network@0 |
940 | +MB/NET3 PCIE network-pciex8086,105e |
941 | + /pci@0/pci@0/pci@1/pci@0/pci@3/network@0,1 |
942 | +MB/SASHBA PCIE scsi-pciex1000,58 LSI,1068E |
943 | + /pci@0/pci@0/pci@2/scsi@0 |
944 | +MB PCIX usb-pciclass,0c0310 |
945 | + /pci@0/pci@0/pci@1/pci@0/pci@1/pci@0/usb@0 |
946 | +MB PCIX usb-pciclass,0c0310 |
947 | + /pci@0/pci@0/pci@1/pci@0/pci@1/pci@0/usb@0,1 |
948 | +MB PCIX usb-pciclass,0c0320 |
949 | + /pci@0/pci@0/pci@1/pci@0/pci@1/pci@0/usb@0,2 |
950 | + |
951 | +============================ Environmental Status ============================ |
952 | +Fan sensors: |
953 | +All fan sensors are OK. |
954 | + |
955 | +Temperature sensors: |
956 | +All temperature sensors are OK. |
957 | + |
958 | +Current sensors: |
959 | +All current sensors are OK. |
960 | + |
961 | +Voltage sensors: |
962 | +All voltage sensors are OK. |
963 | + |
964 | +Voltage indicators: |
965 | +All voltage indicators are OK. |
966 | + |
967 | +============================ FRU Status ============================ |
968 | +All FRUs are enabled. |
969 | |
970 | === modified file 'spec/spec_helper.rb' |
971 | --- spec/spec_helper.rb 2011-10-12 11:29:53 +0000 |
972 | +++ spec/spec_helper.rb 2012-01-27 20:04:26 +0000 |
973 | @@ -2,6 +2,11 @@ |
974 | |
975 | SPECDIR = dir |
976 | |
977 | +def fixture_data(file) |
978 | + File.read(File.join(SPECDIR, "fixtures", file)) |
979 | +end |
980 | + |
981 | + |
982 | $LOAD_PATH.unshift("#{dir}/") |
983 | $LOAD_PATH.unshift("#{dir}/../lib") |
984 | |
985 | |
986 | === modified file 'spec/unit/architecture_spec.rb' |
987 | --- spec/unit/architecture_spec.rb 2011-10-12 11:29:53 +0000 |
988 | +++ spec/unit/architecture_spec.rb 2012-01-27 20:04:26 +0000 |
989 | @@ -6,49 +6,49 @@ |
990 | |
991 | describe "Architecture fact" do |
992 | |
993 | - it "should default to the hardware model" do |
994 | - Facter.fact(:hardwaremodel).stubs(:value).returns("NonSpecialCasedHW") |
995 | - |
996 | - Facter.fact(:architecture).value.should == "NonSpecialCasedHW" |
997 | - end |
998 | - |
999 | - os_archs = Hash.new |
1000 | - os_archs = { |
1001 | - ["Debian","x86_64"] => "amd64", |
1002 | - ["Gentoo","x86_64"] => "amd64", |
1003 | - ["GNU/kFreeBSD","x86_64"] => "amd64", |
1004 | - ["Ubuntu","x86_64"] => "amd64", |
1005 | - ["Gentoo","i386"] => "x86", |
1006 | - ["Gentoo","i486"] => "x86", |
1007 | - ["Gentoo","i586"] => "x86", |
1008 | - ["Gentoo","i686"] => "x86", |
1009 | - ["Gentoo","pentium"] => "x86", |
1010 | - } |
1011 | - generic_archs = Hash.new |
1012 | - generic_archs = { |
1013 | - "i386" => "i386", |
1014 | - "i486" => "i386", |
1015 | - "i586" => "i386", |
1016 | - "i686" => "i386", |
1017 | - "pentium" => "i386", |
1018 | - } |
1019 | - |
1020 | - os_archs.each do |pair, result| |
1021 | - it "should be #{result} if os is #{pair[0]} and hardwaremodel is #{pair[1]}" do |
1022 | - Facter.fact(:operatingsystem).stubs(:value).returns(pair[0]) |
1023 | - Facter.fact(:hardwaremodel).stubs(:value).returns(pair[1]) |
1024 | - |
1025 | - Facter.fact(:architecture).value.should == result |
1026 | - end |
1027 | - end |
1028 | - |
1029 | - generic_archs.each do |hw, result| |
1030 | - it "should be #{result} if hardwaremodel is #{hw}" do |
1031 | - Facter.fact(:hardwaremodel).stubs(:value).returns(hw) |
1032 | - Facter.fact(:operatingsystem).stubs(:value).returns("NonSpecialCasedOS") |
1033 | - |
1034 | - Facter.fact(:architecture).value.should == result |
1035 | - end |
1036 | - end |
1037 | + it "should default to the hardware model" do |
1038 | + Facter.fact(:hardwaremodel).stubs(:value).returns("NonSpecialCasedHW") |
1039 | + |
1040 | + Facter.fact(:architecture).value.should == "NonSpecialCasedHW" |
1041 | + end |
1042 | + |
1043 | + os_archs = Hash.new |
1044 | + os_archs = { |
1045 | + ["Debian","x86_64"] => "amd64", |
1046 | + ["Gentoo","x86_64"] => "amd64", |
1047 | + ["GNU/kFreeBSD","x86_64"] => "amd64", |
1048 | + ["Ubuntu","x86_64"] => "amd64", |
1049 | + ["Gentoo","i386"] => "x86", |
1050 | + ["Gentoo","i486"] => "x86", |
1051 | + ["Gentoo","i586"] => "x86", |
1052 | + ["Gentoo","i686"] => "x86", |
1053 | + ["Gentoo","pentium"] => "x86", |
1054 | + } |
1055 | + generic_archs = Hash.new |
1056 | + generic_archs = { |
1057 | + "i386" => "i386", |
1058 | + "i486" => "i386", |
1059 | + "i586" => "i386", |
1060 | + "i686" => "i386", |
1061 | + "pentium" => "i386", |
1062 | + } |
1063 | + |
1064 | + os_archs.each do |pair, result| |
1065 | + it "should be #{result} if os is #{pair[0]} and hardwaremodel is #{pair[1]}" do |
1066 | + Facter.fact(:operatingsystem).stubs(:value).returns(pair[0]) |
1067 | + Facter.fact(:hardwaremodel).stubs(:value).returns(pair[1]) |
1068 | + |
1069 | + Facter.fact(:architecture).value.should == result |
1070 | + end |
1071 | + end |
1072 | + |
1073 | + generic_archs.each do |hw, result| |
1074 | + it "should be #{result} if hardwaremodel is #{hw}" do |
1075 | + Facter.fact(:hardwaremodel).stubs(:value).returns(hw) |
1076 | + Facter.fact(:operatingsystem).stubs(:value).returns("NonSpecialCasedOS") |
1077 | + |
1078 | + Facter.fact(:architecture).value.should == result |
1079 | + end |
1080 | + end |
1081 | |
1082 | end |
1083 | |
1084 | === modified file 'spec/unit/facter_spec.rb' |
1085 | --- spec/unit/facter_spec.rb 2011-10-06 10:48:30 +0000 |
1086 | +++ spec/unit/facter_spec.rb 2012-01-27 20:04:26 +0000 |
1087 | @@ -4,268 +4,270 @@ |
1088 | |
1089 | describe Facter do |
1090 | |
1091 | - it "should have a version" do |
1092 | - Facter.version.should =~ /^[0-9]+(\.[0-9]+)*$/ |
1093 | - end |
1094 | - |
1095 | - it "should have a method for returning its collection" do |
1096 | - Facter.should respond_to(:collection) |
1097 | - end |
1098 | - |
1099 | - it "should cache the collection" do |
1100 | - Facter.collection.should equal(Facter.collection) |
1101 | - end |
1102 | - |
1103 | - it "should delegate the :flush method to the collection" do |
1104 | - Facter.collection.expects(:flush) |
1105 | - Facter.flush |
1106 | - end |
1107 | - |
1108 | - it "should delegate the :fact method to the collection" do |
1109 | - Facter.collection.expects(:fact) |
1110 | - Facter.fact |
1111 | - end |
1112 | - |
1113 | - it "should delegate the :list method to the collection" do |
1114 | - Facter.collection.expects(:list) |
1115 | - Facter.list |
1116 | - end |
1117 | - |
1118 | - it "should load all facts when listing" do |
1119 | - Facter.collection.expects(:load_all) |
1120 | - Facter.collection.stubs(:list) |
1121 | - Facter.list |
1122 | - end |
1123 | - |
1124 | - it "should delegate the :to_hash method to the collection" do |
1125 | - Facter.collection.expects(:to_hash) |
1126 | - Facter.to_hash |
1127 | - end |
1128 | - |
1129 | - it "should load all facts when calling :to_hash" do |
1130 | - Facter.collection.expects(:load_all) |
1131 | - Facter.collection.stubs(:to_hash) |
1132 | - Facter.to_hash |
1133 | - end |
1134 | - |
1135 | - it "should delegate the :value method to the collection" do |
1136 | - Facter.collection.expects(:value) |
1137 | - Facter.value |
1138 | - end |
1139 | - |
1140 | - it "should delegate the :each method to the collection" do |
1141 | - Facter.collection.expects(:each) |
1142 | - Facter.each |
1143 | - end |
1144 | - |
1145 | - it "should load all facts when calling :each" do |
1146 | - Facter.collection.expects(:load_all) |
1147 | - Facter.collection.stubs(:each) |
1148 | - Facter.each |
1149 | - end |
1150 | - |
1151 | - it "should yield to the block when using :each" do |
1152 | - Facter.collection.stubs(:load_all) |
1153 | - Facter.collection.stubs(:each).yields "foo" |
1154 | - result = [] |
1155 | - Facter.each { |f| result << f } |
1156 | - result.should == %w{foo} |
1157 | - end |
1158 | - |
1159 | - describe "when provided code as a string" do |
1160 | - it "should execute the code in the shell" do |
1161 | - Facter.add("shell_testing") do |
1162 | - setcode "echo yup" |
1163 | - end |
1164 | - |
1165 | - Facter["shell_testing"].value.should == "yup" |
1166 | - end |
1167 | - end |
1168 | - |
1169 | - describe "when asked for a fact as an undefined Facter class method" do |
1170 | - describe "and the collection is already initialized" do |
1171 | - it "should return the fact's value" do |
1172 | - Facter.collection |
1173 | - Facter.ipaddress.should == Facter['ipaddress'].value |
1174 | - end |
1175 | - end |
1176 | - |
1177 | - describe "and the collection has been just reset" do |
1178 | - it "should return the fact's value" do |
1179 | - Facter.reset |
1180 | - Facter.ipaddress.should == Facter['ipaddress'].value |
1181 | - end |
1182 | - end |
1183 | - end |
1184 | - |
1185 | - describe "when passed code as a block" do |
1186 | - it "should execute the provided block" do |
1187 | - Facter.add("block_testing") { setcode { "foo" } } |
1188 | - |
1189 | - Facter["block_testing"].value.should == "foo" |
1190 | - end |
1191 | - end |
1192 | - |
1193 | - describe Facter[:hostname] do |
1194 | - it "should have its ldapname set to 'cn'" do |
1195 | - Facter[:hostname].ldapname.should == "cn" |
1196 | - end |
1197 | - end |
1198 | - |
1199 | - describe Facter[:ipaddress] do |
1200 | - it "should have its ldapname set to 'iphostnumber'" do |
1201 | - Facter[:ipaddress].ldapname.should == "iphostnumber" |
1202 | - end |
1203 | - end |
1204 | - |
1205 | - # #33 Make sure we only get one mac address |
1206 | - it "should only return one mac address" do |
1207 | - Facter.value(:macaddress).should_not be_include(" ") |
1208 | - end |
1209 | - |
1210 | - it "should have a method for registering directories to search" do |
1211 | - Facter.should respond_to(:search) |
1212 | - end |
1213 | - |
1214 | - it "should have a method for returning the registered search directories" do |
1215 | - Facter.should respond_to(:search_path) |
1216 | - end |
1217 | - |
1218 | - it "should have a method to query debugging mode" do |
1219 | - Facter.should respond_to(:debugging?) |
1220 | - end |
1221 | - |
1222 | - it "should have a method to query timing mode" do |
1223 | - Facter.should respond_to(:timing?) |
1224 | - end |
1225 | - |
1226 | - it "should have a method to show timing information" do |
1227 | - Facter.should respond_to(:show_time) |
1228 | - end |
1229 | - |
1230 | - it "should have a method to warn" do |
1231 | - Facter.should respond_to(:warn) |
1232 | - end |
1233 | - |
1234 | - describe "when warning" do |
1235 | - it "should warn if debugging is enabled" do |
1236 | - Facter.debugging(true) |
1237 | - Kernel.stubs(:warn) |
1238 | - Kernel.expects(:warn).with('foo') |
1239 | - Facter.warn('foo') |
1240 | - end |
1241 | - |
1242 | - it "should not warn if debugging is enabled but nil is passed" do |
1243 | - Facter.debugging(true) |
1244 | - Kernel.stubs(:warn) |
1245 | - Kernel.expects(:warn).never |
1246 | - Facter.warn(nil) |
1247 | - end |
1248 | - |
1249 | - it "should not warn if debugging is enabled but an empyt string is passed" do |
1250 | - Facter.debugging(true) |
1251 | - Kernel.stubs(:warn) |
1252 | - Kernel.expects(:warn).never |
1253 | - Facter.warn('') |
1254 | - end |
1255 | - |
1256 | - it "should not warn if debugging is disabled" do |
1257 | - Facter.debugging(false) |
1258 | - Kernel.stubs(:warn) |
1259 | - Kernel.expects(:warn).never |
1260 | - Facter.warn('foo') |
1261 | - end |
1262 | - |
1263 | - it "should warn for any given element for an array if debugging is enabled" do |
1264 | - Facter.debugging(true) |
1265 | - Kernel.stubs(:warn) |
1266 | - Kernel.expects(:warn).with('foo') |
1267 | - Kernel.expects(:warn).with('bar') |
1268 | - Facter.warn( ['foo','bar']) |
1269 | - end |
1270 | - end |
1271 | - |
1272 | - describe "when warning once" do |
1273 | - it "should only warn once" do |
1274 | - Kernel.stubs(:warnonce) |
1275 | - Kernel.expects(:warn).with('foo').once |
1276 | - Facter.warnonce('foo') |
1277 | - Facter.warnonce('foo') |
1278 | - end |
1279 | - |
1280 | - it "should not warnonce if nil is passed" do |
1281 | - Kernel.stubs(:warn) |
1282 | - Kernel.expects(:warnonce).never |
1283 | - Facter.warnonce(nil) |
1284 | - end |
1285 | - |
1286 | - it "should not warnonce if an empty string is passed" do |
1287 | - Kernel.stubs(:warn) |
1288 | - Kernel.expects(:warnonce).never |
1289 | - Facter.warnonce('') |
1290 | - end |
1291 | - end |
1292 | - |
1293 | - describe "when setting debugging mode" do |
1294 | - it "should have debugging enabled using 1" do |
1295 | - Facter.debugging(1) |
1296 | - Facter.should be_debugging |
1297 | - end |
1298 | - it "should have debugging enabled using true" do |
1299 | - Facter.debugging(true) |
1300 | - Facter.should be_debugging |
1301 | - end |
1302 | - it "should have debugging enabled using any string except off" do |
1303 | - Facter.debugging('aaaaa') |
1304 | - Facter.should be_debugging |
1305 | - end |
1306 | - it "should have debugging disabled using 0" do |
1307 | - Facter.debugging(0) |
1308 | - Facter.should_not be_debugging |
1309 | - end |
1310 | - it "should have debugging disabled using false" do |
1311 | - Facter.debugging(false) |
1312 | - Facter.should_not be_debugging |
1313 | - end |
1314 | - it "should have debugging disabled using the string 'off'" do |
1315 | - Facter.debugging('off') |
1316 | - Facter.should_not be_debugging |
1317 | - end |
1318 | - end |
1319 | - |
1320 | - describe "when setting timing mode" do |
1321 | - it "should have timing enabled using 1" do |
1322 | - Facter.timing(1) |
1323 | - Facter.should be_timing |
1324 | - end |
1325 | - it "should have timing enabled using true" do |
1326 | - Facter.timing(true) |
1327 | - Facter.should be_timing |
1328 | - end |
1329 | - it "should have timing disabled using 0" do |
1330 | - Facter.timing(0) |
1331 | - Facter.should_not be_timing |
1332 | - end |
1333 | - it "should have timing disabled using false" do |
1334 | - Facter.timing(false) |
1335 | - Facter.should_not be_timing |
1336 | - end |
1337 | - end |
1338 | - |
1339 | - describe "when registering directories to search" do |
1340 | - after { Facter.instance_variable_set("@search_path", []) } |
1341 | - |
1342 | - it "should allow registration of a directory" do |
1343 | - Facter.search "/my/dir" |
1344 | - end |
1345 | - |
1346 | - it "should allow registration of multiple directories" do |
1347 | - Facter.search "/my/dir", "/other/dir" |
1348 | - end |
1349 | - |
1350 | - it "should return all registered directories when asked" do |
1351 | - Facter.search "/my/dir", "/other/dir" |
1352 | - Facter.search_path.should == %w{/my/dir /other/dir} |
1353 | - end |
1354 | - end |
1355 | + it "should have a version" do |
1356 | + Facter.version.should =~ /^[0-9]+(\.[0-9]+)*$/ |
1357 | + end |
1358 | + |
1359 | + it "should have a method for returning its collection" do |
1360 | + Facter.should respond_to(:collection) |
1361 | + end |
1362 | + |
1363 | + it "should cache the collection" do |
1364 | + Facter.collection.should equal(Facter.collection) |
1365 | + end |
1366 | + |
1367 | + it "should delegate the :flush method to the collection" do |
1368 | + Facter.collection.expects(:flush) |
1369 | + Facter.flush |
1370 | + end |
1371 | + |
1372 | + it "should delegate the :fact method to the collection" do |
1373 | + Facter.collection.expects(:fact) |
1374 | + Facter.fact |
1375 | + end |
1376 | + |
1377 | + it "should delegate the :list method to the collection" do |
1378 | + Facter.collection.expects(:list) |
1379 | + Facter.list |
1380 | + end |
1381 | + |
1382 | + it "should load all facts when listing" do |
1383 | + Facter.collection.expects(:load_all) |
1384 | + Facter.collection.stubs(:list) |
1385 | + Facter.list |
1386 | + end |
1387 | + |
1388 | + it "should delegate the :to_hash method to the collection" do |
1389 | + Facter.collection.expects(:to_hash) |
1390 | + Facter.to_hash |
1391 | + end |
1392 | + |
1393 | + it "should load all facts when calling :to_hash" do |
1394 | + Facter.collection.expects(:load_all) |
1395 | + Facter.collection.stubs(:to_hash) |
1396 | + Facter.to_hash |
1397 | + end |
1398 | + |
1399 | + it "should delegate the :value method to the collection" do |
1400 | + Facter.collection.expects(:value) |
1401 | + Facter.value |
1402 | + end |
1403 | + |
1404 | + it "should delegate the :each method to the collection" do |
1405 | + Facter.collection.expects(:each) |
1406 | + Facter.each |
1407 | + end |
1408 | + |
1409 | + it "should load all facts when calling :each" do |
1410 | + Facter.collection.expects(:load_all) |
1411 | + Facter.collection.stubs(:each) |
1412 | + Facter.each |
1413 | + end |
1414 | + |
1415 | + it "should yield to the block when using :each" do |
1416 | + Facter.collection.stubs(:load_all) |
1417 | + Facter.collection.stubs(:each).yields "foo" |
1418 | + result = [] |
1419 | + Facter.each { |f| result << f } |
1420 | + result.should == %w{foo} |
1421 | + end |
1422 | + |
1423 | + describe "when provided code as a string" do |
1424 | + it "should execute the code in the shell" do |
1425 | + Facter.add("shell_testing") do |
1426 | + setcode "echo yup" |
1427 | + end |
1428 | + |
1429 | + Facter["shell_testing"].value.should == "yup" |
1430 | + end |
1431 | + end |
1432 | + |
1433 | + describe "when asked for a fact as an undefined Facter class method" do |
1434 | + describe "and the collection is already initialized" do |
1435 | + it "should return the fact's value" do |
1436 | + Facter.collection |
1437 | + Facter.ipaddress.should == Facter['ipaddress'].value |
1438 | + end |
1439 | + end |
1440 | + |
1441 | + describe "and the collection has been just reset" do |
1442 | + it "should return the fact's value" do |
1443 | + Facter.reset |
1444 | + Facter.ipaddress.should == Facter['ipaddress'].value |
1445 | + end |
1446 | + end |
1447 | + end |
1448 | + |
1449 | + describe "when passed code as a block" do |
1450 | + it "should execute the provided block" do |
1451 | + Facter.add("block_testing") { setcode { "foo" } } |
1452 | + |
1453 | + Facter["block_testing"].value.should == "foo" |
1454 | + end |
1455 | + end |
1456 | + |
1457 | + describe Facter[:hostname] do |
1458 | + it "should have its ldapname set to 'cn'" do |
1459 | + Facter[:hostname].ldapname.should == "cn" |
1460 | + end |
1461 | + end |
1462 | + |
1463 | + describe Facter[:ipaddress] do |
1464 | + it "should have its ldapname set to 'iphostnumber'" do |
1465 | + Facter[:ipaddress].ldapname.should == "iphostnumber" |
1466 | + end |
1467 | + end |
1468 | + |
1469 | + # #33 Make sure we only get one mac address |
1470 | + it "should only return one mac address" do |
1471 | + if macaddress = Facter.value(:macaddress) |
1472 | + macaddress.should_not be_include(" ") |
1473 | + end |
1474 | + end |
1475 | + |
1476 | + it "should have a method for registering directories to search" do |
1477 | + Facter.should respond_to(:search) |
1478 | + end |
1479 | + |
1480 | + it "should have a method for returning the registered search directories" do |
1481 | + Facter.should respond_to(:search_path) |
1482 | + end |
1483 | + |
1484 | + it "should have a method to query debugging mode" do |
1485 | + Facter.should respond_to(:debugging?) |
1486 | + end |
1487 | + |
1488 | + it "should have a method to query timing mode" do |
1489 | + Facter.should respond_to(:timing?) |
1490 | + end |
1491 | + |
1492 | + it "should have a method to show timing information" do |
1493 | + Facter.should respond_to(:show_time) |
1494 | + end |
1495 | + |
1496 | + it "should have a method to warn" do |
1497 | + Facter.should respond_to(:warn) |
1498 | + end |
1499 | + |
1500 | + describe "when warning" do |
1501 | + it "should warn if debugging is enabled" do |
1502 | + Facter.debugging(true) |
1503 | + Kernel.stubs(:warn) |
1504 | + Kernel.expects(:warn).with('foo') |
1505 | + Facter.warn('foo') |
1506 | + end |
1507 | + |
1508 | + it "should not warn if debugging is enabled but nil is passed" do |
1509 | + Facter.debugging(true) |
1510 | + Kernel.stubs(:warn) |
1511 | + Kernel.expects(:warn).never |
1512 | + Facter.warn(nil) |
1513 | + end |
1514 | + |
1515 | + it "should not warn if debugging is enabled but an empyt string is passed" do |
1516 | + Facter.debugging(true) |
1517 | + Kernel.stubs(:warn) |
1518 | + Kernel.expects(:warn).never |
1519 | + Facter.warn('') |
1520 | + end |
1521 | + |
1522 | + it "should not warn if debugging is disabled" do |
1523 | + Facter.debugging(false) |
1524 | + Kernel.stubs(:warn) |
1525 | + Kernel.expects(:warn).never |
1526 | + Facter.warn('foo') |
1527 | + end |
1528 | + |
1529 | + it "should warn for any given element for an array if debugging is enabled" do |
1530 | + Facter.debugging(true) |
1531 | + Kernel.stubs(:warn) |
1532 | + Kernel.expects(:warn).with('foo') |
1533 | + Kernel.expects(:warn).with('bar') |
1534 | + Facter.warn( ['foo','bar']) |
1535 | + end |
1536 | + end |
1537 | + |
1538 | + describe "when warning once" do |
1539 | + it "should only warn once" do |
1540 | + Kernel.stubs(:warnonce) |
1541 | + Kernel.expects(:warn).with('foo').once |
1542 | + Facter.warnonce('foo') |
1543 | + Facter.warnonce('foo') |
1544 | + end |
1545 | + |
1546 | + it "should not warnonce if nil is passed" do |
1547 | + Kernel.stubs(:warn) |
1548 | + Kernel.expects(:warnonce).never |
1549 | + Facter.warnonce(nil) |
1550 | + end |
1551 | + |
1552 | + it "should not warnonce if an empty string is passed" do |
1553 | + Kernel.stubs(:warn) |
1554 | + Kernel.expects(:warnonce).never |
1555 | + Facter.warnonce('') |
1556 | + end |
1557 | + end |
1558 | + |
1559 | + describe "when setting debugging mode" do |
1560 | + it "should have debugging enabled using 1" do |
1561 | + Facter.debugging(1) |
1562 | + Facter.should be_debugging |
1563 | + end |
1564 | + it "should have debugging enabled using true" do |
1565 | + Facter.debugging(true) |
1566 | + Facter.should be_debugging |
1567 | + end |
1568 | + it "should have debugging enabled using any string except off" do |
1569 | + Facter.debugging('aaaaa') |
1570 | + Facter.should be_debugging |
1571 | + end |
1572 | + it "should have debugging disabled using 0" do |
1573 | + Facter.debugging(0) |
1574 | + Facter.should_not be_debugging |
1575 | + end |
1576 | + it "should have debugging disabled using false" do |
1577 | + Facter.debugging(false) |
1578 | + Facter.should_not be_debugging |
1579 | + end |
1580 | + it "should have debugging disabled using the string 'off'" do |
1581 | + Facter.debugging('off') |
1582 | + Facter.should_not be_debugging |
1583 | + end |
1584 | + end |
1585 | + |
1586 | + describe "when setting timing mode" do |
1587 | + it "should have timing enabled using 1" do |
1588 | + Facter.timing(1) |
1589 | + Facter.should be_timing |
1590 | + end |
1591 | + it "should have timing enabled using true" do |
1592 | + Facter.timing(true) |
1593 | + Facter.should be_timing |
1594 | + end |
1595 | + it "should have timing disabled using 0" do |
1596 | + Facter.timing(0) |
1597 | + Facter.should_not be_timing |
1598 | + end |
1599 | + it "should have timing disabled using false" do |
1600 | + Facter.timing(false) |
1601 | + Facter.should_not be_timing |
1602 | + end |
1603 | + end |
1604 | + |
1605 | + describe "when registering directories to search" do |
1606 | + after { Facter.instance_variable_set("@search_path", []) } |
1607 | + |
1608 | + it "should allow registration of a directory" do |
1609 | + Facter.search "/my/dir" |
1610 | + end |
1611 | + |
1612 | + it "should allow registration of multiple directories" do |
1613 | + Facter.search "/my/dir", "/other/dir" |
1614 | + end |
1615 | + |
1616 | + it "should return all registered directories when asked" do |
1617 | + Facter.search "/my/dir", "/other/dir" |
1618 | + Facter.search_path.should == %w{/my/dir /other/dir} |
1619 | + end |
1620 | + end |
1621 | end |
1622 | |
1623 | === modified file 'spec/unit/id_spec.rb' |
1624 | --- spec/unit/id_spec.rb 2011-10-06 10:48:30 +0000 |
1625 | +++ spec/unit/id_spec.rb 2012-01-27 20:04:26 +0000 |
1626 | @@ -4,25 +4,25 @@ |
1627 | |
1628 | describe "id fact" do |
1629 | |
1630 | - kernel = [ 'Linux', 'Darwin', 'windows', 'FreeBSD', 'OpenBSD', 'NetBSD', 'AIX', 'HP-UX' ] |
1631 | - |
1632 | - kernel.each do |k| |
1633 | - describe "with kernel reported as #{k}" do |
1634 | - it "should return the current user" do |
1635 | - Facter.fact(:kernel).stubs(:value).returns(k) |
1636 | - Facter::Util::Config.stubs(:is_windows?).returns(k == 'windows') |
1637 | - Facter::Util::Resolution.expects(:exec).once.with('whoami').returns 'bar' |
1638 | - |
1639 | - Facter.fact(:id).value.should == 'bar' |
1640 | - end |
1641 | - end |
1642 | - end |
1643 | - |
1644 | - it "should return the current user on Solaris" do |
1645 | - Facter::Util::Config.stubs(:is_windows?).returns(false) |
1646 | - Facter::Util::Resolution.stubs(:exec).with('uname -s').returns('SunOS') |
1647 | - Facter::Util::Resolution.expects(:exec).once.with('/usr/xpg4/bin/id -un').returns 'bar' |
1648 | - |
1649 | - Facter.fact(:id).value.should == 'bar' |
1650 | - end |
1651 | + kernel = [ 'Linux', 'Darwin', 'windows', 'FreeBSD', 'OpenBSD', 'NetBSD', 'AIX', 'HP-UX' ] |
1652 | + |
1653 | + kernel.each do |k| |
1654 | + describe "with kernel reported as #{k}" do |
1655 | + it "should return the current user" do |
1656 | + Facter.fact(:kernel).stubs(:value).returns(k) |
1657 | + Facter::Util::Config.stubs(:is_windows?).returns(k == 'windows') |
1658 | + Facter::Util::Resolution.expects(:exec).once.with('whoami').returns 'bar' |
1659 | + |
1660 | + Facter.fact(:id).value.should == 'bar' |
1661 | + end |
1662 | + end |
1663 | + end |
1664 | + |
1665 | + it "should return the current user on Solaris" do |
1666 | + Facter::Util::Config.stubs(:is_windows?).returns(false) |
1667 | + Facter::Util::Resolution.stubs(:exec).with('uname -s').returns('SunOS') |
1668 | + Facter::Util::Resolution.expects(:exec).once.with('/usr/xpg4/bin/id -un').returns 'bar' |
1669 | + |
1670 | + Facter.fact(:id).value.should == 'bar' |
1671 | + end |
1672 | end |
1673 | |
1674 | === modified file 'spec/unit/interfaces_spec.rb' |
1675 | --- spec/unit/interfaces_spec.rb 2011-10-06 10:48:30 +0000 |
1676 | +++ spec/unit/interfaces_spec.rb 2012-01-27 20:04:26 +0000 |
1677 | @@ -6,13 +6,13 @@ |
1678 | require 'facter/util/ip' |
1679 | |
1680 | describe "Per Interface IP facts" do |
1681 | - it "should replace the ':' in an interface list with '_'" do |
1682 | - # So we look supported |
1683 | - Facter.fact(:kernel).stubs(:value).returns("SunOS") |
1684 | + it "should replace the ':' in an interface list with '_'" do |
1685 | + # So we look supported |
1686 | + Facter.fact(:kernel).stubs(:value).returns("SunOS") |
1687 | |
1688 | - Facter::Util::IP.stubs(:get_interfaces).returns %w{eth0:1 eth1:2} |
1689 | - Facter.fact(:interfaces).value.should == %{eth0_1,eth1_2} |
1690 | - end |
1691 | + Facter::Util::IP.stubs(:get_interfaces).returns %w{eth0:1 eth1:2} |
1692 | + Facter.fact(:interfaces).value.should == %{eth0_1,eth1_2} |
1693 | + end |
1694 | |
1695 | it "should replace non-alphanumerics in an interface list with '_'" do |
1696 | Facter.fact(:kernel).stubs(:value).returns("windows") |
1697 | |
1698 | === modified file 'spec/unit/macaddress_spec.rb' |
1699 | --- spec/unit/macaddress_spec.rb 2011-10-06 10:48:30 +0000 |
1700 | +++ spec/unit/macaddress_spec.rb 2012-01-27 20:04:26 +0000 |
1701 | @@ -18,21 +18,45 @@ |
1702 | Facter::Util::Config.stubs(:is_windows?).returns(false) |
1703 | end |
1704 | |
1705 | - it "should return macaddress information for Linux" do |
1706 | - Facter.fact(:kernel).stubs(:value).returns("Linux") |
1707 | - Facter.fact(:operatingsystem).stubs(:value).returns("Linux") |
1708 | - Facter::Util::Resolution.stubs(:exec).with('/sbin/ifconfig -a'). |
1709 | - returns(ifconfig_fixture('linux_ifconfig_all_with_multiple_interfaces')) |
1710 | - |
1711 | - Facter.value(:macaddress).should == "00:12:3f:be:22:01" |
1712 | + describe "when run on Linux" do |
1713 | + before :each do |
1714 | + Facter.fact(:kernel).stubs(:value).returns("Linux") |
1715 | + Facter.fact(:operatingsystem).stubs(:value).returns("Linux") |
1716 | + end |
1717 | + |
1718 | + it "should return the macaddress of the first interface" do |
1719 | + Facter::Util::Resolution.stubs(:exec).with('/sbin/ifconfig -a'). |
1720 | + returns(ifconfig_fixture('linux_ifconfig_all_with_multiple_interfaces')) |
1721 | + |
1722 | + Facter.value(:macaddress).should == "00:12:3f:be:22:01" |
1723 | + end |
1724 | + |
1725 | + it "should return nil when no macaddress can be found" do |
1726 | + Facter::Util::Resolution.stubs(:exec).with('/sbin/ifconfig -a'). |
1727 | + returns(ifconfig_fixture('linux_ifconfig_no_mac')) |
1728 | + |
1729 | + proc { Facter.value(:macaddress) }.should_not raise_error |
1730 | + Facter.value(:macaddress).should be_nil |
1731 | + end |
1732 | + |
1733 | + # some interfaces dont have a real mac addresses (like venet inside a container) |
1734 | + it "should return nil when no interface has a real macaddress" do |
1735 | + Facter::Util::Resolution.stubs(:exec).with('/sbin/ifconfig -a'). |
1736 | + returns(ifconfig_fixture('linux_ifconfig_venet')) |
1737 | + |
1738 | + proc { Facter.value(:macaddress) }.should_not raise_error |
1739 | + Facter.value(:macaddress).should be_nil |
1740 | + end |
1741 | end |
1742 | |
1743 | - it "should return macaddress information for BSD" do |
1744 | - Facter.fact(:kernel).stubs(:value).returns("FreeBSD") |
1745 | - Facter::Util::Resolution.stubs(:exec).with('/sbin/ifconfig'). |
1746 | - returns(ifconfig_fixture('bsd_ifconfig_all_with_multiple_interfaces')) |
1747 | + describe "when run on BSD" do |
1748 | + it "should return macaddress information" do |
1749 | + Facter.fact(:kernel).stubs(:value).returns("FreeBSD") |
1750 | + Facter::Util::Resolution.stubs(:exec).with('/sbin/ifconfig'). |
1751 | + returns(ifconfig_fixture('bsd_ifconfig_all_with_multiple_interfaces')) |
1752 | |
1753 | - Facter.value(:macaddress).should == "00:0b:db:93:09:67" |
1754 | + Facter.value(:macaddress).should == "00:0b:db:93:09:67" |
1755 | + end |
1756 | end |
1757 | |
1758 | end |
1759 | |
1760 | === modified file 'spec/unit/memory_spec.rb' |
1761 | --- spec/unit/memory_spec.rb 2011-10-12 11:29:53 +0000 |
1762 | +++ spec/unit/memory_spec.rb 2012-01-27 20:04:26 +0000 |
1763 | @@ -5,146 +5,146 @@ |
1764 | require 'facter' |
1765 | |
1766 | describe "Memory facts" do |
1767 | - before do |
1768 | - # We need these facts loaded, but they belong to a file with a |
1769 | - # different name, so load the file explicitly. |
1770 | - Facter.collection.loader.load(:memory) |
1771 | - end |
1772 | - |
1773 | - after do |
1774 | - Facter.clear |
1775 | + before do |
1776 | + # We need these facts loaded, but they belong to a file with a |
1777 | + # different name, so load the file explicitly. |
1778 | + Facter.collection.loader.load(:memory) |
1779 | + end |
1780 | + |
1781 | + after do |
1782 | + Facter.clear |
1783 | + end |
1784 | + |
1785 | + it "should return the current swap size" do |
1786 | + |
1787 | + Facter.fact(:kernel).stubs(:value).returns("Darwin") |
1788 | + Facter::Util::Resolution.stubs(:exec).with('sysctl vm.swapusage').returns("vm.swapusage: total = 64.00M used = 0.00M free = 64.00M (encrypted)") |
1789 | + swapusage = "vm.swapusage: total = 64.00M used = 0.00M free = 64.00M (encrypted)" |
1790 | + |
1791 | + if swapusage =~ /total = (\S+).*/ |
1792 | + Facter.fact(:swapfree).value.should == $1 |
1793 | + end |
1794 | + end |
1795 | + |
1796 | + it "should return the current swap free" do |
1797 | + Facter.fact(:kernel).stubs(:value).returns("Darwin") |
1798 | + Facter::Util::Resolution.stubs(:exec).with('sysctl vm.swapusage').returns("vm.swapusage: total = 64.00M used = 0.00M free = 64.00M (encrypted)") |
1799 | + swapusage = "vm.swapusage: total = 64.00M used = 0.00M free = 64.00M (encrypted)" |
1800 | + |
1801 | + if swapusage =~ /free = (\S+).*/ |
1802 | + Facter.fact(:swapfree).value.should == $1 |
1803 | + end |
1804 | + end |
1805 | + |
1806 | + it "should return whether swap is encrypted" do |
1807 | + Facter.fact(:kernel).stubs(:value).returns("Darwin") |
1808 | + Facter::Util::Resolution.stubs(:exec).with('sysctl vm.swapusage').returns("vm.swapusage: total = 64.00M used = 0.00M free = 64.00M (encrypted)") |
1809 | + swapusage = "vm.swapusage: total = 64.00M used = 0.00M free = 64.00M (encrypted)" |
1810 | + |
1811 | + swapusage =~ /\(encrypted\)/ |
1812 | + Facter.fact(:swapencrypted).value.should == true |
1813 | + end |
1814 | + |
1815 | + describe "on OpenBSD" do |
1816 | + before :each do |
1817 | + Facter.clear |
1818 | + Facter.fact(:kernel).stubs(:value).returns("OpenBSD") |
1819 | + |
1820 | + swapusage = "total: 148342k bytes allocated = 0k used, 148342k available" |
1821 | + Facter::Util::Resolution.stubs(:exec).with('swapctl -s').returns(swapusage) |
1822 | + |
1823 | + vmstat = <<EOS |
1824 | + procs memory page disks traps cpu |
1825 | + r b w avm fre flt re pi po fr sr cd0 sd0 int sys cs us sy id |
1826 | + 0 0 0 11048 181028 39 0 0 0 0 0 0 1 3 90 17 0 0 100 |
1827 | +EOS |
1828 | + Facter::Util::Resolution.stubs(:exec).with('vmstat').returns(vmstat) |
1829 | + |
1830 | + Facter::Util::Resolution.stubs(:exec).with("sysctl hw.physmem | cut -d'=' -f2").returns('267321344') |
1831 | + |
1832 | + Facter.collection.loader.load(:memory) |
1833 | + end |
1834 | + |
1835 | + after :each do |
1836 | + Facter.clear |
1837 | + end |
1838 | + |
1839 | + it "should return the current swap free" do |
1840 | + Facter.fact(:swapfree).value.should == "144.87 MB" |
1841 | end |
1842 | |
1843 | it "should return the current swap size" do |
1844 | - |
1845 | - Facter.fact(:kernel).stubs(:value).returns("Darwin") |
1846 | - Facter::Util::Resolution.stubs(:exec).with('sysctl vm.swapusage').returns("vm.swapusage: total = 64.00M used = 0.00M free = 64.00M (encrypted)") |
1847 | - swapusage = "vm.swapusage: total = 64.00M used = 0.00M free = 64.00M (encrypted)" |
1848 | - |
1849 | - if swapusage =~ /total = (\S+).*/ |
1850 | - Facter.fact(:swapfree).value.should == $1 |
1851 | - end |
1852 | - end |
1853 | - |
1854 | - it "should return the current swap free" do |
1855 | - Facter.fact(:kernel).stubs(:value).returns("Darwin") |
1856 | - Facter::Util::Resolution.stubs(:exec).with('sysctl vm.swapusage').returns("vm.swapusage: total = 64.00M used = 0.00M free = 64.00M (encrypted)") |
1857 | - swapusage = "vm.swapusage: total = 64.00M used = 0.00M free = 64.00M (encrypted)" |
1858 | - |
1859 | - if swapusage =~ /free = (\S+).*/ |
1860 | - Facter.fact(:swapfree).value.should == $1 |
1861 | - end |
1862 | - end |
1863 | - |
1864 | - it "should return whether swap is encrypted" do |
1865 | - Facter.fact(:kernel).stubs(:value).returns("Darwin") |
1866 | - Facter::Util::Resolution.stubs(:exec).with('sysctl vm.swapusage').returns("vm.swapusage: total = 64.00M used = 0.00M free = 64.00M (encrypted)") |
1867 | - swapusage = "vm.swapusage: total = 64.00M used = 0.00M free = 64.00M (encrypted)" |
1868 | - |
1869 | - swapusage =~ /\(encrypted\)/ |
1870 | - Facter.fact(:swapencrypted).value.should == true |
1871 | - end |
1872 | - |
1873 | - describe "on OpenBSD" do |
1874 | - before :each do |
1875 | - Facter.clear |
1876 | - Facter.fact(:kernel).stubs(:value).returns("OpenBSD") |
1877 | - |
1878 | - swapusage = "total: 148342k bytes allocated = 0k used, 148342k available" |
1879 | - Facter::Util::Resolution.stubs(:exec).with('swapctl -s').returns(swapusage) |
1880 | - |
1881 | - vmstat = <<EOS |
1882 | - procs memory page disks traps cpu |
1883 | - r b w avm fre flt re pi po fr sr cd0 sd0 int sys cs us sy id |
1884 | - 0 0 0 11048 181028 39 0 0 0 0 0 0 1 3 90 17 0 0 100 |
1885 | -EOS |
1886 | - Facter::Util::Resolution.stubs(:exec).with('vmstat').returns(vmstat) |
1887 | - |
1888 | - Facter::Util::Resolution.stubs(:exec).with("sysctl hw.physmem | cut -d'=' -f2").returns('267321344') |
1889 | - |
1890 | - Facter.collection.loader.load(:memory) |
1891 | - end |
1892 | - |
1893 | - after :each do |
1894 | - Facter.clear |
1895 | - end |
1896 | - |
1897 | - it "should return the current swap free" do |
1898 | - Facter.fact(:swapfree).value.should == "144.87 MB" |
1899 | - end |
1900 | - |
1901 | - it "should return the current swap size" do |
1902 | - Facter.fact(:swapsize).value.should == "144.87 MB" |
1903 | - end |
1904 | - |
1905 | - it "should return the current memorysize" do |
1906 | - Facter.fact(:memorytotal).value.should == "254.94 MB" |
1907 | - end |
1908 | - end |
1909 | - |
1910 | - describe "on DragonFly BSD" do |
1911 | - before :each do |
1912 | - Facter.clear |
1913 | - Facter.fact(:kernel).stubs(:value).returns("dragonfly") |
1914 | - |
1915 | - swapusage = "total: 148342k bytes allocated = 0k used, 148342k available" |
1916 | - Facter::Util::Resolution.stubs(:exec).with('/sbin/sysctl -n hw.pagesize').returns("4096") |
1917 | - Facter::Util::Resolution.stubs(:exec).with('/sbin/sysctl -n vm.swap_size').returns("128461") |
1918 | - Facter::Util::Resolution.stubs(:exec).with('/sbin/sysctl -n vm.swap_anon_use').returns("2635") |
1919 | - Facter::Util::Resolution.stubs(:exec).with('/sbin/sysctl -n vm.swap_cache_use').returns("0") |
1920 | - |
1921 | - vmstat = <<EOS |
1922 | - procs memory page disks faults cpu |
1923 | - r b w avm fre flt re pi po fr sr da0 sg1 in sy cs us sy id |
1924 | + Facter.fact(:swapsize).value.should == "144.87 MB" |
1925 | + end |
1926 | + |
1927 | + it "should return the current memorysize" do |
1928 | + Facter.fact(:memorytotal).value.should == "254.94 MB" |
1929 | + end |
1930 | + end |
1931 | + |
1932 | + describe "on DragonFly BSD" do |
1933 | + before :each do |
1934 | + Facter.clear |
1935 | + Facter.fact(:kernel).stubs(:value).returns("dragonfly") |
1936 | + |
1937 | + swapusage = "total: 148342k bytes allocated = 0k used, 148342k available" |
1938 | + Facter::Util::Resolution.stubs(:exec).with('/sbin/sysctl -n hw.pagesize').returns("4096") |
1939 | + Facter::Util::Resolution.stubs(:exec).with('/sbin/sysctl -n vm.swap_size').returns("128461") |
1940 | + Facter::Util::Resolution.stubs(:exec).with('/sbin/sysctl -n vm.swap_anon_use').returns("2635") |
1941 | + Facter::Util::Resolution.stubs(:exec).with('/sbin/sysctl -n vm.swap_cache_use').returns("0") |
1942 | + |
1943 | + vmstat = <<EOS |
1944 | + procs memory page disks faults cpu |
1945 | + r b w avm fre flt re pi po fr sr da0 sg1 in sy cs us sy id |
1946 | 0 0 0 33152 13940 1902120 2198 53119 11642 6544597 5460994 0 0 6148243 7087927 3484264 0 1 9 |
1947 | EOS |
1948 | - Facter::Util::Resolution.stubs(:exec).with('vmstat').returns(vmstat) |
1949 | - |
1950 | - Facter::Util::Resolution.stubs(:exec).with("sysctl -n hw.physmem").returns('248512512') |
1951 | - |
1952 | - Facter.collection.loader.load(:memory) |
1953 | - end |
1954 | - |
1955 | - after :each do |
1956 | - Facter.clear |
1957 | - end |
1958 | - |
1959 | - it "should return the current swap free" do |
1960 | - Facter.fact(:swapfree).value.should == "491.51 MB" |
1961 | - end |
1962 | - |
1963 | - it "should return the current swap size" do |
1964 | - Facter.fact(:swapsize).value.should == "501.80 MB" |
1965 | - end |
1966 | - |
1967 | - it "should return the current memorysize" do |
1968 | - Facter.fact(:memorytotal).value.should == "237.00 MB" |
1969 | - end |
1970 | - end |
1971 | - |
1972 | - describe "on Windows" do |
1973 | - before :each do |
1974 | - Facter.clear |
1975 | - Facter.fact(:kernel).stubs(:value).returns("windows") |
1976 | - Facter.collection.loader.load(:memory) |
1977 | - |
1978 | - require 'facter/util/wmi' |
1979 | - end |
1980 | - |
1981 | - it "should return free memory" do |
1982 | - os = stubs 'os' |
1983 | - os.stubs(:FreePhysicalMemory).returns("3415624") |
1984 | - Facter::Util::WMI.stubs(:execquery).returns([os]) |
1985 | - |
1986 | - Facter.fact(:MemoryFree).value.should == '3.26 GB' |
1987 | - end |
1988 | - |
1989 | - it "should return total memory" do |
1990 | - computer = stubs 'computer' |
1991 | - computer.stubs(:TotalPhysicalMemory).returns("4193837056") |
1992 | - Facter::Util::WMI.stubs(:execquery).returns([computer]) |
1993 | - |
1994 | - Facter.fact(:MemoryTotal).value.should == '3.91 GB' |
1995 | - end |
1996 | - end |
1997 | + Facter::Util::Resolution.stubs(:exec).with('vmstat').returns(vmstat) |
1998 | + |
1999 | + Facter::Util::Resolution.stubs(:exec).with("sysctl -n hw.physmem").returns('248512512') |
2000 | + |
2001 | + Facter.collection.loader.load(:memory) |
2002 | + end |
2003 | + |
2004 | + after :each do |
2005 | + Facter.clear |
2006 | + end |
2007 | + |
2008 | + it "should return the current swap free" do |
2009 | + Facter.fact(:swapfree).value.should == "491.51 MB" |
2010 | + end |
2011 | + |
2012 | + it "should return the current swap size" do |
2013 | + Facter.fact(:swapsize).value.should == "501.80 MB" |
2014 | + end |
2015 | + |
2016 | + it "should return the current memorysize" do |
2017 | + Facter.fact(:memorytotal).value.should == "237.00 MB" |
2018 | + end |
2019 | + end |
2020 | + |
2021 | + describe "on Windows" do |
2022 | + before :each do |
2023 | + Facter.clear |
2024 | + Facter.fact(:kernel).stubs(:value).returns("windows") |
2025 | + Facter.collection.loader.load(:memory) |
2026 | + |
2027 | + require 'facter/util/wmi' |
2028 | + end |
2029 | + |
2030 | + it "should return free memory" do |
2031 | + os = stubs 'os' |
2032 | + os.stubs(:FreePhysicalMemory).returns("3415624") |
2033 | + Facter::Util::WMI.stubs(:execquery).returns([os]) |
2034 | + |
2035 | + Facter.fact(:MemoryFree).value.should == '3.26 GB' |
2036 | + end |
2037 | + |
2038 | + it "should return total memory" do |
2039 | + computer = stubs 'computer' |
2040 | + computer.stubs(:TotalPhysicalMemory).returns("4193837056") |
2041 | + Facter::Util::WMI.stubs(:execquery).returns([computer]) |
2042 | + |
2043 | + Facter.fact(:MemoryTotal).value.should == '3.91 GB' |
2044 | + end |
2045 | + end |
2046 | end |
2047 | |
2048 | === modified file 'spec/unit/operatingsystem_spec.rb' |
2049 | --- spec/unit/operatingsystem_spec.rb 2011-10-06 10:48:30 +0000 |
2050 | +++ spec/unit/operatingsystem_spec.rb 2012-01-27 20:04:26 +0000 |
2051 | @@ -6,78 +6,87 @@ |
2052 | |
2053 | describe "Operating System fact" do |
2054 | |
2055 | - before do |
2056 | - Facter.clear |
2057 | - end |
2058 | - |
2059 | - after do |
2060 | - Facter.clear |
2061 | - end |
2062 | - |
2063 | - it "should default to the kernel name" do |
2064 | - Facter.fact(:kernel).stubs(:value).returns("Nutmeg") |
2065 | - |
2066 | - Facter.fact(:operatingsystem).value.should == "Nutmeg" |
2067 | - end |
2068 | - |
2069 | - it "should be Solaris for SunOS" do |
2070 | - Facter.fact(:kernel).stubs(:value).returns("SunOS") |
2071 | - |
2072 | - Facter.fact(:operatingsystem).value.should == "Solaris" |
2073 | - end |
2074 | - |
2075 | - it "should be ESXi for VMkernel" do |
2076 | - Facter.fact(:kernel).stubs(:value).returns("VMkernel") |
2077 | - |
2078 | - Facter.fact(:operatingsystem).value.should == "ESXi" |
2079 | - end |
2080 | - |
2081 | - it "should identify Oracle VM as OVS" do |
2082 | - Facter.fact(:kernel).stubs(:value).returns("Linux") |
2083 | - Facter.stubs(:value).with(:lsbdistid).returns(nil) |
2084 | - FileTest.stubs(:exists?).returns false |
2085 | - |
2086 | - FileTest.expects(:exists?).with("/etc/ovs-release").returns true |
2087 | - FileTest.expects(:exists?).with("/etc/enterprise-release").returns true |
2088 | - |
2089 | - Facter.fact(:operatingsystem).value.should == "OVS" |
2090 | - end |
2091 | + before do |
2092 | + Facter.clear |
2093 | + end |
2094 | + |
2095 | + after do |
2096 | + Facter.clear |
2097 | + end |
2098 | + |
2099 | + it "should default to the kernel name" do |
2100 | + Facter.fact(:kernel).stubs(:value).returns("Nutmeg") |
2101 | + |
2102 | + Facter.fact(:operatingsystem).value.should == "Nutmeg" |
2103 | + end |
2104 | + |
2105 | + it "should be Solaris for SunOS" do |
2106 | + Facter.fact(:kernel).stubs(:value).returns("SunOS") |
2107 | + |
2108 | + Facter.fact(:operatingsystem).value.should == "Solaris" |
2109 | + end |
2110 | + |
2111 | + it "should be ESXi for VMkernel" do |
2112 | + Facter.fact(:kernel).stubs(:value).returns("VMkernel") |
2113 | + |
2114 | + Facter.fact(:operatingsystem).value.should == "ESXi" |
2115 | + end |
2116 | + |
2117 | + it "should identify Oracle VM as OVS" do |
2118 | + Facter.fact(:kernel).stubs(:value).returns("Linux") |
2119 | + Facter.stubs(:value).with(:lsbdistid).returns(nil) |
2120 | + FileTest.stubs(:exists?).returns false |
2121 | + |
2122 | + FileTest.expects(:exists?).with("/etc/ovs-release").returns true |
2123 | + FileTest.expects(:exists?).with("/etc/enterprise-release").returns true |
2124 | + |
2125 | + Facter.fact(:operatingsystem).value.should == "OVS" |
2126 | + end |
2127 | |
2128 | - it "should identify VMWare ESX" do |
2129 | - Facter.fact(:kernel).stubs(:value).returns("Linux") |
2130 | - Facter.stubs(:value).with(:lsbdistid).returns(nil) |
2131 | - FileTest.stubs(:exists?).returns false |
2132 | - |
2133 | - FileTest.expects(:exists?).with("/etc/vmware-release").returns true |
2134 | - |
2135 | - Facter.fact(:operatingsystem).value.should == "VMWareESX" |
2136 | - end |
2137 | - |
2138 | - it "should identify Alpine Linux" do |
2139 | - Facter.fact(:kernel).stubs(:value).returns("Linux") |
2140 | - |
2141 | - FileTest.stubs(:exists?).returns false |
2142 | - |
2143 | - FileTest.expects(:exists?).with("/etc/alpine-release").returns true |
2144 | - |
2145 | - Facter.fact(:operatingsystem).value.should == "Alpine" |
2146 | - end |
2147 | - |
2148 | - it "should identify Scientific Linux" do |
2149 | - Facter.fact(:kernel).stubs(:value).returns("Linux") |
2150 | - FileTest.stubs(:exists?).returns false |
2151 | - |
2152 | - FileTest.expects(:exists?).with("/etc/redhat-release").returns true |
2153 | - File.expects(:read).with("/etc/redhat-release").returns("Scientific Linux SLC 5.7 (Boron)") |
2154 | - Facter.fact(:operatingsystem).value.should == "Scientific" |
2155 | - end |
2156 | - |
2157 | - it "should differentiate between Scientific Linux CERN and Scientific Linux" do |
2158 | - Facter.fact(:kernel).stubs(:value).returns("Linux") |
2159 | - FileTest.stubs(:exists?).returns false |
2160 | - |
2161 | - FileTest.expects(:exists?).with("/etc/redhat-release").returns true |
2162 | - File.expects(:read).with("/etc/redhat-release").returns("Scientific Linux CERN SLC 5.7 (Boron)") |
2163 | - Facter.fact(:operatingsystem).value.should == "SLC" |
2164 | - end |
2165 | + it "should identify VMWare ESX" do |
2166 | + Facter.fact(:kernel).stubs(:value).returns("Linux") |
2167 | + Facter.stubs(:value).with(:lsbdistid).returns(nil) |
2168 | + FileTest.stubs(:exists?).returns false |
2169 | + |
2170 | + FileTest.expects(:exists?).with("/etc/vmware-release").returns true |
2171 | + |
2172 | + Facter.fact(:operatingsystem).value.should == "VMWareESX" |
2173 | + end |
2174 | + |
2175 | + it "should identify Alpine Linux" do |
2176 | + Facter.fact(:kernel).stubs(:value).returns("Linux") |
2177 | + |
2178 | + FileTest.stubs(:exists?).returns false |
2179 | + |
2180 | + FileTest.expects(:exists?).with("/etc/alpine-release").returns true |
2181 | + |
2182 | + Facter.fact(:operatingsystem).value.should == "Alpine" |
2183 | + end |
2184 | + |
2185 | + it "should identify Scientific Linux" do |
2186 | + Facter.fact(:kernel).stubs(:value).returns("Linux") |
2187 | + FileTest.stubs(:exists?).returns false |
2188 | + |
2189 | + FileTest.expects(:exists?).with("/etc/redhat-release").returns true |
2190 | + File.expects(:read).with("/etc/redhat-release").returns("Scientific Linux SLC 5.7 (Boron)") |
2191 | + Facter.fact(:operatingsystem).value.should == "Scientific" |
2192 | + end |
2193 | + |
2194 | + it "should differentiate between Scientific Linux CERN and Scientific Linux" do |
2195 | + Facter.fact(:kernel).stubs(:value).returns("Linux") |
2196 | + FileTest.stubs(:exists?).returns false |
2197 | + |
2198 | + FileTest.expects(:exists?).with("/etc/redhat-release").returns true |
2199 | + File.expects(:read).with("/etc/redhat-release").returns("Scientific Linux CERN SLC 5.7 (Boron)") |
2200 | + Facter.fact(:operatingsystem).value.should == "SLC" |
2201 | + end |
2202 | + |
2203 | + it "should identify Ascendos Linux" do |
2204 | + Facter.fact(:kernel).stubs(:value).returns("Linux") |
2205 | + FileTest.stubs(:exists?).returns false |
2206 | + |
2207 | + FileTest.expects(:exists?).with("/etc/redhat-release").returns true |
2208 | + File.expects(:read).with("/etc/redhat-release").returns("Ascendos release 6.0 (Nameless)") |
2209 | + Facter.fact(:operatingsystem).value.should == "Ascendos" |
2210 | + end |
2211 | end |
2212 | |
2213 | === modified file 'spec/unit/operatingsystemrelease_spec.rb' |
2214 | --- spec/unit/operatingsystemrelease_spec.rb 2011-10-06 10:48:30 +0000 |
2215 | +++ spec/unit/operatingsystemrelease_spec.rb 2012-01-27 20:04:26 +0000 |
2216 | @@ -6,55 +6,56 @@ |
2217 | |
2218 | describe "Operating System Release fact" do |
2219 | |
2220 | - before do |
2221 | - Facter.clear |
2222 | - end |
2223 | - |
2224 | - after do |
2225 | - Facter.clear |
2226 | - end |
2227 | - |
2228 | - test_cases = { |
2229 | - "CentOS" => "/etc/redhat-release", |
2230 | - "RedHat" => "/etc/redhat-release", |
2231 | - "Scientific" => "/etc/redhat-release", |
2232 | - "Fedora" => "/etc/fedora-release", |
2233 | - "MeeGo" => "/etc/meego-release", |
2234 | - "OEL" => "/etc/enterprise-release", |
2235 | - "oel" => "/etc/enterprise-release", |
2236 | - "OVS" => "/etc/ovs-release", |
2237 | - "ovs" => "/etc/ovs-release", |
2238 | - "OracleLinux" => "/etc/oracle-release", |
2239 | - } |
2240 | - |
2241 | - test_cases.each do |system, file| |
2242 | - describe "with operatingsystem reported as #{system.inspect}" do |
2243 | - it "should read the #{file.inspect} file" do |
2244 | - Facter.fact(:operatingsystem).stubs(:value).returns(system) |
2245 | - |
2246 | - File.expects(:open).with(file, "r").at_least(1) |
2247 | - |
2248 | - Facter.fact(:operatingsystemrelease).value |
2249 | - end |
2250 | - end |
2251 | - end |
2252 | - |
2253 | - it "for VMWareESX it should run the vmware -v command" do |
2254 | - Facter.fact(:kernel).stubs(:value).returns("VMkernel") |
2255 | - Facter.fact(:kernelrelease).stubs(:value).returns("4.1.0") |
2256 | - Facter.fact(:operatingsystem).stubs(:value).returns("VMwareESX") |
2257 | - |
2258 | - Facter::Util::Resolution.stubs(:exec).with('vmware -v').returns('foo') |
2259 | + before do |
2260 | + Facter.clear |
2261 | + end |
2262 | + |
2263 | + after do |
2264 | + Facter.clear |
2265 | + end |
2266 | + |
2267 | + test_cases = { |
2268 | + "CentOS" => "/etc/redhat-release", |
2269 | + "RedHat" => "/etc/redhat-release", |
2270 | + "Scientific" => "/etc/redhat-release", |
2271 | + "Fedora" => "/etc/fedora-release", |
2272 | + "MeeGo" => "/etc/meego-release", |
2273 | + "OEL" => "/etc/enterprise-release", |
2274 | + "oel" => "/etc/enterprise-release", |
2275 | + "OVS" => "/etc/ovs-release", |
2276 | + "ovs" => "/etc/ovs-release", |
2277 | + "OracleLinux" => "/etc/oracle-release", |
2278 | + "Ascendos" => "/etc/redhat-release", |
2279 | + } |
2280 | + |
2281 | + test_cases.each do |system, file| |
2282 | + describe "with operatingsystem reported as #{system.inspect}" do |
2283 | + it "should read the #{file.inspect} file" do |
2284 | + Facter.fact(:operatingsystem).stubs(:value).returns(system) |
2285 | + |
2286 | + File.expects(:open).with(file, "r").at_least(1) |
2287 | |
2288 | Facter.fact(:operatingsystemrelease).value |
2289 | - end |
2290 | - |
2291 | - it "for Alpine it should use the contents of /etc/alpine-release" do |
2292 | - Facter.fact(:kernel).stubs(:value).returns("Linux") |
2293 | - Facter.fact(:operatingsystem).stubs(:value).returns("Alpine") |
2294 | - |
2295 | - File.expects(:read).with("/etc/alpine-release").returns("foo") |
2296 | - |
2297 | - Facter.fact(:operatingsystemrelease).value.should == "foo" |
2298 | - end |
2299 | + end |
2300 | + end |
2301 | + end |
2302 | + |
2303 | + it "for VMWareESX it should run the vmware -v command" do |
2304 | + Facter.fact(:kernel).stubs(:value).returns("VMkernel") |
2305 | + Facter.fact(:kernelrelease).stubs(:value).returns("4.1.0") |
2306 | + Facter.fact(:operatingsystem).stubs(:value).returns("VMwareESX") |
2307 | + |
2308 | + Facter::Util::Resolution.stubs(:exec).with('vmware -v').returns('foo') |
2309 | + |
2310 | + Facter.fact(:operatingsystemrelease).value |
2311 | + end |
2312 | + |
2313 | + it "for Alpine it should use the contents of /etc/alpine-release" do |
2314 | + Facter.fact(:kernel).stubs(:value).returns("Linux") |
2315 | + Facter.fact(:operatingsystem).stubs(:value).returns("Alpine") |
2316 | + |
2317 | + File.expects(:read).with("/etc/alpine-release").returns("foo") |
2318 | + |
2319 | + Facter.fact(:operatingsystemrelease).value.should == "foo" |
2320 | + end |
2321 | end |
2322 | |
2323 | === modified file 'spec/unit/processor_spec.rb' |
2324 | --- spec/unit/processor_spec.rb 2011-10-12 11:29:53 +0000 |
2325 | +++ spec/unit/processor_spec.rb 2012-01-27 20:04:26 +0000 |
2326 | @@ -207,7 +207,7 @@ |
2327 | File.stubs(:exists?).with('/sys/devices/system/cpu').returns(true) |
2328 | ## sysfs method is only used if cpuinfo method returned no processors |
2329 | File.stubs(:exists?).with("/proc/cpuinfo").returns(true) |
2330 | - File.stubs(:readlines).with("/proc/cpuinfo").returns("") |
2331 | + File.stubs(:readlines).with("/proc/cpuinfo").returns([]) |
2332 | Dir.stubs(:glob).with("/sys/devices/system/cpu/cpu[0-9]*").returns(%w{ |
2333 | /sys/devices/system/cpu/cpu0 |
2334 | /sys/devices/system/cpu/cpu1 |
2335 | @@ -221,7 +221,7 @@ |
2336 | File.stubs(:exists?).with('/sys/devices/system/cpu').returns(true) |
2337 | ## sysfs method is only used if cpuinfo method returned no processors |
2338 | File.stubs(:exists?).with("/proc/cpuinfo").returns(true) |
2339 | - File.stubs(:readlines).with("/proc/cpuinfo").returns("") |
2340 | + File.stubs(:readlines).with("/proc/cpuinfo").returns([]) |
2341 | Dir.stubs(:glob).with("/sys/devices/system/cpu/cpu[0-9]*").returns(%w{ |
2342 | /sys/devices/system/cpu/cpu0 |
2343 | /sys/devices/system/cpu/cpu1 |
2344 | |
2345 | === modified file 'spec/unit/selinux_spec.rb' |
2346 | --- spec/unit/selinux_spec.rb 2011-10-06 10:48:30 +0000 |
2347 | +++ spec/unit/selinux_spec.rb 2012-01-27 20:04:26 +0000 |
2348 | @@ -7,84 +7,84 @@ |
2349 | describe "SELinux facts" do |
2350 | |
2351 | |
2352 | - after do |
2353 | - Facter.clear |
2354 | - end |
2355 | - |
2356 | - it "should return true if SELinux enabled" do |
2357 | - Facter.fact(:kernel).stubs(:value).returns("Linux") |
2358 | - |
2359 | - FileTest.stubs(:exists?).returns false |
2360 | - File.stubs(:read).with("/proc/self/attr/current").returns("notkernel") |
2361 | - |
2362 | - FileTest.expects(:exists?).with("/selinux/enforce").returns true |
2363 | - FileTest.expects(:exists?).with("/proc/self/attr/current").returns true |
2364 | - File.expects(:read).with("/proc/self/attr/current").returns("kernel") |
2365 | - |
2366 | - Facter.fact(:selinux).value.should == "true" |
2367 | - end |
2368 | - |
2369 | - it "should return true if SELinux policy enabled" do |
2370 | - Facter.fact(:selinux).stubs(:value).returns("true") |
2371 | - |
2372 | - FileTest.stubs(:exists?).returns false |
2373 | - File.stubs(:read).with("/selinux/enforce").returns("0") |
2374 | - |
2375 | - FileTest.expects(:exists?).with("/selinux/enforce").returns true |
2376 | - File.expects(:read).with("/selinux/enforce").returns("1") |
2377 | - |
2378 | - Facter.fact(:selinux_enforced).value.should == "true" |
2379 | - end |
2380 | - |
2381 | - it "should return an SELinux policy version" do |
2382 | - Facter.fact(:selinux).stubs(:value).returns("true") |
2383 | - FileTest.stubs(:exists?).with("/proc/self/mountinfo").returns false |
2384 | - |
2385 | - File.stubs(:read).with("/selinux/policyvers").returns("") |
2386 | - |
2387 | - File.expects(:read).with("/selinux/policyvers").returns("1") |
2388 | - |
2389 | - Facter.fact(:selinux_policyversion).value.should == "1" |
2390 | - end |
2391 | - |
2392 | - it "should return the SELinux current mode" do |
2393 | - Facter.fact(:selinux).stubs(:value).returns("true") |
2394 | - |
2395 | - sample_output_file = File.dirname(__FILE__) + '/data/selinux_sestatus' |
2396 | - selinux_sestatus = File.read(sample_output_file) |
2397 | - |
2398 | - Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/sestatus').returns(selinux_sestatus) |
2399 | - |
2400 | - Facter.fact(:selinux_current_mode).value.should == "permissive" |
2401 | - end |
2402 | - |
2403 | - it "should return the SELinux mode from the configuration file" do |
2404 | - Facter.fact(:selinux).stubs(:value).returns("true") |
2405 | - |
2406 | - sample_output_file = File.dirname(__FILE__) + '/data/selinux_sestatus' |
2407 | - selinux_sestatus = File.read(sample_output_file) |
2408 | - |
2409 | - Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/sestatus').returns(selinux_sestatus) |
2410 | - |
2411 | - Facter.fact(:selinux_config_mode).value.should == "permissive" |
2412 | - end |
2413 | - |
2414 | - it "should return the SELinux configuration file policy" do |
2415 | - Facter.fact(:selinux).stubs(:value).returns("true") |
2416 | - |
2417 | - sample_output_file = File.dirname(__FILE__) + '/data/selinux_sestatus' |
2418 | - selinux_sestatus = File.read(sample_output_file) |
2419 | - |
2420 | - Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/sestatus').returns(selinux_sestatus) |
2421 | - |
2422 | - Facter.fact(:selinux_config_policy).value.should == "targeted" |
2423 | - end |
2424 | - |
2425 | - it "should ensure legacy selinux_mode facts returns same value as selinux_config_policy fact" do |
2426 | - Facter.fact(:selinux).stubs(:value).returns("true") |
2427 | - |
2428 | - Facter.fact(:selinux_config_policy).stubs(:value).returns("targeted") |
2429 | - |
2430 | - Facter.fact(:selinux_mode).value.should == "targeted" |
2431 | - end |
2432 | + after do |
2433 | + Facter.clear |
2434 | + end |
2435 | + |
2436 | + it "should return true if SELinux enabled" do |
2437 | + Facter.fact(:kernel).stubs(:value).returns("Linux") |
2438 | + |
2439 | + FileTest.stubs(:exists?).returns false |
2440 | + File.stubs(:read).with("/proc/self/attr/current").returns("notkernel") |
2441 | + |
2442 | + FileTest.expects(:exists?).with("/selinux/enforce").returns true |
2443 | + FileTest.expects(:exists?).with("/proc/self/attr/current").returns true |
2444 | + File.expects(:read).with("/proc/self/attr/current").returns("kernel") |
2445 | + |
2446 | + Facter.fact(:selinux).value.should == "true" |
2447 | + end |
2448 | + |
2449 | + it "should return true if SELinux policy enabled" do |
2450 | + Facter.fact(:selinux).stubs(:value).returns("true") |
2451 | + |
2452 | + FileTest.stubs(:exists?).returns false |
2453 | + File.stubs(:read).with("/selinux/enforce").returns("0") |
2454 | + |
2455 | + FileTest.expects(:exists?).with("/selinux/enforce").returns true |
2456 | + File.expects(:read).with("/selinux/enforce").returns("1") |
2457 | + |
2458 | + Facter.fact(:selinux_enforced).value.should == "true" |
2459 | + end |
2460 | + |
2461 | + it "should return an SELinux policy version" do |
2462 | + Facter.fact(:selinux).stubs(:value).returns("true") |
2463 | + FileTest.stubs(:exists?).with("/proc/self/mountinfo").returns false |
2464 | + |
2465 | + File.stubs(:read).with("/selinux/policyvers").returns("") |
2466 | + |
2467 | + File.expects(:read).with("/selinux/policyvers").returns("1") |
2468 | + |
2469 | + Facter.fact(:selinux_policyversion).value.should == "1" |
2470 | + end |
2471 | + |
2472 | + it "should return the SELinux current mode" do |
2473 | + Facter.fact(:selinux).stubs(:value).returns("true") |
2474 | + |
2475 | + sample_output_file = File.dirname(__FILE__) + '/data/selinux_sestatus' |
2476 | + selinux_sestatus = File.read(sample_output_file) |
2477 | + |
2478 | + Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/sestatus').returns(selinux_sestatus) |
2479 | + |
2480 | + Facter.fact(:selinux_current_mode).value.should == "permissive" |
2481 | + end |
2482 | + |
2483 | + it "should return the SELinux mode from the configuration file" do |
2484 | + Facter.fact(:selinux).stubs(:value).returns("true") |
2485 | + |
2486 | + sample_output_file = File.dirname(__FILE__) + '/data/selinux_sestatus' |
2487 | + selinux_sestatus = File.read(sample_output_file) |
2488 | + |
2489 | + Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/sestatus').returns(selinux_sestatus) |
2490 | + |
2491 | + Facter.fact(:selinux_config_mode).value.should == "permissive" |
2492 | + end |
2493 | + |
2494 | + it "should return the SELinux configuration file policy" do |
2495 | + Facter.fact(:selinux).stubs(:value).returns("true") |
2496 | + |
2497 | + sample_output_file = File.dirname(__FILE__) + '/data/selinux_sestatus' |
2498 | + selinux_sestatus = File.read(sample_output_file) |
2499 | + |
2500 | + Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/sestatus').returns(selinux_sestatus) |
2501 | + |
2502 | + Facter.fact(:selinux_config_policy).value.should == "targeted" |
2503 | + end |
2504 | + |
2505 | + it "should ensure legacy selinux_mode facts returns same value as selinux_config_policy fact" do |
2506 | + Facter.fact(:selinux).stubs(:value).returns("true") |
2507 | + |
2508 | + Facter.fact(:selinux_config_policy).stubs(:value).returns("targeted") |
2509 | + |
2510 | + Facter.fact(:selinux_mode).value.should == "targeted" |
2511 | + end |
2512 | end |
2513 | |
2514 | === modified file 'spec/unit/util/collection_spec.rb' |
2515 | --- spec/unit/util/collection_spec.rb 2011-03-18 12:06:08 +0000 |
2516 | +++ spec/unit/util/collection_spec.rb 2012-01-27 20:04:26 +0000 |
2517 | @@ -5,251 +5,251 @@ |
2518 | require 'facter/util/collection' |
2519 | |
2520 | describe Facter::Util::Collection do |
2521 | - it "should have a method for adding facts" do |
2522 | - Facter::Util::Collection.new.should respond_to(:add) |
2523 | - end |
2524 | - |
2525 | - it "should have a method for returning a loader" do |
2526 | - Facter::Util::Collection.new.should respond_to(:loader) |
2527 | - end |
2528 | - |
2529 | - it "should use an instance of the Loader class as its loader" do |
2530 | - Facter::Util::Collection.new.loader.should be_instance_of(Facter::Util::Loader) |
2531 | - end |
2532 | - |
2533 | - it "should cache its loader" do |
2534 | - coll = Facter::Util::Collection.new |
2535 | - coll.loader.should equal(coll.loader) |
2536 | - end |
2537 | - |
2538 | - it "should have a method for loading all facts" do |
2539 | - Facter::Util::Collection.new.should respond_to(:load_all) |
2540 | - end |
2541 | - |
2542 | - it "should delegate its load_all method to its loader" do |
2543 | - coll = Facter::Util::Collection.new |
2544 | - coll.loader.expects(:load_all) |
2545 | - coll.load_all |
2546 | - end |
2547 | - |
2548 | - describe "when adding facts" do |
2549 | - before do |
2550 | - @coll = Facter::Util::Collection.new |
2551 | - end |
2552 | - |
2553 | - it "should create a new fact if no fact with the same name already exists" do |
2554 | - fact = mock 'fact' |
2555 | - Facter::Util::Fact.expects(:new).with { |name, *args| name == :myname }.returns fact |
2556 | - |
2557 | - @coll.add(:myname) |
2558 | - end |
2559 | - |
2560 | - it "should accept options" do |
2561 | - @coll.add(:myname, :ldapname => "whatever") { } |
2562 | - end |
2563 | - |
2564 | - it "should set any appropriate options on the fact instances" do |
2565 | - # Use a real fact instance, because we're using respond_to? |
2566 | - fact = Facter::Util::Fact.new(:myname) |
2567 | - fact.expects(:ldapname=).with("testing") |
2568 | - Facter::Util::Fact.expects(:new).with(:myname).returns fact |
2569 | - |
2570 | - @coll.add(:myname, :ldapname => "testing") |
2571 | - end |
2572 | - |
2573 | - it "should set appropriate options on the resolution instance" do |
2574 | - fact = Facter::Util::Fact.new(:myname) |
2575 | - Facter::Util::Fact.expects(:new).with(:myname).returns fact |
2576 | - |
2577 | - resolve = Facter::Util::Resolution.new(:myname) {} |
2578 | - fact.expects(:add).returns resolve |
2579 | - |
2580 | - @coll.add(:myname, :timeout => "myval") {} |
2581 | - end |
2582 | - |
2583 | - it "should not pass fact-specific options to resolutions" do |
2584 | - fact = Facter::Util::Fact.new(:myname) |
2585 | - Facter::Util::Fact.expects(:new).with(:myname).returns fact |
2586 | - |
2587 | - resolve = Facter::Util::Resolution.new(:myname) {} |
2588 | - fact.expects(:add).returns resolve |
2589 | - |
2590 | - fact.expects(:ldapname=).with("foo") |
2591 | - resolve.expects(:timeout=).with("myval") |
2592 | - |
2593 | - @coll.add(:myname, :timeout => "myval", :ldapname => "foo") {} |
2594 | - end |
2595 | - |
2596 | - it "should fail if invalid options are provided" do |
2597 | - lambda { @coll.add(:myname, :foo => :bar) }.should raise_error(ArgumentError) |
2598 | - end |
2599 | - |
2600 | - describe "and a block is provided" do |
2601 | - it "should use the block to add a resolution to the fact" do |
2602 | - fact = mock 'fact' |
2603 | - Facter::Util::Fact.expects(:new).returns fact |
2604 | - |
2605 | - fact.expects(:add) |
2606 | - |
2607 | - @coll.add(:myname) {} |
2608 | - end |
2609 | - end |
2610 | - end |
2611 | - |
2612 | - it "should have a method for retrieving facts by name" do |
2613 | - Facter::Util::Collection.new.should respond_to(:fact) |
2614 | - end |
2615 | - |
2616 | - describe "when retrieving facts" do |
2617 | - before do |
2618 | - @coll = Facter::Util::Collection.new |
2619 | - |
2620 | - @fact = @coll.add("YayNess") |
2621 | - end |
2622 | - |
2623 | - it "should return the fact instance specified by the name" do |
2624 | - @coll.fact("YayNess").should equal(@fact) |
2625 | - end |
2626 | - |
2627 | - it "should be case-insensitive" do |
2628 | - @coll.fact("yayness").should equal(@fact) |
2629 | - end |
2630 | - |
2631 | - it "should treat strings and symbols equivalently" do |
2632 | - @coll.fact(:yayness).should equal(@fact) |
2633 | - end |
2634 | - |
2635 | - it "should use its loader to try to load the fact if no fact can be found" do |
2636 | - @coll.loader.expects(:load).with(:testing) |
2637 | - @coll.fact("testing") |
2638 | - end |
2639 | - |
2640 | - it "should return nil if it cannot find or load the fact" do |
2641 | - @coll.loader.expects(:load).with(:testing) |
2642 | - @coll.fact("testing").should be_nil |
2643 | - end |
2644 | - end |
2645 | - |
2646 | - it "should have a method for returning a fact's value" do |
2647 | - Facter::Util::Collection.new.should respond_to(:value) |
2648 | - end |
2649 | - |
2650 | - describe "when returning a fact's value" do |
2651 | - before do |
2652 | - @coll = Facter::Util::Collection.new |
2653 | - @fact = @coll.add("YayNess") |
2654 | - |
2655 | - @fact.stubs(:value).returns "result" |
2656 | - end |
2657 | - |
2658 | - it "should use the 'fact' method to retrieve the fact" do |
2659 | - @coll.expects(:fact).with(:yayness).returns @fact |
2660 | - @coll.value(:yayness) |
2661 | - end |
2662 | - |
2663 | - it "should return the result of calling :value on the fact" do |
2664 | - @fact.expects(:value).returns "result" |
2665 | - |
2666 | - @coll.value("YayNess").should == "result" |
2667 | - end |
2668 | - |
2669 | - it "should be case-insensitive" do |
2670 | - @coll.value("yayness").should_not be_nil |
2671 | - end |
2672 | - |
2673 | - it "should treat strings and symbols equivalently" do |
2674 | - @coll.value(:yayness).should_not be_nil |
2675 | - end |
2676 | - end |
2677 | - |
2678 | - it "should return the fact's value when the array index method is used" do |
2679 | - @coll = Facter::Util::Collection.new |
2680 | - @coll.expects(:value).with("myfact").returns "foo" |
2681 | - @coll["myfact"].should == "foo" |
2682 | - end |
2683 | - |
2684 | - it "should have a method for flushing all facts" do |
2685 | - @coll = Facter::Util::Collection.new |
2686 | - @fact = @coll.add("YayNess") |
2687 | - |
2688 | - @fact.expects(:flush) |
2689 | - |
2690 | - @coll.flush |
2691 | - end |
2692 | - |
2693 | - it "should have a method that returns all fact names" do |
2694 | - @coll = Facter::Util::Collection.new |
2695 | - @coll.add(:one) |
2696 | - @coll.add(:two) |
2697 | - |
2698 | - @coll.list.sort { |a,b| a.to_s <=> b.to_s }.should == [:one, :two] |
2699 | - end |
2700 | - |
2701 | - it "should have a method for returning a hash of fact values" do |
2702 | - Facter::Util::Collection.new.should respond_to(:to_hash) |
2703 | - end |
2704 | - |
2705 | - describe "when returning a hash of values" do |
2706 | - before do |
2707 | - @coll = Facter::Util::Collection.new |
2708 | - @fact = @coll.add(:one) |
2709 | - @fact.stubs(:value).returns "me" |
2710 | - end |
2711 | - |
2712 | - it "should return a hash of fact names and values with the fact names as strings" do |
2713 | - @coll.to_hash.should == {"one" => "me"} |
2714 | - end |
2715 | - |
2716 | - it "should not include facts that did not return a value" do |
2717 | - f = @coll.add(:two) |
2718 | - f.stubs(:value).returns nil |
2719 | - @coll.to_hash.should_not be_include(:two) |
2720 | - end |
2721 | - end |
2722 | - |
2723 | - it "should have a method for iterating over all facts" do |
2724 | - Facter::Util::Collection.new.should respond_to(:each) |
2725 | - end |
2726 | - |
2727 | - it "should include Enumerable" do |
2728 | - Facter::Util::Collection.ancestors.should be_include(Enumerable) |
2729 | - end |
2730 | - |
2731 | - describe "when iterating over facts" do |
2732 | - before do |
2733 | - @coll = Facter::Util::Collection.new |
2734 | - @one = @coll.add(:one) |
2735 | - @two = @coll.add(:two) |
2736 | - end |
2737 | - |
2738 | - it "should yield each fact name and the fact value" do |
2739 | - @one.stubs(:value).returns "ONE" |
2740 | - @two.stubs(:value).returns "TWO" |
2741 | - facts = {} |
2742 | - @coll.each do |fact, value| |
2743 | - facts[fact] = value |
2744 | - end |
2745 | - facts.should == {"one" => "ONE", "two" => "TWO"} |
2746 | - end |
2747 | - |
2748 | - it "should convert the fact name to a string" do |
2749 | - @one.stubs(:value).returns "ONE" |
2750 | - @two.stubs(:value).returns "TWO" |
2751 | - facts = {} |
2752 | - @coll.each do |fact, value| |
2753 | - fact.should be_instance_of(String) |
2754 | - end |
2755 | - end |
2756 | - |
2757 | - it "should only yield facts that have values" do |
2758 | - @one.stubs(:value).returns "ONE" |
2759 | - @two.stubs(:value).returns nil |
2760 | - facts = {} |
2761 | - @coll.each do |fact, value| |
2762 | - facts[fact] = value |
2763 | - end |
2764 | - |
2765 | - facts.should_not be_include("two") |
2766 | - end |
2767 | - end |
2768 | + it "should have a method for adding facts" do |
2769 | + Facter::Util::Collection.new.should respond_to(:add) |
2770 | + end |
2771 | + |
2772 | + it "should have a method for returning a loader" do |
2773 | + Facter::Util::Collection.new.should respond_to(:loader) |
2774 | + end |
2775 | + |
2776 | + it "should use an instance of the Loader class as its loader" do |
2777 | + Facter::Util::Collection.new.loader.should be_instance_of(Facter::Util::Loader) |
2778 | + end |
2779 | + |
2780 | + it "should cache its loader" do |
2781 | + coll = Facter::Util::Collection.new |
2782 | + coll.loader.should equal(coll.loader) |
2783 | + end |
2784 | + |
2785 | + it "should have a method for loading all facts" do |
2786 | + Facter::Util::Collection.new.should respond_to(:load_all) |
2787 | + end |
2788 | + |
2789 | + it "should delegate its load_all method to its loader" do |
2790 | + coll = Facter::Util::Collection.new |
2791 | + coll.loader.expects(:load_all) |
2792 | + coll.load_all |
2793 | + end |
2794 | + |
2795 | + describe "when adding facts" do |
2796 | + before do |
2797 | + @coll = Facter::Util::Collection.new |
2798 | + end |
2799 | + |
2800 | + it "should create a new fact if no fact with the same name already exists" do |
2801 | + fact = mock 'fact' |
2802 | + Facter::Util::Fact.expects(:new).with { |name, *args| name == :myname }.returns fact |
2803 | + |
2804 | + @coll.add(:myname) |
2805 | + end |
2806 | + |
2807 | + it "should accept options" do |
2808 | + @coll.add(:myname, :ldapname => "whatever") { } |
2809 | + end |
2810 | + |
2811 | + it "should set any appropriate options on the fact instances" do |
2812 | + # Use a real fact instance, because we're using respond_to? |
2813 | + fact = Facter::Util::Fact.new(:myname) |
2814 | + fact.expects(:ldapname=).with("testing") |
2815 | + Facter::Util::Fact.expects(:new).with(:myname).returns fact |
2816 | + |
2817 | + @coll.add(:myname, :ldapname => "testing") |
2818 | + end |
2819 | + |
2820 | + it "should set appropriate options on the resolution instance" do |
2821 | + fact = Facter::Util::Fact.new(:myname) |
2822 | + Facter::Util::Fact.expects(:new).with(:myname).returns fact |
2823 | + |
2824 | + resolve = Facter::Util::Resolution.new(:myname) {} |
2825 | + fact.expects(:add).returns resolve |
2826 | + |
2827 | + @coll.add(:myname, :timeout => "myval") {} |
2828 | + end |
2829 | + |
2830 | + it "should not pass fact-specific options to resolutions" do |
2831 | + fact = Facter::Util::Fact.new(:myname) |
2832 | + Facter::Util::Fact.expects(:new).with(:myname).returns fact |
2833 | + |
2834 | + resolve = Facter::Util::Resolution.new(:myname) {} |
2835 | + fact.expects(:add).returns resolve |
2836 | + |
2837 | + fact.expects(:ldapname=).with("foo") |
2838 | + resolve.expects(:timeout=).with("myval") |
2839 | + |
2840 | + @coll.add(:myname, :timeout => "myval", :ldapname => "foo") {} |
2841 | + end |
2842 | + |
2843 | + it "should fail if invalid options are provided" do |
2844 | + lambda { @coll.add(:myname, :foo => :bar) }.should raise_error(ArgumentError) |
2845 | + end |
2846 | + |
2847 | + describe "and a block is provided" do |
2848 | + it "should use the block to add a resolution to the fact" do |
2849 | + fact = mock 'fact' |
2850 | + Facter::Util::Fact.expects(:new).returns fact |
2851 | + |
2852 | + fact.expects(:add) |
2853 | + |
2854 | + @coll.add(:myname) {} |
2855 | + end |
2856 | + end |
2857 | + end |
2858 | + |
2859 | + it "should have a method for retrieving facts by name" do |
2860 | + Facter::Util::Collection.new.should respond_to(:fact) |
2861 | + end |
2862 | + |
2863 | + describe "when retrieving facts" do |
2864 | + before do |
2865 | + @coll = Facter::Util::Collection.new |
2866 | + |
2867 | + @fact = @coll.add("YayNess") |
2868 | + end |
2869 | + |
2870 | + it "should return the fact instance specified by the name" do |
2871 | + @coll.fact("YayNess").should equal(@fact) |
2872 | + end |
2873 | + |
2874 | + it "should be case-insensitive" do |
2875 | + @coll.fact("yayness").should equal(@fact) |
2876 | + end |
2877 | + |
2878 | + it "should treat strings and symbols equivalently" do |
2879 | + @coll.fact(:yayness).should equal(@fact) |
2880 | + end |
2881 | + |
2882 | + it "should use its loader to try to load the fact if no fact can be found" do |
2883 | + @coll.loader.expects(:load).with(:testing) |
2884 | + @coll.fact("testing") |
2885 | + end |
2886 | + |
2887 | + it "should return nil if it cannot find or load the fact" do |
2888 | + @coll.loader.expects(:load).with(:testing) |
2889 | + @coll.fact("testing").should be_nil |
2890 | + end |
2891 | + end |
2892 | + |
2893 | + it "should have a method for returning a fact's value" do |
2894 | + Facter::Util::Collection.new.should respond_to(:value) |
2895 | + end |
2896 | + |
2897 | + describe "when returning a fact's value" do |
2898 | + before do |
2899 | + @coll = Facter::Util::Collection.new |
2900 | + @fact = @coll.add("YayNess") |
2901 | + |
2902 | + @fact.stubs(:value).returns "result" |
2903 | + end |
2904 | + |
2905 | + it "should use the 'fact' method to retrieve the fact" do |
2906 | + @coll.expects(:fact).with(:yayness).returns @fact |
2907 | + @coll.value(:yayness) |
2908 | + end |
2909 | + |
2910 | + it "should return the result of calling :value on the fact" do |
2911 | + @fact.expects(:value).returns "result" |
2912 | + |
2913 | + @coll.value("YayNess").should == "result" |
2914 | + end |
2915 | + |
2916 | + it "should be case-insensitive" do |
2917 | + @coll.value("yayness").should_not be_nil |
2918 | + end |
2919 | + |
2920 | + it "should treat strings and symbols equivalently" do |
2921 | + @coll.value(:yayness).should_not be_nil |
2922 | + end |
2923 | + end |
2924 | + |
2925 | + it "should return the fact's value when the array index method is used" do |
2926 | + @coll = Facter::Util::Collection.new |
2927 | + @coll.expects(:value).with("myfact").returns "foo" |
2928 | + @coll["myfact"].should == "foo" |
2929 | + end |
2930 | + |
2931 | + it "should have a method for flushing all facts" do |
2932 | + @coll = Facter::Util::Collection.new |
2933 | + @fact = @coll.add("YayNess") |
2934 | + |
2935 | + @fact.expects(:flush) |
2936 | + |
2937 | + @coll.flush |
2938 | + end |
2939 | + |
2940 | + it "should have a method that returns all fact names" do |
2941 | + @coll = Facter::Util::Collection.new |
2942 | + @coll.add(:one) |
2943 | + @coll.add(:two) |
2944 | + |
2945 | + @coll.list.sort { |a,b| a.to_s <=> b.to_s }.should == [:one, :two] |
2946 | + end |
2947 | + |
2948 | + it "should have a method for returning a hash of fact values" do |
2949 | + Facter::Util::Collection.new.should respond_to(:to_hash) |
2950 | + end |
2951 | + |
2952 | + describe "when returning a hash of values" do |
2953 | + before do |
2954 | + @coll = Facter::Util::Collection.new |
2955 | + @fact = @coll.add(:one) |
2956 | + @fact.stubs(:value).returns "me" |
2957 | + end |
2958 | + |
2959 | + it "should return a hash of fact names and values with the fact names as strings" do |
2960 | + @coll.to_hash.should == {"one" => "me"} |
2961 | + end |
2962 | + |
2963 | + it "should not include facts that did not return a value" do |
2964 | + f = @coll.add(:two) |
2965 | + f.stubs(:value).returns nil |
2966 | + @coll.to_hash.should_not be_include(:two) |
2967 | + end |
2968 | + end |
2969 | + |
2970 | + it "should have a method for iterating over all facts" do |
2971 | + Facter::Util::Collection.new.should respond_to(:each) |
2972 | + end |
2973 | + |
2974 | + it "should include Enumerable" do |
2975 | + Facter::Util::Collection.ancestors.should be_include(Enumerable) |
2976 | + end |
2977 | + |
2978 | + describe "when iterating over facts" do |
2979 | + before do |
2980 | + @coll = Facter::Util::Collection.new |
2981 | + @one = @coll.add(:one) |
2982 | + @two = @coll.add(:two) |
2983 | + end |
2984 | + |
2985 | + it "should yield each fact name and the fact value" do |
2986 | + @one.stubs(:value).returns "ONE" |
2987 | + @two.stubs(:value).returns "TWO" |
2988 | + facts = {} |
2989 | + @coll.each do |fact, value| |
2990 | + facts[fact] = value |
2991 | + end |
2992 | + facts.should == {"one" => "ONE", "two" => "TWO"} |
2993 | + end |
2994 | + |
2995 | + it "should convert the fact name to a string" do |
2996 | + @one.stubs(:value).returns "ONE" |
2997 | + @two.stubs(:value).returns "TWO" |
2998 | + facts = {} |
2999 | + @coll.each do |fact, value| |
3000 | + fact.should be_instance_of(String) |
3001 | + end |
3002 | + end |
3003 | + |
3004 | + it "should only yield facts that have values" do |
3005 | + @one.stubs(:value).returns "ONE" |
3006 | + @two.stubs(:value).returns nil |
3007 | + facts = {} |
3008 | + @coll.each do |fact, value| |
3009 | + facts[fact] = value |
3010 | + end |
3011 | + |
3012 | + facts.should_not be_include("two") |
3013 | + end |
3014 | + end |
3015 | end |
3016 | |
3017 | === modified file 'spec/unit/util/confine_spec.rb' |
3018 | --- spec/unit/util/confine_spec.rb 2011-03-18 12:06:08 +0000 |
3019 | +++ spec/unit/util/confine_spec.rb 2012-01-27 20:04:26 +0000 |
3020 | @@ -8,133 +8,133 @@ |
3021 | include Facter::Util::Values |
3022 | |
3023 | describe Facter::Util::Confine do |
3024 | - it "should require a fact name" do |
3025 | - Facter::Util::Confine.new("yay", true).fact.should == "yay" |
3026 | - end |
3027 | - |
3028 | - it "should accept a value specified individually" do |
3029 | - Facter::Util::Confine.new("yay", "test").values.should == ["test"] |
3030 | - end |
3031 | - |
3032 | - it "should accept multiple values specified at once" do |
3033 | - Facter::Util::Confine.new("yay", "test", "other").values.should == ["test", "other"] |
3034 | - end |
3035 | - |
3036 | - it "should fail if no fact name is provided" do |
3037 | - lambda { Facter::Util::Confine.new(nil, :test) }.should raise_error(ArgumentError) |
3038 | - end |
3039 | - |
3040 | - it "should fail if no values were provided" do |
3041 | - lambda { Facter::Util::Confine.new("yay") }.should raise_error(ArgumentError) |
3042 | - end |
3043 | - |
3044 | - it "should have a method for testing whether it matches" do |
3045 | - Facter::Util::Confine.new("yay", :test).should respond_to(:true?) |
3046 | - end |
3047 | - |
3048 | - describe "when evaluating" do |
3049 | - before do |
3050 | - @confine = Facter::Util::Confine.new("yay", "one", "two", "Four", :xy, true, 1, [3,4]) |
3051 | - @fact = mock 'fact' |
3052 | - Facter.stubs(:[]).returns @fact |
3053 | - end |
3054 | - |
3055 | - it "should return false if the fact does not exist" do |
3056 | - Facter.expects(:[]).with("yay").returns nil |
3057 | - |
3058 | - @confine.true?.should be_false |
3059 | - end |
3060 | - |
3061 | - it "should use the returned fact to get the value" do |
3062 | - Facter.expects(:[]).with("yay").returns @fact |
3063 | - |
3064 | - @fact.expects(:value).returns nil |
3065 | - |
3066 | - @confine.true? |
3067 | - end |
3068 | - |
3069 | - it "should return false if the fact has no value" do |
3070 | - @fact.stubs(:value).returns nil |
3071 | - |
3072 | - @confine.true?.should be_false |
3073 | - end |
3074 | - |
3075 | - it "should return true if any of the provided values matches the fact's value" do |
3076 | - @fact.stubs(:value).returns "two" |
3077 | - |
3078 | - @confine.true?.should be_true |
3079 | - end |
3080 | - |
3081 | - it "should return true if any of the provided symbol values matches the fact's value" do |
3082 | - @fact.stubs(:value).returns :xy |
3083 | - |
3084 | - @confine.true?.should be_true |
3085 | - end |
3086 | - |
3087 | - it "should return true if any of the provided integer values matches the fact's value" do |
3088 | - @fact.stubs(:value).returns 1 |
3089 | - |
3090 | - @confine.true?.should be_true |
3091 | - end |
3092 | - |
3093 | - it "should return true if any of the provided boolan values matches the fact's value" do |
3094 | - @fact.stubs(:value).returns true |
3095 | - |
3096 | - @confine.true?.should be_true |
3097 | - end |
3098 | - |
3099 | - it "should return true if any of the provided array values matches the fact's value" do |
3100 | - @fact.stubs(:value).returns [3,4] |
3101 | - |
3102 | - @confine.true?.should be_true |
3103 | - end |
3104 | - |
3105 | - it "should return true if any of the provided symbol values matches the fact's string value" do |
3106 | - @fact.stubs(:value).returns :one |
3107 | - |
3108 | - @confine.true?.should be_true |
3109 | - end |
3110 | - |
3111 | - it "should return true if any of the provided string values matches case-insensitive the fact's value" do |
3112 | - @fact.stubs(:value).returns "four" |
3113 | - |
3114 | - @confine.true?.should be_true |
3115 | - end |
3116 | - |
3117 | - it "should return true if any of the provided symbol values matches case-insensitive the fact's string value" do |
3118 | - @fact.stubs(:value).returns :four |
3119 | - |
3120 | - @confine.true?.should be_true |
3121 | - end |
3122 | - |
3123 | - it "should return true if any of the provided symbol values matches the fact's string value" do |
3124 | - @fact.stubs(:value).returns :Xy |
3125 | - |
3126 | - @confine.true?.should be_true |
3127 | - end |
3128 | - |
3129 | - it "should return false if none of the provided values matches the fact's value" do |
3130 | - @fact.stubs(:value).returns "three" |
3131 | - |
3132 | - @confine.true?.should be_false |
3133 | - end |
3134 | - |
3135 | - it "should return false if none of the provided integer values matches the fact's value" do |
3136 | - @fact.stubs(:value).returns 2 |
3137 | - |
3138 | - @confine.true?.should be_false |
3139 | - end |
3140 | - |
3141 | - it "should return false if none of the provided boolan values matches the fact's value" do |
3142 | - @fact.stubs(:value).returns false |
3143 | - |
3144 | - @confine.true?.should be_false |
3145 | - end |
3146 | - |
3147 | - it "should return false if none of the provided array values matches the fact's value" do |
3148 | - @fact.stubs(:value).returns [1,2] |
3149 | - |
3150 | - @confine.true?.should be_false |
3151 | - end |
3152 | - end |
3153 | + it "should require a fact name" do |
3154 | + Facter::Util::Confine.new("yay", true).fact.should == "yay" |
3155 | + end |
3156 | + |
3157 | + it "should accept a value specified individually" do |
3158 | + Facter::Util::Confine.new("yay", "test").values.should == ["test"] |
3159 | + end |
3160 | + |
3161 | + it "should accept multiple values specified at once" do |
3162 | + Facter::Util::Confine.new("yay", "test", "other").values.should == ["test", "other"] |
3163 | + end |
3164 | + |
3165 | + it "should fail if no fact name is provided" do |
3166 | + lambda { Facter::Util::Confine.new(nil, :test) }.should raise_error(ArgumentError) |
3167 | + end |
3168 | + |
3169 | + it "should fail if no values were provided" do |
3170 | + lambda { Facter::Util::Confine.new("yay") }.should raise_error(ArgumentError) |
3171 | + end |
3172 | + |
3173 | + it "should have a method for testing whether it matches" do |
3174 | + Facter::Util::Confine.new("yay", :test).should respond_to(:true?) |
3175 | + end |
3176 | + |
3177 | + describe "when evaluating" do |
3178 | + before do |
3179 | + @confine = Facter::Util::Confine.new("yay", "one", "two", "Four", :xy, true, 1, [3,4]) |
3180 | + @fact = mock 'fact' |
3181 | + Facter.stubs(:[]).returns @fact |
3182 | + end |
3183 | + |
3184 | + it "should return false if the fact does not exist" do |
3185 | + Facter.expects(:[]).with("yay").returns nil |
3186 | + |
3187 | + @confine.true?.should be_false |
3188 | + end |
3189 | + |
3190 | + it "should use the returned fact to get the value" do |
3191 | + Facter.expects(:[]).with("yay").returns @fact |
3192 | + |
3193 | + @fact.expects(:value).returns nil |
3194 | + |
3195 | + @confine.true? |
3196 | + end |
3197 | + |
3198 | + it "should return false if the fact has no value" do |
3199 | + @fact.stubs(:value).returns nil |
3200 | + |
3201 | + @confine.true?.should be_false |
3202 | + end |
3203 | + |
3204 | + it "should return true if any of the provided values matches the fact's value" do |
3205 | + @fact.stubs(:value).returns "two" |
3206 | + |
3207 | + @confine.true?.should be_true |
3208 | + end |
3209 | + |
3210 | + it "should return true if any of the provided symbol values matches the fact's value" do |
3211 | + @fact.stubs(:value).returns :xy |
3212 | + |
3213 | + @confine.true?.should be_true |
3214 | + end |
3215 | + |
3216 | + it "should return true if any of the provided integer values matches the fact's value" do |
3217 | + @fact.stubs(:value).returns 1 |
3218 | + |
3219 | + @confine.true?.should be_true |
3220 | + end |
3221 | + |
3222 | + it "should return true if any of the provided boolan values matches the fact's value" do |
3223 | + @fact.stubs(:value).returns true |
3224 | + |
3225 | + @confine.true?.should be_true |
3226 | + end |
3227 | + |
3228 | + it "should return true if any of the provided array values matches the fact's value" do |
3229 | + @fact.stubs(:value).returns [3,4] |
3230 | + |
3231 | + @confine.true?.should be_true |
3232 | + end |
3233 | + |
3234 | + it "should return true if any of the provided symbol values matches the fact's string value" do |
3235 | + @fact.stubs(:value).returns :one |
3236 | + |
3237 | + @confine.true?.should be_true |
3238 | + end |
3239 | + |
3240 | + it "should return true if any of the provided string values matches case-insensitive the fact's value" do |
3241 | + @fact.stubs(:value).returns "four" |
3242 | + |
3243 | + @confine.true?.should be_true |
3244 | + end |
3245 | + |
3246 | + it "should return true if any of the provided symbol values matches case-insensitive the fact's string value" do |
3247 | + @fact.stubs(:value).returns :four |
3248 | + |
3249 | + @confine.true?.should be_true |
3250 | + end |
3251 | + |
3252 | + it "should return true if any of the provided symbol values matches the fact's string value" do |
3253 | + @fact.stubs(:value).returns :Xy |
3254 | + |
3255 | + @confine.true?.should be_true |
3256 | + end |
3257 | + |
3258 | + it "should return false if none of the provided values matches the fact's value" do |
3259 | + @fact.stubs(:value).returns "three" |
3260 | + |
3261 | + @confine.true?.should be_false |
3262 | + end |
3263 | + |
3264 | + it "should return false if none of the provided integer values matches the fact's value" do |
3265 | + @fact.stubs(:value).returns 2 |
3266 | + |
3267 | + @confine.true?.should be_false |
3268 | + end |
3269 | + |
3270 | + it "should return false if none of the provided boolan values matches the fact's value" do |
3271 | + @fact.stubs(:value).returns false |
3272 | + |
3273 | + @confine.true?.should be_false |
3274 | + end |
3275 | + |
3276 | + it "should return false if none of the provided array values matches the fact's value" do |
3277 | + @fact.stubs(:value).returns [1,2] |
3278 | + |
3279 | + @confine.true?.should be_false |
3280 | + end |
3281 | + end |
3282 | end |
3283 | |
3284 | === modified file 'spec/unit/util/fact_spec.rb' |
3285 | --- spec/unit/util/fact_spec.rb 2011-06-24 10:04:12 +0000 |
3286 | +++ spec/unit/util/fact_spec.rb 2012-01-27 20:04:26 +0000 |
3287 | @@ -5,125 +5,125 @@ |
3288 | require 'facter/util/fact' |
3289 | |
3290 | describe Facter::Util::Fact do |
3291 | - it "should require a name" do |
3292 | - lambda { Facter::Util::Fact.new }.should raise_error(ArgumentError) |
3293 | - end |
3294 | - |
3295 | - it "should always downcase the name and convert it to a symbol" do |
3296 | - Facter::Util::Fact.new("YayNess").name.should == :yayness |
3297 | - end |
3298 | - |
3299 | - it "should default to its name converted to a string as its ldapname" do |
3300 | - Facter::Util::Fact.new("YayNess").ldapname.should == "yayness" |
3301 | - end |
3302 | - |
3303 | - it "should allow specifying the ldap name at initialization" do |
3304 | - Facter::Util::Fact.new("YayNess", :ldapname => "fooness").ldapname.should == "fooness" |
3305 | - end |
3306 | - |
3307 | - it "should fail if an unknown option is provided" do |
3308 | - lambda { Facter::Util::Fact.new('yay', :foo => :bar) }.should raise_error(ArgumentError) |
3309 | - end |
3310 | - |
3311 | - it "should have a method for adding resolution mechanisms" do |
3312 | - Facter::Util::Fact.new("yay").should respond_to(:add) |
3313 | - end |
3314 | - |
3315 | - describe "when adding resolution mechanisms" do |
3316 | - before do |
3317 | - @fact = Facter::Util::Fact.new("yay") |
3318 | - |
3319 | - @resolution = mock 'resolution' |
3320 | - @resolution.stub_everything |
3321 | - |
3322 | - end |
3323 | - |
3324 | - it "should fail if no block is given" do |
3325 | - lambda { @fact.add }.should raise_error(ArgumentError) |
3326 | - end |
3327 | - |
3328 | - it "should create a new resolution instance" do |
3329 | - Facter::Util::Resolution.expects(:new).returns @resolution |
3330 | - |
3331 | - @fact.add { } |
3332 | - end |
3333 | - |
3334 | - it "should instance_eval the passed block on the new resolution" do |
3335 | - @resolution.expects(:instance_eval) |
3336 | - |
3337 | - Facter::Util::Resolution.stubs(:new).returns @resolution |
3338 | - |
3339 | - @fact.add { } |
3340 | - end |
3341 | - |
3342 | - it "should re-sort the resolutions by weight, so the most restricted resolutions are first" do |
3343 | - r1 = stub 'r1', :weight => 1 |
3344 | - r2 = stub 'r2', :weight => 2 |
3345 | - r3 = stub 'r3', :weight => 0 |
3346 | - Facter::Util::Resolution.expects(:new).times(3).returns(r1).returns(r2).returns(r3) |
3347 | - @fact.add { } |
3348 | - @fact.add { } |
3349 | - @fact.add { } |
3350 | - |
3351 | - @fact.instance_variable_get("@resolves").should == [r2, r1, r3] |
3352 | - end |
3353 | - end |
3354 | - |
3355 | - it "should be able to return a value" do |
3356 | - Facter::Util::Fact.new("yay").should respond_to(:value) |
3357 | - end |
3358 | - |
3359 | - describe "when returning a value" do |
3360 | - before do |
3361 | - @fact = Facter::Util::Fact.new("yay") |
3362 | - end |
3363 | - |
3364 | - it "should return nil if there are no resolutions" do |
3365 | - Facter::Util::Fact.new("yay").value.should be_nil |
3366 | - end |
3367 | - |
3368 | - it "should return the first value returned by a resolution" do |
3369 | - r1 = stub 'r1', :weight => 2, :value => nil, :suitable? => true |
3370 | - r2 = stub 'r2', :weight => 1, :value => "yay", :suitable? => true |
3371 | - r3 = stub 'r3', :weight => 0, :value => "foo", :suitable? => true |
3372 | - Facter::Util::Resolution.expects(:new).times(3).returns(r1).returns(r2).returns(r3) |
3373 | - @fact.add { } |
3374 | - @fact.add { } |
3375 | - @fact.add { } |
3376 | - |
3377 | - @fact.value.should == "yay" |
3378 | - end |
3379 | - |
3380 | - it "should short-cut returning the value once one is found" do |
3381 | - r1 = stub 'r1', :weight => 2, :value => "foo", :suitable? => true |
3382 | - r2 = stub 'r2', :weight => 1, :suitable? => true # would fail if 'value' were asked for |
3383 | - Facter::Util::Resolution.expects(:new).times(2).returns(r1).returns(r2) |
3384 | - @fact.add { } |
3385 | - @fact.add { } |
3386 | - |
3387 | - @fact.value |
3388 | - end |
3389 | - |
3390 | - it "should skip unsuitable resolutions" do |
3391 | - r1 = stub 'r1', :weight => 2, :suitable? => false # would fail if 'value' were asked for' |
3392 | - r2 = stub 'r2', :weight => 1, :value => "yay", :suitable? => true |
3393 | - Facter::Util::Resolution.expects(:new).times(2).returns(r1).returns(r2) |
3394 | - @fact.add { } |
3395 | - @fact.add { } |
3396 | - |
3397 | - @fact.value.should == "yay" |
3398 | - end |
3399 | - |
3400 | - it "should return nil if the value is the empty string" do |
3401 | - r1 = stub 'r1', :suitable? => true, :value => "" |
3402 | - Facter::Util::Resolution.expects(:new).returns r1 |
3403 | - @fact.add { } |
3404 | - |
3405 | - @fact.value.should be_nil |
3406 | - end |
3407 | - end |
3408 | - |
3409 | - it "should have a method for flushing the cached fact" do |
3410 | - Facter::Util::Fact.new(:foo).should respond_to(:flush) |
3411 | - end |
3412 | + it "should require a name" do |
3413 | + lambda { Facter::Util::Fact.new }.should raise_error(ArgumentError) |
3414 | + end |
3415 | + |
3416 | + it "should always downcase the name and convert it to a symbol" do |
3417 | + Facter::Util::Fact.new("YayNess").name.should == :yayness |
3418 | + end |
3419 | + |
3420 | + it "should default to its name converted to a string as its ldapname" do |
3421 | + Facter::Util::Fact.new("YayNess").ldapname.should == "yayness" |
3422 | + end |
3423 | + |
3424 | + it "should allow specifying the ldap name at initialization" do |
3425 | + Facter::Util::Fact.new("YayNess", :ldapname => "fooness").ldapname.should == "fooness" |
3426 | + end |
3427 | + |
3428 | + it "should fail if an unknown option is provided" do |
3429 | + lambda { Facter::Util::Fact.new('yay', :foo => :bar) }.should raise_error(ArgumentError) |
3430 | + end |
3431 | + |
3432 | + it "should have a method for adding resolution mechanisms" do |
3433 | + Facter::Util::Fact.new("yay").should respond_to(:add) |
3434 | + end |
3435 | + |
3436 | + describe "when adding resolution mechanisms" do |
3437 | + before do |
3438 | + @fact = Facter::Util::Fact.new("yay") |
3439 | + |
3440 | + @resolution = mock 'resolution' |
3441 | + @resolution.stub_everything |
3442 | + |
3443 | + end |
3444 | + |
3445 | + it "should fail if no block is given" do |
3446 | + lambda { @fact.add }.should raise_error(ArgumentError) |
3447 | + end |
3448 | + |
3449 | + it "should create a new resolution instance" do |
3450 | + Facter::Util::Resolution.expects(:new).returns @resolution |
3451 | + |
3452 | + @fact.add { } |
3453 | + end |
3454 | + |
3455 | + it "should instance_eval the passed block on the new resolution" do |
3456 | + @resolution.expects(:instance_eval) |
3457 | + |
3458 | + Facter::Util::Resolution.stubs(:new).returns @resolution |
3459 | + |
3460 | + @fact.add { } |
3461 | + end |
3462 | + |
3463 | + it "should re-sort the resolutions by weight, so the most restricted resolutions are first" do |
3464 | + r1 = stub 'r1', :weight => 1 |
3465 | + r2 = stub 'r2', :weight => 2 |
3466 | + r3 = stub 'r3', :weight => 0 |
3467 | + Facter::Util::Resolution.expects(:new).times(3).returns(r1).returns(r2).returns(r3) |
3468 | + @fact.add { } |
3469 | + @fact.add { } |
3470 | + @fact.add { } |
3471 | + |
3472 | + @fact.instance_variable_get("@resolves").should == [r2, r1, r3] |
3473 | + end |
3474 | + end |
3475 | + |
3476 | + it "should be able to return a value" do |
3477 | + Facter::Util::Fact.new("yay").should respond_to(:value) |
3478 | + end |
3479 | + |
3480 | + describe "when returning a value" do |
3481 | + before do |
3482 | + @fact = Facter::Util::Fact.new("yay") |
3483 | + end |
3484 | + |
3485 | + it "should return nil if there are no resolutions" do |
3486 | + Facter::Util::Fact.new("yay").value.should be_nil |
3487 | + end |
3488 | + |
3489 | + it "should return the first value returned by a resolution" do |
3490 | + r1 = stub 'r1', :weight => 2, :value => nil, :suitable? => true |
3491 | + r2 = stub 'r2', :weight => 1, :value => "yay", :suitable? => true |
3492 | + r3 = stub 'r3', :weight => 0, :value => "foo", :suitable? => true |
3493 | + Facter::Util::Resolution.expects(:new).times(3).returns(r1).returns(r2).returns(r3) |
3494 | + @fact.add { } |
3495 | + @fact.add { } |
3496 | + @fact.add { } |
3497 | + |
3498 | + @fact.value.should == "yay" |
3499 | + end |
3500 | + |
3501 | + it "should short-cut returning the value once one is found" do |
3502 | + r1 = stub 'r1', :weight => 2, :value => "foo", :suitable? => true |
3503 | + r2 = stub 'r2', :weight => 1, :suitable? => true # would fail if 'value' were asked for |
3504 | + Facter::Util::Resolution.expects(:new).times(2).returns(r1).returns(r2) |
3505 | + @fact.add { } |
3506 | + @fact.add { } |
3507 | + |
3508 | + @fact.value |
3509 | + end |
3510 | + |
3511 | + it "should skip unsuitable resolutions" do |
3512 | + r1 = stub 'r1', :weight => 2, :suitable? => false # would fail if 'value' were asked for' |
3513 | + r2 = stub 'r2', :weight => 1, :value => "yay", :suitable? => true |
3514 | + Facter::Util::Resolution.expects(:new).times(2).returns(r1).returns(r2) |
3515 | + @fact.add { } |
3516 | + @fact.add { } |
3517 | + |
3518 | + @fact.value.should == "yay" |
3519 | + end |
3520 | + |
3521 | + it "should return nil if the value is the empty string" do |
3522 | + r1 = stub 'r1', :suitable? => true, :value => "" |
3523 | + Facter::Util::Resolution.expects(:new).returns r1 |
3524 | + @fact.add { } |
3525 | + |
3526 | + @fact.value.should be_nil |
3527 | + end |
3528 | + end |
3529 | + |
3530 | + it "should have a method for flushing the cached fact" do |
3531 | + Facter::Util::Fact.new(:foo).should respond_to(:flush) |
3532 | + end |
3533 | end |
3534 | |
3535 | === modified file 'spec/unit/util/ip_spec.rb' |
3536 | --- spec/unit/util/ip_spec.rb 2011-10-06 10:48:30 +0000 |
3537 | +++ spec/unit/util/ip_spec.rb 2012-01-27 20:04:26 +0000 |
3538 | @@ -5,295 +5,295 @@ |
3539 | require 'facter/util/ip' |
3540 | |
3541 | describe Facter::Util::IP do |
3542 | + before :each do |
3543 | + Facter::Util::Config.stubs(:is_windows?).returns(false) |
3544 | + end |
3545 | + |
3546 | + [:freebsd, :linux, :netbsd, :openbsd, :sunos, :darwin, :"hp-ux", :"gnu/kfreebsd", :windows].each do |platform| |
3547 | + it "should be supported on #{platform}" do |
3548 | + Facter::Util::Config.stubs(:is_windows?).returns(platform == :windows) |
3549 | + Facter::Util::IP.supported_platforms.should be_include(platform) |
3550 | + end |
3551 | + end |
3552 | + |
3553 | + it "should return a list of interfaces" do |
3554 | + Facter::Util::IP.should respond_to(:get_interfaces) |
3555 | + end |
3556 | + |
3557 | + it "should return an empty list of interfaces on an unknown kernel" do |
3558 | + Facter.stubs(:value).returns("UnknownKernel") |
3559 | + Facter::Util::IP.get_interfaces().should == [] |
3560 | + end |
3561 | + |
3562 | + it "should return a list with a single interface and the loopback interface on Linux with a single interface" do |
3563 | + sample_output_file = File.dirname(__FILE__) + '/../data/linux_ifconfig_all_with_single_interface' |
3564 | + linux_ifconfig = File.read(sample_output_file) |
3565 | + Facter::Util::IP.stubs(:get_all_interface_output).returns(linux_ifconfig) |
3566 | + Facter::Util::IP.get_interfaces().should == ["eth0", "lo"] |
3567 | + end |
3568 | + |
3569 | + it "should return a list two interfaces on Darwin with two interfaces" do |
3570 | + sample_output_file = File.dirname(__FILE__) + '/../data/darwin_ifconfig_all_with_multiple_interfaces' |
3571 | + darwin_ifconfig = File.read(sample_output_file) |
3572 | + Facter::Util::IP.stubs(:get_all_interface_output).returns(darwin_ifconfig) |
3573 | + Facter::Util::IP.get_interfaces().should == ["lo0", "en0"] |
3574 | + end |
3575 | + |
3576 | + it "should return a list two interfaces on Solaris with two interfaces multiply reporting" do |
3577 | + sample_output_file = File.dirname(__FILE__) + '/../data/solaris_ifconfig_all_with_multiple_interfaces' |
3578 | + solaris_ifconfig = File.read(sample_output_file) |
3579 | + Facter::Util::IP.stubs(:get_all_interface_output).returns(solaris_ifconfig) |
3580 | + Facter::Util::IP.get_interfaces().should == ["lo0", "e1000g0"] |
3581 | + end |
3582 | + |
3583 | + it "should return a list three interfaces on HP-UX with three interfaces multiply reporting" do |
3584 | + sample_output_file = File.dirname(__FILE__) + '/../data/hpux_netstat_all_interfaces' |
3585 | + hpux_netstat = File.read(sample_output_file) |
3586 | + Facter::Util::IP.stubs(:get_all_interface_output).returns(hpux_netstat) |
3587 | + Facter::Util::IP.get_interfaces().should == ["lan1", "lan0", "lo0"] |
3588 | + end |
3589 | + |
3590 | + it "should return a list of six interfaces on a GNU/kFreeBSD with six interfaces" do |
3591 | + sample_output_file = File.dirname(__FILE__) + '/../data/debian_kfreebsd_ifconfig' |
3592 | + kfreebsd_ifconfig = File.read(sample_output_file) |
3593 | + Facter::Util::IP.stubs(:get_all_interface_output).returns(kfreebsd_ifconfig) |
3594 | + Facter::Util::IP.get_interfaces().should == ["em0", "em1", "bge0", "bge1", "lo0", "vlan0"] |
3595 | + end |
3596 | + |
3597 | + it "should return a list of only connected interfaces on Windows" do |
3598 | + Facter.fact(:kernel).stubs(:value).returns("windows") |
3599 | + sample_output_file = File.dirname(__FILE__) + '/../data/windows_netsh_all_interfaces' |
3600 | + windows_netsh = File.read(sample_output_file) |
3601 | + Facter::Util::IP.stubs(:get_all_interface_output).returns(windows_netsh) |
3602 | + Facter::Util::IP.get_interfaces().should == ["Loopback Pseudo-Interface 1", "Local Area Connection", "Teredo Tunneling Pseudo-Interface"] |
3603 | + end |
3604 | + |
3605 | + it "should return a value for a specific interface" do |
3606 | + Facter::Util::IP.should respond_to(:get_interface_value) |
3607 | + end |
3608 | + |
3609 | + it "should not return interface information for unsupported platforms" do |
3610 | + Facter.stubs(:value).with(:kernel).returns("bleah") |
3611 | + Facter::Util::IP.get_interface_value("e1000g0", "netmask").should == [] |
3612 | + end |
3613 | + |
3614 | + it "should return ipaddress information for Solaris" do |
3615 | + sample_output_file = File.dirname(__FILE__) + "/../data/solaris_ifconfig_single_interface" |
3616 | + solaris_ifconfig_interface = File.read(sample_output_file) |
3617 | + |
3618 | + Facter::Util::IP.expects(:get_single_interface_output).with("e1000g0").returns(solaris_ifconfig_interface) |
3619 | + Facter.stubs(:value).with(:kernel).returns("SunOS") |
3620 | + |
3621 | + Facter::Util::IP.get_interface_value("e1000g0", "ipaddress").should == "172.16.15.138" |
3622 | + end |
3623 | + |
3624 | + it "should return netmask information for Solaris" do |
3625 | + sample_output_file = File.dirname(__FILE__) + "/../data/solaris_ifconfig_single_interface" |
3626 | + solaris_ifconfig_interface = File.read(sample_output_file) |
3627 | + |
3628 | + Facter::Util::IP.expects(:get_single_interface_output).with("e1000g0").returns(solaris_ifconfig_interface) |
3629 | + Facter.stubs(:value).with(:kernel).returns("SunOS") |
3630 | + |
3631 | + Facter::Util::IP.get_interface_value("e1000g0", "netmask").should == "255.255.255.0" |
3632 | + end |
3633 | + |
3634 | + it "should return calculated network information for Solaris" do |
3635 | + sample_output_file = File.dirname(__FILE__) + "/../data/solaris_ifconfig_single_interface" |
3636 | + solaris_ifconfig_interface = File.read(sample_output_file) |
3637 | + |
3638 | + Facter::Util::IP.stubs(:get_single_interface_output).with("e1000g0").returns(solaris_ifconfig_interface) |
3639 | + Facter.stubs(:value).with(:kernel).returns("SunOS") |
3640 | + |
3641 | + Facter::Util::IP.get_network_value("e1000g0").should == "172.16.15.0" |
3642 | + end |
3643 | + |
3644 | + it "should return ipaddress information for HP-UX" do |
3645 | + sample_output_file = File.dirname(__FILE__) + "/../data/hpux_ifconfig_single_interface" |
3646 | + hpux_ifconfig_interface = File.read(sample_output_file) |
3647 | + |
3648 | + Facter::Util::IP.expects(:get_single_interface_output).with("lan0").returns(hpux_ifconfig_interface) |
3649 | + Facter.stubs(:value).with(:kernel).returns("HP-UX") |
3650 | + |
3651 | + Facter::Util::IP.get_interface_value("lan0", "ipaddress").should == "168.24.80.71" |
3652 | + end |
3653 | + |
3654 | + it "should return macaddress information for HP-UX" do |
3655 | + sample_output_file = File.dirname(__FILE__) + "/../data/hpux_ifconfig_single_interface" |
3656 | + hpux_ifconfig_interface = File.read(sample_output_file) |
3657 | + |
3658 | + Facter::Util::IP.expects(:get_single_interface_output).with("lan0").returns(hpux_ifconfig_interface) |
3659 | + Facter.stubs(:value).with(:kernel).returns("HP-UX") |
3660 | + |
3661 | + Facter::Util::IP.get_interface_value("lan0", "macaddress").should == "00:13:21:BD:9C:B7" |
3662 | + end |
3663 | + |
3664 | + it "should return macaddress with leading zeros stripped off for GNU/kFreeBSD" do |
3665 | + sample_output_file = File.dirname(__FILE__) + "/../data/debian_kfreebsd_ifconfig" |
3666 | + kfreebsd_ifconfig = File.read(sample_output_file) |
3667 | + |
3668 | + Facter::Util::IP.expects(:get_single_interface_output).with("em0").returns(kfreebsd_ifconfig) |
3669 | + Facter.stubs(:value).with(:kernel).returns("GNU/kFreeBSD") |
3670 | + |
3671 | + Facter::Util::IP.get_interface_value("em0", "macaddress").should == "0:11:a:59:67:90" |
3672 | + end |
3673 | + |
3674 | + it "should return netmask information for HP-UX" do |
3675 | + sample_output_file = File.dirname(__FILE__) + "/../data/hpux_ifconfig_single_interface" |
3676 | + hpux_ifconfig_interface = File.read(sample_output_file) |
3677 | + |
3678 | + Facter::Util::IP.expects(:get_single_interface_output).with("lan0").returns(hpux_ifconfig_interface) |
3679 | + Facter.stubs(:value).with(:kernel).returns("HP-UX") |
3680 | + |
3681 | + Facter::Util::IP.get_interface_value("lan0", "netmask").should == "255.255.255.0" |
3682 | + end |
3683 | + |
3684 | + it "should return calculated network information for HP-UX" do |
3685 | + sample_output_file = File.dirname(__FILE__) + "/../data/hpux_ifconfig_single_interface" |
3686 | + hpux_ifconfig_interface = File.read(sample_output_file) |
3687 | + |
3688 | + Facter::Util::IP.stubs(:get_single_interface_output).with("lan0").returns(hpux_ifconfig_interface) |
3689 | + Facter.stubs(:value).with(:kernel).returns("HP-UX") |
3690 | + |
3691 | + Facter::Util::IP.get_network_value("lan0").should == "168.24.80.0" |
3692 | + end |
3693 | + |
3694 | + it "should return interface information for FreeBSD supported via an alias" do |
3695 | + sample_output_file = File.dirname(__FILE__) + "/../data/6.0-STABLE_FreeBSD_ifconfig" |
3696 | + ifconfig_interface = File.read(sample_output_file) |
3697 | + |
3698 | + Facter::Util::IP.expects(:get_single_interface_output).with("fxp0").returns(ifconfig_interface) |
3699 | + Facter.stubs(:value).with(:kernel).returns("FreeBSD") |
3700 | + |
3701 | + Facter::Util::IP.get_interface_value("fxp0", "macaddress").should == "00:0e:0c:68:67:7c" |
3702 | + end |
3703 | + |
3704 | + it "should return macaddress information for OS X" do |
3705 | + sample_output_file = File.dirname(__FILE__) + "/../data/Mac_OS_X_10.5.5_ifconfig" |
3706 | + ifconfig_interface = File.read(sample_output_file) |
3707 | + |
3708 | + Facter::Util::IP.expects(:get_single_interface_output).with("en1").returns(ifconfig_interface) |
3709 | + Facter.stubs(:value).with(:kernel).returns("Darwin") |
3710 | + |
3711 | + Facter::Util::IP.get_interface_value("en1", "macaddress").should == "00:1b:63:ae:02:66" |
3712 | + end |
3713 | + |
3714 | + it "should return all interfaces correctly on OS X" do |
3715 | + sample_output_file = File.dirname(__FILE__) + "/../data/Mac_OS_X_10.5.5_ifconfig" |
3716 | + ifconfig_interface = File.read(sample_output_file) |
3717 | + |
3718 | + Facter::Util::IP.expects(:get_all_interface_output).returns(ifconfig_interface) |
3719 | + Facter.stubs(:value).with(:kernel).returns("Darwin") |
3720 | + |
3721 | + Facter::Util::IP.get_interfaces().should == ["lo0", "gif0", "stf0", "en0", "fw0", "en1", "vmnet8", "vmnet1"] |
3722 | + end |
3723 | + |
3724 | + it "should return a human readable netmask on Solaris" do |
3725 | + sample_output_file = File.dirname(__FILE__) + "/../data/solaris_ifconfig_single_interface" |
3726 | + solaris_ifconfig_interface = File.read(sample_output_file) |
3727 | + |
3728 | + Facter::Util::IP.expects(:get_single_interface_output).with("e1000g0").returns(solaris_ifconfig_interface) |
3729 | + Facter.stubs(:value).with(:kernel).returns("SunOS") |
3730 | + |
3731 | + Facter::Util::IP.get_interface_value("e1000g0", "netmask").should == "255.255.255.0" |
3732 | + end |
3733 | + |
3734 | + it "should return a human readable netmask on HP-UX" do |
3735 | + sample_output_file = File.dirname(__FILE__) + "/../data/hpux_ifconfig_single_interface" |
3736 | + hpux_ifconfig_interface = File.read(sample_output_file) |
3737 | + |
3738 | + Facter::Util::IP.expects(:get_single_interface_output).with("lan0").returns(hpux_ifconfig_interface) |
3739 | + Facter.stubs(:value).with(:kernel).returns("HP-UX") |
3740 | + |
3741 | + Facter::Util::IP.get_interface_value("lan0", "netmask").should == "255.255.255.0" |
3742 | + end |
3743 | + |
3744 | + it "should return a human readable netmask on Darwin" do |
3745 | + sample_output_file = File.dirname(__FILE__) + "/../data/darwin_ifconfig_single_interface" |
3746 | + |
3747 | + darwin_ifconfig_interface = File.read(sample_output_file) |
3748 | + |
3749 | + Facter::Util::IP.expects(:get_single_interface_output).with("en1").returns(darwin_ifconfig_interface) |
3750 | + Facter.stubs(:value).with(:kernel).returns("Darwin") |
3751 | + |
3752 | + Facter::Util::IP.get_interface_value("en1", "netmask").should == "255.255.255.0" |
3753 | + end |
3754 | + |
3755 | + it "should return a human readable netmask on GNU/kFreeBSD" do |
3756 | + sample_output_file = File.dirname(__FILE__) + "/../data/debian_kfreebsd_ifconfig" |
3757 | + |
3758 | + kfreebsd_ifconfig = File.read(sample_output_file) |
3759 | + |
3760 | + Facter::Util::IP.expects(:get_single_interface_output).with("em1").returns(kfreebsd_ifconfig) |
3761 | + Facter.stubs(:value).with(:kernel).returns("GNU/kFreeBSD") |
3762 | + |
3763 | + Facter::Util::IP.get_interface_value("em1", "netmask").should == "255.255.255.0" |
3764 | + end |
3765 | + |
3766 | + it "should not get bonding master on interface aliases" do |
3767 | + Facter.stubs(:value).with(:kernel).returns("Linux") |
3768 | + |
3769 | + Facter::Util::IP.get_bonding_master("eth0:1").should be_nil |
3770 | + end |
3771 | + |
3772 | + [:freebsd, :netbsd, :openbsd, :sunos, :darwin, :"hp-ux"].each do |platform| |
3773 | + it "should require conversion from hex on #{platform}" do |
3774 | + Facter::Util::IP.convert_from_hex?(platform).should == true |
3775 | + end |
3776 | + end |
3777 | + |
3778 | + [:windows].each do |platform| |
3779 | + it "should not require conversion from hex on #{platform}" do |
3780 | + Facter::Util::IP.convert_from_hex?(platform).should be_false |
3781 | + end |
3782 | + end |
3783 | + |
3784 | + it "should return an arp address on Linux" do |
3785 | + Facter.stubs(:value).with(:kernel).returns("Linux") |
3786 | + |
3787 | + Facter::Util::IP.expects(:get_arp_value).with("eth0").returns("00:00:0c:9f:f0:04") |
3788 | + Facter::Util::IP.get_arp_value("eth0").should == "00:00:0c:9f:f0:04" |
3789 | + end |
3790 | + |
3791 | + describe "on Windows" do |
3792 | before :each do |
3793 | - Facter::Util::Config.stubs(:is_windows?).returns(false) |
3794 | - end |
3795 | - |
3796 | - [:freebsd, :linux, :netbsd, :openbsd, :sunos, :darwin, :"hp-ux", :"gnu/kfreebsd", :windows].each do |platform| |
3797 | - it "should be supported on #{platform}" do |
3798 | - Facter::Util::Config.stubs(:is_windows?).returns(platform == :windows) |
3799 | - Facter::Util::IP.supported_platforms.should be_include(platform) |
3800 | - end |
3801 | - end |
3802 | - |
3803 | - it "should return a list of interfaces" do |
3804 | - Facter::Util::IP.should respond_to(:get_interfaces) |
3805 | - end |
3806 | - |
3807 | - it "should return an empty list of interfaces on an unknown kernel" do |
3808 | - Facter.stubs(:value).returns("UnknownKernel") |
3809 | - Facter::Util::IP.get_interfaces().should == [] |
3810 | - end |
3811 | - |
3812 | - it "should return a list with a single interface and the loopback interface on Linux with a single interface" do |
3813 | - sample_output_file = File.dirname(__FILE__) + '/../data/linux_ifconfig_all_with_single_interface' |
3814 | - linux_ifconfig = File.read(sample_output_file) |
3815 | - Facter::Util::IP.stubs(:get_all_interface_output).returns(linux_ifconfig) |
3816 | - Facter::Util::IP.get_interfaces().should == ["eth0", "lo"] |
3817 | - end |
3818 | - |
3819 | - it "should return a list two interfaces on Darwin with two interfaces" do |
3820 | - sample_output_file = File.dirname(__FILE__) + '/../data/darwin_ifconfig_all_with_multiple_interfaces' |
3821 | - darwin_ifconfig = File.read(sample_output_file) |
3822 | - Facter::Util::IP.stubs(:get_all_interface_output).returns(darwin_ifconfig) |
3823 | - Facter::Util::IP.get_interfaces().should == ["lo0", "en0"] |
3824 | - end |
3825 | - |
3826 | - it "should return a list two interfaces on Solaris with two interfaces multiply reporting" do |
3827 | - sample_output_file = File.dirname(__FILE__) + '/../data/solaris_ifconfig_all_with_multiple_interfaces' |
3828 | - solaris_ifconfig = File.read(sample_output_file) |
3829 | - Facter::Util::IP.stubs(:get_all_interface_output).returns(solaris_ifconfig) |
3830 | - Facter::Util::IP.get_interfaces().should == ["lo0", "e1000g0"] |
3831 | - end |
3832 | - |
3833 | - it "should return a list three interfaces on HP-UX with three interfaces multiply reporting" do |
3834 | - sample_output_file = File.dirname(__FILE__) + '/../data/hpux_netstat_all_interfaces' |
3835 | - hpux_netstat = File.read(sample_output_file) |
3836 | - Facter::Util::IP.stubs(:get_all_interface_output).returns(hpux_netstat) |
3837 | - Facter::Util::IP.get_interfaces().should == ["lan1", "lan0", "lo0"] |
3838 | - end |
3839 | - |
3840 | - it "should return a list of six interfaces on a GNU/kFreeBSD with six interfaces" do |
3841 | - sample_output_file = File.dirname(__FILE__) + '/../data/debian_kfreebsd_ifconfig' |
3842 | - kfreebsd_ifconfig = File.read(sample_output_file) |
3843 | - Facter::Util::IP.stubs(:get_all_interface_output).returns(kfreebsd_ifconfig) |
3844 | - Facter::Util::IP.get_interfaces().should == ["em0", "em1", "bge0", "bge1", "lo0", "vlan0"] |
3845 | - end |
3846 | - |
3847 | - it "should return a list of only connected interfaces on Windows" do |
3848 | - Facter.fact(:kernel).stubs(:value).returns("windows") |
3849 | - sample_output_file = File.dirname(__FILE__) + '/../data/windows_netsh_all_interfaces' |
3850 | - windows_netsh = File.read(sample_output_file) |
3851 | - Facter::Util::IP.stubs(:get_all_interface_output).returns(windows_netsh) |
3852 | - Facter::Util::IP.get_interfaces().should == ["Loopback Pseudo-Interface 1", "Local Area Connection", "Teredo Tunneling Pseudo-Interface"] |
3853 | - end |
3854 | - |
3855 | - it "should return a value for a specific interface" do |
3856 | - Facter::Util::IP.should respond_to(:get_interface_value) |
3857 | - end |
3858 | - |
3859 | - it "should not return interface information for unsupported platforms" do |
3860 | - Facter.stubs(:value).with(:kernel).returns("bleah") |
3861 | - Facter::Util::IP.get_interface_value("e1000g0", "netmask").should == [] |
3862 | - end |
3863 | - |
3864 | - it "should return ipaddress information for Solaris" do |
3865 | - sample_output_file = File.dirname(__FILE__) + "/../data/solaris_ifconfig_single_interface" |
3866 | - solaris_ifconfig_interface = File.read(sample_output_file) |
3867 | - |
3868 | - Facter::Util::IP.expects(:get_single_interface_output).with("e1000g0").returns(solaris_ifconfig_interface) |
3869 | - Facter.stubs(:value).with(:kernel).returns("SunOS") |
3870 | - |
3871 | - Facter::Util::IP.get_interface_value("e1000g0", "ipaddress").should == "172.16.15.138" |
3872 | - end |
3873 | - |
3874 | - it "should return netmask information for Solaris" do |
3875 | - sample_output_file = File.dirname(__FILE__) + "/../data/solaris_ifconfig_single_interface" |
3876 | - solaris_ifconfig_interface = File.read(sample_output_file) |
3877 | - |
3878 | - Facter::Util::IP.expects(:get_single_interface_output).with("e1000g0").returns(solaris_ifconfig_interface) |
3879 | - Facter.stubs(:value).with(:kernel).returns("SunOS") |
3880 | - |
3881 | - Facter::Util::IP.get_interface_value("e1000g0", "netmask").should == "255.255.255.0" |
3882 | - end |
3883 | - |
3884 | - it "should return calculated network information for Solaris" do |
3885 | - sample_output_file = File.dirname(__FILE__) + "/../data/solaris_ifconfig_single_interface" |
3886 | - solaris_ifconfig_interface = File.read(sample_output_file) |
3887 | - |
3888 | - Facter::Util::IP.stubs(:get_single_interface_output).with("e1000g0").returns(solaris_ifconfig_interface) |
3889 | - Facter.stubs(:value).with(:kernel).returns("SunOS") |
3890 | - |
3891 | - Facter::Util::IP.get_network_value("e1000g0").should == "172.16.15.0" |
3892 | - end |
3893 | - |
3894 | - it "should return ipaddress information for HP-UX" do |
3895 | - sample_output_file = File.dirname(__FILE__) + "/../data/hpux_ifconfig_single_interface" |
3896 | - hpux_ifconfig_interface = File.read(sample_output_file) |
3897 | - |
3898 | - Facter::Util::IP.expects(:get_single_interface_output).with("lan0").returns(hpux_ifconfig_interface) |
3899 | - Facter.stubs(:value).with(:kernel).returns("HP-UX") |
3900 | - |
3901 | - Facter::Util::IP.get_interface_value("lan0", "ipaddress").should == "168.24.80.71" |
3902 | - end |
3903 | - |
3904 | - it "should return macaddress information for HP-UX" do |
3905 | - sample_output_file = File.dirname(__FILE__) + "/../data/hpux_ifconfig_single_interface" |
3906 | - hpux_ifconfig_interface = File.read(sample_output_file) |
3907 | - |
3908 | - Facter::Util::IP.expects(:get_single_interface_output).with("lan0").returns(hpux_ifconfig_interface) |
3909 | - Facter.stubs(:value).with(:kernel).returns("HP-UX") |
3910 | - |
3911 | - Facter::Util::IP.get_interface_value("lan0", "macaddress").should == "00:13:21:BD:9C:B7" |
3912 | - end |
3913 | - |
3914 | - it "should return macaddress with leading zeros stripped off for GNU/kFreeBSD" do |
3915 | - sample_output_file = File.dirname(__FILE__) + "/../data/debian_kfreebsd_ifconfig" |
3916 | - kfreebsd_ifconfig = File.read(sample_output_file) |
3917 | - |
3918 | - Facter::Util::IP.expects(:get_single_interface_output).with("em0").returns(kfreebsd_ifconfig) |
3919 | - Facter.stubs(:value).with(:kernel).returns("GNU/kFreeBSD") |
3920 | - |
3921 | - Facter::Util::IP.get_interface_value("em0", "macaddress").should == "0:11:a:59:67:90" |
3922 | - end |
3923 | - |
3924 | - it "should return netmask information for HP-UX" do |
3925 | - sample_output_file = File.dirname(__FILE__) + "/../data/hpux_ifconfig_single_interface" |
3926 | - hpux_ifconfig_interface = File.read(sample_output_file) |
3927 | - |
3928 | - Facter::Util::IP.expects(:get_single_interface_output).with("lan0").returns(hpux_ifconfig_interface) |
3929 | - Facter.stubs(:value).with(:kernel).returns("HP-UX") |
3930 | - |
3931 | - Facter::Util::IP.get_interface_value("lan0", "netmask").should == "255.255.255.0" |
3932 | - end |
3933 | - |
3934 | - it "should return calculated network information for HP-UX" do |
3935 | - sample_output_file = File.dirname(__FILE__) + "/../data/hpux_ifconfig_single_interface" |
3936 | - hpux_ifconfig_interface = File.read(sample_output_file) |
3937 | - |
3938 | - Facter::Util::IP.stubs(:get_single_interface_output).with("lan0").returns(hpux_ifconfig_interface) |
3939 | - Facter.stubs(:value).with(:kernel).returns("HP-UX") |
3940 | - |
3941 | - Facter::Util::IP.get_network_value("lan0").should == "168.24.80.0" |
3942 | - end |
3943 | - |
3944 | - it "should return interface information for FreeBSD supported via an alias" do |
3945 | - sample_output_file = File.dirname(__FILE__) + "/../data/6.0-STABLE_FreeBSD_ifconfig" |
3946 | - ifconfig_interface = File.read(sample_output_file) |
3947 | - |
3948 | - Facter::Util::IP.expects(:get_single_interface_output).with("fxp0").returns(ifconfig_interface) |
3949 | - Facter.stubs(:value).with(:kernel).returns("FreeBSD") |
3950 | - |
3951 | - Facter::Util::IP.get_interface_value("fxp0", "macaddress").should == "00:0e:0c:68:67:7c" |
3952 | - end |
3953 | - |
3954 | - it "should return macaddress information for OS X" do |
3955 | - sample_output_file = File.dirname(__FILE__) + "/../data/Mac_OS_X_10.5.5_ifconfig" |
3956 | - ifconfig_interface = File.read(sample_output_file) |
3957 | - |
3958 | - Facter::Util::IP.expects(:get_single_interface_output).with("en1").returns(ifconfig_interface) |
3959 | - Facter.stubs(:value).with(:kernel).returns("Darwin") |
3960 | - |
3961 | - Facter::Util::IP.get_interface_value("en1", "macaddress").should == "00:1b:63:ae:02:66" |
3962 | - end |
3963 | - |
3964 | - it "should return all interfaces correctly on OS X" do |
3965 | - sample_output_file = File.dirname(__FILE__) + "/../data/Mac_OS_X_10.5.5_ifconfig" |
3966 | - ifconfig_interface = File.read(sample_output_file) |
3967 | - |
3968 | - Facter::Util::IP.expects(:get_all_interface_output).returns(ifconfig_interface) |
3969 | - Facter.stubs(:value).with(:kernel).returns("Darwin") |
3970 | - |
3971 | - Facter::Util::IP.get_interfaces().should == ["lo0", "gif0", "stf0", "en0", "fw0", "en1", "vmnet8", "vmnet1"] |
3972 | - end |
3973 | - |
3974 | - it "should return a human readable netmask on Solaris" do |
3975 | - sample_output_file = File.dirname(__FILE__) + "/../data/solaris_ifconfig_single_interface" |
3976 | - solaris_ifconfig_interface = File.read(sample_output_file) |
3977 | - |
3978 | - Facter::Util::IP.expects(:get_single_interface_output).with("e1000g0").returns(solaris_ifconfig_interface) |
3979 | - Facter.stubs(:value).with(:kernel).returns("SunOS") |
3980 | - |
3981 | - Facter::Util::IP.get_interface_value("e1000g0", "netmask").should == "255.255.255.0" |
3982 | - end |
3983 | - |
3984 | - it "should return a human readable netmask on HP-UX" do |
3985 | - sample_output_file = File.dirname(__FILE__) + "/../data/hpux_ifconfig_single_interface" |
3986 | - hpux_ifconfig_interface = File.read(sample_output_file) |
3987 | - |
3988 | - Facter::Util::IP.expects(:get_single_interface_output).with("lan0").returns(hpux_ifconfig_interface) |
3989 | - Facter.stubs(:value).with(:kernel).returns("HP-UX") |
3990 | - |
3991 | - Facter::Util::IP.get_interface_value("lan0", "netmask").should == "255.255.255.0" |
3992 | - end |
3993 | - |
3994 | - it "should return a human readable netmask on Darwin" do |
3995 | - sample_output_file = File.dirname(__FILE__) + "/../data/darwin_ifconfig_single_interface" |
3996 | - |
3997 | - darwin_ifconfig_interface = File.read(sample_output_file) |
3998 | - |
3999 | - Facter::Util::IP.expects(:get_single_interface_output).with("en1").returns(darwin_ifconfig_interface) |
4000 | - Facter.stubs(:value).with(:kernel).returns("Darwin") |
4001 | - |
4002 | - Facter::Util::IP.get_interface_value("en1", "netmask").should == "255.255.255.0" |
4003 | - end |
4004 | - |
4005 | - it "should return a human readable netmask on GNU/kFreeBSD" do |
4006 | - sample_output_file = File.dirname(__FILE__) + "/../data/debian_kfreebsd_ifconfig" |
4007 | - |
4008 | - kfreebsd_ifconfig = File.read(sample_output_file) |
4009 | - |
4010 | - Facter::Util::IP.expects(:get_single_interface_output).with("em1").returns(kfreebsd_ifconfig) |
4011 | - Facter.stubs(:value).with(:kernel).returns("GNU/kFreeBSD") |
4012 | - |
4013 | - Facter::Util::IP.get_interface_value("em1", "netmask").should == "255.255.255.0" |
4014 | - end |
4015 | - |
4016 | - it "should not get bonding master on interface aliases" do |
4017 | - Facter.stubs(:value).with(:kernel).returns("Linux") |
4018 | - |
4019 | - Facter::Util::IP.get_bonding_master("eth0:1").should be_nil |
4020 | - end |
4021 | - |
4022 | - [:freebsd, :netbsd, :openbsd, :sunos, :darwin, :"hp-ux"].each do |platform| |
4023 | - it "should require conversion from hex on #{platform}" do |
4024 | - Facter::Util::IP.convert_from_hex?(platform).should == true |
4025 | - end |
4026 | - end |
4027 | - |
4028 | - [:windows].each do |platform| |
4029 | - it "should not require conversion from hex on #{platform}" do |
4030 | - Facter::Util::IP.convert_from_hex?(platform).should be_false |
4031 | - end |
4032 | - end |
4033 | - |
4034 | - it "should return an arp address on Linux" do |
4035 | - Facter.stubs(:value).with(:kernel).returns("Linux") |
4036 | - |
4037 | - Facter::Util::IP.expects(:get_arp_value).with("eth0").returns("00:00:0c:9f:f0:04") |
4038 | - Facter::Util::IP.get_arp_value("eth0").should == "00:00:0c:9f:f0:04" |
4039 | - end |
4040 | - |
4041 | - describe "on Windows" do |
4042 | - before :each do |
4043 | - Facter.stubs(:value).with(:kernel).returns("windows") |
4044 | - end |
4045 | - |
4046 | - it "should return ipaddress information" do |
4047 | - sample_output_file = File.dirname(__FILE__) + "/../data/windows_netsh_single_interface" |
4048 | - windows_netsh = File.read(sample_output_file) |
4049 | - |
4050 | - Facter::Util::IP.expects(:get_output_for_interface_and_label).with("Local Area Connection", "ipaddress").returns(windows_netsh) |
4051 | - |
4052 | - Facter::Util::IP.get_interface_value("Local Area Connection", "ipaddress").should == "172.16.138.216" |
4053 | - end |
4054 | - |
4055 | - it "should return a human readable netmask" do |
4056 | - sample_output_file = File.dirname(__FILE__) + "/../data/windows_netsh_single_interface" |
4057 | - windows_netsh = File.read(sample_output_file) |
4058 | - |
4059 | - Facter::Util::IP.expects(:get_output_for_interface_and_label).with("Local Area Connection", "netmask").returns(windows_netsh) |
4060 | - |
4061 | - Facter::Util::IP.get_interface_value("Local Area Connection", "netmask").should == "255.255.255.0" |
4062 | - end |
4063 | - |
4064 | - it "should return network information" do |
4065 | - sample_output_file = File.dirname(__FILE__) + "/../data/windows_netsh_single_interface" |
4066 | - windows_netsh = File.read(sample_output_file) |
4067 | - |
4068 | - Facter::Util::IP.stubs(:get_output_for_interface_and_label).with("Local Area Connection", "ipaddress").returns(windows_netsh) |
4069 | - Facter::Util::IP.stubs(:get_output_for_interface_and_label).with("Local Area Connection", "netmask").returns(windows_netsh) |
4070 | - |
4071 | - Facter::Util::IP.get_network_value("Local Area Connection").should == "172.16.138.0" |
4072 | - end |
4073 | - |
4074 | - it "should return ipaddress6 information" do |
4075 | - sample_output_file = File.dirname(__FILE__) + "/../data/windows_netsh_single_interface6" |
4076 | - windows_netsh = File.read(sample_output_file) |
4077 | - |
4078 | - Facter::Util::IP.expects(:get_output_for_interface_and_label).with("Teredo Tunneling Pseudo-Interface", "ipaddress6").returns(windows_netsh) |
4079 | - |
4080 | - Facter::Util::IP.get_interface_value("Teredo Tunneling Pseudo-Interface", "ipaddress6").should == "2001:0:4137:9e76:2087:77a:53ef:7527" |
4081 | - end |
4082 | - end |
4083 | + Facter.stubs(:value).with(:kernel).returns("windows") |
4084 | + end |
4085 | + |
4086 | + it "should return ipaddress information" do |
4087 | + sample_output_file = File.dirname(__FILE__) + "/../data/windows_netsh_single_interface" |
4088 | + windows_netsh = File.read(sample_output_file) |
4089 | + |
4090 | + Facter::Util::IP.expects(:get_output_for_interface_and_label).with("Local Area Connection", "ipaddress").returns(windows_netsh) |
4091 | + |
4092 | + Facter::Util::IP.get_interface_value("Local Area Connection", "ipaddress").should == "172.16.138.216" |
4093 | + end |
4094 | + |
4095 | + it "should return a human readable netmask" do |
4096 | + sample_output_file = File.dirname(__FILE__) + "/../data/windows_netsh_single_interface" |
4097 | + windows_netsh = File.read(sample_output_file) |
4098 | + |
4099 | + Facter::Util::IP.expects(:get_output_for_interface_and_label).with("Local Area Connection", "netmask").returns(windows_netsh) |
4100 | + |
4101 | + Facter::Util::IP.get_interface_value("Local Area Connection", "netmask").should == "255.255.255.0" |
4102 | + end |
4103 | + |
4104 | + it "should return network information" do |
4105 | + sample_output_file = File.dirname(__FILE__) + "/../data/windows_netsh_single_interface" |
4106 | + windows_netsh = File.read(sample_output_file) |
4107 | + |
4108 | + Facter::Util::IP.stubs(:get_output_for_interface_and_label).with("Local Area Connection", "ipaddress").returns(windows_netsh) |
4109 | + Facter::Util::IP.stubs(:get_output_for_interface_and_label).with("Local Area Connection", "netmask").returns(windows_netsh) |
4110 | + |
4111 | + Facter::Util::IP.get_network_value("Local Area Connection").should == "172.16.138.0" |
4112 | + end |
4113 | + |
4114 | + it "should return ipaddress6 information" do |
4115 | + sample_output_file = File.dirname(__FILE__) + "/../data/windows_netsh_single_interface6" |
4116 | + windows_netsh = File.read(sample_output_file) |
4117 | + |
4118 | + Facter::Util::IP.expects(:get_output_for_interface_and_label).with("Teredo Tunneling Pseudo-Interface", "ipaddress6").returns(windows_netsh) |
4119 | + |
4120 | + Facter::Util::IP.get_interface_value("Teredo Tunneling Pseudo-Interface", "ipaddress6").should == "2001:0:4137:9e76:2087:77a:53ef:7527" |
4121 | + end |
4122 | + end |
4123 | end |
4124 | |
4125 | === modified file 'spec/unit/util/loader_spec.rb' |
4126 | --- spec/unit/util/loader_spec.rb 2011-10-06 10:48:30 +0000 |
4127 | +++ spec/unit/util/loader_spec.rb 2012-01-27 20:04:26 +0000 |
4128 | @@ -19,273 +19,273 @@ |
4129 | |
4130 | |
4131 | describe Facter::Util::Loader do |
4132 | - before :each do |
4133 | - Facter::Util::Loader.any_instance.unstub(:load_all) |
4134 | - end |
4135 | - |
4136 | - def with_env(values) |
4137 | - old = {} |
4138 | - values.each do |var, value| |
4139 | - if old_val = ENV[var] |
4140 | - old[var] = old_val |
4141 | - end |
4142 | - ENV[var] = value |
4143 | - end |
4144 | - yield |
4145 | - values.each do |var, value| |
4146 | - if old.include?(var) |
4147 | - ENV[var] = old[var] |
4148 | - else |
4149 | - ENV.delete(var) |
4150 | - end |
4151 | - end |
4152 | - end |
4153 | - |
4154 | - it "should have a method for loading individual facts by name" do |
4155 | - Facter::Util::Loader.new.should respond_to(:load) |
4156 | - end |
4157 | - |
4158 | - it "should have a method for loading all facts" do |
4159 | - Facter::Util::Loader.new.should respond_to(:load_all) |
4160 | - end |
4161 | - |
4162 | - it "should have a method for returning directories containing facts" do |
4163 | - Facter::Util::Loader.new.should respond_to(:search_path) |
4164 | - end |
4165 | - |
4166 | - describe "when determining the search path" do |
4167 | - before do |
4168 | - @loader = Facter::Util::Loader.new |
4169 | - @settings = mock 'settings' |
4170 | - @settings.stubs(:value).returns "/eh" |
4171 | - end |
4172 | - |
4173 | - it "should include the facter subdirectory of all paths in ruby LOAD_PATH" do |
4174 | - dirs = $LOAD_PATH.collect { |d| File.join(d, "facter") } |
4175 | - paths = @loader.search_path |
4176 | - |
4177 | - dirs.each do |dir| |
4178 | - paths.should be_include(dir) |
4179 | - end |
4180 | - end |
4181 | - |
4182 | - it "should include all search paths registered with Facter" do |
4183 | - Facter.expects(:search_path).returns %w{/one /two} |
4184 | - paths = @loader.search_path |
4185 | - paths.should be_include("/one") |
4186 | - paths.should be_include("/two") |
4187 | - end |
4188 | - |
4189 | - describe "and the FACTERLIB environment variable is set" do |
4190 | - it "should include all paths in FACTERLIB" do |
4191 | - with_env "FACTERLIB" => "/one/path:/two/path" do |
4192 | - paths = @loader.search_path |
4193 | - %w{/one/path /two/path}.each do |dir| |
4194 | - paths.should be_include(dir) |
4195 | - end |
4196 | - end |
4197 | - end |
4198 | - end |
4199 | - end |
4200 | - |
4201 | - describe "when loading facts" do |
4202 | - before do |
4203 | - @loader = Facter::Util::Loader.new |
4204 | - @loader.stubs(:search_path).returns [] |
4205 | - end |
4206 | - |
4207 | - it "should load values from the matching environment variable if one is present" do |
4208 | - Facter.expects(:add).with("testing") |
4209 | - |
4210 | - with_env "facter_testing" => "yayness" do |
4211 | - @loader.load(:testing) |
4212 | - end |
4213 | - end |
4214 | - |
4215 | - it "should load any files in the search path with names matching the fact name" do |
4216 | - @loader.expects(:search_path).returns %w{/one/dir /two/dir} |
4217 | - FileTest.stubs(:exist?).returns false |
4218 | - FileTest.expects(:exist?).with("/one/dir/testing.rb").returns true |
4219 | - FileTest.expects(:exist?).with("/two/dir/testing.rb").returns true |
4220 | - |
4221 | - Kernel.expects(:load).with("/one/dir/testing.rb") |
4222 | - Kernel.expects(:load).with("/two/dir/testing.rb") |
4223 | - |
4224 | - @loader.load(:testing) |
4225 | - end |
4226 | - |
4227 | - it 'should load any ruby files in directories matching the fact name in the search path in sorted order regardless of the order returned by Dir.entries' do |
4228 | - @loader = TestLoader.new |
4229 | - |
4230 | - @loader.stubs(:search_path).returns %w{/one/dir} |
4231 | - FileTest.stubs(:exist?).returns false |
4232 | - FileTest.stubs(:directory?).with("/one/dir/testing").returns true |
4233 | - @loader.stubs(:search_path).returns %w{/one/dir} |
4234 | - |
4235 | - Dir.stubs(:entries).with("/one/dir/testing").returns %w{foo.rb bar.rb} |
4236 | - %w{/one/dir/testing/foo.rb /one/dir/testing/bar.rb}.each do |f| |
4237 | - File.stubs(:directory?).with(f).returns false |
4238 | - Kernel.stubs(:load).with(f) |
4239 | - end |
4240 | - |
4241 | + before :each do |
4242 | + Facter::Util::Loader.any_instance.unstub(:load_all) |
4243 | + end |
4244 | + |
4245 | + def with_env(values) |
4246 | + old = {} |
4247 | + values.each do |var, value| |
4248 | + if old_val = ENV[var] |
4249 | + old[var] = old_val |
4250 | + end |
4251 | + ENV[var] = value |
4252 | + end |
4253 | + yield |
4254 | + values.each do |var, value| |
4255 | + if old.include?(var) |
4256 | + ENV[var] = old[var] |
4257 | + else |
4258 | + ENV.delete(var) |
4259 | + end |
4260 | + end |
4261 | + end |
4262 | + |
4263 | + it "should have a method for loading individual facts by name" do |
4264 | + Facter::Util::Loader.new.should respond_to(:load) |
4265 | + end |
4266 | + |
4267 | + it "should have a method for loading all facts" do |
4268 | + Facter::Util::Loader.new.should respond_to(:load_all) |
4269 | + end |
4270 | + |
4271 | + it "should have a method for returning directories containing facts" do |
4272 | + Facter::Util::Loader.new.should respond_to(:search_path) |
4273 | + end |
4274 | + |
4275 | + describe "when determining the search path" do |
4276 | + before do |
4277 | + @loader = Facter::Util::Loader.new |
4278 | + @settings = mock 'settings' |
4279 | + @settings.stubs(:value).returns "/eh" |
4280 | + end |
4281 | + |
4282 | + it "should include the facter subdirectory of all paths in ruby LOAD_PATH" do |
4283 | + dirs = $LOAD_PATH.collect { |d| File.join(d, "facter") } |
4284 | + paths = @loader.search_path |
4285 | + |
4286 | + dirs.each do |dir| |
4287 | + paths.should be_include(dir) |
4288 | + end |
4289 | + end |
4290 | + |
4291 | + it "should include all search paths registered with Facter" do |
4292 | + Facter.expects(:search_path).returns %w{/one /two} |
4293 | + paths = @loader.search_path |
4294 | + paths.should be_include("/one") |
4295 | + paths.should be_include("/two") |
4296 | + end |
4297 | + |
4298 | + describe "and the FACTERLIB environment variable is set" do |
4299 | + it "should include all paths in FACTERLIB" do |
4300 | + with_env "FACTERLIB" => "/one/path:/two/path" do |
4301 | + paths = @loader.search_path |
4302 | + %w{/one/path /two/path}.each do |dir| |
4303 | + paths.should be_include(dir) |
4304 | + end |
4305 | + end |
4306 | + end |
4307 | + end |
4308 | + end |
4309 | + |
4310 | + describe "when loading facts" do |
4311 | + before do |
4312 | + @loader = Facter::Util::Loader.new |
4313 | + @loader.stubs(:search_path).returns [] |
4314 | + end |
4315 | + |
4316 | + it "should load values from the matching environment variable if one is present" do |
4317 | + Facter.expects(:add).with("testing") |
4318 | + |
4319 | + with_env "facter_testing" => "yayness" do |
4320 | @loader.load(:testing) |
4321 | - @loader.loaded_files.should == %w{/one/dir/testing/bar.rb /one/dir/testing/foo.rb} |
4322 | end |
4323 | - |
4324 | - it "should load any ruby files in directories matching the fact name in the search path" do |
4325 | - @loader.expects(:search_path).returns %w{/one/dir} |
4326 | - FileTest.stubs(:exist?).returns false |
4327 | - FileTest.expects(:directory?).with("/one/dir/testing").returns true |
4328 | - |
4329 | - Dir.expects(:entries).with("/one/dir/testing").returns %w{two.rb} |
4330 | - |
4331 | - Kernel.expects(:load).with("/one/dir/testing/two.rb") |
4332 | - |
4333 | - @loader.load(:testing) |
4334 | - end |
4335 | - |
4336 | - it "should not load files that don't end in '.rb'" do |
4337 | - @loader.expects(:search_path).returns %w{/one/dir} |
4338 | - FileTest.stubs(:exist?).returns false |
4339 | - FileTest.expects(:directory?).with("/one/dir/testing").returns true |
4340 | - |
4341 | - Dir.expects(:entries).with("/one/dir/testing").returns %w{one} |
4342 | - |
4343 | - Kernel.expects(:load).never |
4344 | - |
4345 | - @loader.load(:testing) |
4346 | - end |
4347 | - end |
4348 | - |
4349 | - describe "when loading all facts" do |
4350 | - before do |
4351 | - @loader = Facter::Util::Loader.new |
4352 | - @loader.stubs(:search_path).returns [] |
4353 | - |
4354 | - FileTest.stubs(:directory?).returns true |
4355 | - end |
4356 | - |
4357 | - it "should skip directories that do not exist" do |
4358 | - @loader.expects(:search_path).returns %w{/one/dir} |
4359 | - |
4360 | - FileTest.expects(:directory?).with("/one/dir").returns false |
4361 | - |
4362 | - Dir.expects(:entries).with("/one/dir").never |
4363 | - |
4364 | - @loader.load_all |
4365 | - end |
4366 | - |
4367 | - it "should load all files in all search paths" do |
4368 | - @loader.expects(:search_path).returns %w{/one/dir /two/dir} |
4369 | - |
4370 | - Dir.expects(:entries).with("/one/dir").returns %w{a.rb b.rb} |
4371 | - Dir.expects(:entries).with("/two/dir").returns %w{c.rb d.rb} |
4372 | - |
4373 | - %w{/one/dir/a.rb /one/dir/b.rb /two/dir/c.rb /two/dir/d.rb}.each { |f| Kernel.expects(:load).with(f) } |
4374 | - |
4375 | - @loader.load_all |
4376 | - end |
4377 | - |
4378 | - it "should load all files in all subdirectories in all search paths" do |
4379 | - @loader.expects(:search_path).returns %w{/one/dir /two/dir} |
4380 | - |
4381 | - Dir.expects(:entries).with("/one/dir").returns %w{a} |
4382 | - Dir.expects(:entries).with("/two/dir").returns %w{b} |
4383 | - |
4384 | - %w{/one/dir/a /two/dir/b}.each { |f| File.expects(:directory?).with(f).returns true } |
4385 | - |
4386 | - Dir.expects(:entries).with("/one/dir/a").returns %w{c.rb} |
4387 | - Dir.expects(:entries).with("/two/dir/b").returns %w{d.rb} |
4388 | - |
4389 | - %w{/one/dir/a/c.rb /two/dir/b/d.rb}.each { |f| Kernel.expects(:load).with(f) } |
4390 | - |
4391 | - @loader.load_all |
4392 | - end |
4393 | - |
4394 | - it 'should load all files in sorted order for any given directory regardless of the order returned by Dir.entries' do |
4395 | - @loader = TestLoader.new |
4396 | - |
4397 | - @loader.stubs(:search_path).returns %w{/one/dir} |
4398 | - Dir.stubs(:entries).with("/one/dir").returns %w{foo.rb bar.rb} |
4399 | - |
4400 | - %w{/one/dir}.each { |f| File.stubs(:directory?).with(f).returns true } |
4401 | - |
4402 | - %w{/one/dir/foo.rb /one/dir/bar.rb}.each do |f| |
4403 | - File.stubs(:directory?).with(f).returns false |
4404 | - Kernel.expects(:load).with(f) |
4405 | - end |
4406 | - |
4407 | + end |
4408 | + |
4409 | + it "should load any files in the search path with names matching the fact name" do |
4410 | + @loader.expects(:search_path).returns %w{/one/dir /two/dir} |
4411 | + FileTest.stubs(:exist?).returns false |
4412 | + FileTest.expects(:exist?).with("/one/dir/testing.rb").returns true |
4413 | + FileTest.expects(:exist?).with("/two/dir/testing.rb").returns true |
4414 | + |
4415 | + Kernel.expects(:load).with("/one/dir/testing.rb") |
4416 | + Kernel.expects(:load).with("/two/dir/testing.rb") |
4417 | + |
4418 | + @loader.load(:testing) |
4419 | + end |
4420 | + |
4421 | + it 'should load any ruby files in directories matching the fact name in the search path in sorted order regardless of the order returned by Dir.entries' do |
4422 | + @loader = TestLoader.new |
4423 | + |
4424 | + @loader.stubs(:search_path).returns %w{/one/dir} |
4425 | + FileTest.stubs(:exist?).returns false |
4426 | + FileTest.stubs(:directory?).with("/one/dir/testing").returns true |
4427 | + @loader.stubs(:search_path).returns %w{/one/dir} |
4428 | + |
4429 | + Dir.stubs(:entries).with("/one/dir/testing").returns %w{foo.rb bar.rb} |
4430 | + %w{/one/dir/testing/foo.rb /one/dir/testing/bar.rb}.each do |f| |
4431 | + File.stubs(:directory?).with(f).returns false |
4432 | + Kernel.stubs(:load).with(f) |
4433 | + end |
4434 | + |
4435 | + @loader.load(:testing) |
4436 | + @loader.loaded_files.should == %w{/one/dir/testing/bar.rb /one/dir/testing/foo.rb} |
4437 | + end |
4438 | + |
4439 | + it "should load any ruby files in directories matching the fact name in the search path" do |
4440 | + @loader.expects(:search_path).returns %w{/one/dir} |
4441 | + FileTest.stubs(:exist?).returns false |
4442 | + FileTest.expects(:directory?).with("/one/dir/testing").returns true |
4443 | + |
4444 | + Dir.expects(:entries).with("/one/dir/testing").returns %w{two.rb} |
4445 | + |
4446 | + Kernel.expects(:load).with("/one/dir/testing/two.rb") |
4447 | + |
4448 | + @loader.load(:testing) |
4449 | + end |
4450 | + |
4451 | + it "should not load files that don't end in '.rb'" do |
4452 | + @loader.expects(:search_path).returns %w{/one/dir} |
4453 | + FileTest.stubs(:exist?).returns false |
4454 | + FileTest.expects(:directory?).with("/one/dir/testing").returns true |
4455 | + |
4456 | + Dir.expects(:entries).with("/one/dir/testing").returns %w{one} |
4457 | + |
4458 | + Kernel.expects(:load).never |
4459 | + |
4460 | + @loader.load(:testing) |
4461 | + end |
4462 | + end |
4463 | + |
4464 | + describe "when loading all facts" do |
4465 | + before do |
4466 | + @loader = Facter::Util::Loader.new |
4467 | + @loader.stubs(:search_path).returns [] |
4468 | + |
4469 | + FileTest.stubs(:directory?).returns true |
4470 | + end |
4471 | + |
4472 | + it "should skip directories that do not exist" do |
4473 | + @loader.expects(:search_path).returns %w{/one/dir} |
4474 | + |
4475 | + FileTest.expects(:directory?).with("/one/dir").returns false |
4476 | + |
4477 | + Dir.expects(:entries).with("/one/dir").never |
4478 | + |
4479 | + @loader.load_all |
4480 | + end |
4481 | + |
4482 | + it "should load all files in all search paths" do |
4483 | + @loader.expects(:search_path).returns %w{/one/dir /two/dir} |
4484 | + |
4485 | + Dir.expects(:entries).with("/one/dir").returns %w{a.rb b.rb} |
4486 | + Dir.expects(:entries).with("/two/dir").returns %w{c.rb d.rb} |
4487 | + |
4488 | + %w{/one/dir/a.rb /one/dir/b.rb /two/dir/c.rb /two/dir/d.rb}.each { |f| Kernel.expects(:load).with(f) } |
4489 | + |
4490 | + @loader.load_all |
4491 | + end |
4492 | + |
4493 | + it "should load all files in all subdirectories in all search paths" do |
4494 | + @loader.expects(:search_path).returns %w{/one/dir /two/dir} |
4495 | + |
4496 | + Dir.expects(:entries).with("/one/dir").returns %w{a} |
4497 | + Dir.expects(:entries).with("/two/dir").returns %w{b} |
4498 | + |
4499 | + %w{/one/dir/a /two/dir/b}.each { |f| File.expects(:directory?).with(f).returns true } |
4500 | + |
4501 | + Dir.expects(:entries).with("/one/dir/a").returns %w{c.rb} |
4502 | + Dir.expects(:entries).with("/two/dir/b").returns %w{d.rb} |
4503 | + |
4504 | + %w{/one/dir/a/c.rb /two/dir/b/d.rb}.each { |f| Kernel.expects(:load).with(f) } |
4505 | + |
4506 | + @loader.load_all |
4507 | + end |
4508 | + |
4509 | + it 'should load all files in sorted order for any given directory regardless of the order returned by Dir.entries' do |
4510 | + @loader = TestLoader.new |
4511 | + |
4512 | + @loader.stubs(:search_path).returns %w{/one/dir} |
4513 | + Dir.stubs(:entries).with("/one/dir").returns %w{foo.rb bar.rb} |
4514 | + |
4515 | + %w{/one/dir}.each { |f| File.stubs(:directory?).with(f).returns true } |
4516 | + |
4517 | + %w{/one/dir/foo.rb /one/dir/bar.rb}.each do |f| |
4518 | + File.stubs(:directory?).with(f).returns false |
4519 | + Kernel.expects(:load).with(f) |
4520 | + end |
4521 | + |
4522 | + @loader.load_all |
4523 | + |
4524 | + @loader.loaded_files.should == %w{/one/dir/bar.rb /one/dir/foo.rb} |
4525 | + end |
4526 | + |
4527 | + it "should not load files in the util subdirectory" do |
4528 | + @loader.expects(:search_path).returns %w{/one/dir} |
4529 | + |
4530 | + Dir.expects(:entries).with("/one/dir").returns %w{util} |
4531 | + |
4532 | + File.expects(:directory?).with("/one/dir/util").returns true |
4533 | + |
4534 | + Dir.expects(:entries).with("/one/dir/util").never |
4535 | + |
4536 | + @loader.load_all |
4537 | + end |
4538 | + |
4539 | + it "should not load files in a lib subdirectory" do |
4540 | + @loader.expects(:search_path).returns %w{/one/dir} |
4541 | + |
4542 | + Dir.expects(:entries).with("/one/dir").returns %w{lib} |
4543 | + |
4544 | + File.expects(:directory?).with("/one/dir/lib").returns true |
4545 | + |
4546 | + Dir.expects(:entries).with("/one/dir/lib").never |
4547 | + |
4548 | + @loader.load_all |
4549 | + end |
4550 | + |
4551 | + it "should not load files in '.' or '..'" do |
4552 | + @loader.expects(:search_path).returns %w{/one/dir} |
4553 | + |
4554 | + Dir.expects(:entries).with("/one/dir").returns %w{. ..} |
4555 | + |
4556 | + File.expects(:entries).with("/one/dir/.").never |
4557 | + File.expects(:entries).with("/one/dir/..").never |
4558 | + |
4559 | + @loader.load_all |
4560 | + end |
4561 | + |
4562 | + it "should not raise an exception when a file is unloadable" do |
4563 | + @loader.expects(:search_path).returns %w{/one/dir} |
4564 | + Dir.expects(:entries).with("/one/dir").returns %w{a.rb} |
4565 | + |
4566 | + Kernel.expects(:load).with("/one/dir/a.rb").raises(LoadError) |
4567 | + @loader.expects(:warn) |
4568 | + |
4569 | + lambda { @loader.load_all }.should_not raise_error |
4570 | + end |
4571 | + |
4572 | + it "should load all facts from the environment" do |
4573 | + Facter.expects(:add).with('one') |
4574 | + Facter.expects(:add).with('two') |
4575 | + |
4576 | + with_env "facter_one" => "yayness", "facter_two" => "boo" do |
4577 | @loader.load_all |
4578 | - |
4579 | - @loader.loaded_files.should == %w{/one/dir/bar.rb /one/dir/foo.rb} |
4580 | end |
4581 | - |
4582 | - it "should not load files in the util subdirectory" do |
4583 | - @loader.expects(:search_path).returns %w{/one/dir} |
4584 | - |
4585 | - Dir.expects(:entries).with("/one/dir").returns %w{util} |
4586 | - |
4587 | - File.expects(:directory?).with("/one/dir/util").returns true |
4588 | - |
4589 | - Dir.expects(:entries).with("/one/dir/util").never |
4590 | - |
4591 | - @loader.load_all |
4592 | - end |
4593 | - |
4594 | - it "should not load files in a lib subdirectory" do |
4595 | - @loader.expects(:search_path).returns %w{/one/dir} |
4596 | - |
4597 | - Dir.expects(:entries).with("/one/dir").returns %w{lib} |
4598 | - |
4599 | - File.expects(:directory?).with("/one/dir/lib").returns true |
4600 | - |
4601 | - Dir.expects(:entries).with("/one/dir/lib").never |
4602 | - |
4603 | - @loader.load_all |
4604 | - end |
4605 | - |
4606 | - it "should not load files in '.' or '..'" do |
4607 | - @loader.expects(:search_path).returns %w{/one/dir} |
4608 | - |
4609 | - Dir.expects(:entries).with("/one/dir").returns %w{. ..} |
4610 | - |
4611 | - File.expects(:entries).with("/one/dir/.").never |
4612 | - File.expects(:entries).with("/one/dir/..").never |
4613 | - |
4614 | - @loader.load_all |
4615 | - end |
4616 | - |
4617 | - it "should not raise an exception when a file is unloadable" do |
4618 | - @loader.expects(:search_path).returns %w{/one/dir} |
4619 | - Dir.expects(:entries).with("/one/dir").returns %w{a.rb} |
4620 | - |
4621 | - Kernel.expects(:load).with("/one/dir/a.rb").raises(LoadError) |
4622 | - @loader.expects(:warn) |
4623 | - |
4624 | - lambda { @loader.load_all }.should_not raise_error |
4625 | - end |
4626 | - |
4627 | - it "should load all facts from the environment" do |
4628 | - Facter.expects(:add).with('one') |
4629 | - Facter.expects(:add).with('two') |
4630 | - |
4631 | - with_env "facter_one" => "yayness", "facter_two" => "boo" do |
4632 | - @loader.load_all |
4633 | - end |
4634 | - end |
4635 | - |
4636 | - it "should only load all facts one time" do |
4637 | - @loader.expects(:load_env).once |
4638 | - @loader.load_all |
4639 | - @loader.load_all |
4640 | - end |
4641 | - end |
4642 | - |
4643 | - it "should load facts on the facter search path only once" do |
4644 | - facterlibdir = File.expand_path(File.dirname(__FILE__) + '../../../fixtures/unit/util/loader') |
4645 | - with_env 'FACTERLIB' => facterlibdir do |
4646 | - Facter::Util::Loader.new.load_all |
4647 | - Facter.value(:nosuchfact).should be_nil |
4648 | - end |
4649 | - end |
4650 | + end |
4651 | + |
4652 | + it "should only load all facts one time" do |
4653 | + @loader.expects(:load_env).once |
4654 | + @loader.load_all |
4655 | + @loader.load_all |
4656 | + end |
4657 | + end |
4658 | + |
4659 | + it "should load facts on the facter search path only once" do |
4660 | + facterlibdir = File.expand_path(File.dirname(__FILE__) + '../../../fixtures/unit/util/loader') |
4661 | + with_env 'FACTERLIB' => facterlibdir do |
4662 | + Facter::Util::Loader.new.load_all |
4663 | + Facter.value(:nosuchfact).should be_nil |
4664 | + end |
4665 | + end |
4666 | end |
4667 | |
4668 | === modified file 'spec/unit/util/macaddress_spec.rb' |
4669 | --- spec/unit/util/macaddress_spec.rb 2011-10-06 10:48:30 +0000 |
4670 | +++ spec/unit/util/macaddress_spec.rb 2012-01-27 20:04:26 +0000 |
4671 | @@ -8,10 +8,15 @@ |
4672 | it "should have zeroes added if missing" do |
4673 | Facter::Util::Macaddress::standardize("0:ab:cd:e:12:3").should == "00:ab:cd:0e:12:03" |
4674 | end |
4675 | - |
4676 | + |
4677 | it "should be identical if each octet already has two digits" do |
4678 | Facter::Util::Macaddress::standardize("00:ab:cd:0e:12:03").should == "00:ab:cd:0e:12:03" |
4679 | end |
4680 | + |
4681 | + it "should be nil if input is nil" do |
4682 | + proc { result = Facter::Util::Macaddress.standardize(nil) }.should_not raise_error |
4683 | + Facter::Util::Macaddress.standardize(nil).should be_nil |
4684 | + end |
4685 | end |
4686 | |
4687 | describe "Darwin", :unless => Facter.value(:operatingsystem) == 'windows' do |
4688 | |
4689 | === modified file 'spec/unit/util/macosx_spec.rb' |
4690 | --- spec/unit/util/macosx_spec.rb 2011-03-18 12:06:08 +0000 |
4691 | +++ spec/unit/util/macosx_spec.rb 2012-01-27 20:04:26 +0000 |
4692 | @@ -5,77 +5,77 @@ |
4693 | require 'facter/util/macosx' |
4694 | |
4695 | describe Facter::Util::Macosx do |
4696 | - it "should be able to retrieve profiler data as xml for a given data field" do |
4697 | - Facter::Util::Resolution.expects(:exec).with("/usr/sbin/system_profiler -xml foo").returns "yay" |
4698 | - Facter::Util::Macosx.profiler_xml("foo").should == "yay" |
4699 | - end |
4700 | - |
4701 | - it "should use PList to convert xml to data structures" do |
4702 | - Plist.expects(:parse_xml).with("foo").returns "bar" |
4703 | - |
4704 | - Facter::Util::Macosx.intern_xml("foo").should == "bar" |
4705 | - end |
4706 | - |
4707 | - describe "when collecting profiler data" do |
4708 | - it "should return the first value in the '_items' hash in the first value of the results of the system_profiler data, with the '_name' field removed, if the profiler returns data" do |
4709 | - @result = [ |
4710 | - '_items' => [ |
4711 | - {'_name' => "foo", "yay" => "bar"} |
4712 | - ] |
4713 | - ] |
4714 | - Facter::Util::Macosx.expects(:profiler_xml).with("foo").returns "eh" |
4715 | - Facter::Util::Macosx.expects(:intern_xml).with("eh").returns @result |
4716 | - Facter::Util::Macosx.profiler_data("foo").should == {"yay" => "bar"} |
4717 | - end |
4718 | - |
4719 | - it "should return nil if an exception is thrown during parsing of xml" do |
4720 | - Facter::Util::Macosx.expects(:profiler_xml).with("foo").returns "eh" |
4721 | - Facter::Util::Macosx.expects(:intern_xml).with("eh").raises "boo!" |
4722 | - Facter::Util::Macosx.profiler_data("foo").should be_nil |
4723 | - end |
4724 | - end |
4725 | - |
4726 | - it "should return the profiler data for 'SPHardwareDataType' as the hardware information" do |
4727 | - Facter::Util::Macosx.expects(:profiler_data).with("SPHardwareDataType").returns "eh" |
4728 | - Facter::Util::Macosx.hardware_overview.should == "eh" |
4729 | - end |
4730 | - |
4731 | - it "should return the profiler data for 'SPSoftwareDataType' as the os information" do |
4732 | - Facter::Util::Macosx.expects(:profiler_data).with("SPSoftwareDataType").returns "eh" |
4733 | - Facter::Util::Macosx.os_overview.should == "eh" |
4734 | - end |
4735 | - |
4736 | - describe "when working out software version" do |
4737 | - |
4738 | - before do |
4739 | - Facter::Util::Resolution.expects(:exec).with("/usr/bin/sw_vers -productName").returns "Mac OS X" |
4740 | - Facter::Util::Resolution.expects(:exec).with("/usr/bin/sw_vers -buildVersion").returns "9J62" |
4741 | - end |
4742 | - |
4743 | - it "should have called sw_vers three times when determining software version" do |
4744 | - Facter::Util::Resolution.expects(:exec).with("/usr/bin/sw_vers -productVersion").returns "10.5.7" |
4745 | - Facter::Util::Macosx.sw_vers |
4746 | - end |
4747 | - |
4748 | - it "should return a hash with the correct keys when determining software version" do |
4749 | - Facter::Util::Resolution.expects(:exec).with("/usr/bin/sw_vers -productVersion").returns "10.5.7" |
4750 | - Facter::Util::Macosx.sw_vers.keys.sort.should == ["macosx_productName", |
4751 | - "macosx_buildVersion", |
4752 | - "macosx_productversion_minor", |
4753 | - "macosx_productversion_major", |
4754 | - "macosx_productVersion"].sort |
4755 | - end |
4756 | - |
4757 | - it "should split a product version of 'x.y.z' into separate hash entries correctly" do |
4758 | - Facter::Util::Resolution.expects(:exec).with("/usr/bin/sw_vers -productVersion").returns "1.2.3" |
4759 | - sw_vers = Facter::Util::Macosx.sw_vers |
4760 | - sw_vers["macosx_productversion_major"].should == "1.2" |
4761 | - sw_vers["macosx_productversion_minor"].should == "3" |
4762 | - end |
4763 | - |
4764 | - it "should treat a product version of 'x.y' as 'x.y.0" do |
4765 | - Facter::Util::Resolution.expects(:exec).with("/usr/bin/sw_vers -productVersion").returns "2.3" |
4766 | - Facter::Util::Macosx.sw_vers["macosx_productversion_minor"].should == "0" |
4767 | - end |
4768 | - end |
4769 | + it "should be able to retrieve profiler data as xml for a given data field" do |
4770 | + Facter::Util::Resolution.expects(:exec).with("/usr/sbin/system_profiler -xml foo").returns "yay" |
4771 | + Facter::Util::Macosx.profiler_xml("foo").should == "yay" |
4772 | + end |
4773 | + |
4774 | + it "should use PList to convert xml to data structures" do |
4775 | + Plist.expects(:parse_xml).with("foo").returns "bar" |
4776 | + |
4777 | + Facter::Util::Macosx.intern_xml("foo").should == "bar" |
4778 | + end |
4779 | + |
4780 | + describe "when collecting profiler data" do |
4781 | + it "should return the first value in the '_items' hash in the first value of the results of the system_profiler data, with the '_name' field removed, if the profiler returns data" do |
4782 | + @result = [ |
4783 | + '_items' => [ |
4784 | + {'_name' => "foo", "yay" => "bar"} |
4785 | + ] |
4786 | + ] |
4787 | + Facter::Util::Macosx.expects(:profiler_xml).with("foo").returns "eh" |
4788 | + Facter::Util::Macosx.expects(:intern_xml).with("eh").returns @result |
4789 | + Facter::Util::Macosx.profiler_data("foo").should == {"yay" => "bar"} |
4790 | + end |
4791 | + |
4792 | + it "should return nil if an exception is thrown during parsing of xml" do |
4793 | + Facter::Util::Macosx.expects(:profiler_xml).with("foo").returns "eh" |
4794 | + Facter::Util::Macosx.expects(:intern_xml).with("eh").raises "boo!" |
4795 | + Facter::Util::Macosx.profiler_data("foo").should be_nil |
4796 | + end |
4797 | + end |
4798 | + |
4799 | + it "should return the profiler data for 'SPHardwareDataType' as the hardware information" do |
4800 | + Facter::Util::Macosx.expects(:profiler_data).with("SPHardwareDataType").returns "eh" |
4801 | + Facter::Util::Macosx.hardware_overview.should == "eh" |
4802 | + end |
4803 | + |
4804 | + it "should return the profiler data for 'SPSoftwareDataType' as the os information" do |
4805 | + Facter::Util::Macosx.expects(:profiler_data).with("SPSoftwareDataType").returns "eh" |
4806 | + Facter::Util::Macosx.os_overview.should == "eh" |
4807 | + end |
4808 | + |
4809 | + describe "when working out software version" do |
4810 | + |
4811 | + before do |
4812 | + Facter::Util::Resolution.expects(:exec).with("/usr/bin/sw_vers -productName").returns "Mac OS X" |
4813 | + Facter::Util::Resolution.expects(:exec).with("/usr/bin/sw_vers -buildVersion").returns "9J62" |
4814 | + end |
4815 | + |
4816 | + it "should have called sw_vers three times when determining software version" do |
4817 | + Facter::Util::Resolution.expects(:exec).with("/usr/bin/sw_vers -productVersion").returns "10.5.7" |
4818 | + Facter::Util::Macosx.sw_vers |
4819 | + end |
4820 | + |
4821 | + it "should return a hash with the correct keys when determining software version" do |
4822 | + Facter::Util::Resolution.expects(:exec).with("/usr/bin/sw_vers -productVersion").returns "10.5.7" |
4823 | + Facter::Util::Macosx.sw_vers.keys.sort.should == ["macosx_productName", |
4824 | + "macosx_buildVersion", |
4825 | + "macosx_productversion_minor", |
4826 | + "macosx_productversion_major", |
4827 | + "macosx_productVersion"].sort |
4828 | + end |
4829 | + |
4830 | + it "should split a product version of 'x.y.z' into separate hash entries correctly" do |
4831 | + Facter::Util::Resolution.expects(:exec).with("/usr/bin/sw_vers -productVersion").returns "1.2.3" |
4832 | + sw_vers = Facter::Util::Macosx.sw_vers |
4833 | + sw_vers["macosx_productversion_major"].should == "1.2" |
4834 | + sw_vers["macosx_productversion_minor"].should == "3" |
4835 | + end |
4836 | + |
4837 | + it "should treat a product version of 'x.y' as 'x.y.0" do |
4838 | + Facter::Util::Resolution.expects(:exec).with("/usr/bin/sw_vers -productVersion").returns "2.3" |
4839 | + Facter::Util::Macosx.sw_vers["macosx_productversion_minor"].should == "0" |
4840 | + end |
4841 | + end |
4842 | end |
4843 | |
4844 | === modified file 'spec/unit/util/manufacturer_spec.rb' |
4845 | --- spec/unit/util/manufacturer_spec.rb 2011-10-06 10:48:30 +0000 |
4846 | +++ spec/unit/util/manufacturer_spec.rb 2012-01-27 20:04:26 +0000 |
4847 | @@ -3,52 +3,69 @@ |
4848 | require 'facter/util/manufacturer' |
4849 | |
4850 | describe Facter::Manufacturer do |
4851 | - before :each do |
4852 | - Facter.clear |
4853 | - end |
4854 | - |
4855 | - it "should return the system DMI table" do |
4856 | - Facter::Manufacturer.should respond_to(:get_dmi_table) |
4857 | - end |
4858 | - |
4859 | - it "should return nil on non-supported operating systems" do |
4860 | - Facter.stubs(:value).with(:kernel).returns("SomeThing") |
4861 | - Facter::Manufacturer.get_dmi_table().should be_nil |
4862 | - end |
4863 | - |
4864 | - it "should parse prtdiag output" do |
4865 | - Facter::Util::Resolution.stubs(:exec).returns("System Configuration: Sun Microsystems sun4u Sun SPARC Enterprise M3000 Server") |
4866 | - Facter::Manufacturer.prtdiag_sparc_find_system_info() |
4867 | - Facter.value(:manufacturer).should == "Sun Microsystems" |
4868 | - Facter.value(:productname).should == "Sun SPARC Enterprise M3000 Server" |
4869 | - end |
4870 | - |
4871 | - it "should strip white space on dmi output with spaces" do |
4872 | - sample_output_file = File.dirname(__FILE__) + "/../data/linux_dmidecode_with_spaces" |
4873 | - dmidecode_output = File.new(sample_output_file).read() |
4874 | - Facter::Manufacturer.expects(:get_dmi_table).returns(dmidecode_output) |
4875 | - Facter.fact(:kernel).stubs(:value).returns("Linux") |
4876 | - |
4877 | - query = { '[Ss]ystem [Ii]nformation' => [ { 'Product(?: Name)?:' => 'productname' } ] } |
4878 | - |
4879 | - Facter::Manufacturer.dmi_find_system_info(query) |
4880 | - Facter.value(:productname).should == "MS-6754" |
4881 | - end |
4882 | - |
4883 | - it "should handle output from smbios when run under sunos" do |
4884 | - sample_output_file = File.dirname(__FILE__) + "/../data/opensolaris_smbios" |
4885 | - smbios_output = File.new(sample_output_file).read() |
4886 | - Facter::Manufacturer.expects(:get_dmi_table).returns(smbios_output) |
4887 | - Facter.fact(:kernel).stubs(:value).returns("SunOS") |
4888 | - |
4889 | - query = { 'BIOS information' => [ { 'Release Date:' => 'reldate' } ] } |
4890 | - |
4891 | - Facter::Manufacturer.dmi_find_system_info(query) |
4892 | - Facter.value(:reldate).should == "12/01/2006" |
4893 | - end |
4894 | - |
4895 | - it "should not split on dmi keys containing the string Handle" do |
4896 | - dmidecode_output = <<-eos |
4897 | + before :each do |
4898 | + Facter.clear |
4899 | + end |
4900 | + |
4901 | + it "should return the system DMI table" do |
4902 | + Facter::Manufacturer.should respond_to(:get_dmi_table) |
4903 | + end |
4904 | + |
4905 | + it "should return nil on non-supported operating systems" do |
4906 | + Facter.stubs(:value).with(:kernel).returns("SomeThing") |
4907 | + Facter::Manufacturer.get_dmi_table().should be_nil |
4908 | + end |
4909 | + |
4910 | + it "should parse prtdiag output on a sunfire v120" do |
4911 | + Facter::Util::Resolution.stubs(:exec).returns(fixture_data(File.join("unit", "util", "manufacturer", "solaris_sunfire_v120_prtdiag"))) |
4912 | + Facter::Manufacturer.prtdiag_sparc_find_system_info() |
4913 | + Facter.value(:manufacturer).should == "Sun Microsystems" |
4914 | + Facter.value(:productname).should == "Sun Fire V120 (UltraSPARC-IIe 648MHz)" |
4915 | + end |
4916 | + |
4917 | + it "should parse prtdiag output on a t5220" do |
4918 | + Facter::Util::Resolution.stubs(:exec).returns(fixture_data(File.join("unit", "util", "manufacturer", "solaris_t5220_prtdiag"))) |
4919 | + Facter::Manufacturer.prtdiag_sparc_find_system_info() |
4920 | + Facter.value(:manufacturer).should == "Sun Microsystems" |
4921 | + Facter.value(:productname).should == "SPARC Enterprise T5220" |
4922 | + end |
4923 | + |
4924 | + it "should not set manufacturer or productname if prtdiag output is nil" do |
4925 | + # Stub kernel so we don't have windows fall through to its own mechanism |
4926 | + Facter.fact(:kernel).stubs(:value).returns("SunOS") |
4927 | + |
4928 | + Facter::Util::Resolution.stubs(:exec).returns(nil) |
4929 | + Facter::Manufacturer.prtdiag_sparc_find_system_info() |
4930 | + Facter.value(:manufacturer).should be_nil |
4931 | + Facter.value(:productname).should be_nil |
4932 | + end |
4933 | + |
4934 | + it "should strip white space on dmi output with spaces" do |
4935 | + sample_output_file = File.dirname(__FILE__) + "/../data/linux_dmidecode_with_spaces" |
4936 | + dmidecode_output = File.new(sample_output_file).read() |
4937 | + Facter::Manufacturer.expects(:get_dmi_table).returns(dmidecode_output) |
4938 | + Facter.fact(:kernel).stubs(:value).returns("Linux") |
4939 | + |
4940 | + query = { '[Ss]ystem [Ii]nformation' => [ { 'Product(?: Name)?:' => 'productname' } ] } |
4941 | + |
4942 | + Facter::Manufacturer.dmi_find_system_info(query) |
4943 | + Facter.value(:productname).should == "MS-6754" |
4944 | + end |
4945 | + |
4946 | + it "should handle output from smbios when run under sunos" do |
4947 | + sample_output_file = File.dirname(__FILE__) + "/../data/opensolaris_smbios" |
4948 | + smbios_output = File.new(sample_output_file).read() |
4949 | + Facter::Manufacturer.expects(:get_dmi_table).returns(smbios_output) |
4950 | + Facter.fact(:kernel).stubs(:value).returns("SunOS") |
4951 | + |
4952 | + query = { 'BIOS information' => [ { 'Release Date:' => 'reldate' } ] } |
4953 | + |
4954 | + Facter::Manufacturer.dmi_find_system_info(query) |
4955 | + Facter.value(:reldate).should == "12/01/2006" |
4956 | + end |
4957 | + |
4958 | + it "should not split on dmi keys containing the string Handle" do |
4959 | + dmidecode_output = <<-eos |
4960 | Handle 0x1000, DMI type 16, 15 bytes |
4961 | Physical Memory Array |
4962 | Location: System Board Or Motherboard |
4963 | @@ -61,16 +78,16 @@ |
4964 | Handle 0x001F |
4965 | DMI type 127, 4 bytes. |
4966 | End Of Table |
4967 | - eos |
4968 | - Facter::Manufacturer.expects(:get_dmi_table).returns(dmidecode_output) |
4969 | - Facter.fact(:kernel).stubs(:value).returns("Linux") |
4970 | - query = { 'Physical Memory Array' => [ { 'Number Of Devices:' => 'ramslots'}]} |
4971 | - Facter::Manufacturer.dmi_find_system_info(query) |
4972 | - Facter.value(:ramslots).should == "123" |
4973 | - end |
4974 | + eos |
4975 | + Facter::Manufacturer.expects(:get_dmi_table).returns(dmidecode_output) |
4976 | + Facter.fact(:kernel).stubs(:value).returns("Linux") |
4977 | + query = { 'Physical Memory Array' => [ { 'Number Of Devices:' => 'ramslots'}]} |
4978 | + Facter::Manufacturer.dmi_find_system_info(query) |
4979 | + Facter.value(:ramslots).should == "123" |
4980 | + end |
4981 | |
4982 | - it "should match the key in the defined section and not the first one found" do |
4983 | - dmidecode_output = <<-eos |
4984 | + it "should match the key in the defined section and not the first one found" do |
4985 | + dmidecode_output = <<-eos |
4986 | Handle 0x000C, DMI type 7, 19 bytes |
4987 | Cache Information |
4988 | Socket Designation: Internal L2 Cache |
4989 | @@ -99,55 +116,55 @@ |
4990 | Handle 0x001F |
4991 | DMI type 127, 4 bytes. |
4992 | End Of Table |
4993 | - eos |
4994 | - Facter::Manufacturer.expects(:get_dmi_table).returns(dmidecode_output) |
4995 | - Facter.fact(:kernel).stubs(:value).returns("Linux") |
4996 | - query = { 'Physical Memory Array' => [ { 'Location:' => 'ramlocation'}]} |
4997 | - Facter::Manufacturer.dmi_find_system_info(query) |
4998 | - Facter.value(:ramlocation).should == "System Board Or Motherboard" |
4999 | - end |
5000 | - |
The diff has been truncated for viewing.
This was uploaded a few moments ago and pushed to the bzr branch in r18.