From c1588c5fb232d5425ceaa12258e7b8dd9f1d0cbe Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 30 Oct 2013 01:50:19 +0000 Subject: tests for SIGTTIN and SIGTTOU These are implemented trivially and based on working code, but test them anyways. --- test/test_server.rb | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'test') diff --git a/test/test_server.rb b/test/test_server.rb index 96dc546..79e498d 100644 --- a/test/test_server.rb +++ b/test/test_server.rb @@ -360,6 +360,43 @@ class TestServer < Testcase quit_wait(pid) end + def test_ttin_ttou + err, cfg, host, port = @err, Yahns::Config.new, @srv.addr[3], @srv.addr[1] + ru = lambda { |_| + b = "#$$" + [ 200, {'Content-Length'=>b.size.to_s}, [b] ] + } + cfg.instance_eval do + GTL.synchronize { app(:rack, ru) { listen "#{host}:#{port}" } } + worker_processes 1 + stderr_path err.path + end + pid = mkserver(cfg) + + read_pid = lambda do + c = get_tcp_client(host, port) + c.write("GET /\r\n\r\n") + body = Timeout.timeout(10) { c.read } + c.close + assert_match(/\A\d+\z/, body) + body + end + + orig_worker_pid = read_pid.call.to_i + assert_equal 1, Process.kill(0, orig_worker_pid) + + Process.kill(:TTOU, pid) + poke_until_dead(orig_worker_pid) + + Process.kill(:TTIN, pid) + second_worker_pid = read_pid.call.to_i + + # PID recycling is rare, hope it doesn't fail here + refute_equal orig_worker_pid, second_worker_pid + ensure + quit_wait(pid) + end + def test_mp_hooks err = @err out = tmpfile(%w(mp_hooks .out)) -- cgit v1.2.3-24-ge0c7