sys-proctable 1.0.0-universal-mingw32 → 1.1.0-universal-mingw32

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,40 +1,40 @@
1
- require 'rubygems'
2
-
3
- Gem::Specification.new do |spec|
4
- spec.name = 'sys-proctable'
5
- spec.version = '1.0.0'
6
- spec.author = 'Daniel J. Berger'
7
- spec.license = 'Artistic 2.0'
8
- spec.email = 'djberg96@gmail.com'
9
- spec.homepage = 'http://github.com/djberg96/sys-proctable'
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
- spec.cert_chain = ['certs/djberg96_pub.pem']
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/proctable/version.rb',
20
- 'lib/sys/top.rb',
21
- 'CHANGES',
22
- 'MANIFEST',
23
- 'Rakefile',
24
- 'README',
25
- 'sys-proctable.gemspec'
26
- ]
27
-
28
- spec.extra_rdoc_files = ['CHANGES', 'README', 'MANIFEST', 'doc/top.txt']
29
-
30
- spec.add_development_dependency('test-unit')
31
- spec.add_development_dependency('rake')
32
-
33
- spec.description = <<-EOF
34
- The sys-proctable library provides an interface for gathering information
35
- about processes on your system, i.e. the process table. Most major
36
- platforms are supported and, while different platforms may return
37
- different information, the external interface is identical across
38
- platforms.
39
- EOF
40
- end
1
+ require 'rubygems'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = 'sys-proctable'
5
+ spec.version = '1.1.0'
6
+ spec.author = 'Daniel J. Berger'
7
+ spec.license = 'Apache 2.0'
8
+ spec.email = 'djberg96@gmail.com'
9
+ spec.homepage = 'http://github.com/djberg96/sys-proctable'
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
+ spec.cert_chain = ['certs/djberg96_pub.pem']
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/proctable/version.rb',
20
+ 'lib/sys/top.rb',
21
+ 'CHANGES',
22
+ 'MANIFEST',
23
+ 'Rakefile',
24
+ 'README',
25
+ 'sys-proctable.gemspec'
26
+ ]
27
+
28
+ spec.extra_rdoc_files = ['CHANGES', 'README', 'MANIFEST', 'doc/top.txt']
29
+
30
+ spec.add_development_dependency('test-unit')
31
+ spec.add_development_dependency('rake')
32
+
33
+ spec.description = <<-EOF
34
+ The sys-proctable library provides an interface for gathering information
35
+ about processes on your system, i.e. the process table. Most major
36
+ platforms are supported and, while different platforms may return
37
+ different information, the external interface is identical across
38
+ platforms.
39
+ EOF
40
+ end
@@ -1,87 +1,98 @@
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 'test-unit'
8
- require 'sys/proctable'
9
- require 'test/test_sys_top'
10
- include Sys
11
-
12
- class TC_ProcTable_All < Test::Unit::TestCase
13
- def self.startup
14
- @@windows = File::ALT_SEPARATOR
15
- end
16
-
17
- def setup
18
- @pid = @@windows ? 0 : 1
19
- end
20
-
21
- def test_version
22
- assert_equal('1.0.0', ProcTable::VERSION)
23
- end
24
-
25
- def test_fields
26
- assert_respond_to(ProcTable, :fields)
27
- assert_nothing_raised{ ProcTable.fields }
28
- assert_kind_of(Array, ProcTable.fields)
29
- assert_kind_of(String, ProcTable.fields.first)
30
- end
31
-
32
- def test_ps
33
- assert_respond_to(ProcTable, :ps)
34
- assert_nothing_raised{ ProcTable.ps }
35
- assert_nothing_raised{ ProcTable.ps{} }
36
- end
37
-
38
- def test_ps_with_pid
39
- assert_nothing_raised{ ProcTable.ps(0) }
40
- end
41
-
42
- def test_ps_with_explicit_nil
43
- assert_nothing_raised{ ProcTable.ps(nil) }
44
- assert_kind_of(Array, ProcTable.ps(nil))
45
- end
46
-
47
- def test_ps_return_value
48
- assert_kind_of(Array, ProcTable.ps)
49
- assert_kind_of(Struct::ProcTableStruct, ProcTable.ps(@pid))
50
- assert_equal(nil, ProcTable.ps(999999999))
51
- assert_equal(nil, ProcTable.ps(999999999){})
52
- assert_equal(nil, ProcTable.ps{})
53
- end
54
-
55
- def test_ps_returned_struct_is_frozen
56
- assert_true(ProcTable.ps.first.frozen?)
57
- end
58
-
59
- def test_ps_expected_errors
60
- assert_raises(TypeError){ ProcTable.ps('vim') }
61
- omit_if(@@windows, 'ArgumentError check skipped on MS Windows')
62
- assert_raises(ArgumentError){ ProcTable.ps(0, 'localhost') }
63
- end
64
-
65
- def test_new_not_allowed
66
- assert_raise(NoMethodError){ Sys::ProcTable.new }
67
- end
68
-
69
- def test_error_class_defined
70
- assert_not_nil(Sys::ProcTable::Error)
71
- assert_kind_of(StandardError, Sys::ProcTable::Error.new)
72
- end
73
-
74
- def test_from_thread
75
- Thread.new do
76
- Sys::ProcTable.ps
77
- end.value
78
- end
79
-
80
- def teardown
81
- @pid = nil
82
- end
83
-
84
- def self.teardown
85
- @@windows = nil
86
- end
87
- end
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 'test-unit'
8
+ require 'sys/proctable'
9
+ require 'test/test_sys_top'
10
+ include Sys
11
+
12
+ class TC_ProcTable_All < Test::Unit::TestCase
13
+ def self.startup
14
+ @@windows = File::ALT_SEPARATOR
15
+ end
16
+
17
+ def setup
18
+ @pid = Process.pid
19
+ end
20
+
21
+ test "version is set to expected value" do
22
+ assert_equal('1.1.0', ProcTable::VERSION)
23
+ end
24
+
25
+ test "fields basic functionality" do
26
+ assert_respond_to(ProcTable, :fields)
27
+ assert_nothing_raised{ ProcTable.fields }
28
+ end
29
+
30
+ test "fields returns expected type" do
31
+ assert_kind_of(Array, ProcTable.fields)
32
+ assert_kind_of(String, ProcTable.fields.first)
33
+ end
34
+
35
+ test "ps basic functionality" do
36
+ assert_respond_to(ProcTable, :ps)
37
+ assert_nothing_raised{ ProcTable.ps }
38
+ assert_nothing_raised{ ProcTable.ps{} }
39
+ end
40
+
41
+ test "ps accepts an optional pid" do
42
+ assert_nothing_raised{ ProcTable.ps(0) }
43
+ end
44
+
45
+ test "ps with explicit nil works as expected" do
46
+ assert_nothing_raised{ ProcTable.ps(nil) }
47
+ assert_kind_of(Array, ProcTable.ps(nil))
48
+ end
49
+
50
+ test "ps returns expected results" do
51
+ assert_kind_of(Array, ProcTable.ps)
52
+ assert_kind_of(Struct::ProcTableStruct, ProcTable.ps(@pid))
53
+ end
54
+
55
+ test "ps returns nil if process does not exist" do
56
+ assert_nil(ProcTable.ps(999999999))
57
+ assert_nil(ProcTable.ps(999999999){})
58
+ assert_nil(ProcTable.ps{})
59
+ end
60
+
61
+ test "structs returned by ps are frozen" do
62
+ assert_true(ProcTable.ps.first.frozen?)
63
+ end
64
+
65
+ test "ps accepts numeric arguments only" do
66
+ assert_raises(TypeError){ ProcTable.ps('vim') }
67
+ end
68
+
69
+ test "ps accepts a maximum of one argument on Unix platforms" do
70
+ omit_if(@@windows, 'ArgumentError check skipped on MS Windows')
71
+ assert_raises(ArgumentError){ ProcTable.ps(0, 'localhost') }
72
+ end
73
+
74
+ test "traditional constructor is disabled" do
75
+ assert_raise(NoMethodError){ Sys::ProcTable.new }
76
+ end
77
+
78
+ test "custom error class is defined" do
79
+ assert_not_nil(Sys::ProcTable::Error)
80
+ assert_kind_of(StandardError, Sys::ProcTable::Error.new)
81
+ end
82
+
83
+ test "ps works within a thread" do
84
+ assert_nothing_raised{
85
+ Thread.new do
86
+ Sys::ProcTable.ps
87
+ end.value
88
+ }
89
+ end
90
+
91
+ def teardown
92
+ @pid = nil
93
+ end
94
+
95
+ def self.teardown
96
+ @@windows = nil
97
+ end
98
+ end
@@ -1,324 +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
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