summaryrefslogtreecommitdiff
path: root/bootstraptest
diff options
context:
space:
mode:
Diffstat (limited to 'bootstraptest')
-rw-r--r--bootstraptest/runner.rb29
-rw-r--r--bootstraptest/test_io.rb19
2 files changed, 36 insertions, 12 deletions
diff --git a/bootstraptest/runner.rb b/bootstraptest/runner.rb
index 931fb46..080e7b1 100644
--- a/bootstraptest/runner.rb
+++ b/bootstraptest/runner.rb
@@ -188,7 +188,7 @@ def assert_valid_syntax(testsrc, message = '')
}
end
-def assert_normal_exit(testsrc, message = '')
+def assert_normal_exit(testsrc, message = '', ignore_signals = nil)
newtest
$stderr.puts "\##{@count} #{@location}" if @verbose
faildesc = nil
@@ -205,28 +205,33 @@ def assert_normal_exit(testsrc, message = '')
if status.signaled?
signo = status.termsig
signame = Signal.list.invert[signo]
- sigdesc = "signal #{signo}"
- if signame
- sigdesc = "SIG#{signame} (#{sigdesc})"
- end
- faildesc = pretty(testsrc, "killed by #{sigdesc}", nil)
- stderr_log = File.read("assert_normal_exit_stderr.log")
- if !stderr_log.empty?
- faildesc << "\n" if /\n\z/ !~ faildesc
- stderr_log << "\n" if /\n\z/ !~ stderr_log
- stderr_log.gsub!(/^.*\n/) { '| ' + $& }
- faildesc << stderr_log
+ unless ignore_signals and ignore_signals.include?(signame)
+ sigdesc = "signal #{signo}"
+ if signame
+ sigdesc = "SIG#{signame} (#{sigdesc})"
+ end
+ faildesc = pretty(testsrc, "killed by #{sigdesc}", nil)
+ stderr_log = File.read("assert_normal_exit_stderr.log")
+ if !stderr_log.empty?
+ faildesc << "\n" if /\n\z/ !~ faildesc
+ stderr_log << "\n" if /\n\z/ !~ stderr_log
+ stderr_log.gsub!(/^.*\n/) { '| ' + $& }
+ faildesc << stderr_log
+ end
end
end
if !faildesc
$stderr.print '.'
+ true
else
$stderr.print 'F'
error faildesc, message
+ false
end
rescue Exception => err
$stderr.print 'E'
error err.message, message
+ false
end
def assert_finish(timeout_seconds, testsrc, message = '')
diff --git a/bootstraptest/test_io.rb b/bootstraptest/test_io.rb
index 0721105..c0b906f 100644
--- a/bootstraptest/test_io.rb
+++ b/bootstraptest/test_io.rb
@@ -73,3 +73,22 @@ assert_equal 'ok', %q{
assert_normal_exit %q{
ARGF.set_encoding "foo"
}
+
+50.times do
+ assert_normal_exit %q{
+ at_exit { p :foo }
+
+ megacontent = "abc" * 12345678
+ File.open("megasrc", "w") {|f| f << megacontent }
+
+ Thread.new { sleep rand*0.2; Process.kill(:INT, $$) }
+
+ r1, w1 = IO.pipe
+ r2, w2 = IO.pipe
+ t1 = Thread.new { w1 << megacontent; w1.close }
+ t2 = Thread.new { r2.read }
+ IO.copy_stream(r1, w2) rescue nil
+ r2.close; w2.close
+ r1.close; w1.close
+ }, '', ["INT"] or break
+end