proc-wait3 1.7.1 → 1.9.0

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.
data/Rakefile CHANGED
@@ -1,20 +1,22 @@
1
1
  require 'rake'
2
2
  require 'rake/clean'
3
- require 'rake/testtask'
3
+ require 'rspec/core/rake_task'
4
4
  require 'fileutils'
5
5
  require 'rbconfig'
6
6
  include RbConfig
7
7
 
8
8
  CLEAN.include(
9
- '**/*.gem', # Gem files
10
- '**/*.rbc', # Rubinius
11
- '**/*.o', # C object file
12
- '**/*.log', # Ruby extension build log
13
- '**/Makefile', # C Makefile
14
- '**/conftest.dSYM', # OS X build directory
15
- "**/*.#{CONFIG['DLEXT']}" # C shared object
9
+ '**/*.gem', # Gem files
10
+ '**/*.rbc', # Rubinius
11
+ '**/*.o', # C object file
12
+ '**/*.log', # Ruby extension build log
13
+ '**/Makefile', # C Makefile
14
+ '**/conftest.dSYM', # OS X build directory
15
+ "**/*.#{CONFIG['DLEXT']}", # C shared object
16
+ '**/*.lock' # Bundler
16
17
  )
17
18
 
19
+
18
20
  desc "Build the source (but don't install it)"
19
21
  task :build => [:clean] do |t|
20
22
  Dir.chdir('ext') do
@@ -27,19 +29,16 @@ end
27
29
  namespace :gem do
28
30
  desc "Create the proc-wait3 gem"
29
31
  task :create => [:clean] do
32
+ require 'rubygems/package'
30
33
  spec = eval(IO.read('proc-wait3.gemspec'))
31
- if Gem::VERSION < "2.0"
32
- Gem::Builder.new(spec).build
33
- else
34
- require 'rubygems/package'
35
- Gem::Package.build(spec)
36
- end
34
+ spec.signing_key = File.join(Dir.home, '.ssh', 'gem-private_key.pem')
35
+ Gem::Package.build(spec)
37
36
  end
38
37
 
39
38
  desc "Install the proc-wait3 gem"
40
39
  task :install => [:create] do |t|
41
40
  file = Dir['*.gem'].first
42
- sh "gem install #{file}"
41
+ sh "gem install -l #{file}"
43
42
  end
44
43
  end
45
44
 
@@ -70,11 +69,9 @@ namespace :example do
70
69
  end
71
70
  end
72
71
 
73
- Rake::TestTask.new do |t|
74
- task :test => [:build]
75
- t.libs << 'ext'
76
- t.warning = true
77
- t.verbose = true
72
+ desc "Run the test suite"
73
+ RSpec::Core::RakeTask.new(:spec) do |t|
74
+ t.rspec_opts = '-Iext'
78
75
  end
79
76
 
80
- task :default => :test
77
+ task :default => [:build, :spec]
@@ -0,0 +1,26 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIEcDCCAtigAwIBAgIBATANBgkqhkiG9w0BAQsFADA/MREwDwYDVQQDDAhkamJl
3
+ cmc5NjEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYDY29t
4
+ MB4XDTE4MDMxODE1MjIwN1oXDTI4MDMxNTE1MjIwN1owPzERMA8GA1UEAwwIZGpi
5
+ ZXJnOTYxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkWA2Nv
6
+ bTCCAaIwDQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBALgfaroVM6CI06cxr0/h
7
+ A+j+pc8fgpRgBVmHFaFunq28GPC3IvW7Nvc3Y8SnAW7pP1EQIbhlwRIaQzJ93/yj
8
+ u95KpkP7tA9erypnV7dpzBkzNlX14ACaFD/6pHoXoe2ltBxk3CCyyzx70mTqJpph
9
+ 75IB03ni9a8yqn8pmse+s83bFJOAqddSj009sGPcQO+QOWiNxqYv1n5EHcvj2ebO
10
+ 6hN7YTmhx7aSia4qL/quc4DlIaGMWoAhvML7u1fmo53CYxkKskfN8MOecq2vfEmL
11
+ iLu+SsVVEAufMDDFMXMJlvDsviolUSGMSNRTujkyCcJoXKYYxZSNtIiyd9etI0X3
12
+ ctu0uhrFyrMZXCedutvXNjUolD5r9KGBFSWH1R9u2I3n3SAyFF2yzv/7idQHLJJq
13
+ 74BMnx0FIq6fCpu5slAipvxZ3ZkZpEXZFr3cIBtO1gFvQWW7E/Y3ijliWJS1GQFq
14
+ 058qERadHGu1yu1dojmFRo6W2KZvY9al2yIlbkpDrD5MYQIDAQABo3cwdTAJBgNV
15
+ HRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUFZsMapgzJimzsbaBG2Tm8j5e
16
+ AzgwHQYDVR0RBBYwFIESZGpiZXJnOTZAZ21haWwuY29tMB0GA1UdEgQWMBSBEmRq
17
+ YmVyZzk2QGdtYWlsLmNvbTANBgkqhkiG9w0BAQsFAAOCAYEAW2tnYixXQtKxgGXq
18
+ /3iSWG2bLwvxS4go3srO+aRXZHrFUMlJ5W0mCxl03aazxxKTsVVpZD8QZxvK91OQ
19
+ h9zr9JBYqCLcCVbr8SkmYCi/laxIZxsNE5YI8cC8vvlLI7AMgSfPSnn/Epq1GjGY
20
+ 6L1iRcEDtanGCIvjqlCXO9+BmsnCfEVehqZkQHeYczA03tpOWb6pon2wzvMKSsKH
21
+ ks0ApVdstSLz1kzzAqem/uHdG9FyXdbTAwH1G4ZPv69sQAFAOCgAqYmdnzedsQtE
22
+ 1LQfaQrx0twO+CZJPcRLEESjq8ScQxWRRkfuh2VeR7cEU7L7KqT10mtUwrvw7APf
23
+ DYoeCY9KyjIBjQXfbj2ke5u1hZj94Fsq9FfbEQg8ygCgwThnmkTrrKEiMSs3alYR
24
+ ORVCZpRuCPpmC8qmqxUnARDArzucjaclkxjLWvCVHeFa9UP7K3Nl9oTjJNv+7/jM
25
+ WZs4eecIcUc4tKdHxcAJ0MO/Dkqq7hGaiHpwKY76wQ1+8xAh
26
+ -----END CERTIFICATE-----
@@ -174,10 +174,10 @@ Process::RLIM_SAVED_MAX
174
174
  page at https://github.com/djberg96/proc-wait3.
175
175
 
176
176
  == License
177
- Artistic 2.0
177
+ Apache-2.0
178
178
 
179
179
  == Copyright
180
- (C) 2003-2014 Daniel J. Berger
180
+ (C) 2003-2019 Daniel J. Berger
181
181
  All Rights Reserved.
182
182
 
183
183
  == Warranty
@@ -6,29 +6,6 @@ require 'mkmf'
6
6
 
7
7
  dir_config('proc-wait3')
8
8
 
9
- # We need this for older versions of Ruby.
10
- def have_const(const, header = nil, opt = "", &b)
11
- checking_for const do
12
- header = cpp_include(header)
13
- if try_compile(<<"SRC", opt, &b)
14
- #{COMMON_HEADERS}
15
- #{header}
16
- /* top */
17
- static int t = #{const};
18
- SRC
19
- $defs.push(
20
- format(
21
- "-DHAVE_CONST_%s",
22
- const.strip.upcase.tr_s("^A-Z0-9_", "_")
23
- )
24
- )
25
- true
26
- else
27
- false
28
- end
29
- end
30
- end
31
-
32
9
  have_header('wait.h')
33
10
  have_header('sys/resource.h')
34
11
  have_header('sys/wait.h')
@@ -41,7 +18,16 @@ end
41
18
 
42
19
  # Yay, Linux
43
20
  have_func('str2sig')
44
- have_func('strlcpy')
21
+
22
+ if have_library('bsd')
23
+ if have_header('bsd/string.h')
24
+ have_func('strlcpy', 'bsd/string.h')
25
+ else
26
+ have_func('strlcpy')
27
+ end
28
+ else
29
+ have_func('strlcpy')
30
+ end
45
31
 
46
32
  # wait4, waitid, etc, are optional (HPUX, et al)
47
33
  have_func('wait4')
@@ -92,4 +78,7 @@ have_const('P_PID', 'signal.h') || have_const('P_PID', 'sys/wait.h')
92
78
  have_const('P_PROJID', 'signal.h')
93
79
  have_const('P_TASKID', 'signal.h')
94
80
 
81
+ # RUSAGE_THREAD is Linux-specific
82
+ have_const('RUSAGE_THREAD', 'sys/resource.h')
83
+
95
84
  create_makefile('proc/wait3', 'proc')
@@ -18,33 +18,12 @@
18
18
  #include <signal.h>
19
19
  #endif
20
20
 
21
- #ifndef SIG2STR_MAX
22
- #define SIG2STR_MAX 32
23
- #endif
24
-
25
- /* Ruby 1.9.x */
26
- #ifndef RSTRING_PTR
27
- #define RSTRING_PTR(v) (RSTRING(v)->ptr)
28
- #define RSTRING_LEN(v) (RSTRING(v)->len)
29
- #endif
30
-
31
- #ifndef RARRAY_PTR
32
- #define RARRAY_PTR(v) (RARRAY(v)->ptr)
33
- #define RARRAY_LEN(v) (RARRAY(v)->len)
21
+ #ifdef HAVE_BSD_STRING_H
22
+ #include <bsd/string.h>
34
23
  #endif
35
24
 
36
- /* Copied from process.c in Ruby 1.8.5 */
37
- #ifndef RUBY_HAS_RLIMIT
38
- #if SIZEOF_RLIM_T == SIZEOF_INT
39
- # define RLIM2NUM(v) UINT2NUM(v)
40
- # define NUM2RLIM(v) NUM2UINT(v)
41
- #elif SIZEOF_RLIM_T == SIZEOF_LONG
42
- # define RLIM2NUM(v) ULONG2NUM(v)
43
- # define NUM2RLIM(v) NUM2ULONG(v)
44
- #elif SIZEOF_RLIM_T == SIZEOF_LONG_LONG
45
- # define RLIM2NUM(v) ULL2NUM(v)
46
- # define NUM2RLIM(v) NUM2ULL(v)
47
- #endif
25
+ #ifndef SIG2STR_MAX
26
+ #define SIG2STR_MAX 32
48
27
  #endif
49
28
 
50
29
  VALUE v_last_status;
@@ -184,8 +163,8 @@ static VALUE proc_wait3(int argc, VALUE *argv, VALUE mod){
184
163
  v_last_status = rb_struct_new(v_procstat_struct,
185
164
  INT2FIX(pid),
186
165
  INT2FIX(status),
187
- INT2FIX(r.ru_utime.tv_sec + (r.ru_utime.tv_usec/1000.0)),
188
- INT2FIX(r.ru_stime.tv_sec + (r.ru_stime.tv_usec/1000.0)),
166
+ INT2FIX(r.ru_utime.tv_sec + (r.ru_utime.tv_usec/1e6)),
167
+ INT2FIX(r.ru_stime.tv_sec + (r.ru_stime.tv_usec/1e6)),
189
168
  INT2FIX(r.ru_maxrss),
190
169
  INT2FIX(r.ru_ixrss),
191
170
  INT2FIX(r.ru_idrss),
@@ -256,8 +235,8 @@ static VALUE proc_wait4(int argc, VALUE *argv, VALUE mod){
256
235
  v_last_status = rb_struct_new(v_procstat_struct,
257
236
  INT2FIX(pid),
258
237
  INT2FIX(status),
259
- INT2FIX(r.ru_utime.tv_sec + (r.ru_utime.tv_usec/1000.0)),
260
- INT2FIX(r.ru_stime.tv_sec + (r.ru_stime.tv_usec/1000.0)),
238
+ INT2FIX(r.ru_utime.tv_sec + (r.ru_utime.tv_usec/1e6)),
239
+ INT2FIX(r.ru_stime.tv_sec + (r.ru_stime.tv_usec/1e6)),
261
240
  INT2FIX(r.ru_maxrss),
262
241
  INT2FIX(r.ru_ixrss),
263
242
  INT2FIX(r.ru_idrss),
@@ -730,6 +709,9 @@ static VALUE proc_sigsend(int argc, VALUE* argv, VALUE mod){
730
709
  * process. If +children+ is set to true, it will return information for
731
710
  * terminated and waited for children of the current process.
732
711
  *
712
+ * On Linux platforms the +children+ argument can be set to RUSAGE_THREAD to
713
+ * retrieve thread information instead.
714
+ *
733
715
  * The RUsage struct contains the following members:
734
716
  *
735
717
  * * utime - User time
@@ -758,7 +740,9 @@ static VALUE proc_getrusage(int argc, VALUE* argv, VALUE mod){
758
740
 
759
741
  rb_scan_args(argc, argv, "01", &v_children);
760
742
 
761
- if(RTEST(v_children))
743
+ if(TYPE(v_children) == T_FIXNUM)
744
+ who = FIX2INT(v_children);
745
+ else if(RTEST(v_children))
762
746
  who = RUSAGE_CHILDREN;
763
747
 
764
748
  if(getrusage(who,&r) == -1)
@@ -966,8 +950,12 @@ void Init_wait3()
966
950
  rb_define_const(rb_mProcess, "P_PROJID", INT2FIX(P_PROJID));
967
951
  #endif
968
952
 
969
- /* 1.7.1: The version of the proc-wait3 library */
970
- rb_define_const(rb_mProcess, "WAIT3_VERSION", rb_str_new2("1.7.1"));
953
+ #ifdef HAVE_CONST_RUSAGE_THREAD
954
+ rb_define_const(rb_mProcess, "RUSAGE_THREAD", INT2FIX(RUSAGE_THREAD));
955
+ #endif
956
+
957
+ /* 1.9.0: The version of the proc-wait3 library */
958
+ rb_define_const(rb_mProcess, "WAIT3_VERSION", rb_str_freeze(rb_str_new2("1.9.0")));
971
959
 
972
960
  /* Define this last in our Init_wait3 function */
973
961
  rb_define_readonly_variable("$last_status", &v_last_status);
@@ -0,0 +1 @@
1
+ require 'proc/wait3'
@@ -2,20 +2,28 @@ require 'rubygems'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'proc-wait3'
5
- spec.version = '1.7.1'
5
+ spec.version = '1.9.0'
6
6
  spec.author = 'Daniel J. Berger'
7
- spec.license = 'Artistic 2.0'
7
+ spec.license = 'Apache-2.0'
8
8
  spec.email = 'djberg96@gmail.com'
9
9
  spec.homepage = 'https://github.com/djberg96/proc-wait3'
10
10
  spec.summary = 'Adds wait3, wait4 and other methods to the Process module'
11
- spec.test_file = 'test/test_proc_wait3.rb'
11
+ spec.test_file = 'spec/proc_wait3_spec.rb'
12
12
  spec.extensions = ['ext/extconf.rb']
13
13
  spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
14
+ spec.cert_chain = Dir['certs/*']
14
15
 
15
- spec.extra_rdoc_files = ['CHANGES', 'README', 'MANIFEST', 'ext/proc/wait3.c']
16
-
17
- spec.add_development_dependency('test-unit')
18
16
  spec.add_development_dependency('rake')
17
+ spec.add_development_dependency('rspec', '~> 3.9')
18
+
19
+ spec.metadata = {
20
+ 'homepage_uri' => 'https://github.com/djberg96/proc-wait3',
21
+ 'bug_tracker_uri' => 'https://github.com/djberg96/proc-wait3/issues',
22
+ 'changelog_uri' => 'https://github.com/djberg96/proc-wait3/blob/master/CHANGES.md',
23
+ 'documentation_uri' => 'https://github.com/djberg96/proc-wait3/wiki',
24
+ 'source_code_uri' => 'https://github.com/djberg96/proc-wait3',
25
+ 'wiki_uri' => 'https://github.com/djberg96/proc-wait3/wiki'
26
+ }
19
27
 
20
28
  spec.description = <<-EOF
21
29
  The proc-wait3 library adds the wait3, wait4, waitid, pause, sigsend,
@@ -0,0 +1,234 @@
1
+ #######################################################################
2
+ # proc_wait3_spec.rb
3
+ #
4
+ # Test suite for the Ruby proc-wait3 library. You should run these
5
+ # via the 'rake spec' task.
6
+ #######################################################################
7
+ require 'proc/wait3'
8
+ require 'rspec'
9
+ require 'rbconfig'
10
+
11
+ RSpec.describe Process do
12
+ let(:solaris) { RbConfig::CONFIG['host_os'] =~ /sunos|solaris/i }
13
+ let(:darwin) { RbConfig::CONFIG['host_os'] =~ /darwin|osx/i }
14
+ let(:hpux) { RbConfig::CONFIG['host_os'] =~ /hpux/i }
15
+ let(:linux) { RbConfig::CONFIG['host_os'] =~ /linux/i }
16
+ let(:freebsd) { RbConfig::CONFIG['host_os'] =~ /bsd/i }
17
+
18
+ let(:proc_stat_members) {
19
+ %i[
20
+ pid status utime stime maxrss ixrss idrss isrss minflt majflt nswap
21
+ inblock oublock msgsnd msgrcv nsignals nvcsw nivcsw stopped signaled
22
+ exited success coredump exitstatus termsig stopsig
23
+ ]
24
+ }
25
+
26
+ before do
27
+ @proc_stat = nil
28
+ end
29
+
30
+ example "version constant is set to expected value" do
31
+ expect(Process::WAIT3_VERSION).to eq('1.9.0')
32
+ expect(Process::WAIT3_VERSION).to be_frozen
33
+ end
34
+
35
+ example "wait3 method is defined" do
36
+ expect(Process).to respond_to(:wait3)
37
+ end
38
+
39
+ example "wait3 works as expected" do
40
+ skip 'wait3 test skipped on this platform' if darwin
41
+ fork{ sleep 0.5 }
42
+ expect{ Process.wait3 }.not_to raise_error
43
+ end
44
+
45
+ example "wait3 returns the expected proc status members" do
46
+ skip 'wait3 test skipped on this platform' if darwin
47
+ fork{ sleep 0.5 }
48
+ expect{ @proc_stat = Process.wait3 }.not_to raise_error
49
+ expect( @proc_stat.members).to eq(proc_stat_members)
50
+ end
51
+
52
+ example "wait3 with WNOHANG works as expected" do
53
+ fork{ sleep 0.5 }
54
+ expect{ Process.wait3(Process::WNOHANG) }.not_to raise_error
55
+ end
56
+
57
+ example "wait3 sets and returns $last_status to expected values" do
58
+ skip 'wait3 test skipped on this platform' if darwin
59
+ fork{ sleep 0.5 }
60
+ Process.wait3
61
+ expect($last_status).to be_kind_of(Struct::ProcStat)
62
+ expect($last_status).not_to be_nil
63
+ end
64
+
65
+ example "wait3 sets pid and status members of $?" do
66
+ skip 'wait3 test skipped on this platform' if darwin
67
+ fork{ sleep 0.5 }
68
+ Process.wait3
69
+ expect($?).not_to be_nil
70
+ end
71
+
72
+ example "wait3 returns frozen struct" do
73
+ skip 'wait3 test skipped on this platform' if darwin
74
+ fork{ sleep 0.5 }
75
+ struct = Process.wait3
76
+ expect(struct).to be_frozen
77
+ end
78
+
79
+ example "getdtablesize works as expected" do
80
+ skip 'getdtablesize skipped on this platform' unless solaris
81
+
82
+ expect(Process).to respond_to(:getdtablesize)
83
+ expect(Process.getdtablesize).to be_kind_of(Fixnum)
84
+ assert(Process.getdtablesize > 0)
85
+ end
86
+
87
+ example "wait4 method is defined" do
88
+ skip 'wait4 test skipped on this platform' if hpux
89
+ expect(Process).to respond_to(:wait4)
90
+ end
91
+
92
+ example "wait4 requires at least one argument" do
93
+ skip 'wait4 test skipped on this platform' if hpux
94
+ expect{ Process.wait4 }.to raise_error(ArgumentError)
95
+ end
96
+
97
+ example "wait4 works as expected" do
98
+ skip 'wait4 test skipped on this platform' if hpux || darwin
99
+
100
+ pid = fork{ sleep 0.5 }
101
+ expect{ @proc_stat = Process.wait4(pid) }.not_to raise_error
102
+ expect(@proc_stat).to be_kind_of(Struct::ProcStat)
103
+ end
104
+
105
+ example "wait4 sets and returns $last_status to expected values" do
106
+ skip 'wait4 test skipped on this platform' if hpux || darwin
107
+
108
+ pid = fork{ sleep 0.5 }
109
+ Process.wait4(pid)
110
+ expect($last_status).to be_kind_of(Struct::ProcStat)
111
+ expect($last_status).not_to be_nil
112
+ end
113
+
114
+ example "wait4 sets pid and status members of $?" do
115
+ skip 'wait4 test skipped on this platform' if hpux || darwin
116
+
117
+ pid = fork{ sleep 0.5 }
118
+ Process.wait4(pid)
119
+ expect($?).not_to be_nil
120
+ end
121
+
122
+ example "wait4 returns frozen struct" do
123
+ skip 'wait4 test skipped on this platform' if hpux || darwin
124
+
125
+ pid = fork{ sleep 0.5 }
126
+ struct = Process.wait4(pid)
127
+ expect(struct).to be_frozen
128
+ end
129
+
130
+ example "waitid method is defined" do
131
+ skip 'waitid test skipped on this platform' if hpux || darwin || freebsd
132
+
133
+ expect(Process).to respond_to(:waitid)
134
+ end
135
+
136
+ example "waitid method works as expected" do
137
+ skip 'waitid test skipped on this platform' if hpux || darwin || freebsd
138
+
139
+ pid = fork{ sleep 0.5 }
140
+ expect{ Process.waitid(Process::P_PID, pid, Process::WEXITED) }.not_to raise_error
141
+ end
142
+
143
+ example "waitid method raises expected errors if wrong argument type is passed" do
144
+ skip 'waitid test skipped on this platform' if hpux || darwin || freebsd
145
+
146
+ pid = fork{ sleep 0.5 }
147
+ expect{ Process.waitid("foo", pid, Process::WEXITED) }.to raise_error(TypeError)
148
+ expect{ Process.waitid(Process::P_PID, pid, "foo") }.to raise_error(TypeError)
149
+ expect{ Process.waitid(Process::P_PID, "foo", Process::WEXITED) }.to raise_error(TypeError)
150
+ end
151
+
152
+ example "waitid method raises expected error if invalid argument is passed" do
153
+ skip 'waitid test skipped on this platform' if hpux || darwin || freebsd
154
+
155
+ fork{ sleep 0.5 }
156
+ expect{ Process.waitid(Process::P_PID, 99999999, Process::WEXITED) }.to raise_error(Errno::ECHILD)
157
+ end
158
+
159
+ example "sigsend method is defined" do
160
+ skip 'sigsend test skipped on this platform' unless solaris
161
+
162
+ expect(Process).to respond_to(:sigsend)
163
+ end
164
+
165
+ example "sigsend works as expected" do
166
+ skip 'sigsend test skipped on this platform' unless solaris
167
+
168
+ pid = fork{ sleep 0.5 }
169
+ expect{ Process.sigsend(Process::P_PID, pid, 0) }.not_to raise_error
170
+ end
171
+
172
+ example "getrusage method is defined" do
173
+ expect(Process).to respond_to(:getrusage)
174
+ end
175
+
176
+ example "getrusage works as expected" do
177
+ fork{ sleep 0.5 }
178
+
179
+ expect{ Process.getrusage }.not_to raise_error
180
+ expect{ Process.getrusage(true) }.not_to raise_error
181
+ end
182
+
183
+ example "getrusage can get thread info on Linux" do
184
+ skip 'getrusage only tested on Linux' unless linux
185
+ expect{ Process.getrusage(Process::RUSAGE_THREAD) }.not_to raise_error
186
+ end
187
+
188
+ example "getrusage returns the expected struct" do
189
+ skip 'getrusage only tested on Linux' unless linux
190
+
191
+ fork{ sleep 0.5 }
192
+ expect(Process.getrusage).to be_kind_of(Struct::RUsage)
193
+ expect(Process.getrusage.stime).to be_kind_of(Float)
194
+ expect(Process.getrusage.utime).to be_kind_of(Float)
195
+ end
196
+
197
+ example "pause method is defined" do
198
+ expect(Process).to respond_to(:pause)
199
+ end
200
+
201
+ example "expected constants are defined" do
202
+ skip 'wait constant check skipped on this platform' if darwin || freebsd
203
+
204
+ expect(Process::WCONTINUED).not_to be_nil
205
+ expect(Process::WEXITED).not_to be_nil
206
+ expect(Process::WNOWAIT).not_to be_nil
207
+ expect(Process::WSTOPPED).not_to be_nil
208
+
209
+ skip 'WTRAPPED constant check skipped on this platform' if linux
210
+ expect(Process::WTRAPPED).not_to be_nil
211
+ end
212
+
213
+ example "expected process type flag constants are defined" do
214
+ skip 'process type flag check skipped on this platform' if linux || darwin || freebsd
215
+
216
+ expect(Process::P_ALL).not_to be_nil
217
+ expect(Process::P_CID).not_to be_nil
218
+ expect(Process::P_GID).not_to be_nil
219
+ expect(Process::P_PGID).not_to be_nil
220
+ expect(Process::P_PID).not_to be_nil
221
+ expect(Process::P_SID).not_to be_nil
222
+ expect(Process::P_UID).not_to be_nil
223
+
224
+ skip 'P_MYID constant check skipped on this platform' unless solaris
225
+ expect(Process::P_MYID).not_to be_nil
226
+ end
227
+
228
+ example "solaris-specific process type flags are defined on solaris" do
229
+ skip 'P_TASKID and P_PROJID constant check skipped on this platform' unless solaris
230
+
231
+ expect(Process::P_TASKID).not_to be_nil
232
+ expect(Process::P_PROJID).not_to be_nil
233
+ end
234
+ end