summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-29 16:44:09 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-29 16:44:09 +0000
commit94f4a0e91ee7077bcb4391a6f754c6ec58e78a15 (patch)
tree6adca3ea735006170cc986a21fbd191132846d47 /test
parentfd7d4a871cd3ae035a4a48eb728f9d3fcb37e669 (diff)
`TracePoint#enable(target_thraed:)` [Feature #15473]
* vm_trace.c (tracepoint_enable_m): `TracePoint#enable` supports `target_thread:` keyword to filter a target thread. [Feature #15473] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_settracefunc.rb38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb
index 2ada093f8d..6c07bf90f6 100644
--- a/test/ruby/test_settracefunc.rb
+++ b/test/ruby/test_settracefunc.rb
@@ -2115,4 +2115,42 @@ class TestSetTraceFunc < Test::Unit::TestCase
}
assert_equal [], events
end
+
+ def test_enable_target_thread
+ events = []
+ TracePoint.new(:line) do |tp|
+ events << Thread.current
+ end.enable(target_thread: Thread.current) do
+ a = 1
+ Thread.new{
+ b = 2
+ c = 3
+ }.join
+ d = 4
+ end
+ assert_equal Array.new(3){Thread.current}, events
+
+ events = []
+ tp = TracePoint.new(:line) do |tp|
+ events << Thread.current
+ end
+
+ q1 = Queue.new
+ q2 = Queue.new
+
+ th = Thread.new{
+ q1 << :ok; q2.pop
+ t1 = 1
+ t2 = 2
+ }
+ q1.pop
+ tp.enable(target_thread: th) do
+ q2 << 1
+ a = 1
+ b = 2
+ th.join
+ end
+
+ assert_equal Array.new(2){th}, events
+ end
end