sys-uname 0.7.4-mswin32

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