sys-proctable 0.9.1-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,39 @@
1
+ require 'rubygems'
2
+ require 'rbconfig'
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = 'sys-proctable'
6
+ spec.version = '0.9.1'
7
+ spec.author = 'Daniel J. Berger'
8
+ spec.license = 'Artistic 2.0'
9
+ spec.email = 'djberg96@gmail.com'
10
+ spec.homepage = 'http://www.rubyforge.org/projects/sysutils'
11
+ spec.platform = Gem::Platform::CURRENT # Probably altered by Rake task
12
+ spec.summary = 'An interface for providing process table information'
13
+ spec.test_files = ['test/test_sys_proctable_all.rb']
14
+
15
+ # Additional files for your platform are added by the 'rake gem' task.
16
+ spec.files = [
17
+ 'benchmarks/bench_ps.rb',
18
+ 'examples/example_ps.rb',
19
+ 'lib/sys/top.rb',
20
+ 'CHANGES',
21
+ 'MANIFEST',
22
+ 'Rakefile',
23
+ 'README',
24
+ 'sys-proctable.gemspec'
25
+ ]
26
+
27
+ spec.rubyforge_project = 'sysutils'
28
+ spec.extra_rdoc_files = ['CHANGES', 'README', 'MANIFEST', 'doc/top.txt']
29
+
30
+ spec.add_development_dependency('test-unit', '>= 2.1.2')
31
+
32
+ spec.description = <<-EOF
33
+ The sys-proctable library provides an interface for gathering information
34
+ about processes on your system, i.e. the process table. Most major
35
+ platforms are supported and, while different platforms may return
36
+ different information, the external interface is identical across
37
+ platforms.
38
+ EOF
39
+ end
@@ -0,0 +1,85 @@
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 'rbconfig'
13
+ require 'test/test_sys_top'
14
+ include Sys
15
+
16
+ class TC_ProcTable_All < Test::Unit::TestCase
17
+ def self.startup
18
+ @@windows = Config::CONFIG['host_os'] =~ /windows|win32|msdos|mswin32|mingw|cygwin/i
19
+ end
20
+
21
+ def setup
22
+ @pid = @@windows ? 0 : 1
23
+ end
24
+
25
+ def test_version
26
+ assert_equal('0.9.1', ProcTable::VERSION)
27
+ end
28
+
29
+ def test_fields
30
+ assert_respond_to(ProcTable, :fields)
31
+ assert_nothing_raised{ ProcTable.fields }
32
+ assert_kind_of(Array, ProcTable.fields)
33
+ assert_kind_of(String, ProcTable.fields.first)
34
+ end
35
+
36
+ def test_ps
37
+ assert_respond_to(ProcTable, :ps)
38
+ assert_nothing_raised{ ProcTable.ps }
39
+ assert_nothing_raised{ ProcTable.ps{} }
40
+ end
41
+
42
+ def test_ps_with_pid
43
+ assert_nothing_raised{ ProcTable.ps(0) }
44
+ end
45
+
46
+ def test_ps_with_explicit_nil
47
+ assert_nothing_raised{ ProcTable.ps(nil) }
48
+ assert_kind_of(Array, ProcTable.ps(nil))
49
+ end
50
+
51
+ def test_ps_return_value
52
+ assert_kind_of(Array, ProcTable.ps)
53
+ assert_kind_of(Struct::ProcTableStruct, ProcTable.ps(@pid))
54
+ assert_equal(nil, ProcTable.ps(999999999))
55
+ assert_equal(nil, ProcTable.ps(999999999){})
56
+ assert_equal(nil, ProcTable.ps{})
57
+ end
58
+
59
+ def test_ps_returned_struct_is_frozen
60
+ assert_true(ProcTable.ps.first.frozen?)
61
+ end
62
+
63
+ def test_ps_expected_errors
64
+ assert_raises(TypeError){ ProcTable.ps('vim') }
65
+ omit_if(@@windows, 'ArgumentError check skipped on MS Windows')
66
+ assert_raises(ArgumentError){ ProcTable.ps(0, 'localhost') }
67
+ end
68
+
69
+ def test_new_not_allowed
70
+ assert_raise(NoMethodError){ Sys::ProcTable.new }
71
+ end
72
+
73
+ def test_error_class_defined
74
+ assert_not_nil(Sys::ProcTable::Error)
75
+ assert_kind_of(StandardError, Sys::ProcTable::Error.new)
76
+ end
77
+
78
+ def teardown
79
+ @pid = nil
80
+ end
81
+
82
+ def self.teardown
83
+ @@windows = nil
84
+ end
85
+ end
@@ -0,0 +1,320 @@
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
+ assert_equal(@@fields, @@ptable.members)
303
+ end
304
+
305
+ # Only Windows supports a hostname as a second argument
306
+ def test_ps_with_pid_and_host
307
+ assert_nothing_raised{ ProcTable.ps(0, @@hostname) }
308
+ assert_kind_of(Struct::ProcTableStruct, ProcTable.ps(0, @@hostname))
309
+ end
310
+
311
+ def test_ps_expected_errors
312
+ assert_raise(ArgumentError){ ProcTable.ps(0, @@hostname, 0) }
313
+ end
314
+
315
+ def self.shutdown
316
+ @@ptable = nil
317
+ @@hostname = nil
318
+ @@fields = nil
319
+ end
320
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sys-proctable
3
+ version: !ruby/object:Gem::Version
4
+ hash: 57
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 9
9
+ - 1
10
+ version: 0.9.1
11
+ platform: universal-mingw32
12
+ authors:
13
+ - Daniel J. Berger
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-08-20 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: test-unit
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 15
29
+ segments:
30
+ - 2
31
+ - 1
32
+ - 2
33
+ version: 2.1.2
34
+ type: :development
35
+ version_requirements: *id001
36
+ description: " The sys-proctable library provides an interface for gathering information\n about processes on your system, i.e. the process table. Most major\n platforms are supported and, while different platforms may return\n different information, the external interface is identical across\n platforms.\n"
37
+ email: djberg96@gmail.com
38
+ executables: []
39
+
40
+ extensions: []
41
+
42
+ extra_rdoc_files:
43
+ - CHANGES
44
+ - README
45
+ - MANIFEST
46
+ - doc/top.txt
47
+ files:
48
+ - benchmarks/bench_ps.rb
49
+ - examples/example_ps.rb
50
+ - lib/sys/top.rb
51
+ - CHANGES
52
+ - MANIFEST
53
+ - Rakefile
54
+ - README
55
+ - sys-proctable.gemspec
56
+ - test/test_sys_proctable_all.rb
57
+ - doc/top.txt
58
+ - lib/windows/sys/proctable.rb
59
+ - test/test_sys_proctable_windows.rb
60
+ homepage: http://www.rubyforge.org/projects/sysutils
61
+ licenses:
62
+ - Artistic 2.0
63
+ post_install_message:
64
+ rdoc_options: []
65
+
66
+ require_paths:
67
+ - lib
68
+ - lib/windows
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ hash: 3
75
+ segments:
76
+ - 0
77
+ version: "0"
78
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ hash: 3
84
+ segments:
85
+ - 0
86
+ version: "0"
87
+ requirements: []
88
+
89
+ rubyforge_project: sysutils
90
+ rubygems_version: 1.8.6
91
+ signing_key:
92
+ specification_version: 3
93
+ summary: An interface for providing process table information
94
+ test_files:
95
+ - test/test_sys_proctable_all.rb
96
+ - test/test_sys_proctable_windows.rb