From b1370f088cad667c34a96c992708d952e23bff03 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 19 Oct 2013 22:50:10 +0000 Subject: test_bin: add additional tests for SIGHUP We can just add it into the SIGUSR2 test for now. --- test/test_bin.rb | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/test_bin.rb b/test/test_bin.rb index d21e8b9..8acc91c 100644 --- a/test/test_bin.rb +++ b/test/test_bin.rb @@ -147,19 +147,35 @@ class TestBin < Testcase assert_equal 200, res.code.to_i orig = res.body Process.kill(:USR2, pid) + newpid = pid Timeout.timeout(10) do begin - sleep 0.01 newpid = File.read(@pid.path) rescue Errno::ENOENT - end until newpid.to_i != pid + end while newpid.to_i == pid && sleep(0.01) end Process.kill(:QUIT, pid) _, status = Timeout.timeout(10) { Process.waitpid2(pid) } assert status.success?, status res = Net::HTTP.start(host, port) { |h| h.get("/") } assert_equal 200, res.code.to_i - refute_equal orig, res.body + second = res.body + refute_equal orig, second + + newpid = newpid.to_i + assert_operator newpid, :>, 0 + Process.kill(:HUP, newpid) + third = second + Timeout.timeout(10) do + begin + third = Net::HTTP.start(host, port) { |h| h.get("/") }.body + end while third == second && sleep(0.01) + end + if worker + Process.kill(0, newpid) # nothing should raise + else + poke_until_dead newpid + end rescue => e Yahns::Log.exception(Logger.new($stderr), "test", e) raise -- cgit v1.2.3-24-ge0c7