sys-uname 0.8.3-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.
data/sys-uname.gemspec ADDED
@@ -0,0 +1,37 @@
1
+ require 'rubygems'
2
+
3
+ spec = Gem::Specification.new do |gem|
4
+ gem.name = 'sys-uname'
5
+ gem.version = '0.8.3'
6
+ gem.author = 'Daniel J. Berger'
7
+ gem.email = 'djberg96@gmail.com'
8
+ gem.homepage = 'http://www.rubyforge.org/projects/sysutils'
9
+ gem.platform = Gem::Platform::RUBY
10
+ gem.summary = 'An interface for returning uname (platform) information'
11
+ gem.description = 'An interface for returning uname (platform) information'
12
+ gem.test_file = 'test/tc_uname.rb'
13
+ gem.has_rdoc = true
14
+ gem.extra_rdoc_files = ['CHANGES', 'README', 'MANIFEST', 'doc/uname.txt']
15
+ gem.rubyforge_project = 'sysutils'
16
+ files = Dir["doc/*"] + Dir["test/*"] + Dir["[A-Z]*"]
17
+ files.delete_if{ |item| item.include?('CVS') }
18
+ gem.files = files
19
+ end
20
+
21
+ if $PROGRAM_NAME == __FILE__
22
+ require 'rbconfig'
23
+ include Config
24
+ if CONFIG['host_os'] =~ /mswin|windows/i
25
+ spec.required_ruby_version = '>= 1.8.2'
26
+ spec.files += ['lib/sys/uname.rb']
27
+ spec.platform = Gem::Platform::CURRENT
28
+ else
29
+ spec.required_ruby_version = '>= 1.8.0'
30
+ spec.extensions = ['ext/extconf.rb']
31
+ spec.files += ['ext/sys/uname.c']
32
+ spec.extra_rdoc_files += ['ext/sys/uname.c']
33
+ end
34
+
35
+ Gem.manage_gems
36
+ Gem::Builder.new(spec).build
37
+ end
data/test/tc_uname.rb ADDED
@@ -0,0 +1,474 @@
1
+ ##############################################################################
2
+ # tc_uname.rb
3
+ #
4
+ # Test suite for the sys-uname package. This test suite should be run via
5
+ # the 'rake test' task.
6
+ ##############################################################################
7
+ require 'sys/uname'
8
+ require 'test/unit'
9
+ require 'rbconfig'
10
+ include Sys
11
+ include Config
12
+
13
+ # For testing purposes only
14
+ module Boolean; end
15
+ class TrueClass; include Boolean; end
16
+ class FalseClass; include Boolean; end
17
+
18
+ class TC_Uname < Test::Unit::TestCase
19
+ def test_version_constant
20
+ assert_not_nil(Uname::VERSION)
21
+ assert_nothing_raised{ Uname::VERSION }
22
+ assert_kind_of(String, Uname::VERSION)
23
+ assert_equal('0.8.3', Uname::VERSION)
24
+ end
25
+
26
+ def test_machine
27
+ assert_respond_to(Uname, :machine)
28
+ assert_nothing_raised{ Uname.machine }
29
+ assert_kind_of(String, Uname.machine)
30
+ end
31
+
32
+ def test_version_method
33
+ assert_respond_to(Uname, :version)
34
+ assert_nothing_raised{ Uname.version }
35
+ assert_kind_of(String, Uname.version)
36
+ end
37
+
38
+ def test_nodename
39
+ assert_respond_to(Uname, :nodename)
40
+ assert_nothing_raised{ Uname.nodename }
41
+ assert_kind_of(String, Uname.nodename)
42
+ end
43
+
44
+ def test_release
45
+ assert_respond_to(Uname, :release)
46
+ assert_nothing_raised{ Uname.release }
47
+ assert_kind_of(String, Uname.release)
48
+ end
49
+
50
+ def test_sysname
51
+ assert_respond_to(Uname, :sysname)
52
+ assert_nothing_raised{ Uname.sysname }
53
+ assert_kind_of(String, Uname.sysname, 'Invalid Type')
54
+ end
55
+
56
+ def test_architecture
57
+ if CONFIG['host_os'] =~ /sunos|solaris/i
58
+ assert_respond_to(Uname, :architecture)
59
+ assert_nothing_raised{ Uname.architecture }
60
+ assert_kind_of(String, Uname.architecture)
61
+ else
62
+ puts '"architecture" test skipped on this platform'
63
+ end
64
+ end
65
+
66
+ def test_platform
67
+ if CONFIG['host_os'] =~ /sunos|solaris/i
68
+ assert_respond_to(Uname, :platform)
69
+ assert_nothing_raised{ Uname.platform }
70
+ assert_kind_of(String, Uname.platform)
71
+ else
72
+ puts '"platform" test skipped on this platform'
73
+ end
74
+ end
75
+
76
+ def test_isa_list
77
+ if CONFIG['host_os'] =~ /sunos|solaris/i
78
+ assert_respond_to(Uname, :isa_list)
79
+ assert_nothing_raised{ Uname.isa_list }
80
+ assert_kind_of(String, Uname.isa_list)
81
+ else
82
+ puts '"isa_list" test skipped on this platform'
83
+ end
84
+ end
85
+
86
+ def test_hw_provider
87
+ if CONFIG['host_os'] =~ /sunos|solaris/i
88
+ assert_respond_to(Uname,:hw_provider)
89
+ assert_nothing_raised{ Uname.hw_provider }
90
+ assert_kind_of(String, Uname.hw_provider)
91
+ else
92
+ puts '"hw_provider" test skipped on this platform'
93
+ end
94
+ end
95
+
96
+ def test_hw_serial_number
97
+ if CONFIG['host_os'] =~ /sunos|solaris/i
98
+ assert_respond_to(Uname, :hw_serial_number)
99
+ assert_nothing_raised{ Uname.hw_serial_number }
100
+ assert_kind_of(Integer, Uname.hw_serial_number)
101
+ else
102
+ puts '"hw_serial_number" test skipped on this platform'
103
+ end
104
+ end
105
+
106
+ def test_srpc_domain
107
+ if CONFIG['host_os'] =~ /sunos|solaris/i
108
+ assert_respond_to(Uname, :srpc_domain)
109
+ assert_nothing_raised{ Uname.srpc_domain }
110
+ assert_kind_of(String, Uname.srpc_domain)
111
+ else
112
+ puts '"srpc_domain" test skipped on this platform'
113
+ end
114
+ end
115
+
116
+ def test_dhcp_cache
117
+ if CONFIG['host_os'] =~ /sunos|solaris/i
118
+ assert_respond_to(Uname, :dhcp_cache)
119
+ assert_nothing_raised{ Uname.dhcp_cache }
120
+ assert_kind_of(String, Uname.dhcp_cache)
121
+ else
122
+ puts '"srpc_domain" test skipped on this platform'
123
+ end
124
+ end
125
+
126
+ def test_model
127
+ if CONFIG['host_os'] =~ /darwin|powerpc|bsd|mach/i
128
+ assert_respond_to(Uname, :model)
129
+ assert_nothing_raised{ Uname.model }
130
+ assert_kind_of(String, Uname.model)
131
+ else
132
+ puts '"model" test skipped on this platform'
133
+ end
134
+ end
135
+
136
+ def test_id_number
137
+ if CONFIG['host_os'] =~ /hpux/i
138
+ assert_respond_to(Uname, :id_number)
139
+ assert_nothing_raised{ Uname.id_number }
140
+ assert_kind_of(String, Uname.id_number)
141
+ else
142
+ puts '"test_id_number" test skipped on this platform'
143
+ end
144
+ end
145
+
146
+ def test_uname_struct
147
+ members = %w/sysname nodename machine version release/
148
+ case CONFIG['host_os']
149
+ when /sunos|solaris/i
150
+ members.push('architecture','platform')
151
+ when /powerpc|darwin/i
152
+ members.push('model')
153
+ when /hpux/i
154
+ members.push('id')
155
+ when /win32|mingw|cygwin|dos/i
156
+ members = %w/
157
+ boot_device build_number build_type caption code_set country_code
158
+ creation_class_name cscreation_class_name csd_version cs_name
159
+ current_time_zone debug description distributed
160
+ foreground_application_boost free_physical_memory
161
+ free_space_in_paging_files free_virtual_memory
162
+ install_date last_bootup_time local_date_time locale
163
+ manufacturer max_number_of_processes max_process_memory_size
164
+ name number_of_licensed_users number_of_processes
165
+ number_of_users organization os_language os_product_suite
166
+ os_type other_type_description plus_product_id
167
+ plus_version_number primary quantum_length quantum_type
168
+ registered_user serial_number service_pack_major_version
169
+ service_pack_minor_version size_stored_in_paging_files
170
+ status system_device system_directory total_swap_space_size
171
+ total_virtual_memory_size total_visible_memory_size version
172
+ windows_directory
173
+ /
174
+ end
175
+ assert_nothing_raised{ Uname.uname }
176
+ assert_kind_of(Struct, Uname.uname)
177
+ assert_equal(members, Uname.uname.members)
178
+ end
179
+
180
+ # The following tests are win32 only
181
+ if CONFIG['host_os'] =~ /mswin|windows/i
182
+ def test_boot_device
183
+ assert_nothing_raised{ Uname.uname.boot_device }
184
+ assert_kind_of(String, Uname.uname.boot_device)
185
+ end
186
+
187
+ def test_build_number
188
+ assert_nothing_raised{ Uname.uname.build_number }
189
+ assert_kind_of(String, Uname.uname.build_number)
190
+ end
191
+
192
+ def test_build_type
193
+ assert_nothing_raised{ Uname.uname.build_type }
194
+ assert_kind_of(String, Uname.uname.build_type)
195
+ end
196
+
197
+ def test_caption
198
+ assert_nothing_raised{ Uname.uname.caption }
199
+ assert_kind_of(String, Uname.uname.caption)
200
+ end
201
+
202
+ def test_code_set
203
+ assert_nothing_raised{ Uname.uname.code_set }
204
+ assert_kind_of(String, Uname.uname.code_set)
205
+ end
206
+
207
+ def test_country_code
208
+ assert_nothing_raised{ Uname.uname.country_code }
209
+ assert_kind_of(String, Uname.uname.country_code)
210
+ end
211
+
212
+ def test_creation_class_name
213
+ assert_nothing_raised{ Uname.uname.creation_class_name }
214
+ assert_kind_of(String, Uname.uname.creation_class_name)
215
+ end
216
+
217
+ def test_cscreation_class_name
218
+ assert_nothing_raised{ Uname.uname.cscreation_class_name }
219
+ assert_kind_of(String, Uname.uname.cscreation_class_name)
220
+ end
221
+
222
+ def test_csd_version
223
+ assert_nothing_raised{ Uname.uname.csd_version }
224
+ assert_kind_of(String, Uname.uname.csd_version)
225
+ end
226
+
227
+ def test_cs_name
228
+ assert_nothing_raised{ Uname.uname.cs_name }
229
+ assert_kind_of(String, Uname.uname.cs_name)
230
+ end
231
+
232
+ def test_current_time_zone
233
+ assert_nothing_raised{ Uname.uname.current_time_zone }
234
+ assert_kind_of(Fixnum, Uname.uname.current_time_zone)
235
+ end
236
+
237
+ def test_debug
238
+ assert_nothing_raised{ Uname.uname.debug }
239
+ assert_kind_of(Boolean, Uname.uname.debug)
240
+ end
241
+
242
+ def test_description
243
+ assert_nothing_raised{ Uname.uname.description }
244
+ assert_kind_of(String, Uname.uname.description)
245
+ end
246
+
247
+ def test_distributed
248
+ assert_nothing_raised{ Uname.uname.distributed }
249
+ assert_kind_of(Boolean, Uname.uname.distributed)
250
+ end
251
+
252
+ # Not yet supported - WinXP or later only
253
+ #def test_encryption_level
254
+ # assert_nothing_raised{ Uname.uname.encryption_level }
255
+ # assert_kind_of(Fixnum,Uname.uname.encryption_level)
256
+ #end
257
+
258
+ def test_foreground_application_boost
259
+ assert_nothing_raised{ Uname.uname.foreground_application_boost }
260
+ assert_kind_of(Fixnum, Uname.uname.foreground_application_boost)
261
+ end
262
+
263
+ def test_free_physical_memory
264
+ assert_nothing_raised{ Uname.uname.free_physical_memory }
265
+ assert_kind_of(Fixnum, Uname.uname.free_physical_memory)
266
+ end
267
+
268
+ def test_free_space_in_paging_files
269
+ assert_nothing_raised{ Uname.uname.free_space_in_paging_files }
270
+ assert_kind_of(Fixnum, Uname.uname.free_space_in_paging_files)
271
+ end
272
+
273
+ def test_free_virtual_memory
274
+ assert_nothing_raised{ Uname.uname.free_virtual_memory}
275
+ assert_kind_of(Fixnum, Uname.uname.free_virtual_memory)
276
+ end
277
+
278
+ def test_install_date
279
+ assert_nothing_raised{ Uname.uname.install_date}
280
+ assert_kind_of(Time, Uname.uname.install_date)
281
+ end
282
+
283
+ # Not yet supported - WinXP or later only
284
+ #def test_large_system_cache
285
+ # assert_nothing_raised{ Uname.uname.large_system_cache}
286
+ # assert_kind_of(Time,Uname.uname.large_system_cache)
287
+ #end
288
+
289
+ def test_last_bootup_time
290
+ assert_nothing_raised{ Uname.uname.last_bootup_time}
291
+ assert_kind_of(Time, Uname.uname.last_bootup_time)
292
+ end
293
+
294
+ def test_local_date_time
295
+ assert_nothing_raised{ Uname.uname.local_date_time}
296
+ assert_kind_of(Time, Uname.uname.local_date_time)
297
+ end
298
+
299
+ def test_locale
300
+ assert_nothing_raised{ Uname.uname.locale}
301
+ assert_kind_of(String, Uname.uname.locale)
302
+ end
303
+
304
+ def test_manufacturer
305
+ assert_nothing_raised{ Uname.uname.manufacturer}
306
+ assert_kind_of(String, Uname.uname.manufacturer)
307
+ end
308
+
309
+ def test_max_number_of_processes
310
+ assert_nothing_raised{ Uname.uname.max_number_of_processes}
311
+ assert_kind_of(Fixnum, Uname.uname.max_number_of_processes)
312
+ end
313
+
314
+ def test_max_process_memory_size
315
+ assert_nothing_raised{ Uname.uname.max_process_memory_size}
316
+ assert_kind_of(Fixnum, Uname.uname.max_process_memory_size)
317
+ end
318
+
319
+ def test_name
320
+ assert_nothing_raised{ Uname.uname.name}
321
+ assert_kind_of(String, Uname.uname.name)
322
+ end
323
+
324
+ # Fails on Win XP Pro - returns nil - reason unknown
325
+ #def test_number_of_licensed_users
326
+ # assert_nothing_raised{ Uname.uname.number_of_licensed_users}
327
+ # assert_kind_of(Fixnum,Uname.uname.number_of_licensed_users)
328
+ #end
329
+
330
+ def test_number_of_processes
331
+ assert_nothing_raised{ Uname.uname.number_of_processes}
332
+ assert_kind_of(Fixnum, Uname.uname.number_of_processes)
333
+ end
334
+
335
+ def test_number_of_users
336
+ assert_nothing_raised{ Uname.uname.number_of_users}
337
+ assert_kind_of(Fixnum, Uname.uname.number_of_users)
338
+ end
339
+
340
+ def test_organization
341
+ assert_nothing_raised{ Uname.uname.organization}
342
+ assert_kind_of(String, Uname.uname.organization)
343
+ end
344
+
345
+ # Eventually replace Fixnum with a string (?)
346
+ def test_os_language
347
+ assert_nothing_raised{ Uname.uname.os_language}
348
+ assert_kind_of(Fixnum, Uname.uname.os_language)
349
+ end
350
+
351
+ # Fails on Win XP Pro - returns nil - reason unknown
352
+ #def test_os_product_suite
353
+ # assert_nothing_raised{ Uname.uname.os_product_suite}
354
+ # assert_kind_of(Fixnum,Uname.uname.os_product_suite)
355
+ #end
356
+
357
+ def test_os_type
358
+ assert_nothing_raised{ Uname.uname.os_type}
359
+ assert_kind_of(Fixnum, Uname.uname.os_type)
360
+ end
361
+
362
+ # Fails?
363
+ #def test_other_type_restriction
364
+ # assert_nothing_raised{ Uname.uname.other_type_restriction}
365
+ # assert_kind_of(Fixnum,Uname.uname.other_type_restriction)
366
+ #end
367
+
368
+ # Might be nil
369
+ def test_plus_product_id
370
+ assert_nothing_raised{ Uname.uname.plus_product_id}
371
+ end
372
+
373
+ # Might be nil
374
+ def test_plus_version_number
375
+ assert_nothing_raised{ Uname.uname.plus_version_number}
376
+ end
377
+
378
+ def test_primary
379
+ assert_nothing_raised{ Uname.uname.primary}
380
+ assert_kind_of(Boolean, Uname.uname.primary)
381
+ end
382
+
383
+ # Not yet supported - WinXP or later only
384
+ # def test_product_type
385
+ # assert_nothing_raised{ Uname.uname.product_type}
386
+ # assert_kind_of(Fixnum,Uname.uname.product_type)
387
+ # end
388
+
389
+ def test_quantum_length
390
+ assert_nothing_raised{ Uname.uname.quantum_length}
391
+ assert_kind_of(Fixnum, Uname.uname.quantum_length)
392
+ end
393
+
394
+ def test_quantum_type
395
+ assert_nothing_raised{ Uname.uname.quantum_type}
396
+ assert_kind_of(Fixnum, Uname.uname.quantum_type)
397
+ end
398
+
399
+ def test_registered_user
400
+ assert_nothing_raised{ Uname.uname.registered_user}
401
+ assert_kind_of(String, Uname.uname.registered_user)
402
+ end
403
+
404
+ def test_serial_number
405
+ assert_nothing_raised{ Uname.uname.serial_number}
406
+ assert_kind_of(String, Uname.uname.serial_number)
407
+ end
408
+
409
+ # This is nil on NT 4
410
+ def test_service_pack_major_version
411
+ assert_nothing_raised{ Uname.uname.service_pack_major_version}
412
+ assert_kind_of(Fixnum, Uname.uname.service_pack_major_version)
413
+ end
414
+
415
+ # This is nil on NT 4
416
+ def test_service_pack_major_version
417
+ assert_nothing_raised{ Uname.uname.service_pack_minor_version}
418
+ assert_kind_of(Fixnum, Uname.uname.service_pack_minor_version)
419
+ end
420
+
421
+ def test_status
422
+ assert_nothing_raised{ Uname.uname.status}
423
+ assert_kind_of(String, Uname.uname.status)
424
+ end
425
+
426
+ # Not yet supported - WinXP or later only
427
+ #def test_suite_mask
428
+ # assert_nothing_raised{ Uname.uname.suite_mask}
429
+ # assert_kind_of(String,Uname.uname.suite_mask)
430
+ #end
431
+
432
+ def test_system_device
433
+ assert_nothing_raised{ Uname.uname.system_device}
434
+ assert_kind_of(String, Uname.uname.system_device)
435
+ end
436
+
437
+ def test_system_directory
438
+ assert_nothing_raised{ Uname.uname.system_directory}
439
+ assert_kind_of(String, Uname.uname.system_directory)
440
+ end
441
+
442
+ # Not yet supported - WinXP or later only
443
+ #def test_system_drive
444
+ # assert_nothing_raised{ Uname.uname.system_drive}
445
+ # assert_kind_of(String,Uname.uname.system_drive)
446
+ #end
447
+
448
+ # Fails on Win XP Pro - returns nil - reason unknown
449
+ #def test_total_swap_space_size
450
+ # assert_nothing_raised{ Uname.uname.total_swap_space_size}
451
+ # assert_kind_of(Fixnum,Uname.uname.total_swap_space_size)
452
+ #end
453
+
454
+ def test_total_virtual_memory_size
455
+ assert_nothing_raised{ Uname.uname.total_virtual_memory_size}
456
+ assert_kind_of(Fixnum, Uname.uname.total_virtual_memory_size)
457
+ end
458
+
459
+ def test_total_visible_memory_size
460
+ assert_nothing_raised{ Uname.uname.total_visible_memory_size}
461
+ assert_kind_of(Fixnum, Uname.uname.total_visible_memory_size)
462
+ end
463
+
464
+ def test_version
465
+ assert_nothing_raised{ Uname.uname.version}
466
+ assert_kind_of(String, Uname.uname.version)
467
+ end
468
+
469
+ def test_windows_directory
470
+ assert_nothing_raised{ Uname.uname.windows_directory}
471
+ assert_kind_of(String, Uname.uname.windows_directory)
472
+ end
473
+ end
474
+ end