facter 1.7.3 → 1.7.4.rc1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of facter might be problematic. Click here for more details.
- data/Gemfile +10 -7
- data/bin/facter +0 -58
- data/ext/build_defaults.yaml +2 -2
- data/ext/debian/rules +1 -1
- data/lib/facter/application.rb +69 -24
- data/lib/facter/architecture.rb +14 -1
- data/lib/facter/operatingsystemrelease.rb +3 -3
- data/lib/facter/util/architecture.rb +19 -0
- data/lib/facter/util/collection.rb +13 -7
- data/lib/facter/util/config.rb +11 -5
- data/lib/facter/util/ip/windows.rb +2 -2
- data/lib/facter/util/loader.rb +1 -1
- data/lib/facter/util/memory.rb +19 -3
- data/lib/facter/util/parser.rb +13 -5
- data/lib/facter/util/processor.rb +2 -0
- data/lib/facter/util/resolution.rb +3 -3
- data/lib/facter/util/unix_root.rb +5 -0
- data/lib/facter/util/windows_root.rb +37 -0
- data/lib/facter/version.rb +1 -1
- data/lib/facter/virtual.rb +20 -10
- data/spec/fixtures/cpuinfo/amd64twentyfour +600 -0
- data/spec/fixtures/hpux/machinfo/superdome-server-SD32B +53 -0
- data/spec/fixtures/hpux/machinfo/superdome2-16s +31 -0
- data/spec/fixtures/processorcount/solaris-psrinfo +24 -0
- data/spec/lib/facter_spec/cpuinfo.rb +15 -0
- data/spec/unit/architecture_spec.rb +8 -0
- data/spec/unit/ec2_spec.rb +1 -1
- data/spec/unit/memory_spec.rb +27 -4
- data/spec/unit/operatingsystemrelease_spec.rb +2 -2
- data/spec/unit/processor_spec.rb +120 -151
- data/spec/unit/util/collection_spec.rb +17 -1
- data/spec/unit/util/config_spec.rb +9 -0
- data/spec/unit/util/ip/windows_spec.rb +34 -2
- data/spec/unit/util/loader_spec.rb +1 -1
- data/spec/unit/util/parser_spec.rb +65 -51
- data/spec/unit/util/processor_spec.rb +7 -8
- data/spec/unit/util/resolution_spec.rb +3 -3
- data/spec/unit/virtual_spec.rb +18 -0
- metadata +491 -478
@@ -0,0 +1,53 @@
|
|
1
|
+
CPU info:
|
2
|
+
Number of CPUs = 8
|
3
|
+
Number of enabled CPUs = 2
|
4
|
+
Number of enabled sockets = 2
|
5
|
+
Cores per socket = 2
|
6
|
+
Clock speed = 1598 MHz
|
7
|
+
Bus speed = 533 MT/s
|
8
|
+
CPUID registers
|
9
|
+
vendor information = "GenuineIntel"
|
10
|
+
processor serial number = 0x0000000000000000
|
11
|
+
processor version info = 0x0000000020000704
|
12
|
+
architecture revision: 0
|
13
|
+
processor family: 32 Intel(R) Itanium 2 9000 series
|
14
|
+
processor model: 1 Intel(R) Itanium 2 9000 series
|
15
|
+
Bus features
|
16
|
+
implemented = 0xbdf0000020000000
|
17
|
+
selected = 0x0020000000000000
|
18
|
+
Exclusive Bus Cache Line Replacement Enabled
|
19
|
+
processor revision: 7 Stepping C2
|
20
|
+
largest CPUID reg: 4
|
21
|
+
processor capabilities = 0x0000000000000005
|
22
|
+
implements long branch: 1
|
23
|
+
implements 16-byte atomic operations: 1
|
24
|
+
|
25
|
+
Cache info (per core):
|
26
|
+
L1 Instruction: size = 16 KB, associativity = 4
|
27
|
+
L1 Data: size = 16 KB, associativity = 4
|
28
|
+
L2 Instruction: size = 1024 KB, associativity = 8
|
29
|
+
L2 Data: size = 256 KB, associativity = 8
|
30
|
+
L3 Unified: size = 12288 KB, associativity = 12
|
31
|
+
|
32
|
+
Memory = 32700 MB (31.933594 GB)
|
33
|
+
|
34
|
+
Firmware info:
|
35
|
+
Firmware revision = 9.66
|
36
|
+
FP SWA driver revision: 1.18
|
37
|
+
IPMI is supported on this system.
|
38
|
+
ERROR: Unable to obtain manageability firmware revision info.
|
39
|
+
|
40
|
+
Platform info:
|
41
|
+
model string = "ia64 hp superdome server SD32B"
|
42
|
+
machine id number = STRING_WITH_DASHES
|
43
|
+
machine serial number = STRING
|
44
|
+
|
45
|
+
OS info:
|
46
|
+
sysname = HP-UX
|
47
|
+
nodename = HOSTNAME
|
48
|
+
release = B.11.23
|
49
|
+
version = U (unlimited-user license)
|
50
|
+
machine = ia64
|
51
|
+
idnumber = NUMBER
|
52
|
+
vmunix _release_version:
|
53
|
+
@(#) $Revision: vmunix: B11.23_LR FLAVOR=perf Fri Aug 29 22:35:38 PDT 2003 $
|
@@ -0,0 +1,31 @@
|
|
1
|
+
CPU info:
|
2
|
+
Intel(R) Itanium(R) Processor 9340 (1.6 GHz, 15 MB)
|
3
|
+
4 cores, 8 logical processors per socket
|
4
|
+
4.79 GT/s QPI, CPU version E0
|
5
|
+
Active processor count:
|
6
|
+
2 sockets
|
7
|
+
6 cores (3 per socket)
|
8
|
+
12 logical processors (6 per socket)
|
9
|
+
LCPU attribute is enabled
|
10
|
+
|
11
|
+
Memory: 14332 MB (14 GB)
|
12
|
+
|
13
|
+
Firmware info:
|
14
|
+
Firmware revision: 004.044.000
|
15
|
+
FP SWA driver revision: 1.18
|
16
|
+
IPMI is supported on this system.
|
17
|
+
BMC firmware revision: 2.53
|
18
|
+
|
19
|
+
Platform info:
|
20
|
+
Model: "ia64 hp Superdome2 16s"
|
21
|
+
Machine ID number: STRING_WITH_DASHES
|
22
|
+
Machine serial number: STRING
|
23
|
+
|
24
|
+
OS info:
|
25
|
+
Nodename: HOSTNAME
|
26
|
+
Release: HP-UX B.11.31
|
27
|
+
Version: U (unlimited-user license)
|
28
|
+
Machine: ia64
|
29
|
+
ID Number: NUMBER
|
30
|
+
vmunix _release_version:
|
31
|
+
@(#) $Revision: vmunix: B.11.31_LR FLAVOR=perf
|
@@ -0,0 +1,24 @@
|
|
1
|
+
0 on-line since 10/01/2012 21:05:55
|
2
|
+
1 on-line since 10/01/2012 21:06:00
|
3
|
+
2 on-line since 10/01/2012 21:06:00
|
4
|
+
3 on-line since 10/01/2012 21:06:00
|
5
|
+
4 on-line since 10/01/2012 21:06:00
|
6
|
+
5 on-line since 10/01/2012 21:06:00
|
7
|
+
6 on-line since 10/01/2012 21:06:00
|
8
|
+
7 on-line since 10/01/2012 21:06:00
|
9
|
+
8 on-line since 10/01/2012 21:06:00
|
10
|
+
9 on-line since 10/01/2012 21:06:00
|
11
|
+
10 on-line since 10/01/2012 21:06:00
|
12
|
+
11 on-line since 10/01/2012 21:06:00
|
13
|
+
12 on-line since 10/01/2012 21:06:01
|
14
|
+
13 on-line since 10/01/2012 21:06:01
|
15
|
+
14 on-line since 10/01/2012 21:06:01
|
16
|
+
15 on-line since 10/01/2012 21:06:01
|
17
|
+
16 on-line since 10/01/2012 21:06:01
|
18
|
+
17 on-line since 10/01/2012 21:06:01
|
19
|
+
18 on-line since 10/01/2012 21:06:01
|
20
|
+
19 on-line since 10/01/2012 21:06:01
|
21
|
+
20 on-line since 10/01/2012 21:06:01
|
22
|
+
21 on-line since 10/01/2012 21:06:01
|
23
|
+
22 on-line since 10/01/2012 21:06:01
|
24
|
+
23 on-line since 10/01/2012 21:06:01
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module FacterSpec::Cpuinfo
|
4
|
+
def cpuinfo_fixtures(filename)
|
5
|
+
fixtures('cpuinfo', filename)
|
6
|
+
end
|
7
|
+
|
8
|
+
def cpuinfo_fixture_read(filename)
|
9
|
+
File.read(cpuinfo_fixtures(filename))
|
10
|
+
end
|
11
|
+
|
12
|
+
def cpuinfo_fixture_readlines(filename)
|
13
|
+
cpuinfo_fixture_read(filename).split(/\n/)
|
14
|
+
end
|
15
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
|
+
require 'facter/util/architecture'
|
4
5
|
|
5
6
|
describe "Architecture fact" do
|
6
7
|
|
@@ -52,4 +53,11 @@ describe "Architecture fact" do
|
|
52
53
|
end
|
53
54
|
end
|
54
55
|
|
56
|
+
it "(#16081) should be PowerPC_POWER7 if os is AIX" do
|
57
|
+
Facter.fact(:kernel).stubs(:value).returns("AIX")
|
58
|
+
Facter::Util::Architecture.stubs(:lsattr).returns("type PowerPC_POWER7 Processor type False")
|
59
|
+
Facter.fact(:hardwaremodel).stubs(:value).returns("IBM,8233-E8B")
|
60
|
+
Facter.fact(:architecture).value.should == "PowerPC_POWER7"
|
61
|
+
end
|
62
|
+
|
55
63
|
end
|
data/spec/unit/ec2_spec.rb
CHANGED
@@ -136,8 +136,8 @@ describe "ec2 facts" do
|
|
136
136
|
end
|
137
137
|
|
138
138
|
it "should return nil if open fails" do
|
139
|
+
Facter.stubs(:warn) # do not pollute test output
|
139
140
|
Facter.expects(:warn).with('Could not retrieve ec2 metadata: host unreachable')
|
140
|
-
Facter::Util::Resolution.any_instance.stubs(:warn) # do not pollute test output
|
141
141
|
|
142
142
|
Object.any_instance.expects(:open).
|
143
143
|
with("#{api_prefix}/2008-02-01/meta-data/").
|
data/spec/unit/memory_spec.rb
CHANGED
@@ -154,7 +154,21 @@ device maj,min total free
|
|
154
154
|
/dev/hd6 10, 2 512MB 508MB
|
155
155
|
SWAP
|
156
156
|
|
157
|
-
Facter::Util::Resolution.stubs(:exec).with('swap -l').returns(swapusage)
|
157
|
+
Facter::Util::Resolution.stubs(:exec).with('swap -l 2>/dev/null').returns(swapusage)
|
158
|
+
|
159
|
+
svmon = <<SVMON
|
160
|
+
Unit: KB
|
161
|
+
--------------------------------------------------------------------------------------
|
162
|
+
size inuse free pin virtual available mmode
|
163
|
+
memory 32768000 9948408 22819592 2432080 4448928 27231828 Ded
|
164
|
+
pg space 34078720 15000
|
165
|
+
|
166
|
+
work pers clnt other
|
167
|
+
pin 1478228 0 0 953852
|
168
|
+
in use 4448928 0 5499480
|
169
|
+
SVMON
|
170
|
+
|
171
|
+
Facter::Util::Resolution.stubs(:exec).with('/usr/bin/svmon -O unit=KB').returns(svmon)
|
158
172
|
|
159
173
|
Facter.collection.internal_loader.load(:memory)
|
160
174
|
end
|
@@ -190,6 +204,15 @@ SWAP
|
|
190
204
|
Facter.fact(:swapfree_mb).value.should == "508.00"
|
191
205
|
end
|
192
206
|
end
|
207
|
+
|
208
|
+
it "should return the current memory free in MB" do
|
209
|
+
Facter.fact(:memoryfree_mb).value.should == "22284.76"
|
210
|
+
end
|
211
|
+
|
212
|
+
it "should return the current memory size in MB" do
|
213
|
+
Facter.fact(:memorysize_mb).value.should == "32000.00"
|
214
|
+
end
|
215
|
+
|
193
216
|
end
|
194
217
|
|
195
218
|
|
@@ -264,7 +287,7 @@ VMSTAT
|
|
264
287
|
swapfile dev swaplo blocks free
|
265
288
|
/dev/swap 4294967295,4294967295 16 2097136 2097136
|
266
289
|
SWAP
|
267
|
-
Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/swap -l').returns sample_swap_line
|
290
|
+
Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/swap -l 2>/dev/null').returns sample_swap_line
|
268
291
|
|
269
292
|
Facter.collection.internal_loader.load(:memory)
|
270
293
|
end
|
@@ -293,7 +316,7 @@ swapfile dev swaplo blocks free
|
|
293
316
|
/dev/swap 4294967295,4294967295 16 2097136 2097136
|
294
317
|
/dev/swap2 4294967295,4294967295 16 2097136 2097136
|
295
318
|
SWAP
|
296
|
-
Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/swap -l').returns sample_swap_line
|
319
|
+
Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/swap -l 2>/dev/null').returns sample_swap_line
|
297
320
|
Facter.collection.internal_loader.load(:memory)
|
298
321
|
end
|
299
322
|
|
@@ -316,7 +339,7 @@ SWAP
|
|
316
339
|
|
317
340
|
describe "when no swap exists" do
|
318
341
|
before(:each) do
|
319
|
-
Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/swap -l').returns ""
|
342
|
+
Facter::Util::Resolution.stubs(:exec).with('/usr/sbin/swap -l 2>/dev/null').returns ""
|
320
343
|
|
321
344
|
Facter.collection.internal_loader.load(:memory)
|
322
345
|
end
|
@@ -154,14 +154,14 @@ describe "Operating System Release fact" do
|
|
154
154
|
end
|
155
155
|
|
156
156
|
context "Ubuntu" do
|
157
|
-
let(:
|
157
|
+
let(:lsbrelease) { 'DISTRIB_ID=Ubuntu\nDISTRIB_RELEASE=10.04\nDISTRIB_CODENAME=lucid\nDISTRIB_DESCRIPTION="Ubuntu 10.04.4 LTS"'}
|
158
158
|
before :each do
|
159
159
|
Facter.fact(:kernel).stubs(:value).returns("Linux")
|
160
160
|
Facter.fact(:operatingsystem).stubs(:value).returns("Ubuntu")
|
161
161
|
end
|
162
162
|
|
163
163
|
it "Returns only the major and minor version (not patch version)" do
|
164
|
-
Facter::Util::FileRead.stubs(:read).with("/etc/
|
164
|
+
Facter::Util::FileRead.stubs(:read).with("/etc/lsb-release").returns(lsbrelease)
|
165
165
|
Facter.fact(:operatingsystemrelease).value.should == "10.04"
|
166
166
|
end
|
167
167
|
end
|
data/spec/unit/processor_spec.rb
CHANGED
@@ -2,10 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'facter/util/processor'
|
4
4
|
require 'spec_helper'
|
5
|
-
|
6
|
-
def cpuinfo_fixture(filename)
|
7
|
-
File.open(fixtures('cpuinfo', filename)).readlines
|
8
|
-
end
|
5
|
+
require 'facter_spec/cpuinfo'
|
9
6
|
|
10
7
|
describe "Processor facts" do
|
11
8
|
describe "on Windows" do
|
@@ -68,111 +65,122 @@ describe "Processor facts" do
|
|
68
65
|
end
|
69
66
|
end
|
70
67
|
|
71
|
-
describe "on
|
72
|
-
|
73
|
-
Facter.collection.internal_loader.load(:processor)
|
74
|
-
Facter.fact(:kernel).stubs(:value).returns(:sunos)
|
75
|
-
Facter.stubs(:value).with(:kernelrelease).returns("5.10")
|
76
|
-
end
|
68
|
+
describe "on Linux" do
|
69
|
+
include FacterSpec::Cpuinfo
|
77
70
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
Facter.fact(:processorcount).value.should == 8
|
82
|
-
end
|
71
|
+
shared_context 'Linux processor stubs' do
|
72
|
+
before :each do
|
73
|
+
Facter.collection.internal_loader.load(:processor)
|
83
74
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
75
|
+
Facter.fact(:kernel).stubs(:value).returns 'Linux'
|
76
|
+
Facter.fact(:operatingsystem).stubs(:value).returns 'Linux'
|
77
|
+
File.stubs(:exists?).with("/proc/cpuinfo").returns(true)
|
78
|
+
end
|
88
79
|
end
|
89
|
-
end
|
90
80
|
|
91
|
-
|
92
|
-
|
93
|
-
Facter.collection.internal_loader.load(:processor)
|
94
|
-
end
|
81
|
+
shared_examples_for 'a /proc/cpuinfo based processor fact' do |processor_fact|
|
82
|
+
include_context 'Linux processor stubs'
|
95
83
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
Facter.fact(:architecture).stubs(:value).returns("sparc")
|
100
|
-
File.stubs(:exists?).with("/proc/cpuinfo").returns(true)
|
101
|
-
File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture("sparc"))
|
84
|
+
it "should be 1 in SPARC fixture" do
|
85
|
+
Facter.fact(:architecture).stubs(:value).returns("sparc")
|
86
|
+
File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture_readlines("sparc"))
|
102
87
|
|
103
|
-
|
104
|
-
|
88
|
+
Facter.fact(processor_fact).value.should == "1"
|
89
|
+
end
|
105
90
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
File.stubs(:exists?).with("/proc/cpuinfo").returns(true)
|
110
|
-
File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture("ppc64"))
|
91
|
+
it "should be 2 in ppc64 fixture on Linux" do
|
92
|
+
Facter.fact(:architecture).stubs(:value).returns("ppc64")
|
93
|
+
File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture_readlines("ppc64"))
|
111
94
|
|
112
|
-
|
113
|
-
|
95
|
+
Facter.fact(processor_fact).value.should == "2"
|
96
|
+
end
|
114
97
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
File.stubs(:exists?).with("/proc/cpuinfo").returns(true)
|
119
|
-
File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture("panda-armel"))
|
98
|
+
it "should be 2 in panda-armel fixture on Linux" do
|
99
|
+
Facter.fact(:architecture).stubs(:value).returns("arm")
|
100
|
+
File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture_readlines("panda-armel"))
|
120
101
|
|
121
|
-
|
122
|
-
|
102
|
+
Facter.fact(processor_fact).value.should == "2"
|
103
|
+
end
|
123
104
|
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
File.stubs(:exists?).with("/proc/cpuinfo").returns(true)
|
128
|
-
File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture("bbg3-armel"))
|
105
|
+
it "should be 1 in bbg3-armel fixture on Linux" do
|
106
|
+
Facter.fact(:architecture).stubs(:value).returns("arm")
|
107
|
+
File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture_readlines("bbg3-armel"))
|
129
108
|
|
130
|
-
|
131
|
-
|
109
|
+
Facter.fact(processor_fact).value.should == "1"
|
110
|
+
end
|
132
111
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
File.stubs(:exists?).with("/proc/cpuinfo").returns(true)
|
137
|
-
File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture("beaglexm-armel"))
|
112
|
+
it "should be 1 in beaglexm-armel fixture on Linux" do
|
113
|
+
Facter.fact(:architecture).stubs(:value).returns("arm")
|
114
|
+
File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture_readlines("beaglexm-armel"))
|
138
115
|
|
139
|
-
|
140
|
-
|
116
|
+
Facter.fact(processor_fact).value.should == "1"
|
117
|
+
end
|
118
|
+
|
119
|
+
it "should be 1 in amd64solo fixture on Linux" do
|
120
|
+
Facter.fact(:architecture).stubs(:value).returns("amd64")
|
121
|
+
File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture_readlines("amd64solo"))
|
122
|
+
|
123
|
+
Facter.fact(processor_fact).value.should == "1"
|
124
|
+
end
|
141
125
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
File.stubs(:exists?).with("/proc/cpuinfo").returns(true)
|
146
|
-
File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture("amd64solo"))
|
126
|
+
it "should be 2 in amd64dual fixture on Linux" do
|
127
|
+
Facter.fact(:architecture).stubs(:value).returns("amd64")
|
128
|
+
File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture_readlines("amd64dual"))
|
147
129
|
|
148
|
-
|
130
|
+
Facter.fact(processor_fact).value.should == "2"
|
131
|
+
end
|
132
|
+
|
133
|
+
it "should be 3 in amd64tri fixture on Linux" do
|
134
|
+
Facter.fact(:architecture).stubs(:value).returns("amd64")
|
135
|
+
File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture_readlines("amd64tri"))
|
136
|
+
|
137
|
+
Facter.fact(processor_fact).value.should == "3"
|
138
|
+
end
|
139
|
+
|
140
|
+
it "should be 4 in amd64quad fixture on Linux" do
|
141
|
+
Facter.fact(:architecture).stubs(:value).returns("amd64")
|
142
|
+
File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture_readlines("amd64quad"))
|
143
|
+
|
144
|
+
Facter.fact(processor_fact).value.should == "4"
|
145
|
+
end
|
149
146
|
end
|
150
147
|
|
151
|
-
|
152
|
-
Facter.fact(:kernel).stubs(:value).returns("Linux")
|
153
|
-
Facter.fact(:architecture).stubs(:value).returns("amd64")
|
154
|
-
File.stubs(:exists?).with("/proc/cpuinfo").returns(true)
|
155
|
-
File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture("amd64dual"))
|
148
|
+
it_behaves_like 'a /proc/cpuinfo based processor fact', :processorcount
|
156
149
|
|
157
|
-
|
150
|
+
def sysfs_cpu_stubs(count)
|
151
|
+
(0...count).map { |index| "/sys/devices/system/cpu/cpu#{index}" }
|
158
152
|
end
|
159
153
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
154
|
+
describe 'when /proc/cpuinfo returns 0 processors (#2945)' do
|
155
|
+
include_context 'Linux processor stubs'
|
156
|
+
|
157
|
+
before do
|
158
|
+
File.stubs(:readlines).with("/proc/cpuinfo").returns([])
|
159
|
+
File.stubs(:exists?).with("/sys/devices/system/cpu").returns(true)
|
160
|
+
end
|
161
|
+
|
162
|
+
it "should be 2 via sysfs when cpu0 and cpu1 are present" do
|
163
|
+
Dir.stubs(:glob).with("/sys/devices/system/cpu/cpu[0-9]*").returns(
|
164
|
+
sysfs_cpu_stubs(2)
|
165
|
+
)
|
166
|
+
|
167
|
+
Facter.fact(:processorcount).value.should == "2"
|
168
|
+
end
|
165
169
|
|
166
|
-
|
170
|
+
it "should be 16 via sysfs when cpu0 through cpu15 are present" do
|
171
|
+
Dir.stubs(:glob).with("/sys/devices/system/cpu/cpu[0-9]*").returns(
|
172
|
+
sysfs_cpu_stubs(16)
|
173
|
+
)
|
174
|
+
|
175
|
+
Facter.fact(:processorcount).value.should == "16"
|
176
|
+
end
|
167
177
|
end
|
178
|
+
end
|
168
179
|
|
169
|
-
it "should be 4 in amd64quad fixture on Linux" do
|
170
|
-
Facter.fact(:kernel).stubs(:value).returns("Linux")
|
171
|
-
Facter.fact(:architecture).stubs(:value).returns("amd64")
|
172
|
-
File.stubs(:exists?).with("/proc/cpuinfo").returns(true)
|
173
|
-
File.stubs(:readlines).with("/proc/cpuinfo").returns(cpuinfo_fixture("amd64quad"))
|
174
180
|
|
175
|
-
|
181
|
+
describe "on Unixes" do
|
182
|
+
before :each do
|
183
|
+
Facter.collection.internal_loader.load(:processor)
|
176
184
|
end
|
177
185
|
|
178
186
|
it "should be 2 on dual-processor Darwin box" do
|
@@ -203,90 +211,49 @@ describe "Processor facts" do
|
|
203
211
|
Facter.fact(:processor).value.should == "SomeVendor CPU 3GHz"
|
204
212
|
end
|
205
213
|
|
206
|
-
|
207
214
|
it "should be 2 on dual-processor DragonFly box" do
|
208
215
|
Facter.fact(:kernel).stubs(:value).returns("DragonFly")
|
209
216
|
Facter::Util::Resolution.stubs(:exec).with("sysctl -n hw.ncpu").returns('2')
|
210
217
|
|
211
218
|
Facter.fact(:processorcount).value.should == "2"
|
212
219
|
end
|
220
|
+
end
|
213
221
|
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
File.stubs(:readlines).with("/proc/cpuinfo").returns([])
|
220
|
-
Dir.stubs(:glob).with("/sys/devices/system/cpu/cpu[0-9]*").returns(%w{
|
221
|
-
/sys/devices/system/cpu/cpu0
|
222
|
-
/sys/devices/system/cpu/cpu1
|
223
|
-
})
|
224
|
-
|
225
|
-
Facter.fact(:processorcount).value.should == "2"
|
222
|
+
describe "on solaris" do
|
223
|
+
before :each do
|
224
|
+
Facter::Util::Processor.stubs(:kernel_fact_value).returns :sunos
|
225
|
+
Facter.fact(:kernel).stubs(:value).returns(:sunos)
|
226
|
+
Facter.collection.internal_loader.load(:processor)
|
226
227
|
end
|
227
228
|
|
228
|
-
|
229
|
-
|
230
|
-
File.
|
231
|
-
## sysfs method is only used if cpuinfo method returned no processors
|
232
|
-
File.stubs(:exists?).with("/proc/cpuinfo").returns(true)
|
233
|
-
File.stubs(:readlines).with("/proc/cpuinfo").returns([])
|
234
|
-
Dir.stubs(:glob).with("/sys/devices/system/cpu/cpu[0-9]*").returns(%w{
|
235
|
-
/sys/devices/system/cpu/cpu0
|
236
|
-
/sys/devices/system/cpu/cpu1
|
237
|
-
/sys/devices/system/cpu/cpu2
|
238
|
-
/sys/devices/system/cpu/cpu3
|
239
|
-
/sys/devices/system/cpu/cpu4
|
240
|
-
/sys/devices/system/cpu/cpu5
|
241
|
-
/sys/devices/system/cpu/cpu6
|
242
|
-
/sys/devices/system/cpu/cpu7
|
243
|
-
/sys/devices/system/cpu/cpu8
|
244
|
-
/sys/devices/system/cpu/cpu9
|
245
|
-
/sys/devices/system/cpu/cpu10
|
246
|
-
/sys/devices/system/cpu/cpu11
|
247
|
-
/sys/devices/system/cpu/cpu12
|
248
|
-
/sys/devices/system/cpu/cpu13
|
249
|
-
/sys/devices/system/cpu/cpu14
|
250
|
-
/sys/devices/system/cpu/cpu15
|
251
|
-
})
|
252
|
-
|
253
|
-
Facter.fact(:processorcount).value.should == "16"
|
229
|
+
before :all do
|
230
|
+
@fixture_kstat_sparc = File.read(fixtures('processorcount','solaris-sparc-kstat-cpu-info'))
|
231
|
+
@fixture_kstat_x86_64 = File.read(fixtures('processorcount','solaris-x86_64-kstat-cpu-info'))
|
254
232
|
end
|
255
233
|
|
256
|
-
|
257
|
-
|
258
|
-
@fixture_kstat_sparc = File.read(fixtures('processorcount','solaris-sparc-kstat-cpu-info'))
|
259
|
-
@fixture_kstat_x86_64 = File.read(fixtures('processorcount','solaris-x86_64-kstat-cpu-info'))
|
260
|
-
end
|
261
|
-
|
262
|
-
let(:psrinfo) do
|
263
|
-
"0 on-line since 10/16/2012 14:06:12\n" +
|
264
|
-
"1 on-line since 10/16/2012 14:06:14\n"
|
265
|
-
end
|
266
|
-
|
267
|
-
let(:kstat_sparc) { @fixture_kstat_sparc }
|
268
|
-
let(:kstat_x86_64) { @fixture_kstat_x86_64 }
|
234
|
+
let(:kstat_sparc) { @fixture_kstat_sparc }
|
235
|
+
let(:kstat_x86_64) { @fixture_kstat_x86_64 }
|
269
236
|
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
Facter.stubs(:value).with(:kernelrelease).returns(release)
|
237
|
+
%w{ 5.8 5.9 5.10 5.11 }.each do |release|
|
238
|
+
%w{ sparc x86_64 }.each do |arch|
|
239
|
+
it "uses kstat on release #{release} (#{arch})" do
|
240
|
+
Facter.stubs(:value).with(:kernelrelease).returns(release)
|
275
241
|
|
276
|
-
|
277
|
-
|
278
|
-
|
242
|
+
Facter::Util::Resolution.expects(:exec).with("/usr/sbin/psrinfo").never
|
243
|
+
Facter::Util::Resolution.expects(:exec).with("/usr/bin/kstat cpu_info").returns(self.send("kstat_#{arch}".intern))
|
244
|
+
Facter.fact(:processorcount).value.should == 8
|
279
245
|
end
|
280
246
|
end
|
247
|
+
end
|
281
248
|
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
Facter.stubs(:value).with(:kernelrelease).returns(release)
|
249
|
+
%w{ 5.5.1 5.6 5.7 }.each do |release|
|
250
|
+
it "uses psrinfo on release #{release}" do
|
251
|
+
Facter.stubs(:value).with(:kernelrelease).returns(release)
|
286
252
|
|
287
|
-
|
288
|
-
|
289
|
-
|
253
|
+
fixture_data = File.read(fixtures('processorcount','solaris-psrinfo'))
|
254
|
+
Facter::Util::Resolution.expects(:exec).with("/usr/bin/kstat cpu_info").never
|
255
|
+
Facter::Util::Resolution.expects(:exec).with("/usr/sbin/psrinfo").returns(fixture_data)
|
256
|
+
Facter.fact(:processorcount).value.should == 24
|
290
257
|
end
|
291
258
|
end
|
292
259
|
end
|
@@ -333,6 +300,8 @@ describe "processorX facts" do
|
|
333
300
|
examples << [File.read(fixtures('hpux','machinfo','ia64-rx6600')), "Intel(R) Itanium 2 9100 series processor (1.59 GHz, 18 MB)"]
|
334
301
|
examples << [File.read(fixtures('hpux','machinfo','ia64-rx8640')), "Intel(R) Itanium 2 9100 series"]
|
335
302
|
examples << [File.read(fixtures('hpux','machinfo','hppa-rp4440')), "PA-RISC 8800 processor (1000 MHz, 64 MB)"]
|
303
|
+
examples << [File.read(fixtures('hpux','machinfo','superdome-server-SD32B')), "Intel(R) Itanium 2 9000 series"]
|
304
|
+
examples << [File.read(fixtures('hpux','machinfo','superdome2-16s')), "Intel(R) Itanium(R) Processor 9340 (1.6 GHz, 15 MB)"]
|
336
305
|
examples
|
337
306
|
end
|
338
307
|
|