зеркало из https://github.com/github/ruby.git
* test/dtrace/helper.rb: ignore empty SUDO. reuse SUDO value by using
class variable. use test/unit instead of minitest/autorun. dispose `Interrupted system call' error messages at parallel test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40630 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
95b690d2a7
Коммит
14c9944e88
|
@ -1,26 +1,26 @@
|
||||||
# -*- coding: us-ascii -*-
|
# -*- coding: us-ascii -*-
|
||||||
require 'minitest/autorun'
|
require 'test/unit'
|
||||||
require 'tempfile'
|
require 'tempfile'
|
||||||
require_relative '../ruby/envutil'
|
require_relative '../ruby/envutil'
|
||||||
|
|
||||||
if Process.euid == 0
|
if Process.euid == 0
|
||||||
ok = true
|
ok = true
|
||||||
elsif (sudo = ENV["SUDO"]) and (`#{sudo} echo ok` rescue false)
|
elsif (sudo = ENV["SUDO"]) and !sudo.empty? and (`#{sudo} echo ok` rescue false)
|
||||||
ok = true
|
ok = true
|
||||||
else
|
else
|
||||||
ok = false
|
ok = false
|
||||||
end
|
end
|
||||||
ok &= (`dtrace -V` rescue false)
|
ok &= (`dtrace -V` rescue false)
|
||||||
module DTrace
|
module DTrace
|
||||||
class TestCase < MiniTest::Unit::TestCase
|
class TestCase < Test::Unit::TestCase
|
||||||
INCLUDE = File.expand_path('..', File.dirname(__FILE__))
|
INCLUDE = File.expand_path('..', File.dirname(__FILE__))
|
||||||
|
|
||||||
def trap_probe d_program, ruby_program
|
def trap_probe d_program, ruby_program
|
||||||
d = Tempfile.new('probe.d')
|
d = Tempfile.new(%w'probe .d')
|
||||||
d.write d_program
|
d.write d_program
|
||||||
d.flush
|
d.flush
|
||||||
|
|
||||||
rb = Tempfile.new('probed.rb')
|
rb = Tempfile.new(%w'probed .rb')
|
||||||
rb.write ruby_program
|
rb.write ruby_program
|
||||||
rb.flush
|
rb.flush
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ module DTrace
|
||||||
rb_path = rb.path
|
rb_path = rb.path
|
||||||
|
|
||||||
cmd = ["dtrace", "-q", "-s", d_path, "-c", "#{EnvUtil.rubybin} -I#{INCLUDE} #{rb_path}"]
|
cmd = ["dtrace", "-q", "-s", d_path, "-c", "#{EnvUtil.rubybin} -I#{INCLUDE} #{rb_path}"]
|
||||||
if sudo = ENV["SUDO"]
|
if sudo = @@sudo
|
||||||
[RbConfig::CONFIG["LIBPATHENV"], "RUBY", "RUBYOPT"].each do |name|
|
[RbConfig::CONFIG["LIBPATHENV"], "RUBY", "RUBYOPT"].each do |name|
|
||||||
if name and val = ENV[name]
|
if name and val = ENV[name]
|
||||||
cmd.unshift("#{name}=#{val}")
|
cmd.unshift("#{name}=#{val}")
|
||||||
|
@ -36,7 +36,7 @@ module DTrace
|
||||||
end
|
end
|
||||||
cmd.unshift(sudo)
|
cmd.unshift(sudo)
|
||||||
end
|
end
|
||||||
probes = IO.popen(cmd) do |io|
|
probes = IO.popen(cmd, err: [:child, :out]) do |io|
|
||||||
io.readlines
|
io.readlines
|
||||||
end
|
end
|
||||||
d.close(true)
|
d.close(true)
|
||||||
|
@ -45,3 +45,7 @@ module DTrace
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end if ok
|
end if ok
|
||||||
|
|
||||||
|
if ok
|
||||||
|
DTrace::TestCase.class_variable_set(:@@sudo, sudo)
|
||||||
|
end
|
||||||
|
|
Загрузка…
Ссылка в новой задаче