diff options
Diffstat (limited to 'jni/ruby/test/dtrace/test_require.rb')
-rw-r--r-- | jni/ruby/test/dtrace/test_require.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/jni/ruby/test/dtrace/test_require.rb b/jni/ruby/test/dtrace/test_require.rb new file mode 100644 index 0000000..46a1d76 --- /dev/null +++ b/jni/ruby/test/dtrace/test_require.rb @@ -0,0 +1,34 @@ +require_relative 'helper' + +module DTrace + class TestRequire < TestCase + def test_require_entry + probe = <<-eoprobe +ruby$target:::require-entry +{ + printf("%s %s %d\\n", copyinstr(arg0), copyinstr(arg1), arg2); +} + eoprobe + trap_probe(probe, ruby_program) { |d_file, rb_file, saw| + required = saw.map { |s| s.split }.find_all do |(required, _)| + required == 'dtrace/dummy' + end + assert_equal 10, required.length + } + end + + def test_require_return + probe = <<-eoprobe +ruby$target:::require-return +{ + printf("%s\\n", copyinstr(arg0)); +} + eoprobe + end + + private + def ruby_program + "10.times { require 'dtrace/dummy' }" + end + end +end if defined?(DTrace::TestCase) |