test/tc_wait3.rb in proc-wait3-1.5.1 vs test/tc_wait3.rb in proc-wait3-1.5.2
- old
+ new
@@ -29,10 +29,14 @@
"oublock", "msgsnd", "msgrcv", "nsignals", "nvcsw", "nivcsw",
"stopped", "signaled","exited","success","coredump","exitstatus",
"termsig", "stopsig"]
end
+ def test_wait3_version
+ assert_equal('1.5.2', Process::WAIT3_VERSION)
+ end
+
def test_wait3_basic
assert_respond_to(Process,:wait3)
end
def test_wait3_no_args
@@ -124,11 +128,11 @@
def test_getrusage_in_action
pid = fork{ sleep 1 }
assert_nothing_raised{ Process.getrusage }
assert_nothing_raised{ Process.getrusage(true) }
- assert_kind_of(Struct::RUsage,Process.getrusage)
+ assert_kind_of(Struct::RUsage, Process.getrusage)
end
def test_wait_constants
msg = "Don't panic. It simply appears that this constant is not defined"
msg += "on your particular platform. Ignore"
@@ -138,26 +142,36 @@
assert_not_nil(Process::WNOWAIT, msg)
assert_not_nil(Process::WSTOPPED, msg)
assert_not_nil(Process::WTRAPPED, msg) unless RUBY_PLATFORM.match("linux")
end
- def test_getrlimit
- assert_respond_to(Process, :getrlimit)
- assert_nothing_raised{ Process.getrlimit(Process::RLIMIT_CPU) }
- assert_kind_of(Array, Process.getrlimit(Process::RLIMIT_CPU))
- assert_equal(2, Process.getrlimit(Process::RLIMIT_CPU).length)
- end
+ # Skip these tests on Ruby 1.8.5 or later
+ #
+ if RUBY_VERSION.split('.').last.to_i <= 4
+ def test_getrlimit
+ assert_respond_to(Process, :getrlimit)
+ assert_nothing_raised{ Process.getrlimit(Process::RLIMIT_CPU) }
+ assert_kind_of(Array, Process.getrlimit(Process::RLIMIT_CPU))
+ assert_equal(2, Process.getrlimit(Process::RLIMIT_CPU).length)
+ end
- def test_setrlimit
- assert_respond_to(Process, :setrlimit)
- assert_nothing_raised{
- Process.setrlimit(
- Process::RLIMIT_CPU,
- Process::RLIM_SAVED_CUR,
- Process::RLIM_SAVED_MAX
- )
- }
+ def test_setrlimit
+ assert_respond_to(Process, :setrlimit)
+ assert_nothing_raised{
+ Process.setrlimit(
+ Process::RLIMIT_CPU,
+ Process::RLIM_SAVED_CUR,
+ Process::RLIM_SAVED_MAX
+ )
+ }
+ assert_nothing_raised{
+ Process.setrlimit(Process::RLIMIT_CPU, Process::RLIM_SAVED_CUR)
+ }
+ end
+ else
+ STDOUT.puts('Process.getrlimit test skipped for Ruby 1.8.5 or later')
+ STDOUT.puts('Process.setrlimit test skipped for Ruby 1.8.5 or later')
end
# Test to ensure that the various rlimit constants are defined. Note that
# as of Ruby 1.8.5 these are defined by Ruby itself, except for the
# RLIMIT_VMEM constant, which is platform dependent.
@@ -171,9 +185,19 @@
assert_not_nil(Process::RLIMIT_NOFILE)
assert_not_nil(Process::RLIMIT_STACK)
assert_not_nil(Process::RLIM_INFINITY)
assert_not_nil(Process::RLIM_SAVED_MAX)
assert_not_nil(Process::RLIM_SAVED_CUR)
+ end
+
+ # This test was added to ensure that these three constants are being
+ # defined properly after an issue appeared on Linux with regards to
+ # the value accidentally being assigned a negative value.
+ #
+ def test_rlimit_constants_valid
+ assert(Process::RLIM_INFINITY > 0)
+ assert(Process::RLIM_SAVED_MAX > 0)
+ assert(Process::RLIM_SAVED_CUR > 0)
end
def test_process_type_flags
unless RUBY_PLATFORM.match("linux")
assert_not_nil(Process::P_ALL)