test/tc_wait3.rb in proc-wait3-1.5.3 vs test/tc_wait3.rb in proc-wait3-1.5.4
- old
+ new
@@ -1,40 +1,26 @@
##################################################################
# tc_wait3.rb
#
-# Test suite for the Ruby proc-wait3 package.
+# Test suite for the Ruby proc-wait3 package. You should run this
+# via the 'test' rake task.
##################################################################
-base = File.basename(Dir.pwd)
-
-if base == "test" || base =~ /proc-wait3/
- require "ftools"
- ext = ".so"
- ext = ".sl" if RUBY_PLATFORM =~ /hpux/i
- ext = ".bundle" if RUBY_PLATFORM =~ /darwin|powerpc/i
- file = "wait3" + ext
- Dir.chdir("..") if base == "test"
- Dir.mkdir("proc") rescue nil
- File.copy(file,"proc")
- $LOAD_PATH.unshift(Dir.pwd)
- Dir.chdir("test") rescue nil
-end
-
require "proc/wait3"
require "test/unit"
-class TC_Wait3 < Test::Unit::TestCase
+class TC_Wait3 < Test::Unit::TestCase
def setup
@proc_stat = nil
@proc_stat_members = ["pid", "status", "utime", "stime", "maxrss",
"ixrss", "idrss", "isrss", "minflt", "majflt", "nswap", "inblock",
"oublock", "msgsnd", "msgrcv", "nsignals", "nvcsw", "nivcsw",
"stopped", "signaled","exited","success","coredump","exitstatus",
"termsig", "stopsig"]
end
def test_wait3_version
- assert_equal('1.5.3', Process::WAIT3_VERSION)
+ assert_equal('1.5.4', Process::WAIT3_VERSION)
end
def test_wait3_basic
assert_respond_to(Process, :wait3)
end
@@ -74,54 +60,62 @@
assert_nothing_raised{ @proc_stat = Process.wait4(pid) }
assert_kind_of(Struct::ProcStat, @proc_stat)
end
def test_waitid_basic
- assert_respond_to(Process, :waitid)
+ if RUBY_PLATFORM =~ /mach|darwin|osx/i
+ STDOUT.puts "Skipping 'test_waitid_basic' on this platform"
+ else
+ assert_respond_to(Process, :waitid)
+ end
end
def test_waitid_in_action
- pid = fork{ sleep 1 }
+ if RUBY_PLATFORM =~ /mach|darwin|osx/i
+ STDOUT.puts "Skipping 'test_waitid_in_action' on this platform"
+ else
+ pid = fork{ sleep 1 }
- assert_nothing_raised{
- Process.waitid(Process::P_PID, pid, Process::WEXITED)
- }
+ assert_nothing_raised{
+ Process.waitid(Process::P_PID, pid, Process::WEXITED)
+ }
- assert_raises(TypeError){
- Process.waitid("foo", pid, Process::WEXITED)
- }
+ assert_raises(TypeError){
+ Process.waitid("foo", pid, Process::WEXITED)
+ }
- assert_raises(TypeError){
- Process.waitid(Process::P_PID, pid, "foo")
- }
+ assert_raises(TypeError){
+ Process.waitid(Process::P_PID, pid, "foo")
+ }
- assert_raises(TypeError){
- Process.waitid(Process::P_PID, "foo", Process::WEXITED)
- }
-
- if RUBY_PLATFORM.match("linux")
- assert_raises(Errno::ECHILD){
- Process.waitid(Process::P_PID, 99999999, Process::WEXITED)
+ assert_raises(TypeError){
+ Process.waitid(Process::P_PID, "foo", Process::WEXITED)
}
- else
- assert_raises(Errno::EINVAL){
- Process.waitid(Process::P_PID, 99999999, Process::WEXITED)
- }
+
+ if RUBY_PLATFORM.match("linux")
+ assert_raises(Errno::ECHILD){
+ Process.waitid(Process::P_PID, 99999999, Process::WEXITED)
+ }
+ else
+ assert_raises(Errno::EINVAL){
+ Process.waitid(Process::P_PID, 99999999, Process::WEXITED)
+ }
+ end
end
end
def test_sigsend_basic
if RUBY_PLATFORM.match("linux")
- puts "test_sigsend_basic skipped on this platform"
+ puts "Skipping 'test_sigsend_basic' on this platform"
else
assert_respond_to(Process,:send)
end
end
def test_sigsend_in_action
- if RUBY_PLATFORM.match("linux")
- puts "test_sigsend_in_action skipped on this platform"
+ if RUBY_PLATFORM =~ /linux|mach|darwin|osx/i
+ puts "Skipping 'test_sigsend_in_action' on this platform"
else
pid = fork{ sleep 1 }
assert_nothing_raised{
Process.sigsend(Process::P_PID,pid,0)
@@ -149,15 +143,19 @@
def test_wait_constants
msg = "Don't panic. It simply appears that this constant is not defined"
msg += "on your particular platform. Ignore"
- assert_not_nil(Process::WCONTINUED, msg)
- assert_not_nil(Process::WEXITED, msg)
- assert_not_nil(Process::WNOWAIT, msg)
- assert_not_nil(Process::WSTOPPED, msg)
- assert_not_nil(Process::WTRAPPED, msg) unless RUBY_PLATFORM.match("linux")
+ unless RUBY_PLATFORM =~ /darwin/i
+ assert_not_nil(Process::WCONTINUED, msg)
+ assert_not_nil(Process::WEXITED, msg)
+ assert_not_nil(Process::WNOWAIT, msg)
+ assert_not_nil(Process::WSTOPPED, msg)
+ unless RUBY_PLATFORM.match("linux")
+ assert_not_nil(Process::WTRAPPED, msg)
+ end
+ end
end
# Skip these tests on Ruby 1.8.5 or later
#
if RUBY_VERSION.split('.').last.to_i <= 4
@@ -212,10 +210,10 @@
assert(Process::RLIM_SAVED_MAX > 0)
assert(Process::RLIM_SAVED_CUR > 0)
end
def test_process_type_flags
- unless RUBY_PLATFORM.match("linux")
+ unless RUBY_PLATFORM =~ /linux|mach|darwin|osx/i
assert_not_nil(Process::P_ALL)
assert_not_nil(Process::P_CID)
assert_not_nil(Process::P_GID)
assert_not_nil(Process::P_MYID)
assert_not_nil(Process::P_PGID)