sys-proctable 0.9.2-universal-mingw

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.
@@ -0,0 +1,38 @@
1
+ require 'rubygems'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = 'sys-proctable'
5
+ spec.version = '0.9.2'
6
+ spec.author = 'Daniel J. Berger'
7
+ spec.license = 'Artistic 2.0'
8
+ spec.email = 'djberg96@gmail.com'
9
+ spec.homepage = 'http://www.rubyforge.org/projects/sysutils'
10
+ spec.platform = Gem::Platform::CURRENT # Probably altered by Rake task
11
+ spec.summary = 'An interface for providing process table information'
12
+ spec.test_files = ['test/test_sys_proctable_all.rb']
13
+
14
+ # Additional files for your platform are added by the 'rake gem' task.
15
+ spec.files = [
16
+ 'benchmarks/bench_ps.rb',
17
+ 'examples/example_ps.rb',
18
+ 'lib/sys/top.rb',
19
+ 'CHANGES',
20
+ 'MANIFEST',
21
+ 'Rakefile',
22
+ 'README',
23
+ 'sys-proctable.gemspec'
24
+ ]
25
+
26
+ spec.rubyforge_project = 'sysutils'
27
+ spec.extra_rdoc_files = ['CHANGES', 'README', 'MANIFEST', 'doc/top.txt']
28
+
29
+ spec.add_development_dependency('test-unit', '>= 2.4.0')
30
+
31
+ spec.description = <<-EOF
32
+ The sys-proctable library provides an interface for gathering information
33
+ about processes on your system, i.e. the process table. Most major
34
+ platforms are supported and, while different platforms may return
35
+ different information, the external interface is identical across
36
+ platforms.
37
+ EOF
38
+ end
@@ -0,0 +1,84 @@
1
+ #######################################################################
2
+ # test_sys_proctable_all.rb
3
+ #
4
+ # Test suite for methods common to all platforms. Generally speaking
5
+ # you should run this test case using the 'rake test' task.
6
+ #######################################################################
7
+ require 'rubygems'
8
+ gem 'test-unit'
9
+
10
+ require 'test/unit'
11
+ require 'sys/proctable'
12
+ require 'test/test_sys_top'
13
+ include Sys
14
+
15
+ class TC_ProcTable_All < Test::Unit::TestCase
16
+ def self.startup
17
+ @@windows = File::ALT_SEPARATOR
18
+ end
19
+
20
+ def setup
21
+ @pid = @@windows ? 0 : 1
22
+ end
23
+
24
+ def test_version
25
+ assert_equal('0.9.2', ProcTable::VERSION)
26
+ end
27
+
28
+ def test_fields
29
+ assert_respond_to(ProcTable, :fields)
30
+ assert_nothing_raised{ ProcTable.fields }
31
+ assert_kind_of(Array, ProcTable.fields)
32
+ assert_kind_of(String, ProcTable.fields.first)
33
+ end
34
+
35
+ def test_ps
36
+ assert_respond_to(ProcTable, :ps)
37
+ assert_nothing_raised{ ProcTable.ps }
38
+ assert_nothing_raised{ ProcTable.ps{} }
39
+ end
40
+
41
+ def test_ps_with_pid
42
+ assert_nothing_raised{ ProcTable.ps(0) }
43
+ end
44
+
45
+ def test_ps_with_explicit_nil
46
+ assert_nothing_raised{ ProcTable.ps(nil) }
47
+ assert_kind_of(Array, ProcTable.ps(nil))
48
+ end
49
+
50
+ def test_ps_return_value
51
+ assert_kind_of(Array, ProcTable.ps)
52
+ assert_kind_of(Struct::ProcTableStruct, ProcTable.ps(@pid))
53
+ assert_equal(nil, ProcTable.ps(999999999))
54
+ assert_equal(nil, ProcTable.ps(999999999){})
55
+ assert_equal(nil, ProcTable.ps{})
56
+ end
57
+
58
+ def test_ps_returned_struct_is_frozen
59
+ assert_true(ProcTable.ps.first.frozen?)
60
+ end
61
+
62
+ def test_ps_expected_errors
63
+ assert_raises(TypeError){ ProcTable.ps('vim') }
64
+ omit_if(@@windows, 'ArgumentError check skipped on MS Windows')
65
+ assert_raises(ArgumentError){ ProcTable.ps(0, 'localhost') }
66
+ end
67
+
68
+ def test_new_not_allowed
69
+ assert_raise(NoMethodError){ Sys::ProcTable.new }
70
+ end
71
+
72
+ def test_error_class_defined
73
+ assert_not_nil(Sys::ProcTable::Error)
74
+ assert_kind_of(StandardError, Sys::ProcTable::Error.new)
75
+ end
76
+
77
+ def teardown
78
+ @pid = nil
79
+ end
80
+
81
+ def self.teardown
82
+ @@windows = nil
83
+ end
84
+ end
@@ -0,0 +1,324 @@
1
+ ############################################################################
2
+ # test_sys_proctable_windows.rb
3
+ #
4
+ # Test suite for the sys-proctable library for MS Windows. This should be
5
+ # run via the 'rake test' task.
6
+ ############################################################################
7
+ require 'rubygems'
8
+ gem 'test-unit'
9
+
10
+ require 'sys/proctable'
11
+ require 'socket'
12
+ require 'test/unit'
13
+ require 'test/test_sys_proctable_all'
14
+
15
+ class TC_ProcTable_MSWindows < Test::Unit::TestCase
16
+ def self.startup
17
+ @@hostname = Socket.gethostname
18
+
19
+ @@fields = %w/
20
+ caption
21
+ cmdline
22
+ comm
23
+ creation_class_name
24
+ creation_date
25
+ cs_creation_class_name
26
+ cs_name description
27
+ executable_path
28
+ execution_state
29
+ handle
30
+ handle_count
31
+ install_date
32
+ kernel_mode_time
33
+ maximum_working_set_size
34
+ minimum_working_set_size name
35
+ os_creation_class_name
36
+ os_name
37
+ other_operation_count
38
+ other_transfer_count
39
+ page_faults
40
+ page_file_usage
41
+ ppid
42
+ peak_page_file_usage
43
+ peak_virtual_size
44
+ peak_working_set_size
45
+ priority
46
+ private_page_count
47
+ pid
48
+ quota_non_paged_pool_usage
49
+ quota_paged_pool_usage
50
+ quota_peak_non_paged_pool_usage
51
+ quota_peak_paged_pool_usage
52
+ read_operation_count
53
+ read_transfer_count
54
+ session_id
55
+ status
56
+ termination_date
57
+ thread_count
58
+ user_mode_time
59
+ virtual_size
60
+ windows_version
61
+ working_set_size
62
+ write_operation_count
63
+ write_transfer_count
64
+ /
65
+
66
+ @@ptable = ProcTable.ps.first
67
+ end
68
+
69
+ def test_write_transfer_count
70
+ assert_respond_to(@@ptable, :write_transfer_count)
71
+ assert_kind_of(Integer, @@ptable.write_transfer_count)
72
+ end
73
+
74
+ def test_write_operation_count
75
+ assert_respond_to(@@ptable, :write_operation_count)
76
+ assert_kind_of(Integer, @@ptable.write_operation_count)
77
+ end
78
+
79
+ def test_working_set_size
80
+ assert_respond_to(@@ptable, :working_set_size)
81
+ assert_kind_of(Integer, @@ptable.working_set_size)
82
+ end
83
+
84
+ def test_windows_version
85
+ assert_respond_to(@@ptable, :windows_version)
86
+ assert_kind_of(String, @@ptable.windows_version)
87
+ end
88
+
89
+ def test_virtual_size
90
+ assert_respond_to(@@ptable, :virtual_size)
91
+ assert_kind_of(Integer, @@ptable.virtual_size)
92
+ end
93
+
94
+ def test_user_mode_time
95
+ assert_respond_to(@@ptable, :user_mode_time)
96
+ assert_kind_of(Integer, @@ptable.user_mode_time)
97
+ end
98
+
99
+ def test_thread_count
100
+ assert_respond_to(@@ptable, :thread_count)
101
+ assert_kind_of(Integer, @@ptable.thread_count)
102
+ end
103
+
104
+ def test_termination_date
105
+ assert_respond_to(@@ptable, :termination_date)
106
+ assert_true([NilClass, Date].include?(@@ptable.termination_date.class))
107
+ end
108
+
109
+ def test_status
110
+ assert_respond_to(@@ptable, :status)
111
+ assert_nil(@@ptable.status) # Always null according to MSDN
112
+ end
113
+
114
+ def test_session_id
115
+ assert_respond_to(@@ptable, :session_id)
116
+ assert_kind_of(Integer, @@ptable.session_id)
117
+ end
118
+
119
+ def test_read_transfer_count
120
+ assert_respond_to(@@ptable, :read_transfer_count)
121
+ assert_kind_of(Integer, @@ptable.read_transfer_count)
122
+ end
123
+
124
+ def test_read_operation_count
125
+ assert_respond_to(@@ptable, :read_operation_count)
126
+ assert_kind_of(Integer, @@ptable.read_operation_count)
127
+ end
128
+
129
+ def test_quota_peak_paged_pool_usage
130
+ assert_respond_to(@@ptable, :quota_peak_paged_pool_usage)
131
+ assert_kind_of(Integer, @@ptable.quota_peak_paged_pool_usage)
132
+ end
133
+
134
+ def test_quota_peak_non_paged_pool_usage
135
+ assert_respond_to(@@ptable, :quota_peak_non_paged_pool_usage)
136
+ assert_kind_of(Integer, @@ptable.quota_peak_non_paged_pool_usage)
137
+ end
138
+
139
+ def test_quota_paged_pool_usage
140
+ assert_respond_to(@@ptable, :quota_paged_pool_usage)
141
+ assert_kind_of(Integer, @@ptable.quota_paged_pool_usage)
142
+ end
143
+
144
+ def test_quota_non_paged_pool_usage
145
+ assert_respond_to(@@ptable, :quota_non_paged_pool_usage)
146
+ assert_kind_of(Integer, @@ptable.quota_non_paged_pool_usage)
147
+ end
148
+
149
+ def test_pid
150
+ assert_respond_to(@@ptable, :pid)
151
+ assert_kind_of(Integer, @@ptable.pid)
152
+ end
153
+
154
+ def test_private_page_count
155
+ assert_respond_to(@@ptable, :private_page_count)
156
+ assert_kind_of(Integer, @@ptable.private_page_count)
157
+ end
158
+
159
+ def test_priority
160
+ assert_respond_to(@@ptable, :priority)
161
+ assert_kind_of(Integer, @@ptable.priority)
162
+ end
163
+
164
+ def test_peak_working_set_size
165
+ assert_respond_to(@@ptable, :peak_working_set_size)
166
+ assert_kind_of(Integer, @@ptable.peak_working_set_size)
167
+ end
168
+
169
+ def test_peak_virtual_size
170
+ assert_respond_to(@@ptable, :peak_virtual_size)
171
+ assert_kind_of(Integer, @@ptable.peak_virtual_size)
172
+ end
173
+
174
+ def test_peak_page_file_usage
175
+ assert_respond_to(@@ptable, :peak_page_file_usage)
176
+ assert_kind_of(Integer, @@ptable.peak_page_file_usage)
177
+ end
178
+
179
+ def test_ppid
180
+ assert_respond_to(@@ptable, :ppid)
181
+ assert_kind_of(Integer, @@ptable.ppid)
182
+ end
183
+
184
+ def test_page_file_usage
185
+ assert_respond_to(@@ptable, :page_file_usage)
186
+ assert_kind_of(Integer, @@ptable.page_file_usage)
187
+ end
188
+
189
+ def test_page_faults
190
+ assert_respond_to(@@ptable, :page_faults)
191
+ assert_kind_of(Integer, @@ptable.page_faults)
192
+ end
193
+
194
+ def test_other_transfer_count
195
+ assert_respond_to(@@ptable, :other_transfer_count)
196
+ assert_kind_of(Integer, @@ptable.other_transfer_count)
197
+ end
198
+
199
+ def test_other_operation_count
200
+ assert_respond_to(@@ptable, :other_operation_count)
201
+ assert_kind_of(Integer, @@ptable.other_operation_count)
202
+ end
203
+
204
+ def test_os_name
205
+ assert_respond_to(@@ptable, :os_name)
206
+ assert_kind_of(String, @@ptable.os_name)
207
+ end
208
+
209
+ def test_os_creation_class_name
210
+ assert_respond_to(@@ptable, :os_creation_class_name)
211
+ assert_kind_of(String, @@ptable.os_creation_class_name)
212
+ end
213
+
214
+ def test_name
215
+ assert_respond_to(@@ptable, :name)
216
+ assert_kind_of(String, @@ptable.name)
217
+ end
218
+
219
+ def test_minimum_working_set_size
220
+ assert_respond_to(@@ptable, :minimum_working_set_size)
221
+ assert_true([NilClass, Integer].include?(@@ptable.minimum_working_set_size.class))
222
+ end
223
+
224
+ def test_maximum_working_set_size
225
+ assert_respond_to(@@ptable, :maximum_working_set_size)
226
+ assert_true([NilClass, Integer].include?(@@ptable.maximum_working_set_size.class))
227
+ end
228
+
229
+ def test_kernel_mode_time
230
+ assert_respond_to(@@ptable, :kernel_mode_time)
231
+ assert_kind_of(Integer, @@ptable.kernel_mode_time)
232
+ end
233
+
234
+ def test_install_date
235
+ assert_respond_to(@@ptable, :install_date)
236
+ assert_true([NilClass, Date].include?(@@ptable.install_date.class))
237
+ end
238
+
239
+ def test_handle_count
240
+ assert_respond_to(@@ptable, :handle_count)
241
+ assert_kind_of(Integer, @@ptable.handle_count)
242
+ end
243
+
244
+ def test_handle
245
+ assert_respond_to(@@ptable, :handle)
246
+ assert_kind_of(String, @@ptable.handle) # MSDN says it's a String
247
+ end
248
+
249
+ def test_execution_state
250
+ assert_respond_to(@@ptable, :execution_state)
251
+ assert_nil(@@ptable.execution_state) # Always NULL according to MSDN
252
+ end
253
+
254
+ def test_executable_path
255
+ assert_respond_to(@@ptable, :executable_path)
256
+ assert_true([NilClass, String].include?(@@ptable.executable_path.class))
257
+ end
258
+
259
+ def test_description
260
+ assert_respond_to(@@ptable, :description)
261
+ assert_kind_of(String, @@ptable.description)
262
+ end
263
+
264
+ def test_cs_name
265
+ assert_respond_to(@@ptable, :cs_name)
266
+ assert_kind_of(String, @@ptable.cs_name)
267
+ end
268
+
269
+ def test_cs_creation_class_name
270
+ assert_respond_to(@@ptable, :cs_creation_class_name)
271
+ assert_kind_of(String, @@ptable.cs_creation_class_name)
272
+ end
273
+
274
+ def test_creation_date
275
+ assert_respond_to(@@ptable, :creation_date)
276
+ assert_true([NilClass, Date].include?(@@ptable.creation_date.class))
277
+ end
278
+
279
+ def test_creation_class_name
280
+ assert_respond_to(@@ptable, :creation_class_name)
281
+ assert_kind_of(String, @@ptable.creation_class_name)
282
+ end
283
+
284
+ def test_comm
285
+ assert_respond_to(@@ptable, :comm)
286
+ assert_kind_of(String, @@ptable.comm)
287
+ end
288
+
289
+ def test_cmdline
290
+ assert_respond_to(@@ptable, :cmdline)
291
+ assert_true([NilClass, String].include?(@@ptable.cmdline.class))
292
+ end
293
+
294
+ def test_caption
295
+ assert_respond_to(@@ptable, :caption)
296
+ assert_kind_of(String, @@ptable.caption)
297
+ end
298
+
299
+ def test_field_members
300
+ assert_equal(@@fields.length, @@ptable.length)
301
+ assert_equal(@@fields, ProcTable.fields)
302
+ if RUBY_VERSION.to_f >= 1.9
303
+ assert_equal(@@fields.map(&:to_sym), @@ptable.members)
304
+ else
305
+ assert_equal(@@fields, @@ptable.members)
306
+ end
307
+ end
308
+
309
+ # Only Windows supports a hostname as a second argument
310
+ def test_ps_with_pid_and_host
311
+ assert_nothing_raised{ ProcTable.ps(0, @@hostname) }
312
+ assert_kind_of(Struct::ProcTableStruct, ProcTable.ps(0, @@hostname))
313
+ end
314
+
315
+ def test_ps_expected_errors
316
+ assert_raise(ArgumentError){ ProcTable.ps(0, @@hostname, 0) }
317
+ end
318
+
319
+ def self.shutdown
320
+ @@ptable = nil
321
+ @@hostname = nil
322
+ @@fields = nil
323
+ end
324
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sys-proctable
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.2
5
+ prerelease:
6
+ platform: universal-mingw
7
+ authors:
8
+ - Daniel J. Berger
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: test-unit
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 2.4.0
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 2.4.0
30
+ description: ! " The sys-proctable library provides an interface for gathering
31
+ information\n about processes on your system, i.e. the process table. Most major\n
32
+ \ platforms are supported and, while different platforms may return\n different
33
+ information, the external interface is identical across\n platforms.\n"
34
+ email: djberg96@gmail.com
35
+ executables: []
36
+ extensions: []
37
+ extra_rdoc_files:
38
+ - CHANGES
39
+ - README
40
+ - MANIFEST
41
+ - doc/top.txt
42
+ files:
43
+ - benchmarks/bench_ps.rb
44
+ - examples/example_ps.rb
45
+ - lib/sys/top.rb
46
+ - CHANGES
47
+ - MANIFEST
48
+ - Rakefile
49
+ - README
50
+ - sys-proctable.gemspec
51
+ - test/test_sys_proctable_all.rb
52
+ - doc/top.txt
53
+ - lib/windows/sys/proctable.rb
54
+ - test/test_sys_proctable_windows.rb
55
+ homepage: http://www.rubyforge.org/projects/sysutils
56
+ licenses:
57
+ - Artistic 2.0
58
+ post_install_message:
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ - lib/windows
63
+ required_ruby_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubyforge_project: sysutils
77
+ rubygems_version: 1.8.24
78
+ signing_key:
79
+ specification_version: 3
80
+ summary: An interface for providing process table information
81
+ test_files:
82
+ - test/test_sys_proctable_all.rb
83
+ - test/test_sys_proctable_windows.rb