tddium-sys-proctable 0.9.2-x86-linux
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +294 -0
- data/MANIFEST +30 -0
- data/README +119 -0
- data/Rakefile +158 -0
- data/benchmarks/bench_ps.rb +21 -0
- data/doc/top.txt +47 -0
- data/examples/example_ps.rb +20 -0
- data/lib/linux/sys/proctable.rb +281 -0
- data/lib/sys/top.rb +32 -0
- data/sys-proctable.gemspec +42 -0
- data/test/test_sys_proctable_all.rb +85 -0
- data/test/test_sys_proctable_linux.rb +298 -0
- metadata +82 -0
@@ -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,298 @@
|
|
1
|
+
#######################################################################
|
2
|
+
# test_sys_proctable_linux.rb
|
3
|
+
#
|
4
|
+
# Test suite for the Linux version of the sys-proctable library. You
|
5
|
+
# should run these tests via the 'rake test' task.
|
6
|
+
#######################################################################
|
7
|
+
require 'rubygems'
|
8
|
+
gem 'test-unit'
|
9
|
+
|
10
|
+
require 'sys/proctable'
|
11
|
+
require 'test/test_sys_proctable_all'
|
12
|
+
include Sys
|
13
|
+
|
14
|
+
class TC_ProcTable_Linux < Test::Unit::TestCase
|
15
|
+
def self.startup
|
16
|
+
@@fields = %w/
|
17
|
+
cmdline cwd exe pid name uid euid gid egid comm state ppid pgrp
|
18
|
+
session tty_num tpgid flags minflt cminflt majflt cmajflt utime
|
19
|
+
stime cutime cstime priority nice itrealvalue starttime vsize
|
20
|
+
rss rlim startcode endcode startstack kstkesp kstkeip signal blocked
|
21
|
+
sigignore sigcatch wchan nswap cnswap exit_signal processor environ
|
22
|
+
pctcpu pctmem
|
23
|
+
/
|
24
|
+
end
|
25
|
+
|
26
|
+
def setup
|
27
|
+
@ptable = ProcTable.ps.last
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_cmdline
|
31
|
+
assert_respond_to(@ptable, :cmdline)
|
32
|
+
assert_kind_of(String, @ptable.cmdline)
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_cwd
|
36
|
+
assert_respond_to(@ptable, :cwd)
|
37
|
+
assert_true([NilClass, String].include?(@ptable.cwd.class))
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_environ
|
41
|
+
assert_respond_to(@ptable, :environ)
|
42
|
+
assert_kind_of(Hash, @ptable.environ)
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_exe
|
46
|
+
assert_respond_to(@ptable, :exe)
|
47
|
+
assert_kind_of(String, @ptable.exe)
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_fd
|
51
|
+
assert_respond_to(@ptable, :fd)
|
52
|
+
assert_kind_of(Hash, @ptable.fd)
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_root
|
56
|
+
assert_respond_to(@ptable, :root)
|
57
|
+
assert_kind_of(String, @ptable.root)
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_pid
|
61
|
+
assert_respond_to(@ptable, :pid)
|
62
|
+
assert_kind_of(Fixnum, @ptable.pid)
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_comm
|
66
|
+
assert_respond_to(@ptable, :comm)
|
67
|
+
assert_kind_of(String, @ptable.comm)
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_state
|
71
|
+
assert_respond_to(@ptable, :state)
|
72
|
+
assert_kind_of(String, @ptable.state)
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_ppid
|
76
|
+
assert_respond_to(@ptable, :ppid)
|
77
|
+
assert_kind_of(Fixnum, @ptable.ppid)
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_pgrp
|
81
|
+
assert_respond_to(@ptable, :pgrp)
|
82
|
+
assert_kind_of(Fixnum, @ptable.pgrp)
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_session
|
86
|
+
assert_respond_to(@ptable, :session)
|
87
|
+
assert_kind_of(Fixnum, @ptable.session)
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_tty_nr
|
91
|
+
assert_respond_to(@ptable, :tty_nr)
|
92
|
+
assert_kind_of(Fixnum, @ptable.tty_nr)
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_tpgid
|
96
|
+
assert_respond_to(@ptable, :tpgid)
|
97
|
+
assert_kind_of(Fixnum, @ptable.tpgid)
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_flags
|
101
|
+
assert_respond_to(@ptable, :flags)
|
102
|
+
assert_kind_of(Fixnum, @ptable.flags)
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_minflt
|
106
|
+
assert_respond_to(@ptable, :minflt)
|
107
|
+
assert_kind_of(Fixnum, @ptable.minflt)
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_cminflt
|
111
|
+
assert_respond_to(@ptable, :cminflt)
|
112
|
+
assert_kind_of(Fixnum, @ptable.cminflt)
|
113
|
+
end
|
114
|
+
|
115
|
+
def test_majflt
|
116
|
+
assert_respond_to(@ptable, :majflt)
|
117
|
+
assert_kind_of(Fixnum, @ptable.majflt)
|
118
|
+
end
|
119
|
+
|
120
|
+
def test_cmajflt
|
121
|
+
assert_respond_to(@ptable, :cmajflt)
|
122
|
+
assert_kind_of(Fixnum, @ptable.cmajflt)
|
123
|
+
end
|
124
|
+
|
125
|
+
def test_utime
|
126
|
+
assert_respond_to(@ptable, :utime)
|
127
|
+
assert_kind_of(Fixnum, @ptable.utime)
|
128
|
+
end
|
129
|
+
|
130
|
+
def test_stime
|
131
|
+
assert_respond_to(@ptable, :stime)
|
132
|
+
assert_kind_of(Fixnum, @ptable.stime)
|
133
|
+
end
|
134
|
+
|
135
|
+
def test_cutime
|
136
|
+
assert_respond_to(@ptable, :cutime)
|
137
|
+
assert_kind_of(Fixnum, @ptable.cutime)
|
138
|
+
end
|
139
|
+
|
140
|
+
def test_cstime
|
141
|
+
assert_respond_to(@ptable, :cstime)
|
142
|
+
assert_kind_of(Fixnum, @ptable.cstime)
|
143
|
+
end
|
144
|
+
|
145
|
+
def test_priority
|
146
|
+
assert_respond_to(@ptable, :priority)
|
147
|
+
assert_kind_of(Fixnum, @ptable.priority)
|
148
|
+
end
|
149
|
+
|
150
|
+
def test_nice
|
151
|
+
assert_respond_to(@ptable, :nice)
|
152
|
+
assert_kind_of(Fixnum, @ptable.nice)
|
153
|
+
end
|
154
|
+
|
155
|
+
def test_itrealvalue
|
156
|
+
assert_respond_to(@ptable, :itrealvalue)
|
157
|
+
assert_kind_of(Fixnum, @ptable.itrealvalue)
|
158
|
+
end
|
159
|
+
|
160
|
+
def test_starttime
|
161
|
+
assert_respond_to(@ptable, :starttime)
|
162
|
+
assert_kind_of(Fixnum, @ptable.starttime)
|
163
|
+
end
|
164
|
+
|
165
|
+
def test_vsize
|
166
|
+
assert_respond_to(@ptable, :vsize)
|
167
|
+
assert_kind_of(Fixnum, @ptable.vsize)
|
168
|
+
end
|
169
|
+
|
170
|
+
def test_rss
|
171
|
+
assert_respond_to(@ptable, :rss)
|
172
|
+
assert_kind_of(Fixnum, @ptable.rss)
|
173
|
+
end
|
174
|
+
|
175
|
+
def test_rlim
|
176
|
+
assert_respond_to(@ptable, :rlim)
|
177
|
+
assert_kind_of(Integer, @ptable.rlim)
|
178
|
+
end
|
179
|
+
|
180
|
+
def test_startcode
|
181
|
+
assert_respond_to(@ptable, :startcode)
|
182
|
+
assert_kind_of(Fixnum, @ptable.startcode)
|
183
|
+
end
|
184
|
+
|
185
|
+
def test_endcode
|
186
|
+
assert_respond_to(@ptable, :endcode)
|
187
|
+
assert_kind_of(Fixnum, @ptable.endcode)
|
188
|
+
end
|
189
|
+
|
190
|
+
def test_startstack
|
191
|
+
assert_respond_to(@ptable, :startstack)
|
192
|
+
assert_kind_of(Integer, @ptable.startstack)
|
193
|
+
end
|
194
|
+
|
195
|
+
def test_kstkesp
|
196
|
+
assert_respond_to(@ptable, :kstkesp)
|
197
|
+
assert_kind_of(Integer, @ptable.kstkesp)
|
198
|
+
end
|
199
|
+
|
200
|
+
def test_kstkeip
|
201
|
+
assert_respond_to(@ptable, :kstkeip)
|
202
|
+
assert_kind_of(Integer, @ptable.kstkeip)
|
203
|
+
end
|
204
|
+
|
205
|
+
def test_signal
|
206
|
+
assert_respond_to(@ptable, :signal)
|
207
|
+
assert_kind_of(Integer, @ptable.signal)
|
208
|
+
end
|
209
|
+
|
210
|
+
def test_blocked
|
211
|
+
assert_respond_to(@ptable, :blocked)
|
212
|
+
assert_kind_of(Fixnum, @ptable.blocked)
|
213
|
+
end
|
214
|
+
|
215
|
+
def test_sigignore
|
216
|
+
assert_respond_to(@ptable, :sigignore)
|
217
|
+
assert_kind_of(Fixnum, @ptable.sigignore)
|
218
|
+
end
|
219
|
+
|
220
|
+
def test_sigcatch
|
221
|
+
assert_respond_to(@ptable, :sigcatch)
|
222
|
+
assert_kind_of(Numeric, @ptable.sigcatch)
|
223
|
+
end
|
224
|
+
|
225
|
+
def test_wchan
|
226
|
+
assert_respond_to(@ptable, :wchan)
|
227
|
+
assert_kind_of(Numeric, @ptable.wchan)
|
228
|
+
end
|
229
|
+
|
230
|
+
def test_nswap
|
231
|
+
assert_respond_to(@ptable, :nswap)
|
232
|
+
assert_kind_of(Fixnum, @ptable.nswap)
|
233
|
+
end
|
234
|
+
|
235
|
+
def test_cnswap
|
236
|
+
assert_respond_to(@ptable, :cnswap)
|
237
|
+
assert_kind_of(Fixnum, @ptable.cnswap)
|
238
|
+
end
|
239
|
+
|
240
|
+
def test_exit_signal
|
241
|
+
assert_respond_to(@ptable, :exit_signal)
|
242
|
+
assert_kind_of(Fixnum, @ptable.exit_signal)
|
243
|
+
end
|
244
|
+
|
245
|
+
def test_processor
|
246
|
+
assert_respond_to(@ptable, :processor)
|
247
|
+
assert_kind_of(Fixnum, @ptable.processor)
|
248
|
+
end
|
249
|
+
|
250
|
+
def test_rt_priority
|
251
|
+
assert_respond_to(@ptable, :rt_priority)
|
252
|
+
assert_kind_of(Fixnum, @ptable.rt_priority)
|
253
|
+
end
|
254
|
+
|
255
|
+
def test_policy
|
256
|
+
assert_respond_to(@ptable, :policy)
|
257
|
+
assert_kind_of(Fixnum, @ptable.policy)
|
258
|
+
end
|
259
|
+
|
260
|
+
def test_name
|
261
|
+
assert_respond_to(@ptable, :name)
|
262
|
+
assert_kind_of(String, @ptable.name)
|
263
|
+
end
|
264
|
+
|
265
|
+
def test_uid
|
266
|
+
assert_respond_to(@ptable, :uid)
|
267
|
+
assert_kind_of(Fixnum, @ptable.uid)
|
268
|
+
end
|
269
|
+
|
270
|
+
def test_euid
|
271
|
+
assert_respond_to(@ptable, :euid)
|
272
|
+
assert_kind_of(Fixnum, @ptable.euid)
|
273
|
+
end
|
274
|
+
|
275
|
+
def test_gid
|
276
|
+
assert_respond_to(@ptable, :gid)
|
277
|
+
assert_kind_of(Fixnum, @ptable.gid)
|
278
|
+
end
|
279
|
+
|
280
|
+
def test_egid
|
281
|
+
assert_respond_to(@ptable, :egid)
|
282
|
+
assert_kind_of(Fixnum, @ptable.egid)
|
283
|
+
end
|
284
|
+
|
285
|
+
def test_pctmem
|
286
|
+
assert_respond_to(@ptable, :pctmem)
|
287
|
+
assert_kind_of(Float, @ptable.pctmem)
|
288
|
+
end
|
289
|
+
|
290
|
+
def test_pctcpu
|
291
|
+
assert_respond_to(@ptable, :pctcpu)
|
292
|
+
assert_kind_of(Float, @ptable.pctcpu)
|
293
|
+
end
|
294
|
+
|
295
|
+
def teardown
|
296
|
+
@ptable = nil
|
297
|
+
end
|
298
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tddium-sys-proctable
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.9.2
|
6
|
+
platform: x86-linux
|
7
|
+
authors:
|
8
|
+
- Daniel J. Berger
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-03-18 00:00:00 +00:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: test-unit
|
18
|
+
prerelease: false
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 2.1.2
|
25
|
+
type: :development
|
26
|
+
version_requirements: *id001
|
27
|
+
description: " Testing a separate publish to see if I can get the mac install to work with bundler.\n\n 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"
|
28
|
+
email: info@tddium.com
|
29
|
+
executables: []
|
30
|
+
|
31
|
+
extensions: []
|
32
|
+
|
33
|
+
extra_rdoc_files:
|
34
|
+
- CHANGES
|
35
|
+
- README
|
36
|
+
- MANIFEST
|
37
|
+
- doc/top.txt
|
38
|
+
files:
|
39
|
+
- benchmarks/bench_ps.rb
|
40
|
+
- examples/example_ps.rb
|
41
|
+
- lib/sys/top.rb
|
42
|
+
- CHANGES
|
43
|
+
- MANIFEST
|
44
|
+
- Rakefile
|
45
|
+
- README
|
46
|
+
- sys-proctable.gemspec
|
47
|
+
- test/test_sys_proctable_all.rb
|
48
|
+
- doc/top.txt
|
49
|
+
- lib/linux/sys/proctable.rb
|
50
|
+
- test/test_sys_proctable_linux.rb
|
51
|
+
has_rdoc: true
|
52
|
+
homepage: http://www.rubyforge.org/projects/sysutils
|
53
|
+
licenses:
|
54
|
+
- Artistic 2.0
|
55
|
+
post_install_message:
|
56
|
+
rdoc_options: []
|
57
|
+
|
58
|
+
require_paths:
|
59
|
+
- lib
|
60
|
+
- lib/linux
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: "0"
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: "0"
|
73
|
+
requirements: []
|
74
|
+
|
75
|
+
rubyforge_project: sysutils
|
76
|
+
rubygems_version: 1.5.2
|
77
|
+
signing_key:
|
78
|
+
specification_version: 3
|
79
|
+
summary: An interface for providing process table information
|
80
|
+
test_files:
|
81
|
+
- test/test_sys_proctable_all.rb
|
82
|
+
- test/test_sys_proctable_linux.rb
|