proc-wait3 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (7) hide show
  1. data/CHANGES +61 -0
  2. data/README +53 -0
  3. data/doc/wait3.txt +154 -0
  4. data/extconf.rb +54 -0
  5. data/lib/proc/wait3.c +908 -0
  6. data/test/tc_wait3.rb +199 -0
  7. metadata +51 -0
@@ -0,0 +1,199 @@
1
+ ##################################################################
2
+ # tc_wait3.rb
3
+ #
4
+ # Test suite for the Ruby proc-wait3 package.
5
+ ##################################################################
6
+ base = File.basename(Dir.pwd)
7
+
8
+ if base == "test" || base =~ /proc-wait3/
9
+ require "ftools"
10
+ ext = ".so"
11
+ ext = ".sl" if RUBY_PLATFORM =~ /hpux/i
12
+ ext = ".bundle" if RUBY_PLATFORM =~ /darwin|powerpc/i
13
+ file = "wait3" + ext
14
+ Dir.chdir("..") if base == "test"
15
+ Dir.mkdir("proc") rescue nil
16
+ File.copy(file,"proc")
17
+ $LOAD_PATH.unshift(Dir.pwd)
18
+ Dir.chdir("test") rescue nil
19
+ end
20
+
21
+ require "proc/wait3"
22
+ require "test/unit"
23
+
24
+ class TC_Wait3 < Test::Unit::TestCase
25
+ def setup
26
+ @proc_stat = nil
27
+ @proc_stat_members = ["pid", "status", "utime", "stime", "maxrss",
28
+ "ixrss", "idrss", "isrss", "minflt", "majflt", "nswap", "inblock",
29
+ "oublock", "msgsnd", "msgrcv", "nsignals", "nvcsw", "nivcsw",
30
+ "stopped", "signaled","exited","success","coredump","exitstatus",
31
+ "termsig", "stopsig"]
32
+ end
33
+
34
+ def test_wait3_basic
35
+ assert_respond_to(Process,:wait3)
36
+ end
37
+
38
+ def test_wait3_no_args
39
+ pid = fork{ sleep 1 }
40
+ assert_nothing_raised{ Process.wait3 }
41
+ end
42
+
43
+ def test_wait3_procstat_members
44
+ pid = fork{ sleep 1 }
45
+ assert_nothing_raised{ @proc_stat = Process.wait3 }
46
+ assert_equal(@proc_stat_members, @proc_stat.members)
47
+ end
48
+
49
+ def test_wait3_nohang
50
+ pid = fork{ sleep 1 }
51
+ assert_nothing_raised{ Process.wait3(Process::WNOHANG) }
52
+ end
53
+
54
+ unless RUBY_PLATFORM =~ /hpux/i
55
+ def test_wait4_basic
56
+ assert_respond_to(Process,:wait4)
57
+ assert_raises(ArgumentError){ Process.wait4 } # Must have at least 1 arg
58
+ end
59
+
60
+ def test_wait4_in_action
61
+ pid = fork{ sleep 1 }
62
+ assert_nothing_raised{ @proc_stat = Process.wait4(pid) }
63
+ assert_kind_of(Struct::ProcStat, @proc_stat)
64
+ end
65
+
66
+ def test_waitid_basic
67
+ assert_respond_to(Process, :waitid)
68
+ end
69
+
70
+ def test_waitid_in_action
71
+ pid = fork{ sleep 1 }
72
+
73
+ assert_nothing_raised{
74
+ Process.waitid(Process::P_PID, pid, Process::WEXITED)
75
+ }
76
+
77
+ assert_raises(TypeError){
78
+ Process.waitid("foo", pid, Process::WEXITED)
79
+ }
80
+
81
+ assert_raises(TypeError){
82
+ Process.waitid(Process::P_PID, pid, "foo")
83
+ }
84
+
85
+ assert_raises(TypeError){
86
+ Process.waitid(Process::P_PID, "foo", Process::WEXITED)
87
+ }
88
+
89
+ if RUBY_PLATFORM.match("linux")
90
+ assert_raises(Errno::ECHILD){
91
+ Process.waitid(Process::P_PID, 99999999, Process::WEXITED)
92
+ }
93
+ else
94
+ assert_raises(Errno::EINVAL){
95
+ Process.waitid(Process::P_PID, 99999999, Process::WEXITED)
96
+ }
97
+ end
98
+ end
99
+
100
+ def test_sigsend_basic
101
+ if RUBY_PLATFORM.match("linux")
102
+ puts "test_sigsend_basic skipped on this platform"
103
+ else
104
+ assert_respond_to(Process,:send)
105
+ end
106
+ end
107
+
108
+ def test_sigsend_in_action
109
+ if RUBY_PLATFORM.match("linux")
110
+ puts "test_sigsend_in_action skipped on this platform"
111
+ else
112
+ pid = fork{ sleep 1 }
113
+
114
+ assert_nothing_raised{
115
+ Process.sigsend(Process::P_PID,pid,0)
116
+ }
117
+ end
118
+ end
119
+ end
120
+
121
+ def test_getrusage_basic
122
+ assert_respond_to(Process,:getrusage)
123
+ end
124
+
125
+ def test_getrusage_in_action
126
+ pid = fork{ sleep 1 }
127
+ assert_nothing_raised{ Process.getrusage }
128
+ assert_nothing_raised{ Process.getrusage(true) }
129
+ assert_kind_of(Struct::RUsage,Process.getrusage)
130
+ end
131
+
132
+ def test_wait_constants
133
+ msg = "Don't panic. It simply appears that this constant is not defined"
134
+ msg += "on your particular platform. Ignore"
135
+
136
+ assert_not_nil(Process::WCONTINUED, msg)
137
+ assert_not_nil(Process::WEXITED, msg)
138
+ assert_not_nil(Process::WNOWAIT, msg)
139
+ assert_not_nil(Process::WSTOPPED, msg)
140
+ assert_not_nil(Process::WTRAPPED, msg) unless RUBY_PLATFORM.match("linux")
141
+ end
142
+
143
+ def test_getrlimit
144
+ assert_respond_to(Process, :getrlimit)
145
+ assert_nothing_raised{ Process.getrlimit(Process::RLIMIT_CPU) }
146
+ assert_kind_of(Array, Process.getrlimit(Process::RLIMIT_CPU))
147
+ assert_equal(2, Process.getrlimit(Process::RLIMIT_CPU).length)
148
+ end
149
+
150
+ def test_setrlimit
151
+ assert_respond_to(Process, :setrlimit)
152
+ assert_nothing_raised{
153
+ Process.setrlimit(
154
+ Process::RLIMIT_CPU,
155
+ Process::RLIM_SAVED_CUR,
156
+ Process::RLIM_SAVED_MAX
157
+ )
158
+ }
159
+ end
160
+
161
+ # Test to ensure that the various rlimit constants are defined. Note that
162
+ # as of Ruby 1.8.5 these are defined by Ruby itself, except for the
163
+ # RLIMIT_VMEM constant, which is platform dependent.
164
+ #
165
+ def test_rlimit_constants
166
+ assert_not_nil(Process::RLIMIT_AS)
167
+ assert_not_nil(Process::RLIMIT_CORE)
168
+ assert_not_nil(Process::RLIMIT_CPU)
169
+ assert_not_nil(Process::RLIMIT_DATA)
170
+ assert_not_nil(Process::RLIMIT_FSIZE)
171
+ assert_not_nil(Process::RLIMIT_NOFILE)
172
+ assert_not_nil(Process::RLIMIT_STACK)
173
+ assert_not_nil(Process::RLIM_INFINITY)
174
+ assert_not_nil(Process::RLIM_SAVED_MAX)
175
+ assert_not_nil(Process::RLIM_SAVED_CUR)
176
+ end
177
+
178
+ def test_process_type_flags
179
+ unless RUBY_PLATFORM.match("linux")
180
+ assert_not_nil(Process::P_ALL)
181
+ assert_not_nil(Process::P_CID)
182
+ assert_not_nil(Process::P_GID)
183
+ assert_not_nil(Process::P_MYID)
184
+ assert_not_nil(Process::P_PGID)
185
+ assert_not_nil(Process::P_PID)
186
+ assert_not_nil(Process::P_SID)
187
+ assert_not_nil(Process::P_UID)
188
+ end
189
+ if RUBY_PLATFORM =~ /sunos|solaris/i
190
+ assert_not_nil(Process::P_TASKID)
191
+ assert_not_nil(Process::P_PROJID)
192
+ end
193
+ end
194
+
195
+ def teardown
196
+ @proc_stat = nil
197
+ @proc_stat_members = nil
198
+ end
199
+ end
metadata ADDED
@@ -0,0 +1,51 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.0
3
+ specification_version: 1
4
+ name: proc-wait3
5
+ version: !ruby/object:Gem::Version
6
+ version: 1.5.1
7
+ date: 2006-07-13 00:00:00 -06:00
8
+ summary: Adds the wait3, wait4, waitid, pause, sigsend, and getrusage methods to the Process module
9
+ require_paths:
10
+ - lib
11
+ email: djberg96@gmail.com
12
+ homepage: http://www.rubyforge.org/projects/shards
13
+ rubyforge_project: shards
14
+ description: Adds the wait3, wait4, waitid, pause, sigsend, and getrusage methods to the Process module
15
+ autorequire:
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.8.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Daniel J. Berger
31
+ files:
32
+ - doc/wait3.txt
33
+ - test/tc_wait3.rb
34
+ - lib/proc/wait3.c
35
+ - CHANGES
36
+ - README
37
+ test_files:
38
+ - test/tc_wait3.rb
39
+ rdoc_options: []
40
+
41
+ extra_rdoc_files:
42
+ - CHANGES
43
+ - README
44
+ executables: []
45
+
46
+ extensions:
47
+ - extconf.rb
48
+ requirements: []
49
+
50
+ dependencies: []
51
+