about summary refs log tree commit homepage
path: root/test
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2017-03-23 00:03:57 +0000
committerEric Wong <e@80x24.org>2017-03-23 00:03:57 +0000
commit079da35629a507719a7c15324cfba4e9c5a7be4d (patch)
tree67dabf7b0539f6cfd7faffd53dce6743177aaf2c /test
parent703701aa9907df0c88d52873e47fabb15bb4a320 (diff)
parent19f969d961c0ff6f6f45b4231d859605530d71ab (diff)
downloadunicorn-079da35629a507719a7c15324cfba4e9c5a7be4d.tar.gz
* ccc-tcp-v3:
  test_ccc: use a pipe to synchronize test
  http_request: support proposed Raindrops::TCP states on non-Linux
Diffstat (limited to 'test')
-rw-r--r--test/unit/test_ccc.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/test/unit/test_ccc.rb b/test/unit/test_ccc.rb
index 22b1a9c..0db0c38 100644
--- a/test/unit/test_ccc.rb
+++ b/test/unit/test_ccc.rb
@@ -12,7 +12,9 @@ class TestCccTCPI < Test::Unit::TestCase
     port = srv.addr[1]
     err = Tempfile.new('unicorn_ccc')
     rd, wr = IO.pipe
+    sleep_pipe = IO.pipe
     pid = fork do
+      sleep_pipe[1].close
       reqs = 0
       rd.close
       worker_pid = nil
@@ -22,7 +24,10 @@ class TestCccTCPI < Test::Unit::TestCase
           $$
         end
         reqs += 1
-        sleep(1) if env['PATH_INFO'] == '/sleep'
+
+        # will wake up when writer closes
+        sleep_pipe[0].read if env['PATH_INFO'] == '/sleep'
+
         [ 200, [ %w(Content-Length 0),  %w(Content-Type text/plain) ], [] ]
       end
       ENV['UNICORN_FD'] = srv.fileno.to_s
@@ -57,6 +62,10 @@ class TestCccTCPI < Test::Unit::TestCase
                    "Host: example.com\r\n\r\n")
       client.close
     end
+    sleep_pipe[1].close # wake up the reader in the worker
+    res = sleeper.read
+    assert_match %r{\AHTTP/1\.1 200}, res, 'got part of first sleeper response'
+    assert_match %r{\r\n\r\n\z}, res, 'got end of sleeper response'
     sleeper.close
     kpid = pid
     pid = nil