sys-uname 1.0.4 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,464 +0,0 @@
1
- ##############################################################################
2
- # test_sys_uname.rb
3
- #
4
- # Test suite for the sys-uname library. Run 'rake test' to execute tests.
5
- ##############################################################################
6
- require 'test-unit'
7
- require 'sys/uname'
8
- require 'rbconfig'
9
- include Sys
10
-
11
- class TC_Sys_Uname < Test::Unit::TestCase
12
- def self.startup
13
- @@host_os = RbConfig::CONFIG['host_os']
14
- end
15
-
16
- test "version constant is set to expected value" do
17
- assert_equal('1.0.4', Uname::VERSION)
18
- assert_true(Uname::VERSION.frozen?)
19
- end
20
-
21
- test "machine singleton method works as expected" do
22
- assert_respond_to(Uname, :machine)
23
- assert_nothing_raised{ Uname.machine }
24
- assert_kind_of(String, Uname.machine)
25
- assert_true(Uname.machine.size > 0)
26
- end
27
-
28
- test "version singleton method works as expected" do
29
- assert_respond_to(Uname, :version)
30
- assert_nothing_raised{ Uname.version }
31
- assert_kind_of(String, Uname.version)
32
- assert_true(Uname.version.size > 0)
33
- end
34
-
35
- test "nodename singleton method works as expected" do
36
- assert_respond_to(Uname, :nodename)
37
- assert_nothing_raised{ Uname.nodename }
38
- assert_kind_of(String, Uname.nodename)
39
- assert_true(Uname.nodename.size > 0)
40
- end
41
-
42
- test "release singleton method works as expected" do
43
- assert_respond_to(Uname, :release)
44
- assert_nothing_raised{ Uname.release }
45
- assert_kind_of(String, Uname.release)
46
- assert_true(Uname.release.size > 0)
47
- end
48
-
49
- test "sysname singleton method works as expected" do
50
- assert_respond_to(Uname, :sysname)
51
- assert_nothing_raised{ Uname.sysname }
52
- assert_kind_of(String, Uname.sysname)
53
- assert_true(Uname.sysname.size > 0)
54
- end
55
-
56
- test "architecture singleton method works as expected on solaris" do
57
- omit_unless(@@host_os =~ /sunos|solaris/i, "Solaris only")
58
- assert_respond_to(Uname, :architecture)
59
- assert_nothing_raised{ Uname.architecture }
60
- assert_kind_of(String, Uname.architecture)
61
- end
62
-
63
- test "platform singleton method works as expected on solaris" do
64
- omit_unless(@@host_os =~ /sunos|solaris/i, "Solaris only")
65
- assert_respond_to(Uname, :platform)
66
- assert_nothing_raised{ Uname.platform }
67
- assert_kind_of(String, Uname.platform)
68
- end
69
-
70
- test "isa_list singleton method works as expected on solaris" do
71
- omit_unless(@@host_os =~ /sunos|solaris/i, "Solaris only")
72
- assert_respond_to(Uname, :isa_list)
73
- assert_nothing_raised{ Uname.isa_list }
74
- assert_kind_of(String, Uname.isa_list)
75
- end
76
-
77
- test "hw_provider singleton method works as expected on solaris" do
78
- omit_unless(@@host_os =~ /sunos|solaris/i, "Solaris only")
79
- assert_respond_to(Uname,:hw_provider)
80
- assert_nothing_raised{ Uname.hw_provider }
81
- assert_kind_of(String, Uname.hw_provider)
82
- end
83
-
84
- test "hw_serial singleton method works as expected on solaris" do
85
- omit_unless(@@host_os =~ /sunos|solaris/i, "Solaris only")
86
- assert_respond_to(Uname, :hw_serial)
87
- assert_nothing_raised{ Uname.hw_serial }
88
- assert_kind_of(Integer, Uname.hw_serial)
89
- end
90
-
91
- test "srpc_domain singleton method works as expected on solaris" do
92
- omit_unless(@@host_os =~ /sunos|solaris/i, "Solaris only")
93
- assert_respond_to(Uname, :srpc_domain)
94
- assert_nothing_raised{ Uname.srpc_domain }
95
- assert_kind_of(String, Uname.srpc_domain)
96
- end
97
-
98
- test "dhcp_cache singleton method works as expected on solaris" do
99
- omit_unless(@@host_os =~ /sunos|solaris/i, "Solaris only")
100
- assert_respond_to(Uname, :dhcp_cache)
101
- assert_nothing_raised{ Uname.dhcp_cache }
102
- assert_kind_of(String, Uname.dhcp_cache)
103
- end
104
-
105
- test "model singleton method works as expected on BSD and Darwin" do
106
- omit_unless(@@host_os =~ /darwin|powerpc|bsd|mach/i, "BSD/Darwin only")
107
- assert_respond_to(Uname, :model)
108
- assert_nothing_raised{ Uname.model }
109
- assert_kind_of(String, Uname.model)
110
- end
111
-
112
- test "id_number singleton method works as expected on HP-UX" do
113
- omit_unless(@@host_os =~ /hpux/i, "HP-UX only")
114
- assert_respond_to(Uname, :id_number)
115
- assert_nothing_raised{ Uname.id_number }
116
- assert_kind_of(String, Uname.id_number)
117
- end
118
-
119
- test "uname struct contains expected members based on platform" do
120
- members = %w/sysname nodename machine version release/
121
- case RbConfig::CONFIG['host_os']
122
- when /linux/i
123
- members.push('domainname')
124
- when /sunos|solaris/i
125
- members.push(
126
- 'architecture', 'platform', 'hw_serial', 'hw_provider',
127
- 'srpc_domain', 'isa_list', 'dhcp_cache'
128
- )
129
- when /powerpc|darwin|bsd/i
130
- members.push('model')
131
- when /hpux/i
132
- members.push('id')
133
- when /win32|mingw|cygwin|dos|windows/i
134
- members = %w[
135
- boot_device build_number build_type caption code_set country_code
136
- creation_class_name cscreation_class_name csd_version cs_name
137
- current_time_zone debug description distributed
138
- foreground_application_boost free_physical_memory
139
- free_space_in_paging_files free_virtual_memory
140
- install_date last_bootup_time local_date_time locale
141
- manufacturer max_number_of_processes max_process_memory_size
142
- name number_of_licensed_users number_of_processes
143
- number_of_users organization os_language os_product_suite
144
- os_type other_type_description plus_product_id
145
- plus_version_number primary quantum_length quantum_type
146
- registered_user serial_number service_pack_major_version
147
- service_pack_minor_version size_stored_in_paging_files
148
- status system_device system_directory total_swap_space_size
149
- total_virtual_memory_size total_visible_memory_size version
150
- windows_directory
151
- ]
152
- end
153
-
154
- members.map!{ |e| e.to_sym } if RUBY_VERSION.to_f >= 1.9
155
-
156
- assert_nothing_raised{ Uname.uname }
157
- assert_kind_of(Struct, Uname.uname)
158
- assert_equal(members.sort, Uname.uname.members.sort)
159
- end
160
-
161
- test "ffi and internal functions are not public" do
162
- methods = Uname.methods(false).map{ |e| e.to_s }
163
- assert_false(methods.include?('get_model'))
164
- assert_false(methods.include?('get_si'))
165
- assert_false(methods.include?('uname_c'))
166
- assert_false(methods.include?('sysctl'))
167
- assert_false(methods.include?('sysinfo'))
168
- end
169
-
170
- # The following tests are win32 only
171
- if File::ALT_SEPARATOR
172
- def test_boot_device
173
- assert_nothing_raised{ Uname.uname.boot_device }
174
- assert_kind_of(String, Uname.uname.boot_device)
175
- end
176
-
177
- def test_build_number
178
- assert_nothing_raised{ Uname.uname.build_number }
179
- assert_kind_of(String, Uname.uname.build_number)
180
- end
181
-
182
- def test_build_type
183
- assert_nothing_raised{ Uname.uname.build_type }
184
- assert_kind_of(String, Uname.uname.build_type)
185
- end
186
-
187
- def test_caption
188
- assert_nothing_raised{ Uname.uname.caption }
189
- assert_kind_of(String, Uname.uname.caption)
190
- end
191
-
192
- def test_code_set
193
- assert_nothing_raised{ Uname.uname.code_set }
194
- assert_kind_of(String, Uname.uname.code_set)
195
- end
196
-
197
- def test_country_code
198
- assert_nothing_raised{ Uname.uname.country_code }
199
- assert_kind_of(String, Uname.uname.country_code)
200
- end
201
-
202
- def test_creation_class_name
203
- assert_nothing_raised{ Uname.uname.creation_class_name }
204
- assert_kind_of(String, Uname.uname.creation_class_name)
205
- end
206
-
207
- def test_cscreation_class_name
208
- assert_nothing_raised{ Uname.uname.cscreation_class_name }
209
- assert_kind_of(String, Uname.uname.cscreation_class_name)
210
- end
211
-
212
- def test_csd_version
213
- assert_nothing_raised{ Uname.uname.csd_version }
214
- assert_kind_of([String, NilClass], Uname.uname.csd_version)
215
- end
216
-
217
- def test_cs_name
218
- assert_nothing_raised{ Uname.uname.cs_name }
219
- assert_kind_of(String, Uname.uname.cs_name)
220
- end
221
-
222
- def test_current_time_zone
223
- assert_nothing_raised{ Uname.uname.current_time_zone }
224
- assert_kind_of(Fixnum, Uname.uname.current_time_zone)
225
- end
226
-
227
- def test_debug
228
- assert_nothing_raised{ Uname.uname.debug }
229
- assert_boolean(Uname.uname.debug)
230
- end
231
-
232
- def test_description
233
- assert_nothing_raised{ Uname.uname.description }
234
- assert_kind_of(String, Uname.uname.description)
235
- end
236
-
237
- def test_distributed
238
- assert_nothing_raised{ Uname.uname.distributed }
239
- assert_boolean(Uname.uname.distributed)
240
- end
241
-
242
- # Not yet supported - WinXP or later only
243
- #def test_encryption_level
244
- # assert_nothing_raised{ Uname.uname.encryption_level }
245
- # assert_kind_of(Fixnum,Uname.uname.encryption_level)
246
- #end
247
-
248
- def test_foreground_application_boost
249
- assert_nothing_raised{ Uname.uname.foreground_application_boost }
250
- assert_kind_of(Fixnum, Uname.uname.foreground_application_boost)
251
- end
252
-
253
- def test_free_physical_memory
254
- assert_nothing_raised{ Uname.uname.free_physical_memory }
255
- assert_kind_of(Fixnum, Uname.uname.free_physical_memory)
256
- end
257
-
258
- def test_free_space_in_paging_files
259
- assert_nothing_raised{ Uname.uname.free_space_in_paging_files }
260
- assert_kind_of(Fixnum, Uname.uname.free_space_in_paging_files)
261
- end
262
-
263
- def test_free_virtual_memory
264
- assert_nothing_raised{ Uname.uname.free_virtual_memory}
265
- assert_kind_of(Fixnum, Uname.uname.free_virtual_memory)
266
- end
267
-
268
- def test_install_date
269
- assert_nothing_raised{ Uname.uname.install_date}
270
- assert_kind_of(Time, Uname.uname.install_date)
271
- end
272
-
273
- # Not yet supported - WinXP or later only
274
- #def test_large_system_cache
275
- # assert_nothing_raised{ Uname.uname.large_system_cache}
276
- # assert_kind_of(Time,Uname.uname.large_system_cache)
277
- #end
278
-
279
- def test_last_bootup_time
280
- assert_nothing_raised{ Uname.uname.last_bootup_time}
281
- assert_kind_of(Time, Uname.uname.last_bootup_time)
282
- end
283
-
284
- def test_local_date_time
285
- assert_nothing_raised{ Uname.uname.local_date_time}
286
- assert_kind_of(Time, Uname.uname.local_date_time)
287
- end
288
-
289
- def test_locale
290
- assert_nothing_raised{ Uname.uname.locale}
291
- assert_kind_of(String, Uname.uname.locale)
292
- end
293
-
294
- def test_manufacturer
295
- assert_nothing_raised{ Uname.uname.manufacturer}
296
- assert_kind_of(String, Uname.uname.manufacturer)
297
- end
298
-
299
- def test_max_number_of_processes
300
- assert_nothing_raised{ Uname.uname.max_number_of_processes}
301
- assert_kind_of(Fixnum, Uname.uname.max_number_of_processes)
302
- end
303
-
304
- def test_max_process_memory_size
305
- assert_nothing_raised{ Uname.uname.max_process_memory_size}
306
- assert_kind_of(Integer, Uname.uname.max_process_memory_size)
307
- end
308
-
309
- def test_name
310
- assert_nothing_raised{ Uname.uname.name}
311
- assert_kind_of(String, Uname.uname.name)
312
- end
313
-
314
- # Fails on Win XP Pro - returns nil - reason unknown
315
- #def test_number_of_licensed_users
316
- # assert_nothing_raised{ Uname.uname.number_of_licensed_users}
317
- # assert_kind_of(Fixnum,Uname.uname.number_of_licensed_users)
318
- #end
319
-
320
- def test_number_of_processes
321
- assert_nothing_raised{ Uname.uname.number_of_processes}
322
- assert_kind_of(Fixnum, Uname.uname.number_of_processes)
323
- end
324
-
325
- def test_number_of_users
326
- assert_nothing_raised{ Uname.uname.number_of_users}
327
- assert_kind_of(Fixnum, Uname.uname.number_of_users)
328
- end
329
-
330
- def test_organization
331
- assert_nothing_raised{ Uname.uname.organization}
332
- assert_kind_of(String, Uname.uname.organization)
333
- end
334
-
335
- # Eventually replace Fixnum with a string (?)
336
- def test_os_language
337
- assert_nothing_raised{ Uname.uname.os_language}
338
- assert_kind_of(Fixnum, Uname.uname.os_language)
339
- end
340
-
341
- # Fails on Win XP Pro - returns nil - reason unknown
342
- #def test_os_product_suite
343
- # assert_nothing_raised{ Uname.uname.os_product_suite}
344
- # assert_kind_of(Fixnum,Uname.uname.os_product_suite)
345
- #end
346
-
347
- def test_os_type
348
- assert_nothing_raised{ Uname.uname.os_type}
349
- assert_kind_of(Fixnum, Uname.uname.os_type)
350
- end
351
-
352
- # Fails?
353
- #def test_other_type_restriction
354
- # assert_nothing_raised{ Uname.uname.other_type_restriction}
355
- # assert_kind_of(Fixnum,Uname.uname.other_type_restriction)
356
- #end
357
-
358
- # Might be nil
359
- def test_plus_product_id
360
- assert_nothing_raised{ Uname.uname.plus_product_id }
361
- end
362
-
363
- # Might be nil
364
- def test_plus_version_number
365
- assert_nothing_raised{ Uname.uname.plus_version_number}
366
- end
367
-
368
- def test_primary
369
- assert_nothing_raised{ Uname.uname.primary}
370
- assert_boolean(Uname.uname.primary)
371
- end
372
-
373
- # Not yet supported - WinXP or later only
374
- # def test_product_type
375
- # assert_nothing_raised{ Uname.uname.product_type}
376
- # assert_kind_of(Fixnum,Uname.uname.product_type)
377
- # end
378
-
379
- def test_quantum_length
380
- assert_nothing_raised{ Uname.uname.quantum_length}
381
- assert_kind_of([Fixnum, NilClass], Uname.uname.quantum_length)
382
- end
383
-
384
- def test_quantum_type
385
- assert_nothing_raised{ Uname.uname.quantum_type}
386
- assert_kind_of([Fixnum, NilClass], Uname.uname.quantum_type)
387
- end
388
-
389
- def test_registered_user
390
- assert_nothing_raised{ Uname.uname.registered_user}
391
- assert_kind_of(String, Uname.uname.registered_user)
392
- end
393
-
394
- def test_serial_number
395
- assert_nothing_raised{ Uname.uname.serial_number}
396
- assert_kind_of(String, Uname.uname.serial_number)
397
- end
398
-
399
- # This is nil on NT 4
400
- def test_service_pack_major_version
401
- assert_nothing_raised{ Uname.uname.service_pack_major_version}
402
- assert_kind_of(Fixnum, Uname.uname.service_pack_major_version)
403
- end
404
-
405
- # This is nil on NT 4
406
- def test_service_pack_minor_version
407
- assert_nothing_raised{ Uname.uname.service_pack_minor_version}
408
- assert_kind_of(Fixnum, Uname.uname.service_pack_minor_version)
409
- end
410
-
411
- def test_status
412
- assert_nothing_raised{ Uname.uname.status}
413
- assert_kind_of(String, Uname.uname.status)
414
- end
415
-
416
- # Not yet supported - WinXP or later only
417
- #def test_suite_mask
418
- # assert_nothing_raised{ Uname.uname.suite_mask}
419
- # assert_kind_of(String,Uname.uname.suite_mask)
420
- #end
421
-
422
- def test_system_device
423
- assert_nothing_raised{ Uname.uname.system_device}
424
- assert_kind_of(String, Uname.uname.system_device)
425
- end
426
-
427
- def test_system_directory
428
- assert_nothing_raised{ Uname.uname.system_directory}
429
- assert_kind_of(String, Uname.uname.system_directory)
430
- end
431
-
432
- # Not yet supported - WinXP or later only
433
- #def test_system_drive
434
- # assert_nothing_raised{ Uname.uname.system_drive}
435
- # assert_kind_of(String,Uname.uname.system_drive)
436
- #end
437
-
438
- # Fails on Win XP Pro - returns nil - reason unknown
439
- #def test_total_swap_space_size
440
- # assert_nothing_raised{ Uname.uname.total_swap_space_size}
441
- # assert_kind_of(Fixnum,Uname.uname.total_swap_space_size)
442
- #end
443
-
444
- def test_total_virtual_memory_size
445
- assert_nothing_raised{ Uname.uname.total_virtual_memory_size}
446
- assert_kind_of(Fixnum, Uname.uname.total_virtual_memory_size)
447
- end
448
-
449
- def test_total_visible_memory_size
450
- assert_nothing_raised{ Uname.uname.total_visible_memory_size}
451
- assert_kind_of(Fixnum, Uname.uname.total_visible_memory_size)
452
- end
453
-
454
- def test_version
455
- assert_nothing_raised{ Uname.uname.version}
456
- assert_kind_of(String, Uname.uname.version)
457
- end
458
-
459
- def test_windows_directory
460
- assert_nothing_raised{ Uname.uname.windows_directory}
461
- assert_kind_of(String, Uname.uname.windows_directory)
462
- end
463
- end
464
- end