sys-proctable 0.7.6 → 1.2.4

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.
Files changed (57) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/{CHANGES → CHANGES.rdoc} +197 -0
  5. data/LICENSE +177 -0
  6. data/MANIFEST.rdoc +26 -0
  7. data/README.md +158 -0
  8. data/Rakefile +94 -0
  9. data/benchmarks/bench_ips_ps.rb +63 -0
  10. data/benchmarks/bench_ps.rb +21 -0
  11. data/examples/example_ps.rb +20 -0
  12. data/lib/aix/sys/proctable.rb +458 -0
  13. data/lib/darwin/sys/proctable.rb +406 -0
  14. data/lib/freebsd/sys/proctable.rb +363 -0
  15. data/lib/linux/sys/proctable.rb +315 -0
  16. data/lib/linux/sys/proctable/cgroup_entry.rb +50 -0
  17. data/lib/linux/sys/proctable/smaps.rb +118 -0
  18. data/lib/sunos/sys/proctable.rb +456 -0
  19. data/lib/sys-proctable.rb +1 -0
  20. data/lib/sys-top.rb +1 -0
  21. data/lib/sys/proctable.rb +18 -0
  22. data/lib/sys/proctable/version.rb +6 -0
  23. data/lib/sys/top.rb +28 -19
  24. data/lib/windows/sys/proctable.rb +208 -0
  25. data/spec/spec_helper.rb +22 -0
  26. data/spec/sys_proctable_aix_spec.rb +328 -0
  27. data/spec/sys_proctable_all_spec.rb +90 -0
  28. data/spec/sys_proctable_darwin_spec.rb +120 -0
  29. data/spec/sys_proctable_freebsd_spec.rb +210 -0
  30. data/spec/sys_proctable_linux_spec.rb +323 -0
  31. data/spec/sys_proctable_sunos_spec.rb +316 -0
  32. data/spec/sys_proctable_windows_spec.rb +317 -0
  33. data/spec/sys_top_spec.rb +51 -0
  34. data/sys-proctable.gemspec +48 -0
  35. metadata +150 -67
  36. metadata.gz.sig +7 -0
  37. data/MANIFEST +0 -41
  38. data/README +0 -140
  39. data/doc/freebsd.txt +0 -90
  40. data/doc/hpux.txt +0 -77
  41. data/doc/linux.txt +0 -85
  42. data/doc/solaris.txt +0 -99
  43. data/doc/top.txt +0 -53
  44. data/doc/windows.txt +0 -122
  45. data/ext/extconf.rb +0 -98
  46. data/ext/sunos/sunos.c +0 -374
  47. data/ext/sunos/sunos.h +0 -177
  48. data/ext/version.h +0 -2
  49. data/test/tc_all.rb +0 -59
  50. data/test/tc_freebsd.rb +0 -45
  51. data/test/tc_hpux.rb +0 -49
  52. data/test/tc_kvm_bsd.rb +0 -31
  53. data/test/tc_linux.rb +0 -45
  54. data/test/tc_sunos.rb +0 -52
  55. data/test/tc_top.rb +0 -26
  56. data/test/tc_windows.rb +0 -40
  57. data/test/test_memleak.rb +0 -54
@@ -0,0 +1,90 @@
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.4')
20
+ expect(Sys::ProcTable::VERSION).to be_frozen
21
+ end
22
+
23
+ it "defines a custom error class" do
24
+ expect{ Sys::ProcTable::Error }.to_not raise_error
25
+ expect(Sys::ProcTable::Error.new).to be_kind_of(StandardError)
26
+ end
27
+
28
+ context "fields" do
29
+ it "has a fields singleton method" do
30
+ expect(described_class).to respond_to(:fields)
31
+ end
32
+
33
+ it "returns the expected data type for the fields singleton method" do
34
+ expect(described_class.fields).to be_kind_of(Array)
35
+ expect(described_class.fields.first).to be_kind_of(String)
36
+ end
37
+ end
38
+
39
+ context "ps" do
40
+ it "defines a ps singleton method" do
41
+ expect(described_class).to respond_to(:ps)
42
+ end
43
+
44
+ it "allows a pid option as an argument" do
45
+ expect{ described_class.ps(pid: 0) }.to_not raise_error
46
+ end
47
+
48
+ it "allows the pid to be nil" do
49
+ expect{ described_class.ps(pid: nil) }.to_not raise_error
50
+ expect(described_class.ps(pid: nil)).to be_kind_of(Array)
51
+ end
52
+
53
+ it "returns expected results with no arguments" do
54
+ expect(described_class.ps).to be_kind_of(Array)
55
+ end
56
+
57
+ it "returns expected results with a pid argument" do
58
+ expect(described_class.ps(pid: @pid)).to be_kind_of(Struct::ProcTableStruct)
59
+ end
60
+
61
+ it "returns nil if the process does not exist" do
62
+ expect(described_class.ps(pid: 999999999)).to be_nil
63
+ end
64
+
65
+ it "returns nil in block form whether or not a pid was provided" do
66
+ expect(described_class.ps{}).to be_nil
67
+ expect(described_class.ps(pid: 999999999){}).to be_nil
68
+ end
69
+
70
+ it "returns frozen structs" do
71
+ expect(described_class.ps.first.frozen?).to eql(true)
72
+ end
73
+
74
+ it "expects a numeric pid argument if present" do
75
+ expect{ described_class.ps(pid: 'vim') }.to raise_error(TypeError)
76
+ end
77
+
78
+ it "accepts keyword arguments only" do
79
+ expect{ described_class.ps(0, 'localhost') }.to raise_error(ArgumentError)
80
+ end
81
+
82
+ it "disables the traditional constructor" do
83
+ expect{ described_class.new }.to raise_error(NoMethodError)
84
+ end
85
+
86
+ it "works within a thread" do
87
+ expect{ Thread.new{ described_class.ps }.value }.to_not raise_error
88
+ end
89
+ end
90
+ 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", :skip_jruby 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", :skip_jruby 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", :skip_jruby 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", :skip_jruby 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", :skip_jruby 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,323 @@
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 environ exe fd root pid name uid euid gid egid comm state ppid pgrp
14
+ session tty_nr tpgid flags minflt cminflt majflt cmajflt utime
15
+ stime cutime cstime priority nice num_threads itrealvalue starttime vsize
16
+ rss rlim startcode endcode startstack kstkesp kstkeip signal blocked
17
+ sigignore sigcatch wchan nswap cnswap exit_signal processor rt_priority
18
+ policy 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 num_threads member and returns the expected value" do
151
+ expect(subject).to respond_to(:num_threads)
152
+ expect(subject.num_threads).to be_kind_of(Numeric)
153
+ end
154
+
155
+ it "contains a itrealvalue member and returns the expected value" do
156
+ expect(subject).to respond_to(:itrealvalue)
157
+ expect(subject.itrealvalue).to be_kind_of(Numeric)
158
+ end
159
+
160
+ it "contains a starttime member and returns the expected value" do
161
+ expect(subject).to respond_to(:starttime)
162
+ expect(subject.starttime).to be_kind_of(Numeric)
163
+ end
164
+
165
+ it "contains a vsize member and returns the expected value" do
166
+ expect(subject).to respond_to(:vsize)
167
+ expect(subject.vsize).to be_kind_of(Numeric)
168
+ end
169
+
170
+ it "contains a rss member and returns the expected value" do
171
+ expect(subject).to respond_to(:rss)
172
+ expect(subject.rss).to be_kind_of(Numeric)
173
+ end
174
+
175
+ it "contains an rlim member and returns the expected value" do
176
+ expect(subject).to respond_to(:rlim)
177
+ expect(subject.rlim).to be_kind_of(Numeric)
178
+ end
179
+
180
+ it "contains an startcode member and returns the expected value" do
181
+ expect(subject).to respond_to(:startcode)
182
+ expect(subject.startcode).to be_kind_of(Numeric)
183
+ end
184
+
185
+ it "contains an endcode member and returns the expected value" do
186
+ expect(subject).to respond_to(:endcode)
187
+ expect(subject.endcode).to be_kind_of(Numeric)
188
+ end
189
+
190
+ it "contains a startstack member and returns the expected value" do
191
+ expect(subject).to respond_to(:startstack)
192
+ expect(subject.startstack).to be_kind_of(Integer)
193
+ end
194
+
195
+ it "contains a kstkesp member and returns the expected value" do
196
+ expect(subject).to respond_to(:kstkesp)
197
+ expect(subject.kstkesp).to be_kind_of(Integer)
198
+ end
199
+
200
+ it "contains a kstkeip member and returns the expected value" do
201
+ expect(subject).to respond_to(:kstkeip)
202
+ expect(subject.kstkeip).to be_kind_of(Integer)
203
+ end
204
+
205
+ it "contains a signal member and returns the expected value" do
206
+ expect(subject).to respond_to(:signal)
207
+ expect(subject.signal).to be_kind_of(Integer)
208
+ end
209
+
210
+ it "contains a blocked member and returns the expected value" do
211
+ expect(subject).to respond_to(:blocked)
212
+ expect(subject.blocked).to be_kind_of(Integer)
213
+ end
214
+
215
+ it "contains a sigignore member and returns the expected value" do
216
+ expect(subject).to respond_to(:sigignore)
217
+ expect(subject.sigignore).to be_kind_of(Integer)
218
+ end
219
+
220
+ it "contains a sigcatch member and returns the expected value" do
221
+ expect(subject).to respond_to(:sigcatch)
222
+ expect(subject.sigcatch).to be_kind_of(Integer)
223
+ end
224
+
225
+ it "contains a wchan member and returns the expected value" do
226
+ expect(subject).to respond_to(:wchan)
227
+ expect(subject.wchan).to be_kind_of(Integer)
228
+ end
229
+
230
+ it "contains a nswap member and returns the expected value" do
231
+ expect(subject).to respond_to(:nswap)
232
+ expect(subject.nswap).to be_kind_of(Integer)
233
+ end
234
+
235
+ it "contains a cnswap member and returns the expected value" do
236
+ expect(subject).to respond_to(:cnswap)
237
+ expect(subject.cnswap).to be_kind_of(Integer)
238
+ end
239
+
240
+ it "contains a exit_signal member and returns the expected value" do
241
+ expect(subject).to respond_to(:exit_signal)
242
+ expect(subject.exit_signal).to be_kind_of(Integer)
243
+ end
244
+
245
+ it "contains a processor member and returns the expected value" do
246
+ expect(subject).to respond_to(:processor)
247
+ expect(subject.processor).to be_kind_of(Integer)
248
+ end
249
+
250
+ it "contains a rt_priority member and returns the expected value" do
251
+ expect(subject).to respond_to(:rt_priority)
252
+ expect(subject.rt_priority).to be_kind_of(Integer)
253
+ end
254
+
255
+ it "contains a policy member and returns the expected value" do
256
+ expect(subject).to respond_to(:policy)
257
+ expect(subject.policy).to be_kind_of(Integer)
258
+ end
259
+
260
+ it "contains a name member and returns the expected value" do
261
+ expect(subject).to respond_to(:name)
262
+ expect(subject.name).to be_kind_of(String)
263
+ end
264
+
265
+ it "contains a uid member and returns the expected value" do
266
+ expect(subject).to respond_to(:uid)
267
+ expect(subject.uid).to be_kind_of(Integer)
268
+ end
269
+
270
+ it "contains a euid member and returns the expected value" do
271
+ expect(subject).to respond_to(:euid)
272
+ expect(subject.euid).to be_kind_of(Integer)
273
+ end
274
+
275
+ it "contains a gid member and returns the expected value" do
276
+ expect(subject).to respond_to(:gid)
277
+ expect(subject.gid).to be_kind_of(Integer)
278
+ end
279
+
280
+ it "contains a egid member and returns the expected value" do
281
+ expect(subject).to respond_to(:egid)
282
+ expect(subject.egid).to be_kind_of(Integer)
283
+ end
284
+
285
+ it "contains a pctmem member and returns the expected value" do
286
+ expect(subject).to respond_to(:pctmem)
287
+ expect(subject.pctmem).to be_kind_of(Float)
288
+ end
289
+
290
+ it "contains a pctcpu member and returns the expected value" do
291
+ expect(subject).to respond_to(:pctcpu)
292
+ expect(subject.pctcpu).to be_kind_of(Float)
293
+ end
294
+
295
+ it "contains a nlwp member and returns the expected value" do
296
+ expect(subject).to respond_to(:nlwp)
297
+ expect(subject.nlwp).to be_kind_of(Integer)
298
+ end
299
+ end
300
+
301
+ context "custom structs" do
302
+ subject{ described_class.ps.last }
303
+
304
+ it "contains a cgroup member and returns the expected value" do
305
+ expect(subject).to respond_to(:cgroup)
306
+ expect(subject.cgroup).to be_kind_of(Array)
307
+ expect(subject.cgroup.first).to be_kind_of(Sys::ProcTable::CgroupEntry)
308
+ end
309
+
310
+ it "contains a smaps member and returns the expected value" do
311
+ expect(subject).to respond_to(:cgroup)
312
+ expect(subject.smaps).to be_kind_of(Sys::ProcTable::Smaps)
313
+ end
314
+ end
315
+
316
+ context "fields" do
317
+ it "has a fields method that returns the expected results" do
318
+ expect(described_class).to respond_to(:fields)
319
+ expect(described_class.fields).to be_kind_of(Array)
320
+ expect(described_class.fields).to match_array(fields)
321
+ end
322
+ end
323
+ end