sys-proctable 0.9.1-universal-mingw32 → 0.9.2-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,13 +9,12 @@ gem 'test-unit'
9
9
 
10
10
  require 'test/unit'
11
11
  require 'sys/proctable'
12
- require 'rbconfig'
13
12
  require 'test/test_sys_top'
14
13
  include Sys
15
14
 
16
15
  class TC_ProcTable_All < Test::Unit::TestCase
17
16
  def self.startup
18
- @@windows = Config::CONFIG['host_os'] =~ /windows|win32|msdos|mswin32|mingw|cygwin/i
17
+ @@windows = File::ALT_SEPARATOR
19
18
  end
20
19
 
21
20
  def setup
@@ -23,7 +22,7 @@ class TC_ProcTable_All < Test::Unit::TestCase
23
22
  end
24
23
 
25
24
  def test_version
26
- assert_equal('0.9.1', ProcTable::VERSION)
25
+ assert_equal('0.9.2', ProcTable::VERSION)
27
26
  end
28
27
 
29
28
  def test_fields
@@ -1,320 +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
- 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
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