sys-proctable 0.9.3-universal-solaris → 0.9.4-universal-solaris

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.
@@ -7,19 +7,21 @@ module Sys
7
7
  class Top
8
8
 
9
9
  # The version of the sys-top library
10
- VERSION = '1.0.3'
10
+ VERSION = '1.0.4'
11
11
 
12
12
  # Returns an array of Struct::ProcTableStruct elements containing up
13
13
  # to +num+ elements, sorted by +field+. The default number of elements
14
14
  # is 10, while the default field is 'pctcpu'.
15
15
  #
16
- # Exception: the default sort field is 'pid' on Linux and Windows.
16
+ # Exception: the default sort field is 'pid' on AIX and Windows.
17
17
  #
18
18
  def self.top(num=10, field='pctcpu')
19
19
  field = field.to_s if field.is_a?(Symbol)
20
20
 
21
- # Sort by pid on Windows by default
22
- if File::ALT_SEPARATOR && field == 'pctcpu'
21
+ aix = RbConfig::CONFIG['host_os'] =~ /aix/i
22
+
23
+ # Sort by pid on Windows and AIX by default
24
+ if (File::ALT_SEPARATOR || aix) && field == 'pctcpu'
23
25
  field = 'pid'
24
26
  end
25
27
 
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'sys-proctable'
5
- spec.version = '0.9.3'
5
+ spec.version = '0.9.4'
6
6
  spec.author = 'Daniel J. Berger'
7
7
  spec.license = 'Artistic 2.0'
8
8
  spec.email = 'djberg96@gmail.com'
@@ -26,7 +26,8 @@ Gem::Specification.new do |spec|
26
26
  spec.rubyforge_project = 'sysutils'
27
27
  spec.extra_rdoc_files = ['CHANGES', 'README', 'MANIFEST', 'doc/top.txt']
28
28
 
29
- spec.add_development_dependency('test-unit', '>= 2.4.0')
29
+ spec.add_development_dependency('test-unit')
30
+ spec.add_development_dependency('rake')
30
31
 
31
32
  spec.description = <<-EOF
32
33
  The sys-proctable library provides an interface for gathering information
@@ -4,10 +4,7 @@
4
4
  # Test suite for methods common to all platforms. Generally speaking
5
5
  # you should run this test case using the 'rake test' task.
6
6
  #######################################################################
7
- require 'rubygems'
8
- gem 'test-unit'
9
-
10
- require 'test/unit'
7
+ require 'test-unit'
11
8
  require 'sys/proctable'
12
9
  require 'test/test_sys_top'
13
10
  include Sys
@@ -22,7 +19,7 @@ class TC_ProcTable_All < Test::Unit::TestCase
22
19
  end
23
20
 
24
21
  def test_version
25
- assert_equal('0.9.3', ProcTable::VERSION)
22
+ assert_equal('0.9.4', ProcTable::VERSION)
26
23
  end
27
24
 
28
25
  def test_fields
@@ -1,308 +1,306 @@
1
1
  #######################################################################
2
- # tc_sunos.rb
2
+ # test_sys_proctable_sunos.rb
3
3
  #
4
4
  # Test suite for sys-proctable for SunOS/Solaris. This should be run
5
5
  # run via the 'rake test' task.
6
6
  #######################################################################
7
- require 'rubygems'
8
- gem 'test-unit'
9
-
7
+ require 'test-unit'
10
8
  require 'sys/proctable'
11
9
  require 'test/test_sys_proctable_all'
12
10
  include Sys
13
11
 
14
12
  class TC_ProcTable_SunOS < Test::Unit::TestCase
15
- def self.startup
16
- @@fields = %w//
17
- end
18
-
19
- def setup
20
- @ptable = ProcTable.ps.first
21
- end
22
-
23
- # PSINFO
24
-
25
- def test_flag
26
- assert_respond_to(@ptable, :flag)
27
- assert_kind_of(Integer, @ptable.flag)
28
- end
29
-
30
- def test_nlwp
31
- assert_respond_to(@ptable, :nlwp)
32
- assert_kind_of(Integer, @ptable.nlwp)
33
- assert_true(@ptable.nlwp >= 0)
34
- end
35
-
36
- def test_pid
37
- assert_respond_to(@ptable, :pid)
38
- assert_kind_of(Integer, @ptable.pid)
39
- assert_true(@ptable.pid >= 0)
40
- end
41
-
42
- def test_ppid
43
- assert_respond_to(@ptable, :ppid)
44
- assert_kind_of(Integer, @ptable.ppid)
45
- assert_true(@ptable.ppid >= 0)
46
- end
47
-
48
- def test_pgid
49
- assert_respond_to(@ptable, :pgid)
50
- assert_kind_of(Integer, @ptable.pgid)
51
- assert_true(@ptable.pgid >= 0)
52
- end
53
-
54
- def test_sid
55
- assert_respond_to(@ptable, :sid)
56
- assert_kind_of(Integer, @ptable.sid)
57
- assert_true(@ptable.sid >= 0)
58
- end
59
-
60
- def test_uid
61
- assert_respond_to(@ptable, :uid)
62
- assert_kind_of(Integer, @ptable.uid)
63
- assert_true(@ptable.uid >= 0)
64
- end
65
-
66
- def test_euid
67
- assert_respond_to(@ptable, :euid)
68
- assert_kind_of(Integer, @ptable.euid)
69
- assert_true(@ptable.euid >= 0)
70
- end
71
-
72
- def test_gid
73
- assert_respond_to(@ptable, :gid)
74
- assert_kind_of(Integer, @ptable.gid)
75
- assert_true(@ptable.gid >= 0)
76
- end
77
-
78
- def test_egid
79
- assert_respond_to(@ptable, :egid)
80
- assert_kind_of(Integer, @ptable.egid)
81
- assert_true(@ptable.egid >= 0)
82
- end
83
-
84
- def test_addr
85
- assert_respond_to(@ptable, :addr)
86
- assert_kind_of(Integer, @ptable.addr)
87
- assert_true(@ptable.addr >= 0)
88
- end
89
-
90
- def test_size
91
- assert_respond_to(@ptable, :size)
92
- assert_kind_of(Integer, @ptable.size)
93
- assert_true(@ptable.size >= 0)
94
- end
95
-
96
- def test_rssize
97
- assert_respond_to(@ptable, :rssize)
98
- assert_kind_of(Integer, @ptable.rssize)
99
- assert_true(@ptable.rssize >= 0)
100
- end
101
-
102
- def test_ttydev
103
- assert_respond_to(@ptable, :ttydev)
104
- assert_kind_of(Integer, @ptable.ttydev)
105
- assert_true(@ptable.ttydev >= 0 || @ptable.ttydev == -1)
106
- end
107
-
108
- def test_pctcpu
109
- assert_respond_to(@ptable, :pctcpu)
110
- assert_kind_of(Float, @ptable.pctcpu)
111
- assert_true(@ptable.pctcpu >= 0)
112
- end
113
-
114
- def test_pctmem
115
- assert_respond_to(@ptable, :pctmem)
116
- assert_kind_of(Float, @ptable.pctmem)
117
- assert_true(@ptable.pctmem >= 0)
118
- end
119
-
120
- def test_start
121
- assert_respond_to(@ptable, :start)
122
- assert_kind_of(Time, @ptable.start)
123
- end
124
-
125
- def test_time
126
- assert_respond_to(@ptable, :time)
127
- assert_kind_of(Integer, @ptable.time)
128
- assert_true(@ptable.time >= 0)
129
- end
130
-
131
- def test_ctime
132
- assert_respond_to(@ptable, :ctime)
133
- assert_kind_of(Integer, @ptable.ctime)
134
- assert_true(@ptable.ctime >= 0)
135
- end
136
-
137
- def test_fname
138
- assert_respond_to(@ptable, :fname)
139
- assert_kind_of(String, @ptable.fname)
140
- assert_true(@ptable.fname.size > 0)
141
- end
142
-
143
- def test_comm_alias
144
- assert_respond_to(@ptable, :comm)
145
- assert_kind_of(String, @ptable.comm)
146
- assert_true(@ptable.comm.size > 0)
147
- end
148
-
149
- def test_psargs
150
- assert_respond_to(@ptable, :psargs)
151
- assert_kind_of(String, @ptable.psargs)
152
- assert_true(@ptable.psargs.size > 0)
153
- end
154
-
155
- def test_wstat
156
- assert_respond_to(@ptable, :wstat)
157
- assert_kind_of(Integer, @ptable.wstat)
158
- assert_true(@ptable.wstat >= 0)
159
- end
160
-
161
- def test_argc
162
- assert_respond_to(@ptable, :argc)
163
- assert_kind_of(Integer, @ptable.argc)
164
- assert_true(@ptable.argc >= 0)
165
- end
166
-
167
- def test_argv
168
- assert_respond_to(@ptable, :argv)
169
- assert_kind_of(Integer, @ptable.argv)
170
- assert_true(@ptable.argv >= 0)
171
- end
172
-
173
- def test_envp
174
- assert_respond_to(@ptable, :envp)
175
- assert_kind_of(Integer, @ptable.envp)
176
- assert_true(@ptable.envp >= 0)
177
- end
178
-
179
- def test_dmodel
180
- assert_respond_to(@ptable, :dmodel)
181
- assert_kind_of(Integer, @ptable.dmodel)
182
- assert_true(@ptable.dmodel >= 0)
183
- end
184
-
185
- def test_taskid
186
- assert_respond_to(@ptable, :taskid)
187
- assert_kind_of(Integer, @ptable.taskid)
188
- assert_true(@ptable.taskid >= 0)
189
- end
190
-
191
- def test_projid
192
- assert_respond_to(@ptable, :projid)
193
- assert_kind_of(Integer, @ptable.projid)
194
- assert_true(@ptable.projid >= 0)
195
- end
196
-
197
- def test_nzomb
198
- assert_respond_to(@ptable, :nzomb)
199
- assert_kind_of(Integer, @ptable.nzomb)
200
- assert_true(@ptable.nzomb >= 0)
201
- end
202
-
203
- def test_poolid
204
- assert_respond_to(@ptable, :poolid)
205
- assert_kind_of(Integer, @ptable.poolid)
206
- assert_true(@ptable.poolid >= 0)
207
- end
208
-
209
- def test_zoneid
210
- assert_respond_to(@ptable, :zoneid)
211
- assert_kind_of(Integer, @ptable.zoneid)
212
- assert_true(@ptable.zoneid >= 0)
213
- end
214
-
215
- def test_contract
216
- assert_respond_to(@ptable, :contract)
217
- assert_kind_of(Integer, @ptable.contract)
218
- assert_true(@ptable.contract >= 0 || @ptable.contract == -1)
219
- end
220
-
221
- # LWPSINFO
222
-
223
- def test_lwpid
224
- assert_respond_to(@ptable, :lwpid)
225
- assert_kind_of(Integer, @ptable.lwpid)
226
- assert_true(@ptable.lwpid >= 0)
227
- end
228
-
229
- def test_wchan
230
- assert_respond_to(@ptable, :wchan)
231
- assert_kind_of(Integer, @ptable.wchan)
232
- assert_true(@ptable.wchan >= 0)
233
- end
234
-
235
- def test_stype
236
- assert_respond_to(@ptable, :stype)
237
- assert_kind_of(Fixnum, @ptable.stype)
238
- assert_true(@ptable.stype >= 0)
239
- end
240
-
241
- def test_state
242
- assert_respond_to(@ptable, :state)
243
- assert_kind_of(Fixnum, @ptable.state)
244
- assert_true(@ptable.state >= 0)
245
- end
246
-
247
- def test_sname
248
- assert_respond_to(@ptable, :sname)
249
- assert_kind_of(String, @ptable.sname)
250
- assert_true(['S', 'R', 'Z', 'T', 'I', 'O'].include?(@ptable.sname))
251
- end
252
-
253
- def test_nice
254
- assert_respond_to(@ptable, :nice)
255
- assert_kind_of(Fixnum, @ptable.nice)
256
- assert_true(@ptable.nice >= 0)
257
- end
258
-
259
- def test_syscall
260
- assert_respond_to(@ptable, :syscall)
261
- assert_kind_of(Fixnum, @ptable.syscall)
262
- assert_true(@ptable.syscall >= 0)
263
- end
264
-
265
- def test_pri
266
- assert_respond_to(@ptable, :pri)
267
- assert_kind_of(Fixnum, @ptable.pri)
268
- assert_true(@ptable.pri >= 0)
269
- end
270
-
271
- def test_clname
272
- assert_respond_to(@ptable, :clname)
273
- assert_kind_of(String, @ptable.clname)
274
- assert_true(@ptable.clname.length >= 0 && @ptable.clname.length <= 8)
275
- end
276
-
277
- def test_name
278
- assert_respond_to(@ptable, :name)
279
- assert_kind_of(String, @ptable.name)
280
- assert_true(@ptable.name.length >= 0 && @ptable.name.length <= 16)
281
- end
282
-
283
- def test_onpro
284
- assert_respond_to(@ptable, :onpro)
285
- assert_kind_of(Fixnum, @ptable.onpro)
286
- assert_true(@ptable.onpro >= 0)
287
- end
288
-
289
- def test_bindpro
290
- assert_respond_to(@ptable, :bindpro)
291
- assert_kind_of(Fixnum, @ptable.bindpro)
292
- assert_true(@ptable.bindpro >= 0 || @ptable.bindpro == -1)
293
- end
294
-
295
- def test_bindpset
296
- assert_respond_to(@ptable, :bindpset)
297
- assert_kind_of(Fixnum, @ptable.bindpset)
298
- assert_true(@ptable.bindpset >= 0 || @ptable.bindpset == -1)
299
- end
300
-
301
- def teardown
302
- @ptable = nil
303
- end
304
-
305
- def self.shutdown
306
- @@fields = nil
307
- end
13
+ def self.startup
14
+ @@fields = %w//
15
+ end
16
+
17
+ def setup
18
+ @ptable = ProcTable.ps.first
19
+ end
20
+
21
+ # PSINFO
22
+
23
+ def test_flag
24
+ assert_respond_to(@ptable, :flag)
25
+ assert_kind_of(Integer, @ptable.flag)
26
+ end
27
+
28
+ def test_nlwp
29
+ assert_respond_to(@ptable, :nlwp)
30
+ assert_kind_of(Integer, @ptable.nlwp)
31
+ assert_true(@ptable.nlwp >= 0)
32
+ end
33
+
34
+ def test_pid
35
+ assert_respond_to(@ptable, :pid)
36
+ assert_kind_of(Integer, @ptable.pid)
37
+ assert_true(@ptable.pid >= 0)
38
+ end
39
+
40
+ def test_ppid
41
+ assert_respond_to(@ptable, :ppid)
42
+ assert_kind_of(Integer, @ptable.ppid)
43
+ assert_true(@ptable.ppid >= 0)
44
+ end
45
+
46
+ def test_pgid
47
+ assert_respond_to(@ptable, :pgid)
48
+ assert_kind_of(Integer, @ptable.pgid)
49
+ assert_true(@ptable.pgid >= 0)
50
+ end
51
+
52
+ def test_sid
53
+ assert_respond_to(@ptable, :sid)
54
+ assert_kind_of(Integer, @ptable.sid)
55
+ assert_true(@ptable.sid >= 0)
56
+ end
57
+
58
+ def test_uid
59
+ assert_respond_to(@ptable, :uid)
60
+ assert_kind_of(Integer, @ptable.uid)
61
+ assert_true(@ptable.uid >= 0)
62
+ end
63
+
64
+ def test_euid
65
+ assert_respond_to(@ptable, :euid)
66
+ assert_kind_of(Integer, @ptable.euid)
67
+ assert_true(@ptable.euid >= 0)
68
+ end
69
+
70
+ def test_gid
71
+ assert_respond_to(@ptable, :gid)
72
+ assert_kind_of(Integer, @ptable.gid)
73
+ assert_true(@ptable.gid >= 0)
74
+ end
75
+
76
+ def test_egid
77
+ assert_respond_to(@ptable, :egid)
78
+ assert_kind_of(Integer, @ptable.egid)
79
+ assert_true(@ptable.egid >= 0)
80
+ end
81
+
82
+ def test_addr
83
+ assert_respond_to(@ptable, :addr)
84
+ assert_kind_of(Integer, @ptable.addr)
85
+ assert_true(@ptable.addr >= 0)
86
+ end
87
+
88
+ def test_size
89
+ assert_respond_to(@ptable, :size)
90
+ assert_kind_of(Integer, @ptable.size)
91
+ assert_true(@ptable.size >= 0)
92
+ end
93
+
94
+ def test_rssize
95
+ assert_respond_to(@ptable, :rssize)
96
+ assert_kind_of(Integer, @ptable.rssize)
97
+ assert_true(@ptable.rssize >= 0)
98
+ end
99
+
100
+ def test_ttydev
101
+ assert_respond_to(@ptable, :ttydev)
102
+ assert_kind_of(Integer, @ptable.ttydev)
103
+ assert_true(@ptable.ttydev >= 0 || @ptable.ttydev == -1)
104
+ end
105
+
106
+ def test_pctcpu
107
+ assert_respond_to(@ptable, :pctcpu)
108
+ assert_kind_of(Float, @ptable.pctcpu)
109
+ assert_true(@ptable.pctcpu >= 0)
110
+ end
111
+
112
+ def test_pctmem
113
+ assert_respond_to(@ptable, :pctmem)
114
+ assert_kind_of(Float, @ptable.pctmem)
115
+ assert_true(@ptable.pctmem >= 0)
116
+ end
117
+
118
+ def test_start
119
+ assert_respond_to(@ptable, :start)
120
+ assert_kind_of(Time, @ptable.start)
121
+ end
122
+
123
+ def test_time
124
+ assert_respond_to(@ptable, :time)
125
+ assert_kind_of(Integer, @ptable.time)
126
+ assert_true(@ptable.time >= 0)
127
+ end
128
+
129
+ def test_ctime
130
+ assert_respond_to(@ptable, :ctime)
131
+ assert_kind_of(Integer, @ptable.ctime)
132
+ assert_true(@ptable.ctime >= 0)
133
+ end
134
+
135
+ def test_fname
136
+ assert_respond_to(@ptable, :fname)
137
+ assert_kind_of(String, @ptable.fname)
138
+ assert_true(@ptable.fname.size > 0)
139
+ end
140
+
141
+ def test_comm_alias
142
+ assert_respond_to(@ptable, :comm)
143
+ assert_kind_of(String, @ptable.comm)
144
+ assert_true(@ptable.comm.size > 0)
145
+ end
146
+
147
+ def test_psargs
148
+ assert_respond_to(@ptable, :psargs)
149
+ assert_kind_of(String, @ptable.psargs)
150
+ assert_true(@ptable.psargs.size > 0)
151
+ end
152
+
153
+ def test_wstat
154
+ assert_respond_to(@ptable, :wstat)
155
+ assert_kind_of(Integer, @ptable.wstat)
156
+ assert_true(@ptable.wstat >= 0)
157
+ end
158
+
159
+ def test_argc
160
+ assert_respond_to(@ptable, :argc)
161
+ assert_kind_of(Integer, @ptable.argc)
162
+ assert_true(@ptable.argc >= 0)
163
+ end
164
+
165
+ def test_argv
166
+ assert_respond_to(@ptable, :argv)
167
+ assert_kind_of(Integer, @ptable.argv)
168
+ assert_true(@ptable.argv >= 0)
169
+ end
170
+
171
+ def test_envp
172
+ assert_respond_to(@ptable, :envp)
173
+ assert_kind_of(Integer, @ptable.envp)
174
+ assert_true(@ptable.envp >= 0)
175
+ end
176
+
177
+ def test_dmodel
178
+ assert_respond_to(@ptable, :dmodel)
179
+ assert_kind_of(Integer, @ptable.dmodel)
180
+ assert_true(@ptable.dmodel >= 0)
181
+ end
182
+
183
+ def test_taskid
184
+ assert_respond_to(@ptable, :taskid)
185
+ assert_kind_of(Integer, @ptable.taskid)
186
+ assert_true(@ptable.taskid >= 0)
187
+ end
188
+
189
+ def test_projid
190
+ assert_respond_to(@ptable, :projid)
191
+ assert_kind_of(Integer, @ptable.projid)
192
+ assert_true(@ptable.projid >= 0)
193
+ end
194
+
195
+ def test_nzomb
196
+ assert_respond_to(@ptable, :nzomb)
197
+ assert_kind_of(Integer, @ptable.nzomb)
198
+ assert_true(@ptable.nzomb >= 0)
199
+ end
200
+
201
+ def test_poolid
202
+ assert_respond_to(@ptable, :poolid)
203
+ assert_kind_of(Integer, @ptable.poolid)
204
+ assert_true(@ptable.poolid >= 0)
205
+ end
206
+
207
+ def test_zoneid
208
+ assert_respond_to(@ptable, :zoneid)
209
+ assert_kind_of(Integer, @ptable.zoneid)
210
+ assert_true(@ptable.zoneid >= 0)
211
+ end
212
+
213
+ def test_contract
214
+ assert_respond_to(@ptable, :contract)
215
+ assert_kind_of(Integer, @ptable.contract)
216
+ assert_true(@ptable.contract >= 0 || @ptable.contract == -1)
217
+ end
218
+
219
+ # LWPSINFO
220
+
221
+ def test_lwpid
222
+ assert_respond_to(@ptable, :lwpid)
223
+ assert_kind_of(Integer, @ptable.lwpid)
224
+ assert_true(@ptable.lwpid >= 0)
225
+ end
226
+
227
+ def test_wchan
228
+ assert_respond_to(@ptable, :wchan)
229
+ assert_kind_of(Integer, @ptable.wchan)
230
+ assert_true(@ptable.wchan >= 0)
231
+ end
232
+
233
+ def test_stype
234
+ assert_respond_to(@ptable, :stype)
235
+ assert_kind_of(Fixnum, @ptable.stype)
236
+ assert_true(@ptable.stype >= 0)
237
+ end
238
+
239
+ def test_state
240
+ assert_respond_to(@ptable, :state)
241
+ assert_kind_of(Fixnum, @ptable.state)
242
+ assert_true(@ptable.state >= 0)
243
+ end
244
+
245
+ def test_sname
246
+ assert_respond_to(@ptable, :sname)
247
+ assert_kind_of(String, @ptable.sname)
248
+ assert_true(['S', 'R', 'Z', 'T', 'I', 'O'].include?(@ptable.sname))
249
+ end
250
+
251
+ def test_nice
252
+ assert_respond_to(@ptable, :nice)
253
+ assert_kind_of(Fixnum, @ptable.nice)
254
+ assert_true(@ptable.nice >= 0)
255
+ end
256
+
257
+ def test_syscall
258
+ assert_respond_to(@ptable, :syscall)
259
+ assert_kind_of(Fixnum, @ptable.syscall)
260
+ assert_true(@ptable.syscall >= 0)
261
+ end
262
+
263
+ def test_pri
264
+ assert_respond_to(@ptable, :pri)
265
+ assert_kind_of(Fixnum, @ptable.pri)
266
+ assert_true(@ptable.pri >= 0)
267
+ end
268
+
269
+ def test_clname
270
+ assert_respond_to(@ptable, :clname)
271
+ assert_kind_of(String, @ptable.clname)
272
+ assert_true(@ptable.clname.length >= 0 && @ptable.clname.length <= 8)
273
+ end
274
+
275
+ def test_name
276
+ assert_respond_to(@ptable, :name)
277
+ assert_kind_of(String, @ptable.name)
278
+ assert_true(@ptable.name.length >= 0 && @ptable.name.length <= 16)
279
+ end
280
+
281
+ def test_onpro
282
+ assert_respond_to(@ptable, :onpro)
283
+ assert_kind_of(Fixnum, @ptable.onpro)
284
+ assert_true(@ptable.onpro >= 0)
285
+ end
286
+
287
+ def test_bindpro
288
+ assert_respond_to(@ptable, :bindpro)
289
+ assert_kind_of(Fixnum, @ptable.bindpro)
290
+ assert_true(@ptable.bindpro >= 0 || @ptable.bindpro == -1)
291
+ end
292
+
293
+ def test_bindpset
294
+ assert_respond_to(@ptable, :bindpset)
295
+ assert_kind_of(Fixnum, @ptable.bindpset)
296
+ assert_true(@ptable.bindpset >= 0 || @ptable.bindpset == -1)
297
+ end
298
+
299
+ def teardown
300
+ @ptable = nil
301
+ end
302
+
303
+ def self.shutdown
304
+ @@fields = nil
305
+ end
308
306
  end