ruby-changes:25929
From: nobu <ko1@a...>
Date: Thu, 29 Nov 2012 17:13:24 +0900 (JST)
Subject: [ruby-changes:25929] nobu:r37986 (trunk): helper.rb: try with sudo
nobu 2012-11-29 17:13:16 +0900 (Thu, 29 Nov 2012) New Revision: 37986 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=37986 Log: helper.rb: try with sudo * test/dtrace/helper.rb (DTrace::TestCase#trap_probe): try with $SUDO if set. Modified files: trunk/test/dtrace/helper.rb Index: test/dtrace/helper.rb =================================================================== --- test/dtrace/helper.rb (revision 37985) +++ test/dtrace/helper.rb (revision 37986) @@ -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 @@ 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 @@ yield(d_path, rb_path, probes) end end -end if Process.euid == 0 and (`dtrace -V` rescue false) +end if ok -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/