sys-proctable 1.2.6 → 1.2.7
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/{CHANGES.rdoc → CHANGES.md} +64 -49
- data/Gemfile +2 -0
- data/{MANIFEST.rdoc → MANIFEST.md} +1 -0
- data/README.md +8 -3
- data/Rakefile +7 -4
- data/certs/djberg96_pub.pem +26 -0
- data/lib/darwin/sys/proctable.rb +53 -20
- data/lib/freebsd/sys/proctable.rb +1 -1
- data/lib/linux/sys/proctable/cgroup_entry.rb +4 -2
- data/lib/linux/sys/proctable/smaps.rb +29 -17
- data/lib/linux/sys/proctable.rb +41 -35
- data/lib/sunos/sys/proctable.rb +2 -2
- data/lib/sys/proctable/version.rb +1 -1
- data/lib/sys/top.rb +1 -1
- data/lib/windows/sys/proctable.rb +36 -32
- data/spec/spec_helper.rb +13 -0
- data/spec/sys_proctable_aix_spec.rb +74 -76
- data/spec/sys_proctable_all_spec.rb +45 -45
- data/spec/sys_proctable_darwin_spec.rb +85 -58
- data/spec/sys_proctable_freebsd_spec.rb +111 -113
- data/spec/sys_proctable_linux_spec.rb +196 -195
- data/spec/sys_proctable_sunos_spec.rb +190 -192
- data/spec/sys_proctable_windows_spec.rb +153 -153
- data/spec/sys_top_spec.rb +20 -21
- data/sys-proctable.gemspec +15 -24
- data.tar.gz.sig +0 -0
- metadata +54 -16
- metadata.gz.sig +0 -0
@@ -4,11 +4,9 @@
|
|
4
4
|
# Test suite for the Darwin version of the sys-proctable library. You
|
5
5
|
# should run these tests via the 'rake test' task.
|
6
6
|
########################################################################
|
7
|
-
require '
|
8
|
-
require 'sys/proctable'
|
9
|
-
require_relative 'sys_proctable_all_spec'
|
7
|
+
require 'spec_helper'
|
10
8
|
|
11
|
-
describe Sys::ProcTable do
|
9
|
+
RSpec.describe Sys::ProcTable, :darwin do
|
12
10
|
let(:fields){
|
13
11
|
%w[
|
14
12
|
flags status xstatus pid ppid uid gid ruid rgid svuid svgid rfu1 comm
|
@@ -21,8 +19,8 @@ describe Sys::ProcTable do
|
|
21
19
|
}
|
22
20
|
|
23
21
|
before(:all) do
|
24
|
-
@pid1 = Process.spawn({'A' => 'B', 'Z' => nil},
|
25
|
-
@pid2 = Process.spawn(
|
22
|
+
@pid1 = Process.spawn({'A' => 'B', 'Z' => nil}, 'sleep 60')
|
23
|
+
@pid2 = Process.spawn('ruby', '-Ilib', '-e', "sleep \'120\'.to_i", '--', 'foo bar')
|
26
24
|
sleep 1 # wait to make sure env is replaced by sleep
|
27
25
|
end
|
28
26
|
|
@@ -31,90 +29,119 @@ describe Sys::ProcTable do
|
|
31
29
|
Process.kill('TERM', @pid2)
|
32
30
|
end
|
33
31
|
|
34
|
-
context
|
35
|
-
it
|
32
|
+
context 'fields singleton method' do
|
33
|
+
it 'responds to a fields method' do
|
36
34
|
expect(described_class).to respond_to(:fields)
|
37
35
|
end
|
38
36
|
|
39
|
-
it
|
37
|
+
it 'returns the expected results for the fields method' do
|
40
38
|
expect(described_class.fields).to be_kind_of(Array)
|
41
39
|
expect(described_class.fields).to eq(fields)
|
42
40
|
end
|
43
41
|
end
|
44
42
|
|
45
|
-
context
|
46
|
-
subject
|
43
|
+
context 'ProcTable::Struct members' do
|
44
|
+
subject(:process){ described_class.ps(:pid => @pid1) }
|
47
45
|
|
48
|
-
it
|
49
|
-
expect(
|
50
|
-
expect(
|
51
|
-
expect(
|
46
|
+
it 'contains a pid member and returns the expected value' do
|
47
|
+
expect(process).to respond_to(:pid)
|
48
|
+
expect(process.pid).to be_kind_of(Numeric)
|
49
|
+
expect(process.pid).to eq(@pid1)
|
52
50
|
end
|
53
51
|
|
54
|
-
it
|
55
|
-
expect(
|
56
|
-
expect(
|
57
|
-
expect(
|
52
|
+
it 'contains a ppid member and returns the expected value' do
|
53
|
+
expect(process).to respond_to(:ppid)
|
54
|
+
expect(process.ppid).to be_kind_of(Numeric)
|
55
|
+
expect(process.ppid).to eq(Process.pid)
|
58
56
|
end
|
59
57
|
|
60
|
-
it
|
61
|
-
expect(
|
62
|
-
expect(
|
63
|
-
expect(
|
58
|
+
it 'contains a pgid member and returns the expected value' do
|
59
|
+
expect(process).to respond_to(:pgid)
|
60
|
+
expect(process.pgid).to be_kind_of(Numeric)
|
61
|
+
expect(process.pgid).to eq(Process.getpgrp)
|
64
62
|
end
|
65
63
|
|
66
|
-
it
|
67
|
-
expect(
|
68
|
-
expect(
|
69
|
-
expect(
|
64
|
+
it 'contains a ruid member and returns the expected value' do
|
65
|
+
expect(process).to respond_to(:ruid)
|
66
|
+
expect(process.ruid).to be_kind_of(Numeric)
|
67
|
+
expect(process.ruid).to eq(Process.uid)
|
70
68
|
end
|
71
69
|
|
72
|
-
it
|
73
|
-
expect(
|
74
|
-
expect(
|
75
|
-
expect(
|
70
|
+
it 'contains an rgid member and returns the expected value' do
|
71
|
+
expect(process).to respond_to(:rgid)
|
72
|
+
expect(process.rgid).to be_kind_of(Numeric)
|
73
|
+
expect(process.rgid).to eq(Process.gid)
|
76
74
|
end
|
77
75
|
|
78
|
-
it
|
79
|
-
expect(
|
80
|
-
expect(
|
81
|
-
expect(
|
76
|
+
it 'contains an svuid member and returns the expected value' do
|
77
|
+
expect(process).to respond_to(:svuid)
|
78
|
+
expect(process.svuid).to be_kind_of(Numeric)
|
79
|
+
expect(process.svuid).to eq(Process.uid)
|
82
80
|
end
|
83
81
|
|
84
|
-
it
|
85
|
-
expect(
|
86
|
-
expect(
|
87
|
-
expect(
|
82
|
+
it 'contains an svgid member and returns the expected value' do
|
83
|
+
expect(process).to respond_to(:svgid)
|
84
|
+
expect(process.svgid).to be_kind_of(Numeric)
|
85
|
+
expect(process.svgid).to eq(Process.gid)
|
88
86
|
end
|
89
87
|
|
90
|
-
it
|
91
|
-
expect(
|
92
|
-
expect(
|
93
|
-
expect(
|
88
|
+
it 'contains a comm member and returns the expected value' do
|
89
|
+
expect(process).to respond_to(:comm)
|
90
|
+
expect(process.comm).to be_kind_of(String)
|
91
|
+
expect(process.comm).to eq('sleep')
|
94
92
|
end
|
95
93
|
|
96
|
-
it
|
97
|
-
expect(
|
98
|
-
expect(
|
99
|
-
expect(
|
94
|
+
it 'contains a cmdline member and returns the expected value' do
|
95
|
+
expect(process).to respond_to(:cmdline)
|
96
|
+
expect(process.cmdline).to be_kind_of(String)
|
97
|
+
expect(process.cmdline).to eq('sleep 60')
|
100
98
|
end
|
101
99
|
|
102
|
-
it
|
103
|
-
ptable = Sys::ProcTable.ps(pid
|
100
|
+
it 'returns a string with the expected arguments for the cmdline member', :skip => :jruby do
|
101
|
+
ptable = Sys::ProcTable.ps(:pid => @pid2)
|
104
102
|
expect(ptable.cmdline).to eq('ruby -Ilib -e sleep \'120\'.to_i -- foo bar')
|
105
103
|
end
|
106
104
|
|
107
|
-
it
|
108
|
-
expect(
|
109
|
-
expect(
|
110
|
-
expect(
|
105
|
+
it 'contains an exe member and returns the expected value' do
|
106
|
+
expect(process).to respond_to(:exe)
|
107
|
+
expect(process.exe).to be_kind_of(String)
|
108
|
+
expect(process.exe).to eq(`which sleep`.chomp)
|
111
109
|
end
|
112
110
|
|
113
|
-
it
|
114
|
-
|
115
|
-
expect(
|
116
|
-
expect(
|
117
|
-
expect(
|
111
|
+
it 'contains an environ member and returns the expected value' do
|
112
|
+
skip 'It appears to no longer be possible to get environ on spawned processes on Catalina or later in most cases'
|
113
|
+
expect(process).to respond_to(:environ)
|
114
|
+
expect(process.environ).to be_kind_of(Hash)
|
115
|
+
expect(process.environ['A']).to eq('B')
|
116
|
+
expect(process.environ['Z']).to be_nil
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
context 'private constants' do
|
121
|
+
it 'makes FFI methods private' do
|
122
|
+
expect(described_class).not_to respond_to(:sysctl)
|
123
|
+
expect(described_class).not_to respond_to(:proc_listallpids)
|
124
|
+
expect(described_class).not_to respond_to(:proc_pidinfo)
|
125
|
+
end
|
126
|
+
|
127
|
+
it 'makes FFI structs private' do
|
128
|
+
expect(described_class.constants).not_to include(:ProcBsdInfo)
|
129
|
+
expect(described_class.constants).not_to include(:ProcThreadInfo)
|
130
|
+
expect(described_class.constants).not_to include(:ProcTaskInfo)
|
131
|
+
expect(described_class.constants).not_to include(:ProcTaskAllInfo)
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'makes internal constants private' do
|
135
|
+
expect(described_class.constants).not_to include(:PROC_PIDTASKALLINFO)
|
136
|
+
expect(described_class.constants).not_to include(:PROC_PIDTHREADINFO)
|
137
|
+
expect(described_class.constants).not_to include(:PROC_PIDLISTTHREADS)
|
138
|
+
expect(described_class.constants).not_to include(:CTL_KERN)
|
139
|
+
expect(described_class.constants).not_to include(:KERN_PROCARGS)
|
140
|
+
expect(described_class.constants).not_to include(:KERN_PROCARGS2)
|
141
|
+
expect(described_class.constants).not_to include(:MAX_COMLEN)
|
142
|
+
expect(described_class.constants).not_to include(:MAX_PATHLEN)
|
143
|
+
expect(described_class.constants).not_to include(:MAXTHREADNAMESIZE)
|
144
|
+
expect(described_class.constants).not_to include(:PROC_PIDPATHINFO_MAXSIZE)
|
118
145
|
end
|
119
146
|
end
|
120
147
|
end
|
@@ -2,13 +2,11 @@
|
|
2
2
|
# sys_proctable_freebsd_rspec.rb
|
3
3
|
#
|
4
4
|
# Test suite for FreeBSD for the sys-proctable library.
|
5
|
-
# You should run these tests via 'rake
|
5
|
+
# You should run these tests via the 'rake spec' task.
|
6
6
|
################################################################
|
7
|
-
require '
|
8
|
-
require 'sys/proctable'
|
9
|
-
require_relative 'sys_proctable_all_spec'
|
7
|
+
require 'spec_helper'
|
10
8
|
|
11
|
-
describe Sys::ProcTable do
|
9
|
+
RSpec.describe Sys::ProcTable, :freebsd do
|
12
10
|
let(:fields){
|
13
11
|
%w[
|
14
12
|
pid ppid pgid tpgid sid tsid jobc uid ruid rgid
|
@@ -21,190 +19,190 @@ describe Sys::ProcTable do
|
|
21
19
|
]
|
22
20
|
}
|
23
21
|
|
24
|
-
context
|
25
|
-
it
|
22
|
+
context 'fields singleton method' do
|
23
|
+
it 'responds to a fields method' do
|
26
24
|
expect(described_class).to respond_to(:fields)
|
27
25
|
end
|
28
26
|
|
29
|
-
it
|
27
|
+
it 'returns the expected results for the fields method' do
|
30
28
|
expect(described_class.fields).to be_kind_of(Array)
|
31
29
|
expect(described_class.fields).to eql(fields)
|
32
30
|
end
|
33
31
|
end
|
34
32
|
|
35
|
-
context
|
36
|
-
subject
|
33
|
+
context 'ProcTable::Struct members' do
|
34
|
+
subject(:process){ described_class.ps(:pid => Process.pid) }
|
37
35
|
|
38
|
-
it
|
39
|
-
expect(
|
40
|
-
expect(
|
41
|
-
expect(
|
36
|
+
it 'contains a pid member and returns the expected value' do
|
37
|
+
expect(process).to respond_to(:pid)
|
38
|
+
expect(process.pid).to be_kind_of(Numeric)
|
39
|
+
expect(process.pid).to eql(Process.pid)
|
42
40
|
end
|
43
41
|
|
44
|
-
it
|
45
|
-
expect(
|
46
|
-
expect(
|
42
|
+
it 'contains a ppid member and returns the expected value' do
|
43
|
+
expect(process).to respond_to(:ppid)
|
44
|
+
expect(process.ppid).to be_kind_of(Integer)
|
47
45
|
end
|
48
46
|
|
49
|
-
it
|
50
|
-
expect(
|
51
|
-
expect(
|
47
|
+
it 'contains a pgid member and returns the expected value' do
|
48
|
+
expect(process).to respond_to(:pgid)
|
49
|
+
expect(process.pgid).to be_kind_of(Integer)
|
52
50
|
end
|
53
51
|
|
54
|
-
it
|
55
|
-
expect(
|
56
|
-
expect(
|
52
|
+
it 'contains a ruid member and returns the expected value' do
|
53
|
+
expect(process).to respond_to(:ruid)
|
54
|
+
expect(process.ruid).to be_kind_of(Integer)
|
57
55
|
end
|
58
56
|
|
59
|
-
it
|
60
|
-
expect(
|
61
|
-
expect(
|
57
|
+
it 'contains a rgid member and returns the expected value' do
|
58
|
+
expect(process).to respond_to(:rgid)
|
59
|
+
expect(process.rgid).to be_kind_of(Integer)
|
62
60
|
end
|
63
61
|
|
64
|
-
it
|
65
|
-
expect(
|
66
|
-
expect(
|
62
|
+
it 'contains a comm member and returns the expected value' do
|
63
|
+
expect(process).to respond_to(:comm)
|
64
|
+
expect(process.comm).to be_kind_of(String)
|
67
65
|
end
|
68
66
|
|
69
|
-
it
|
70
|
-
expect(
|
71
|
-
expect(
|
67
|
+
it 'contains a state member and returns the expected value' do
|
68
|
+
expect(process).to respond_to(:state)
|
69
|
+
expect(process.state).to be_kind_of(String)
|
72
70
|
end
|
73
71
|
|
74
|
-
it
|
75
|
-
expect(
|
76
|
-
expect(
|
72
|
+
it 'contains a pctcpu member and returns the expected value' do
|
73
|
+
expect(process).to respond_to(:pctcpu)
|
74
|
+
expect(process.pctcpu).to be_kind_of(Float)
|
77
75
|
end
|
78
76
|
|
79
|
-
it
|
80
|
-
expect(
|
81
|
-
expect(
|
77
|
+
it 'contains a oncpu member and returns the expected value' do
|
78
|
+
expect(process).to respond_to(:oncpu)
|
79
|
+
expect(process.oncpu).to be_kind_of(Integer)
|
82
80
|
end
|
83
81
|
|
84
|
-
it
|
85
|
-
expect(
|
86
|
-
expect(
|
82
|
+
it 'contains a ttynum member and returns the expected value' do
|
83
|
+
expect(process).to respond_to(:ttynum)
|
84
|
+
expect(process.ttynum).to be_kind_of(Integer)
|
87
85
|
end
|
88
86
|
|
89
|
-
it
|
90
|
-
expect(
|
91
|
-
expect(
|
87
|
+
it 'contains a ttydev member and returns the expected value' do
|
88
|
+
expect(process).to respond_to(:ttydev)
|
89
|
+
expect(process.ttydev).to be_kind_of(String)
|
92
90
|
end
|
93
91
|
|
94
|
-
it
|
95
|
-
expect(
|
96
|
-
expect(
|
92
|
+
it 'contains a wmesg member and returns the expected value' do
|
93
|
+
expect(process).to respond_to(:wmesg)
|
94
|
+
expect(process.wmesg).to be_kind_of(String)
|
97
95
|
end
|
98
96
|
|
99
|
-
it
|
100
|
-
expect(
|
101
|
-
expect(
|
97
|
+
it 'contains a runtime member and returns the expected value' do
|
98
|
+
expect(process).to respond_to(:runtime)
|
99
|
+
expect(process.runtime).to be_kind_of(Integer)
|
102
100
|
end
|
103
101
|
|
104
|
-
it
|
105
|
-
expect(
|
106
|
-
expect(
|
102
|
+
it 'contains a priority member and returns the expected value' do
|
103
|
+
expect(process).to respond_to(:priority)
|
104
|
+
expect(process.priority).to be_kind_of(Integer)
|
107
105
|
end
|
108
106
|
|
109
|
-
it
|
110
|
-
expect(
|
111
|
-
expect(
|
107
|
+
it 'contains a usrpri member and returns the expected value' do
|
108
|
+
expect(process).to respond_to(:usrpri)
|
109
|
+
expect(process.usrpri).to be_kind_of(Integer)
|
112
110
|
end
|
113
111
|
|
114
|
-
it
|
115
|
-
expect(
|
116
|
-
expect(
|
112
|
+
it 'contains a nice member and returns the expected value' do
|
113
|
+
expect(process).to respond_to(:nice)
|
114
|
+
expect(process.nice).to be_kind_of(Integer)
|
117
115
|
end
|
118
116
|
|
119
|
-
it
|
120
|
-
expect(
|
121
|
-
expect(
|
117
|
+
it 'contains a cmdline member and returns the expected value' do
|
118
|
+
expect(process).to respond_to(:cmdline)
|
119
|
+
expect(process.cmdline).to be_kind_of(String)
|
122
120
|
end
|
123
121
|
|
124
|
-
it
|
125
|
-
expect(
|
126
|
-
expect(
|
122
|
+
it 'contains a start member and returns the expected value' do
|
123
|
+
expect(process).to respond_to(:start)
|
124
|
+
expect(process.start).to be_kind_of(Time)
|
127
125
|
end
|
128
126
|
|
129
|
-
it
|
130
|
-
expect(
|
131
|
-
expect(
|
127
|
+
it 'contains a maxrss member and returns the expected value' do
|
128
|
+
expect(process).to respond_to(:maxrss)
|
129
|
+
expect(process.maxrss).to be_kind_of(Integer)
|
132
130
|
end
|
133
131
|
|
134
|
-
it
|
135
|
-
expect(
|
136
|
-
expect(
|
132
|
+
it 'contains a ixrss member and returns the expected value' do
|
133
|
+
expect(process).to respond_to(:ixrss)
|
134
|
+
expect(process.ixrss).to be_kind_of(Integer)
|
137
135
|
end
|
138
136
|
|
139
137
|
# TODO: The value returned on PC BSD 10 does not appear to be valid. Investigate.
|
140
|
-
it
|
141
|
-
expect(
|
142
|
-
expect(
|
138
|
+
it 'contains a idrss member and returns the expected value' do
|
139
|
+
expect(process).to respond_to(:idrss)
|
140
|
+
expect(process.idrss).to be_kind_of(Numeric)
|
143
141
|
end
|
144
142
|
|
145
|
-
it
|
146
|
-
expect(
|
147
|
-
expect(
|
143
|
+
it 'contains a isrss member and returns the expected value' do
|
144
|
+
expect(process).to respond_to(:isrss)
|
145
|
+
expect(process.isrss).to be_kind_of(Integer)
|
148
146
|
end
|
149
147
|
|
150
|
-
it
|
151
|
-
expect(
|
152
|
-
expect(
|
148
|
+
it 'contains a minflt member and returns the expected value' do
|
149
|
+
expect(process).to respond_to(:minflt)
|
150
|
+
expect(process.minflt).to be_kind_of(Integer)
|
153
151
|
end
|
154
152
|
|
155
|
-
it
|
156
|
-
expect(
|
157
|
-
expect(
|
153
|
+
it 'contains a majflt member and returns the expected value' do
|
154
|
+
expect(process).to respond_to(:majflt)
|
155
|
+
expect(process.majflt).to be_kind_of(Integer)
|
158
156
|
end
|
159
157
|
|
160
|
-
it
|
161
|
-
expect(
|
162
|
-
expect(
|
158
|
+
it 'contains a nswap member and returns the expected value' do
|
159
|
+
expect(process).to respond_to(:nswap)
|
160
|
+
expect(process.nswap).to be_kind_of(Integer)
|
163
161
|
end
|
164
162
|
|
165
|
-
it
|
166
|
-
expect(
|
167
|
-
expect(
|
163
|
+
it 'contains a inblock member and returns the expected value' do
|
164
|
+
expect(process).to respond_to(:inblock)
|
165
|
+
expect(process.inblock).to be_kind_of(Integer)
|
168
166
|
end
|
169
167
|
|
170
|
-
it
|
171
|
-
expect(
|
172
|
-
expect(
|
168
|
+
it 'contains a oublock member and returns the expected value' do
|
169
|
+
expect(process).to respond_to(:oublock)
|
170
|
+
expect(process.oublock).to be_kind_of(Integer)
|
173
171
|
end
|
174
172
|
|
175
|
-
it
|
176
|
-
expect(
|
177
|
-
expect(
|
173
|
+
it 'contains a msgsnd member and returns the expected value' do
|
174
|
+
expect(process).to respond_to(:msgsnd)
|
175
|
+
expect(process.msgsnd).to be_kind_of(Integer)
|
178
176
|
end
|
179
177
|
|
180
|
-
it
|
181
|
-
expect(
|
182
|
-
expect(
|
178
|
+
it 'contains a msgrcv member and returns the expected value' do
|
179
|
+
expect(process).to respond_to(:msgrcv)
|
180
|
+
expect(process.msgrcv).to be_kind_of(Integer)
|
183
181
|
end
|
184
182
|
|
185
|
-
it
|
186
|
-
expect(
|
187
|
-
expect(
|
183
|
+
it 'contains a nsignals member and returns the expected value' do
|
184
|
+
expect(process).to respond_to(:nsignals)
|
185
|
+
expect(process.nsignals).to be_kind_of(Integer)
|
188
186
|
end
|
189
187
|
|
190
|
-
it
|
191
|
-
expect(
|
192
|
-
expect(
|
188
|
+
it 'contains a nvcsw member and returns the expected value' do
|
189
|
+
expect(process).to respond_to(:nvcsw)
|
190
|
+
expect(process.nvcsw).to be_kind_of(Integer)
|
193
191
|
end
|
194
192
|
|
195
|
-
it
|
196
|
-
expect(
|
197
|
-
expect(
|
193
|
+
it 'contains a nivcsw member and returns the expected value' do
|
194
|
+
expect(process).to respond_to(:nivcsw)
|
195
|
+
expect(process.nivcsw).to be_kind_of(Integer)
|
198
196
|
end
|
199
197
|
|
200
|
-
it
|
201
|
-
expect(
|
202
|
-
expect(
|
198
|
+
it 'contains a utime member and returns the expected value' do
|
199
|
+
expect(process).to respond_to(:utime)
|
200
|
+
expect(process.utime).to be_kind_of(Integer)
|
203
201
|
end
|
204
202
|
|
205
|
-
it
|
206
|
-
expect(
|
207
|
-
expect(
|
203
|
+
it 'contains a stime member and returns the expected value' do
|
204
|
+
expect(process).to respond_to(:stime)
|
205
|
+
expect(process.stime).to be_kind_of(Integer)
|
208
206
|
end
|
209
207
|
end
|
210
208
|
end
|