sys-proctable 0.7.6 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +1 -0
  4. data/CHANGES +165 -0
  5. data/MANIFEST +33 -41
  6. data/README +115 -135
  7. data/Rakefile +94 -0
  8. data/benchmarks/bench_ps.rb +21 -0
  9. data/doc/top.txt +5 -11
  10. data/examples/example_ps.rb +20 -0
  11. data/lib/aix/sys/proctable.rb +458 -0
  12. data/lib/darwin/sys/proctable.rb +363 -0
  13. data/lib/freebsd/sys/proctable.rb +363 -0
  14. data/lib/linux/sys/proctable.rb +314 -0
  15. data/lib/linux/sys/proctable/cgroup_entry.rb +50 -0
  16. data/lib/linux/sys/proctable/smaps.rb +118 -0
  17. data/lib/sunos/sys/proctable.rb +456 -0
  18. data/lib/sys-proctable.rb +1 -0
  19. data/lib/sys-top.rb +1 -0
  20. data/lib/sys/proctable.rb +18 -0
  21. data/lib/sys/proctable/version.rb +6 -0
  22. data/lib/sys/top.rb +28 -19
  23. data/lib/windows/sys/proctable.rb +208 -0
  24. data/spec/sys_proctable_aix_spec.rb +328 -0
  25. data/spec/sys_proctable_all_spec.rb +89 -0
  26. data/spec/sys_proctable_darwin_spec.rb +120 -0
  27. data/spec/sys_proctable_freebsd_spec.rb +210 -0
  28. data/spec/sys_proctable_linux_spec.rb +310 -0
  29. data/spec/sys_proctable_sunos_spec.rb +316 -0
  30. data/spec/sys_proctable_windows_spec.rb +317 -0
  31. data/spec/sys_top_spec.rb +51 -0
  32. data/sys-proctable.gemspec +38 -0
  33. metadata +140 -64
  34. metadata.gz.sig +0 -0
  35. data/doc/freebsd.txt +0 -90
  36. data/doc/hpux.txt +0 -77
  37. data/doc/linux.txt +0 -85
  38. data/doc/solaris.txt +0 -99
  39. data/doc/windows.txt +0 -122
  40. data/ext/extconf.rb +0 -98
  41. data/ext/sunos/sunos.c +0 -374
  42. data/ext/sunos/sunos.h +0 -177
  43. data/ext/version.h +0 -2
  44. data/test/tc_all.rb +0 -59
  45. data/test/tc_freebsd.rb +0 -45
  46. data/test/tc_hpux.rb +0 -49
  47. data/test/tc_kvm_bsd.rb +0 -31
  48. data/test/tc_linux.rb +0 -45
  49. data/test/tc_sunos.rb +0 -52
  50. data/test/tc_top.rb +0 -26
  51. data/test/tc_windows.rb +0 -40
  52. data/test/test_memleak.rb +0 -54
@@ -0,0 +1,89 @@
1
+ #######################################################################
2
+ # sys_proctable_all_spec.rb
3
+ #
4
+ # Test suite for methods common to all platforms. Generally speaking
5
+ # you should run these specs using the 'rake test' task.
6
+ #######################################################################
7
+ require 'rspec'
8
+ require 'sys/proctable'
9
+ require_relative 'sys_top_spec'
10
+
11
+ describe Sys::ProcTable do
12
+ let(:windows) { File::ALT_SEPARATOR }
13
+
14
+ before(:all) do
15
+ @pid = Process.pid
16
+ end
17
+
18
+ it "has a VERSION constant set to the expected value" do
19
+ expect(Sys::ProcTable::VERSION).to eql('1.2.0')
20
+ end
21
+
22
+ it "defines a custom error class" do
23
+ expect{ Sys::ProcTable::Error }.to_not raise_error
24
+ expect(Sys::ProcTable::Error.new).to be_kind_of(StandardError)
25
+ end
26
+
27
+ context "fields" do
28
+ it "has a fields singleton method" do
29
+ expect(described_class).to respond_to(:fields)
30
+ end
31
+
32
+ it "returns the expected data type for the fields singleton method" do
33
+ expect(described_class.fields).to be_kind_of(Array)
34
+ expect(described_class.fields.first).to be_kind_of(String)
35
+ end
36
+ end
37
+
38
+ context "ps" do
39
+ it "defines a ps singleton method" do
40
+ expect(described_class).to respond_to(:ps)
41
+ end
42
+
43
+ it "allows a pid option as an argument" do
44
+ expect{ described_class.ps(pid: 0) }.to_not raise_error
45
+ end
46
+
47
+ it "allows the pid to be nil" do
48
+ expect{ described_class.ps(pid: nil) }.to_not raise_error
49
+ expect(described_class.ps(pid: nil)).to be_kind_of(Array)
50
+ end
51
+
52
+ it "returns expected results with no arguments" do
53
+ expect(described_class.ps).to be_kind_of(Array)
54
+ end
55
+
56
+ it "returns expected results with a pid argument" do
57
+ expect(described_class.ps(pid: @pid)).to be_kind_of(Struct::ProcTableStruct)
58
+ end
59
+
60
+ it "returns nil if the process does not exist" do
61
+ expect(described_class.ps(pid: 999999999)).to be_nil
62
+ end
63
+
64
+ it "returns nil in block form whether or not a pid was provided" do
65
+ expect(described_class.ps{}).to be_nil
66
+ expect(described_class.ps(pid: 999999999){}).to be_nil
67
+ end
68
+
69
+ it "returns frozen structs" do
70
+ expect(described_class.ps.first.frozen?).to eql(true)
71
+ end
72
+
73
+ it "expects a numeric pid argument if present" do
74
+ expect{ described_class.ps(pid: 'vim') }.to raise_error(TypeError)
75
+ end
76
+
77
+ it "accepts keyword arguments only" do
78
+ expect{ described_class.ps(0, 'localhost') }.to raise_error(ArgumentError)
79
+ end
80
+
81
+ it "disables the traditional constructor" do
82
+ expect{ described_class.new }.to raise_error(NoMethodError)
83
+ end
84
+
85
+ it "works within a thread" do
86
+ expect{ Thread.new{ described_class.ps }.value }.to_not raise_error
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,120 @@
1
+ ########################################################################
2
+ # sys_proctable_darwin_spec.rb
3
+ #
4
+ # Test suite for the Darwin version of the sys-proctable library. You
5
+ # should run these tests via the 'rake test' task.
6
+ ########################################################################
7
+ require 'rspec'
8
+ require 'sys/proctable'
9
+ require_relative 'sys_proctable_all_spec'
10
+
11
+ describe Sys::ProcTable do
12
+ let(:fields){
13
+ %w[
14
+ flags status xstatus pid ppid uid gid ruid rgid svuid svgid rfu1 comm
15
+ name nfiles pgid pjobc tdev tpgid nice start_tvsec start_tvusec
16
+ virtual_size resident_size total_user total_system threads_user
17
+ threads_system policy faults pageins cow_faults messages_sent
18
+ messages_received syscalls_mach syscalls_unix csw threadnum numrunning
19
+ priority cmdline exe environ threadinfo
20
+ ]
21
+ }
22
+
23
+ before(:all) do
24
+ @pid1 = fork { exec('env', '-i', 'A=B', 'Z=', 'sleep', '60') }
25
+ @pid2 = fork { exec('ruby', '-Ilib', '-e', 'sleep \'120\'.to_i', '--', 'foo bar') }
26
+ sleep 1 # wait to make sure env is replaced by sleep
27
+ end
28
+
29
+ after(:all) do
30
+ Process.kill('TERM', @pid1)
31
+ Process.kill('TERM', @pid2)
32
+ end
33
+
34
+ context "fields singleton method" do
35
+ it "responds to a fields method" do
36
+ expect(described_class).to respond_to(:fields)
37
+ end
38
+
39
+ it "returns the expected results for the fields method" do
40
+ expect(described_class.fields).to be_kind_of(Array)
41
+ expect(described_class.fields).to eql(fields)
42
+ end
43
+ end
44
+
45
+ context "ProcTable::Struct members" do
46
+ subject { described_class.ps(pid: @pid1) }
47
+
48
+ it "contains a pid member and returns the expected value" do
49
+ expect(subject).to respond_to(:pid)
50
+ expect(subject.pid).to be_kind_of(Numeric)
51
+ expect(subject.pid).to eql(@pid1)
52
+ end
53
+
54
+ it "contains a ppid member and returns the expected value" do
55
+ expect(subject).to respond_to(:ppid)
56
+ expect(subject.ppid).to be_kind_of(Numeric)
57
+ expect(subject.ppid).to eql(Process.pid)
58
+ end
59
+
60
+ it "contains a pgid member and returns the expected value" do
61
+ expect(subject).to respond_to(:pgid)
62
+ expect(subject.pgid).to be_kind_of(Numeric)
63
+ expect(subject.pgid).to eql(Process.getpgrp)
64
+ end
65
+
66
+ it "contains a ruid member and returns the expected value" do
67
+ expect(subject).to respond_to(:ruid)
68
+ expect(subject.ruid).to be_kind_of(Numeric)
69
+ expect(subject.ruid).to eql(Process.uid)
70
+ end
71
+
72
+ it "contains an rgid member and returns the expected value" do
73
+ expect(subject).to respond_to(:rgid)
74
+ expect(subject.rgid).to be_kind_of(Numeric)
75
+ expect(subject.rgid).to eql(Process.gid)
76
+ end
77
+
78
+ it "contains an svuid member and returns the expected value" do
79
+ expect(subject).to respond_to(:svuid)
80
+ expect(subject.svuid).to be_kind_of(Numeric)
81
+ expect(subject.svuid).to eql(Process.uid)
82
+ end
83
+
84
+ it "contains an svgid member and returns the expected value" do
85
+ expect(subject).to respond_to(:svgid)
86
+ expect(subject.svgid).to be_kind_of(Numeric)
87
+ expect(subject.svgid).to eql(Process.gid)
88
+ end
89
+
90
+ it "contains a comm member and returns the expected value" do
91
+ expect(subject).to respond_to(:comm)
92
+ expect(subject.comm).to be_kind_of(String)
93
+ expect(subject.comm).to eql('sleep')
94
+ end
95
+
96
+ it "contains a cmdline member and returns the expected value" do
97
+ expect(subject).to respond_to(:cmdline)
98
+ expect(subject.cmdline).to be_kind_of(String)
99
+ expect(subject.cmdline).to eql('sleep 60')
100
+ end
101
+
102
+ it "returns a string with the expected arguments for the cmdline member" do
103
+ ptable = Sys::ProcTable.ps(pid: @pid2)
104
+ expect(ptable.cmdline).to eql('ruby -Ilib -e sleep \'120\'.to_i -- foo bar')
105
+ end
106
+
107
+ it "contains an exe member and returns the expected value" do
108
+ expect(subject).to respond_to(:exe)
109
+ expect(subject.exe).to be_kind_of(String)
110
+ expect(subject.exe).to eql(`which sleep`.chomp)
111
+ end
112
+
113
+ it "contains an environ member and returns the expected value" do
114
+ expect(subject).to respond_to(:environ)
115
+ expect(subject.environ).to be_kind_of(Hash)
116
+ expect(subject.environ['A']).to eql('B')
117
+ expect(subject.environ['Z']).to be_nil
118
+ end
119
+ end
120
+ end
@@ -0,0 +1,210 @@
1
+ ################################################################
2
+ # sys_proctable_freebsd_rspec.rb
3
+ #
4
+ # Test suite for FreeBSD for the sys-proctable library.
5
+ # You should run these tests via 'rake test'.
6
+ ################################################################
7
+ require 'rspec'
8
+ require 'sys/proctable'
9
+ require_relative 'sys_proctable_all_spec'
10
+
11
+ describe Sys::ProcTable do
12
+ let(:fields){
13
+ %w[
14
+ pid ppid pgid tpgid sid tsid jobc uid ruid rgid
15
+ ngroups groups size rssize swrss tsize dsize ssize
16
+ xstat acflag pctcpu estcpu slptime swtime runtime start
17
+ flag state nice lock rqindex oncpu lastcpu wmesg login
18
+ lockname comm ttynum ttydev jid priority usrpri cmdline
19
+ utime stime maxrss ixrss idrss isrss minflt majflt nswap
20
+ inblock oublock msgsnd msgrcv nsignals nvcsw nivcsw
21
+ ]
22
+ }
23
+
24
+ context "fields singleton method" do
25
+ it "responds to a fields method" do
26
+ expect(described_class).to respond_to(:fields)
27
+ end
28
+
29
+ it "returns the expected results for the fields method" do
30
+ expect(described_class.fields).to be_kind_of(Array)
31
+ expect(described_class.fields).to eql(fields)
32
+ end
33
+ end
34
+
35
+ context "ProcTable::Struct members" do
36
+ subject { described_class.ps(pid: Process.pid) }
37
+
38
+ it "contains a pid member and returns the expected value" do
39
+ expect(subject).to respond_to(:pid)
40
+ expect(subject.pid).to be_kind_of(Numeric)
41
+ expect(subject.pid).to eql(Process.pid)
42
+ end
43
+
44
+ it "contains a ppid member and returns the expected value" do
45
+ expect(subject).to respond_to(:ppid)
46
+ expect(subject.ppid).to be_kind_of(Fixnum)
47
+ end
48
+
49
+ it "contains a pgid member and returns the expected value" do
50
+ expect(subject).to respond_to(:pgid)
51
+ expect(subject.pgid).to be_kind_of(Fixnum)
52
+ end
53
+
54
+ it "contains a ruid member and returns the expected value" do
55
+ expect(subject).to respond_to(:ruid)
56
+ expect(subject.ruid).to be_kind_of(Fixnum)
57
+ end
58
+
59
+ it "contains a rgid member and returns the expected value" do
60
+ expect(subject).to respond_to(:rgid)
61
+ expect(subject.rgid).to be_kind_of(Fixnum)
62
+ end
63
+
64
+ it "contains a comm member and returns the expected value" do
65
+ expect(subject).to respond_to(:comm)
66
+ expect(subject.comm).to be_kind_of(String)
67
+ end
68
+
69
+ it "contains a state member and returns the expected value" do
70
+ expect(subject).to respond_to(:state)
71
+ expect(subject.state).to be_kind_of(String)
72
+ end
73
+
74
+ it "contains a pctcpu member and returns the expected value" do
75
+ expect(subject).to respond_to(:pctcpu)
76
+ expect(subject.pctcpu).to be_kind_of(Float)
77
+ end
78
+
79
+ it "contains a oncpu member and returns the expected value" do
80
+ expect(subject).to respond_to(:oncpu)
81
+ expect(subject.oncpu).to be_kind_of(Fixnum)
82
+ end
83
+
84
+ it "contains a ttynum member and returns the expected value" do
85
+ expect(subject).to respond_to(:ttynum)
86
+ expect(subject.ttynum).to be_kind_of(Fixnum)
87
+ end
88
+
89
+ it "contains a ttydev member and returns the expected value" do
90
+ expect(subject).to respond_to(:ttydev)
91
+ expect(subject.ttydev).to be_kind_of(String)
92
+ end
93
+
94
+ it "contains a wmesg member and returns the expected value" do
95
+ expect(subject).to respond_to(:wmesg)
96
+ expect(subject.wmesg).to be_kind_of(String)
97
+ end
98
+
99
+ it "contains a runtime member and returns the expected value" do
100
+ expect(subject).to respond_to(:runtime)
101
+ expect(subject.runtime).to be_kind_of(Fixnum)
102
+ end
103
+
104
+ it "contains a priority member and returns the expected value" do
105
+ expect(subject).to respond_to(:priority)
106
+ expect(subject.priority).to be_kind_of(Fixnum)
107
+ end
108
+
109
+ it "contains a usrpri member and returns the expected value" do
110
+ expect(subject).to respond_to(:usrpri)
111
+ expect(subject.usrpri).to be_kind_of(Fixnum)
112
+ end
113
+
114
+ it "contains a nice member and returns the expected value" do
115
+ expect(subject).to respond_to(:nice)
116
+ expect(subject.nice).to be_kind_of(Fixnum)
117
+ end
118
+
119
+ it "contains a cmdline member and returns the expected value" do
120
+ expect(subject).to respond_to(:cmdline)
121
+ expect(subject.cmdline).to be_kind_of(String)
122
+ end
123
+
124
+ it "contains a start member and returns the expected value" do
125
+ expect(subject).to respond_to(:start)
126
+ expect(subject.start).to be_kind_of(Time)
127
+ end
128
+
129
+ it "contains a maxrss member and returns the expected value" do
130
+ expect(subject).to respond_to(:maxrss)
131
+ expect(subject.maxrss).to be_kind_of(Fixnum)
132
+ end
133
+
134
+ it "contains a ixrss member and returns the expected value" do
135
+ expect(subject).to respond_to(:ixrss)
136
+ expect(subject.ixrss).to be_kind_of(Fixnum)
137
+ end
138
+
139
+ # TODO: The value returned on PC BSD 10 does not appear to be valid. Investigate.
140
+ it "contains a idrss member and returns the expected value" do
141
+ expect(subject).to respond_to(:idrss)
142
+ expect(subject.idrss).to be_kind_of(Numeric)
143
+ end
144
+
145
+ it "contains a isrss member and returns the expected value" do
146
+ expect(subject).to respond_to(:isrss)
147
+ expect(subject.isrss).to be_kind_of(Fixnum)
148
+ end
149
+
150
+ it "contains a minflt member and returns the expected value" do
151
+ expect(subject).to respond_to(:minflt)
152
+ expect(subject.minflt).to be_kind_of(Fixnum)
153
+ end
154
+
155
+ it "contains a majflt member and returns the expected value" do
156
+ expect(subject).to respond_to(:majflt)
157
+ expect(subject.majflt).to be_kind_of(Fixnum)
158
+ end
159
+
160
+ it "contains a nswap member and returns the expected value" do
161
+ expect(subject).to respond_to(:nswap)
162
+ expect(subject.nswap).to be_kind_of(Fixnum)
163
+ end
164
+
165
+ it "contains a inblock member and returns the expected value" do
166
+ expect(subject).to respond_to(:inblock)
167
+ expect(subject.inblock).to be_kind_of(Fixnum)
168
+ end
169
+
170
+ it "contains a oublock member and returns the expected value" do
171
+ expect(subject).to respond_to(:oublock)
172
+ expect(subject.oublock).to be_kind_of(Fixnum)
173
+ end
174
+
175
+ it "contains a msgsnd member and returns the expected value" do
176
+ expect(subject).to respond_to(:msgsnd)
177
+ expect(subject.msgsnd).to be_kind_of(Fixnum)
178
+ end
179
+
180
+ it "contains a msgrcv member and returns the expected value" do
181
+ expect(subject).to respond_to(:msgrcv)
182
+ expect(subject.msgrcv).to be_kind_of(Fixnum)
183
+ end
184
+
185
+ it "contains a nsignals member and returns the expected value" do
186
+ expect(subject).to respond_to(:nsignals)
187
+ expect(subject.nsignals).to be_kind_of(Fixnum)
188
+ end
189
+
190
+ it "contains a nvcsw member and returns the expected value" do
191
+ expect(subject).to respond_to(:nvcsw)
192
+ expect(subject.nvcsw).to be_kind_of(Fixnum)
193
+ end
194
+
195
+ it "contains a nivcsw member and returns the expected value" do
196
+ expect(subject).to respond_to(:nivcsw)
197
+ expect(subject.nivcsw).to be_kind_of(Fixnum)
198
+ end
199
+
200
+ it "contains a utime member and returns the expected value" do
201
+ expect(subject).to respond_to(:utime)
202
+ expect(subject.utime).to be_kind_of(Fixnum)
203
+ end
204
+
205
+ it "contains a stime member and returns the expected value" do
206
+ expect(subject).to respond_to(:stime)
207
+ expect(subject.stime).to be_kind_of(Fixnum)
208
+ end
209
+ end
210
+ end
@@ -0,0 +1,310 @@
1
+ #######################################################################
2
+ # sys_proctable_linux_spec.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 'rspec'
8
+ require 'sys/proctable'
9
+ require_relative 'sys_proctable_all_spec'
10
+
11
+ describe Sys::ProcTable do
12
+ let(:fields){ %w[
13
+ cmdline cwd exe pid name uid euid gid egid comm state ppid pgrp
14
+ session tty_num tpgid flags minflt cminflt majflt cmajflt utime
15
+ stime cutime cstime priority nice itrealvalue starttime vsize
16
+ rss rlim startcode endcode startstack kstkesp kstkeip signal blocked
17
+ sigignore sigcatch wchan nswap cnswap exit_signal processor environ
18
+ pctcpu pctmem nlwp cgroup smaps
19
+ ]
20
+ }
21
+
22
+ context "struct members" do
23
+ subject{ described_class.ps.last }
24
+
25
+ it "contains a cmdline member and returns the expected value" do
26
+ expect(subject).to respond_to(:cmdline)
27
+ expect(subject.cmdline).to be_kind_of(String)
28
+ end
29
+
30
+ it "contains a cwd member and returns the expected value" do
31
+ expect(subject).to respond_to(:cwd)
32
+ expect(subject.cwd).to be_kind_of(String) if subject.cwd
33
+ end
34
+
35
+ it "contains a environ member and returns the expected value" do
36
+ expect(subject).to respond_to(:environ)
37
+ expect(subject.environ).to be_kind_of(Hash)
38
+ end
39
+
40
+ it "contains an exe member and returns the expected value" do
41
+ expect(subject).to respond_to(:exe)
42
+ expect(subject.exe).to be_kind_of(String) if subject.exe
43
+ end
44
+
45
+ it "contains an fd member and returns the expected value" do
46
+ expect(subject).to respond_to(:fd)
47
+ expect(subject.fd).to be_kind_of(Hash)
48
+ end
49
+
50
+ it "contains a root member and returns the expected value" do
51
+ expect(subject).to respond_to(:root)
52
+ expect(subject.root).to be_kind_of(String) if subject.root
53
+ end
54
+
55
+ it "contains a pid member and returns the expected value" do
56
+ expect(subject).to respond_to(:pid)
57
+ expect(subject.pid).to be_kind_of(Integer)
58
+ end
59
+
60
+ it "contains a comm member and returns the expected value" do
61
+ expect(subject).to respond_to(:comm)
62
+ expect(subject.comm).to be_kind_of(String)
63
+ end
64
+
65
+ it "contains a state member and returns the expected value" do
66
+ expect(subject).to respond_to(:state)
67
+ expect(subject.state).to be_kind_of(String)
68
+ end
69
+
70
+ it "contains a ppid member and returns the expected value" do
71
+ expect(subject).to respond_to(:state)
72
+ expect(subject.state).to be_kind_of(String)
73
+ end
74
+
75
+ it "contains a pgrp member and returns the expected value" do
76
+ expect(subject).to respond_to(:pgrp)
77
+ expect(subject.pgrp).to be_kind_of(Integer)
78
+ end
79
+
80
+ it "contains a session member and returns the expected value" do
81
+ expect(subject).to respond_to(:session)
82
+ expect(subject.session).to be_kind_of(Integer)
83
+ end
84
+
85
+ it "contains a tty_nr member and returns the expected value" do
86
+ expect(subject).to respond_to(:tty_nr)
87
+ expect(subject.tty_nr).to be_kind_of(Integer)
88
+ end
89
+
90
+ it "contains a tpgid member and returns the expected value" do
91
+ expect(subject).to respond_to(:tpgid)
92
+ expect(subject.tpgid).to be_kind_of(Integer)
93
+ end
94
+
95
+ it "contains a flags member and returns the expected value" do
96
+ expect(subject).to respond_to(:flags)
97
+ expect(subject.flags).to be_kind_of(Numeric)
98
+ end
99
+
100
+ it "contains a minflt member and returns the expected value" do
101
+ expect(subject).to respond_to(:minflt)
102
+ expect(subject.minflt).to be_kind_of(Numeric)
103
+ end
104
+
105
+ it "contains a cminflt member and returns the expected value" do
106
+ expect(subject).to respond_to(:cminflt)
107
+ expect(subject.cminflt).to be_kind_of(Numeric)
108
+ end
109
+
110
+ it "contains a majflt member and returns the expected value" do
111
+ expect(subject).to respond_to(:majflt)
112
+ expect(subject.majflt).to be_kind_of(Numeric)
113
+ end
114
+
115
+ it "contains a cmajflt member and returns the expected value" do
116
+ expect(subject).to respond_to(:cmajflt)
117
+ expect(subject.cmajflt).to be_kind_of(Numeric)
118
+ end
119
+
120
+ it "contains a utime member and returns the expected value" do
121
+ expect(subject).to respond_to(:utime)
122
+ expect(subject.utime).to be_kind_of(Numeric)
123
+ end
124
+
125
+ it "contains a stime member and returns the expected value" do
126
+ expect(subject).to respond_to(:stime)
127
+ expect(subject.stime).to be_kind_of(Numeric)
128
+ end
129
+
130
+ it "contains a cutime member and returns the expected value" do
131
+ expect(subject).to respond_to(:cutime)
132
+ expect(subject.cutime).to be_kind_of(Numeric)
133
+ end
134
+
135
+ it "contains a cstime member and returns the expected value" do
136
+ expect(subject).to respond_to(:cstime)
137
+ expect(subject.cstime).to be_kind_of(Numeric)
138
+ end
139
+
140
+ it "contains a priority member and returns the expected value" do
141
+ expect(subject).to respond_to(:priority)
142
+ expect(subject.priority).to be_kind_of(Numeric)
143
+ end
144
+
145
+ it "contains a nice member and returns the expected value" do
146
+ expect(subject).to respond_to(:nice)
147
+ expect(subject.nice).to be_kind_of(Numeric)
148
+ end
149
+
150
+ it "contains a itrealvalue member and returns the expected value" do
151
+ expect(subject).to respond_to(:itrealvalue)
152
+ expect(subject.itrealvalue).to be_kind_of(Numeric)
153
+ end
154
+
155
+ it "contains a starttime member and returns the expected value" do
156
+ expect(subject).to respond_to(:starttime)
157
+ expect(subject.starttime).to be_kind_of(Numeric)
158
+ end
159
+
160
+ it "contains a vsize member and returns the expected value" do
161
+ expect(subject).to respond_to(:vsize)
162
+ expect(subject.vsize).to be_kind_of(Numeric)
163
+ end
164
+
165
+ it "contains a rss member and returns the expected value" do
166
+ expect(subject).to respond_to(:rss)
167
+ expect(subject.rss).to be_kind_of(Numeric)
168
+ end
169
+
170
+ it "contains an rlim member and returns the expected value" do
171
+ expect(subject).to respond_to(:rlim)
172
+ expect(subject.rlim).to be_kind_of(Numeric)
173
+ end
174
+
175
+ it "contains an startcode member and returns the expected value" do
176
+ expect(subject).to respond_to(:startcode)
177
+ expect(subject.startcode).to be_kind_of(Numeric)
178
+ end
179
+
180
+ it "contains an endcode member and returns the expected value" do
181
+ expect(subject).to respond_to(:endcode)
182
+ expect(subject.endcode).to be_kind_of(Numeric)
183
+ end
184
+
185
+ it "contains a startstack member and returns the expected value" do
186
+ expect(subject).to respond_to(:startstack)
187
+ expect(subject.startstack).to be_kind_of(Integer)
188
+ end
189
+
190
+ it "contains a kstkesp member and returns the expected value" do
191
+ expect(subject).to respond_to(:kstkesp)
192
+ expect(subject.kstkesp).to be_kind_of(Integer)
193
+ end
194
+
195
+ it "contains a kstkeip member and returns the expected value" do
196
+ expect(subject).to respond_to(:kstkeip)
197
+ expect(subject.kstkeip).to be_kind_of(Integer)
198
+ end
199
+
200
+ it "contains a signal member and returns the expected value" do
201
+ expect(subject).to respond_to(:signal)
202
+ expect(subject.signal).to be_kind_of(Integer)
203
+ end
204
+
205
+ it "contains a blocked member and returns the expected value" do
206
+ expect(subject).to respond_to(:blocked)
207
+ expect(subject.blocked).to be_kind_of(Integer)
208
+ end
209
+
210
+ it "contains a sigignore member and returns the expected value" do
211
+ expect(subject).to respond_to(:sigignore)
212
+ expect(subject.sigignore).to be_kind_of(Integer)
213
+ end
214
+
215
+ it "contains a sigcatch member and returns the expected value" do
216
+ expect(subject).to respond_to(:sigcatch)
217
+ expect(subject.sigcatch).to be_kind_of(Integer)
218
+ end
219
+
220
+ it "contains a wchan member and returns the expected value" do
221
+ expect(subject).to respond_to(:wchan)
222
+ expect(subject.wchan).to be_kind_of(Integer)
223
+ end
224
+
225
+ it "contains a nswap member and returns the expected value" do
226
+ expect(subject).to respond_to(:nswap)
227
+ expect(subject.nswap).to be_kind_of(Integer)
228
+ end
229
+
230
+ it "contains a cnswap member and returns the expected value" do
231
+ expect(subject).to respond_to(:cnswap)
232
+ expect(subject.cnswap).to be_kind_of(Integer)
233
+ end
234
+
235
+ it "contains a exit_signal member and returns the expected value" do
236
+ expect(subject).to respond_to(:exit_signal)
237
+ expect(subject.exit_signal).to be_kind_of(Integer)
238
+ end
239
+
240
+ it "contains a processor member and returns the expected value" do
241
+ expect(subject).to respond_to(:processor)
242
+ expect(subject.processor).to be_kind_of(Integer)
243
+ end
244
+
245
+ it "contains a rt_priority member and returns the expected value" do
246
+ expect(subject).to respond_to(:rt_priority)
247
+ expect(subject.rt_priority).to be_kind_of(Integer)
248
+ end
249
+
250
+ it "contains a policy member and returns the expected value" do
251
+ expect(subject).to respond_to(:policy)
252
+ expect(subject.policy).to be_kind_of(Integer)
253
+ end
254
+
255
+ it "contains a name member and returns the expected value" do
256
+ expect(subject).to respond_to(:name)
257
+ expect(subject.name).to be_kind_of(String)
258
+ end
259
+
260
+ it "contains a uid member and returns the expected value" do
261
+ expect(subject).to respond_to(:uid)
262
+ expect(subject.uid).to be_kind_of(Integer)
263
+ end
264
+
265
+ it "contains a euid member and returns the expected value" do
266
+ expect(subject).to respond_to(:euid)
267
+ expect(subject.euid).to be_kind_of(Integer)
268
+ end
269
+
270
+ it "contains a gid member and returns the expected value" do
271
+ expect(subject).to respond_to(:gid)
272
+ expect(subject.gid).to be_kind_of(Integer)
273
+ end
274
+
275
+ it "contains a egid member and returns the expected value" do
276
+ expect(subject).to respond_to(:egid)
277
+ expect(subject.egid).to be_kind_of(Integer)
278
+ end
279
+
280
+ it "contains a pctmem member and returns the expected value" do
281
+ expect(subject).to respond_to(:pctmem)
282
+ expect(subject.pctmem).to be_kind_of(Float)
283
+ end
284
+
285
+ it "contains a pctcpu member and returns the expected value" do
286
+ expect(subject).to respond_to(:pctcpu)
287
+ expect(subject.pctcpu).to be_kind_of(Float)
288
+ end
289
+
290
+ it "contains a nlwp member and returns the expected value" do
291
+ expect(subject).to respond_to(:nlwp)
292
+ expect(subject.nlwp).to be_kind_of(Integer)
293
+ end
294
+ end
295
+
296
+ context "custom structs" do
297
+ subject{ described_class.ps.last }
298
+
299
+ it "contains a cgroup member and returns the expected value" do
300
+ expect(subject).to respond_to(:cgroup)
301
+ expect(subject.cgroup).to be_kind_of(Array)
302
+ expect(subject.cgroup.first).to be_kind_of(Sys::ProcTable::CgroupEntry)
303
+ end
304
+
305
+ it "contains a smaps member and returns the expected value" do
306
+ expect(subject).to respond_to(:cgroup)
307
+ expect(subject.smaps).to be_kind_of(Sys::ProcTable::Smaps)
308
+ end
309
+ end
310
+ end