summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-04 16:30:03 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-06-04 16:30:03 +0000
commit4a14d3c04b61851abffbf020bcdc82f5276a3d12 (patch)
tree8cb5f1b00d091ab1a990f200d6ace81166629b3c
parentc9977b82a83562d6b873095237cb1e8a95488ddf (diff)
* test/ruby/test_process.rb: add tests.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16820 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--test/ruby/test_process.rb141
-rw-r--r--version.h6
3 files changed, 148 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 509b16097b..6a21d998e1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Thu Jun 5 01:27:42 2008 Yusuke Endoh <mame@tsg.ne.jp>
+
+ * test/ruby/test_process.rb: add tests.
+
Wed Jun 4 23:10:08 2008 Yusuke Endoh <mame@tsg.ne.jp>
* ext/zlib/zlib.c (rb_gzfile_set_mtime): fix typo.
diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb
index 6e96281bb8..73d55c5e4e 100644
--- a/test/ruby/test_process.rb
+++ b/test/ruby/test_process.rb
@@ -5,6 +5,14 @@ require_relative 'envutil'
class TestProcess < Test::Unit::TestCase
RUBY = EnvUtil.rubybin
+ def setup
+ Process.waitall
+ end
+
+ def teardown
+ Process.waitall
+ end
+
def write_file(filename, content)
File.open(filename, "w") {|f|
f << content
@@ -339,6 +347,7 @@ class TestProcess < Test::Unit::TestCase
w1.puts "b"
w1.close
assert_equal("a\nb\nc\n", r2.read)
+ Process.wait(pid)
}
}
@@ -478,6 +487,7 @@ class TestProcess < Test::Unit::TestCase
errmsg = io.read
assert_equal("", r.read)
assert_not_equal("", errmsg)
+ Process.wait
}
with_pipe {|r, w|
errmsg = `#{RUBY} -e "STDERR.reopen(STDOUT); IO.new(#{w.fileno}).puts(123)"`
@@ -527,6 +537,7 @@ class TestProcess < Test::Unit::TestCase
errmsg = io.read
assert_equal("", r.read)
assert_not_equal("", errmsg)
+ Process.wait
}
with_pipe {|r, w|
io = IO.popen([RUBY, "-e", "STDERR.reopen(STDOUT); IO.new(#{w.fileno}).puts('mo')", :close_others=>false])
@@ -534,6 +545,7 @@ class TestProcess < Test::Unit::TestCase
errmsg = io.read
assert_equal("mo\n", r.read)
assert_equal("", errmsg)
+ Process.wait
}
with_pipe {|r, w|
io = IO.popen([RUBY, "-e", "STDERR.reopen(STDOUT); IO.new(#{w.fileno}).puts('mo')", :close_others=>nil])
@@ -541,6 +553,7 @@ class TestProcess < Test::Unit::TestCase
errmsg = io.read
assert_equal("mo\n", r.read)
assert_equal("", errmsg)
+ Process.wait
}
}
@@ -789,6 +802,7 @@ class TestProcess < Test::Unit::TestCase
assert_equal(4, $?.exitstatus)
assert_equal("1", IO.popen([[RUBY, "qwerty"], "-e", "print 1"]).read)
+ Process.wait
write_file("s", <<-"End")
exec([#{RUBY.dump}, "lkjh"], "-e", "exit 5")
@@ -840,4 +854,131 @@ class TestProcess < Test::Unit::TestCase
}
end
+ def test_status
+ with_tmpchdir do
+ s = run_in_child("exit 1")
+ assert_equal("#<Process::Status: pid #{ s.pid } exit #{ s.exitstatus }>", s.inspect)
+
+ assert_equal(s, s)
+ assert_equal(s, s.to_i)
+
+ assert_equal(s.to_i & 0x55555555, s & 0x55555555)
+ assert_equal(s.to_i >> 1, s >> 1)
+ assert_equal(false, s.stopped?)
+ assert_equal(nil, s.stopsig)
+ end
+ end
+
+ def test_status_kill
+ return unless Process.respond_to?(:kill)
+ return unless Signal.list.include?("QUIT")
+
+ with_tmpchdir do
+ write_file("foo", "sleep 30")
+ pid = spawn(RUBY, "foo")
+ Thread.new { sleep 1; Process.kill(:SIGQUIT, pid) }
+ Process.wait(pid)
+ s = $?
+ assert_equal("#<Process::Status: pid #{ s.pid } SIGQUIT (signal #{ s.termsig })>", s.inspect)
+ assert_equal(false, s.exited?)
+ assert_equal(nil, s.success?)
+ end
+ end
+
+ def test_wait_without_arg
+ with_tmpchdir do
+ write_file("foo", "sleep 0.1")
+ pid = spawn(RUBY, "foo")
+ assert_equal(pid, Process.wait)
+ end
+ end
+
+ def test_wait2
+ with_tmpchdir do
+ write_file("foo", "sleep 0.1")
+ pid = spawn(RUBY, "foo")
+ assert_equal([pid, 0], Process.wait2)
+ end
+ end
+
+ def test_waitall
+ with_tmpchdir do
+ write_file("foo", "sleep 0.1")
+ ps = (0...3).map { spawn(RUBY, "foo") }.sort
+ ss = Process.waitall.sort
+ ps.zip(ss) do |p1, (p2, s)|
+ assert_equal(p1, p2)
+ assert_equal(p1, s.pid)
+ end
+ end
+ end
+
+ def test_abort
+ with_tmpchdir do
+ s = run_in_child("abort")
+ assert_not_equal(0, s.exitstatus)
+ end
+ end
+
+ def test_sleep
+ assert_raise(ArgumentError) { sleep(1, 1) }
+ end
+
+ def test_getpgid
+ assert_kind_of(Integer, Process.getpgid(Process.ppid))
+ rescue NotImplementedError
+ end
+
+ def test_getpriority
+ assert_kind_of(Integer, Process.getpriority(Process::PRIO_USER, 0))
+ rescue NotImplementedError
+ end
+
+ def test_setpriority
+ assert_nothing_raised do
+ pr = Process.getpriority(Process::PRIO_USER, 0)
+ Process.setpriority(Process::PRIO_USER, 0, pr)
+ end
+ rescue NotImplementedError
+ end
+
+ def test_getuid
+ assert_kind_of(Integer, Process.uid)
+ end
+
+ def test_groups
+ gs = Process.groups
+ assert_instance_of(Array, gs)
+ gs.each {|g| assert_kind_of(Integer, g) }
+ rescue NotImplementedError
+ end
+
+ def test_maxgroups
+ assert_kind_of(Integer, Process.maxgroups)
+ end
+
+ def test_geteuid
+ assert_kind_of(Integer, Process.egid)
+ end
+
+ def test_uid_re_exchangeable_p
+ r = Process::UID.re_exchangeable?
+ assert(true == r || false == r)
+ end
+
+ def test_gid_re_exchangeable_p
+ r = Process::GID.re_exchangeable?
+ assert(true == r || false == r)
+ end
+
+ def test_uid_sid_available?
+ r = Process::UID.sid_available?
+ assert(true == r || false == r)
+ end
+
+ def test_gid_sid_available?
+ r = Process::GID.sid_available?
+ assert(true == r || false == r)
+ end
+
end
diff --git a/version.h b/version.h
index 0ed020ea5e..f8de956dfe 100644
--- a/version.h
+++ b/version.h
@@ -1,7 +1,7 @@
#define RUBY_VERSION "1.9.0"
-#define RUBY_RELEASE_DATE "2008-06-04"
+#define RUBY_RELEASE_DATE "2008-06-05"
#define RUBY_VERSION_CODE 190
-#define RUBY_RELEASE_CODE 20080604
+#define RUBY_RELEASE_CODE 20080605
#define RUBY_PATCHLEVEL 0
#define RUBY_VERSION_MAJOR 1
@@ -9,7 +9,7 @@
#define RUBY_VERSION_TEENY 0
#define RUBY_RELEASE_YEAR 2008
#define RUBY_RELEASE_MONTH 6
-#define RUBY_RELEASE_DAY 4
+#define RUBY_RELEASE_DAY 5
#ifdef RUBY_EXTERN
RUBY_EXTERN const char ruby_version[];