diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-02-14 20:04:06 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-02-14 20:04:06 +0000 |
commit | 44d3cf03fd13ba0d83aca858cc53e71b71958354 (patch) | |
tree | bf802a7ae474cc4bfa1a6c1b62c55e5683db10b1 | |
parent | dbda1e9ea795d1340e3818b1309c90132818eff5 (diff) |
merge revision(s) 32705,32717: [Backport #6016]
* test/rinda/test_rinda.rb (test_remote_array_and_hash):
add local variables to protect objects from GC. [ruby-dev:44253]
[Bug #5104]
* test/rinda/test_rinda.rb: decrease the code that depends on timing.
[Bug #372] [Bug #4160]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@34602 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | test/rinda/test_rinda.rb | 94 | ||||
-rw-r--r-- | version.h | 2 |
3 files changed, 42 insertions, 65 deletions
@@ -1,3 +1,14 @@ +Wed Feb 15 05:03:41 2012 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp> + + * test/rinda/test_rinda.rb: decrease the code that depends on timing. + [Bug #372] [Bug #4160] + +Wed Feb 15 05:03:41 2012 CHIKANAGA Tomoyuki <nagachika00@gmail.com> + + * test/rinda/test_rinda.rb (test_remote_array_and_hash): + add local variables to protect objects from GC. [ruby-dev:44253] + [Bug #5104] + Wed Feb 15 05:02:43 2012 Masaki Suketa <masaki.suketa@nifty.ne.jp> * test/win32ole/test_err_in_callback.rb (test_err_in_callback): diff --git a/test/rinda/test_rinda.rb b/test/rinda/test_rinda.rb index b69b63ac78..8154b46da3 100644 --- a/test/rinda/test_rinda.rb +++ b/test/rinda/test_rinda.rb @@ -269,37 +269,29 @@ module TupleSpaceTestModule assert_equal([[:req, 2], [:req, 2], [:req, 2], [:req, 2], [:req, 2]], @ts.read_all([nil, nil])) - taker = Thread.new do + taker = Thread.new(5) do |count| s = 0 - while true - begin - tuple = @ts.take([:req, Integer], 1) - assert_equal(2, tuple[1]) - s += tuple[1] - rescue Rinda::RequestExpiredError - break - end + count.times do + tuple = @ts.take([:req, Integer]) + assert_equal(2, tuple[1]) + s += tuple[1] end @ts.write([:ans, s]) s end assert_equal(10, thread_join(taker)) - tuple = @ts.take([:ans, nil]) - assert_equal(10, tuple[1]) + assert_equal([:ans, 10], @ts.take([:ans, 10])) + assert_equal([], @ts.read_all([nil, nil])) end def test_core_02 - taker = Thread.new do + taker = Thread.new(5) do |count| s = 0 - while true - begin - tuple = @ts.take([:req, Integer], 1) - assert_equal(2, tuple[1]) - s += tuple[1] - rescue Rinda::RequestExpiredError - break - end + count.times do + tuple = @ts.take([:req, Integer]) + assert_equal(2, tuple[1]) + s += tuple[1] end @ts.write([:ans, s]) s @@ -310,22 +302,20 @@ module TupleSpaceTestModule end assert_equal(10, thread_join(taker)) - tuple = @ts.take([:ans, nil]) - assert_equal(10, tuple[1]) + assert_equal([:ans, 10], @ts.take([:ans, 10])) assert_equal([], @ts.read_all([nil, nil])) end def test_core_03_notify notify1 = @ts.notify(nil, [:req, Integer]) - notify2 = @ts.notify(nil, [:ans, Integer], 8) - notify3 = @ts.notify(nil, {"message"=>String, "name"=>String}, 8) + notify2 = @ts.notify(nil, {"message"=>String, "name"=>String}, 8) @ts.write({"message"=>"first", "name"=>"3"}, 3) @ts.write({"message"=>"second", "name"=>"1"}, 1) @ts.write({"message"=>"third", "name"=>"0"}) @ts.take({"message"=>"third", "name"=>"0"}) - listener1 = Thread.new do + listener = Thread.new do lv = 0 n = 0 notify1.each do |ev, tuple| @@ -343,35 +333,12 @@ module TupleSpaceTestModule [lv, n] end - listener2 = Thread.new do - result = nil - lv = 0 - n = 0 - notify2.each do |ev, tuple| - n += 1 - if ev == 'write' - lv = lv + 1 - elsif ev == 'take' - lv = lv - 1 - elsif ev == 'close' - result = [lv, n] - break - end - assert(lv >= 0) - assert_equal([:ans, 10], tuple) - end - result - end - - taker = Thread.new do + taker = Thread.new(5) do |count| s = 0 - while true - begin - tuple = @ts.take([:req, Integer], 1) - s += tuple[1] - rescue Rinda::RequestExpiredError - break - end + count.times do + tuple = @ts.take([:req, Integer]) + assert_equal(2, tuple[1]) + s += tuple[1] end @ts.write([:ans, s]) s @@ -383,19 +350,14 @@ module TupleSpaceTestModule @ts.take({"message"=>"first", "name"=>"3"}) - sleep(4) assert_equal(10, thread_join(taker)) - # notify2 must not expire until this @ts.take. - # sleep(4) might be short enough for the timeout of notify2 (8 secs) - tuple = @ts.take([:ans, nil]) - assert_equal(10, tuple[1]) + assert_equal([:ans, 10], @ts.take([:ans, 10])) assert_equal([], @ts.read_all([nil, nil])) notify1.cancel - sleep(7) # notify2 expired (sleep(4)+sleep(7) > 8) + sleep(8) - assert_equal([0, 11], thread_join(listener1)) - assert_equal([0, 3], thread_join(listener2)) + assert_equal([0, 11], thread_join(listener)) ary = [] ary.push(["write", {"message"=>"first", "name"=>"3"}]) @@ -406,7 +368,7 @@ module TupleSpaceTestModule ary.push(["delete", {"message"=>"second", "name"=>"1"}]) ary.push(["close"]) - notify3.each do |ev| + notify2.each do |ev| assert_equal(ary.shift, ev) end assert_equal([], ary) @@ -539,9 +501,13 @@ class TupleSpaceProxyTest < Test::Unit::TestCase end def test_remote_array_and_hash - @ts.write(DRbObject.new([1, 2, 3])) + # Don't remove ary/hsh local variables. + # These are necessary to protect objects from GC. + ary = [1, 2, 3] + @ts.write(DRbObject.new(ary)) assert_equal([1, 2, 3], @ts.take([1, 2, 3], 0)) - @ts.write(DRbObject.new({'head' => 1, 'tail' => 2})) + hsh = {'head' => 1, 'tail' => 2} + @ts.write(DRbObject.new(hsh)) assert_equal({'head' => 1, 'tail' => 2}, @ts.take({'head' => 1, 'tail' => 2}, 0)) end @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.3" -#define RUBY_PATCHLEVEL 112 +#define RUBY_PATCHLEVEL 113 #define RUBY_RELEASE_DATE "2012-02-15" #define RUBY_RELEASE_YEAR 2012 |