diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-01-25 01:37:34 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-01-25 01:37:34 +0000 |
commit | 8cc69387e0ad01de1bdf685413364799c61ff18b (patch) | |
tree | 17d8bea1d9e5041fc972ac934253fb72acb5c12f | |
parent | c8a4d4b071d8689678711c0711daf64ba1c8015e (diff) | |
download | ruby-8cc69387e0ad01de1bdf685413364799c61ff18b.tar.gz |
test_process.rb: reduce command string size
* test/ruby/test_process.rb (test_spawn_too_long_path),
(test_aspawn_too_long_path): reduce command string size until
intended exception occurs. [ruby-core:51592] [Bug #7721]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38934 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | test/ruby/test_process.rb | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb index 682b32f5c4..9746cf008b 100644 --- a/test/ruby/test_process.rb +++ b/test/ruby/test_process.rb @@ -1377,20 +1377,30 @@ class TestProcess < Test::Unit::TestCase end end if File.executable?("/bin/sh") - def test_too_long_path + def test_spawn_too_long_path bug4314 = '[ruby-core:34842]' - exs = [Errno::ENOENT] - exs << Errno::E2BIG if defined?(Errno::E2BIG) - EnvUtil.suppress_warning do - assert_raise(*exs, bug4314) {Process.spawn("a" * 10_000_000)} - end + assert_fail_too_long_path(bug4314) end - def test_too_long_path2 + def test_aspawn_too_long_path bug4315 = '[ruby-core:34833]' + assert_fail_too_long_path(bug4315) + end + + def assert_fail_too_long_path(cmd, mesg = nil) + size = 1_000_000 / cmd.size exs = [Errno::ENOENT] exs << Errno::E2BIG if defined?(Errno::E2BIG) - assert_raise(*exs, bug4315) {Process.spawn('"a"|'*10_000_000)} + EnvUtil.suppress_warning do + assert_raise(*exs, mesg) do + begin + Process.spawn(cmd * size) + rescue NoMemoryError + raise if (size /= 2) < 250 + retry + end + end + end end def test_system_sigpipe |