diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-29 08:13:16 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-29 08:13:16 +0000 |
commit | 8818a574a1ed9a322f8d2374db6276a9e8d279b8 (patch) | |
tree | 84d9d9497751846863ab8db80ce5ba95b54fdefe /test/dtrace | |
parent | d22ac50ad493256c707b7b39eadf3ac46d989224 (diff) | |
download | ruby-8818a574a1ed9a322f8d2374db6276a9e8d279b8.tar.gz |
helper.rb: try with sudo
* test/dtrace/helper.rb (DTrace::TestCase#trap_probe): try with $SUDO if set.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/dtrace')
-rw-r--r-- | test/dtrace/helper.rb | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/test/dtrace/helper.rb b/test/dtrace/helper.rb index 2aea3d9d08..5f74f52512 100644 --- a/test/dtrace/helper.rb +++ b/test/dtrace/helper.rb @@ -2,6 +2,14 @@ require 'minitest/autorun' require 'tempfile' +if Process.euid == 0 + ok = true +elsif (sudo = ENV["SUDO"]) and (`#{sudo} echo ok` rescue false) + ok = true +else + ok = false +end +ok &= (`dtrace -V` rescue false) module DTrace class TestCase < MiniTest::Unit::TestCase INCLUDE = File.expand_path(File.join(File.dirname(__FILE__), '..')) @@ -18,7 +26,8 @@ module DTrace d_path = d.path rb_path = rb.path - cmd = "dtrace -q -s #{d_path} -c '#{Gem.ruby} -I#{INCLUDE} #{rb_path}'" + cmd = ["dtrace", "-q", "-s", d_path, "-c", "#{Gem.ruby} -I#{INCLUDE} #{rb_path}"] + sudo = ENV["SUDO"] and cmd.unshift(sudo) probes = IO.popen(cmd) do |io| io.readlines end @@ -27,4 +36,4 @@ module DTrace yield(d_path, rb_path, probes) end end -end if Process.euid == 0 and (`dtrace -V` rescue false) +end if ok |