Kouhei Sutou
null+****@clear*****
Mon Mar 14 15:02:32 JST 2016
Kouhei Sutou 2016-03-14 15:02:32 +0900 (Mon, 14 Mar 2016) New Revision: 41e955bed79e55b49650554a68686f1eee1c07d1 https://github.com/groonga/grntest/commit/41e955bed79e55b49650554a68686f1eee1c07d1 Message: Support SEGV detection at exit Modified files: lib/grntest/executors/base-executor.rb lib/grntest/executors/http-executor.rb lib/grntest/test-runner.rb Modified: lib/grntest/executors/base-executor.rb (+26 -0) =================================================================== --- lib/grntest/executors/base-executor.rb 2016-03-14 15:01:17 +0900 (6df216d) +++ lib/grntest/executors/base-executor.rb 2016-03-14 15:02:32 +0900 (d8d4cbe) @@ -72,7 +72,33 @@ module Grntest @context.result end + def shutdown(pid) + begin + send_command(command("shutdown")) + rescue + return false + end + + status = nil + total_sleep_time = 0 + sleep_time = 0.1 + loop do + _, status = Process.waitpid2(pid, Process::WNOHANG) + break if status + sleep(sleep_time) + total_sleep_time += sleep_time + return false if total_sleep_time > timeout + end + + log_error(read_all_log) unless status.success? + true + end + private + def command(command_line) + Groonga::Command::Parser.parse(command_line) + end + def create_parser parser = Groonga::Command::Parser.new parser.on_command do |command| Modified: lib/grntest/executors/http-executor.rb (+0 -11) =================================================================== --- lib/grntest/executors/http-executor.rb 2016-03-14 15:01:17 +0900 (f266687) +++ lib/grntest/executors/http-executor.rb 2016-03-14 15:02:32 +0900 (1446256) @@ -49,22 +49,11 @@ module Grntest end end - def shutdown - begin - send_command(command("shutdown")) - rescue Error - end - end - def create_sub_executor(context) self.class.new(@host, @port, context) end private - def command(command_line) - Groonga::Command::Parser.parse(command_line) - end - MAX_URI_SIZE = 4096 def send_load_command(command) lines = command.original_source.lines Modified: lib/grntest/test-runner.rb (+6 -2) =================================================================== --- lib/grntest/test-runner.rb 2016-03-14 15:01:17 +0900 (137074d) +++ lib/grntest/test-runner.rb 2016-03-14 15:02:32 +0900 (4a84370) @@ -204,7 +204,11 @@ module Grntest groonga_output, context) executor.ensure_groonga_ready - yield(executor) + begin + yield(executor) + ensure + pid = nil if executor.shutdown(pid) + end end ensure Process.waitpid(pid) if pid @@ -339,7 +343,7 @@ call chdir("#{context.temporary_directory_path}") end yield(executor) ensure - executor.shutdown + pid = nil if executor.shutdown(pid) if wait_groonga_http_shutdown(pid_file_path, shutdown_wait_timeout) pid = nil if wait_pid(pid, shutdown_wait_timeout) end -------------- next part -------------- HTML����������������������������...Télécharger