[前][次][番号順一覧][スレッド一覧]

ruby-changes:72065

From: Yusuke <ko1@a...>
Date: Mon, 6 Jun 2022 12:55:43 +0900 (JST)
Subject: [ruby-changes:72065] 5d014bcb61 (master): Use `sleep 0.5` for tests of GVL instrumentation API

https://git.ruby-lang.org/ruby.git/commit/?id=5d014bcb61

From 5d014bcb61cbc443be6e6bd722573bf9e482a9be Mon Sep 17 00:00:00 2001
From: Yusuke Endoh <mame@r...>
Date: Mon, 6 Jun 2022 12:52:15 +0900
Subject: Use `sleep 0.5` for tests of GVL instrumentation API

The tests fail randomly on some platforms.

http://rubyci.s3.amazonaws.com/ubuntu/ruby-master/log/20220605T213004Z.fail.html.gz
http://rubyci.s3.amazonaws.com/arch/ruby-master/log/20220605T210003Z.fail.html.gz
```
[15737/21701] TestThreadInstrumentation#test_thread_instrumentation_fork_safe/home/chkbuild/chkbuild/tmp/build/20220605T213004Z/ruby/tool/lib/test/unit/assertions.rb:109:in `assert': Expected 0 to be nonzero?. (Test::Unit::AssertionFailedError)
```

The failures seem to depend on context switches. I suspect `sleep 0.05`
is too short, so this change tries to extend the wait time.
---
 test/-ext-/thread/test_instrumentation_api.rb | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/-ext-/thread/test_instrumentation_api.rb b/test/-ext-/thread/test_instrumentation_api.rb
index 9f3f3601a6..08bcda7ed9 100644
--- a/test/-ext-/thread/test_instrumentation_api.rb
+++ b/test/-ext-/thread/test_instrumentation_api.rb
@@ -10,7 +10,7 @@ class TestThreadInstrumentation < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/-ext-/thread/test_instrumentation_api.rb#L10
     Bug::ThreadInstrumentation::register_callback
 
     begin
-      threads = 5.times.map { Thread.new { sleep 0.05; 1 + 1; sleep 0.02 } }
+      threads = 5.times.map { Thread.new { sleep 0.5; 1 + 1; sleep 0.2 } }
       threads.each(&:join)
       Bug::ThreadInstrumentation.counters.each do |c|
         assert_predicate c,:nonzero?
@@ -29,7 +29,7 @@ class TestThreadInstrumentation < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/-ext-/thread/test_instrumentation_api.rb#L29
     begin
       pid = fork do
         Bug::ThreadInstrumentation.reset_counters
-        threads = 5.times.map { Thread.new { sleep 0.05; 1 + 1; sleep 0.02 } }
+        threads = 5.times.map { Thread.new { sleep 0.5; 1 + 1; sleep 0.2 } }
         threads.each(&:join)
         Bug::ThreadInstrumentation.counters.each do |c|
           assert_predicate c,:nonzero?
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]