diff options
author | Eric Wong <normalperson@yhbt.net> | 2010-08-17 08:35:03 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2010-08-17 08:41:15 +0000 |
commit | ac05e7035e1946b78ce4679548db7680aa01734c (patch) | |
tree | 1379997b2686b9fa777216ad06f1ffe9be5b6027 /t/t0032-close-pipe-to_path-response.sh | |
parent | 9c5669e232f8f57c2d8e08d84e21bf09cd87bfa1 (diff) | |
download | rainbows-ac05e7035e1946b78ce4679548db7680aa01734c.tar.gz |
First off we use an FD_MAP to avoid creating redundant IO objects which map to the same FD. When that doesn't work, we'll fall back to trapping Errno::EBADF and IOError where appropriate.
Diffstat (limited to 't/t0032-close-pipe-to_path-response.sh')
-rwxr-xr-x | t/t0032-close-pipe-to_path-response.sh | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/t/t0032-close-pipe-to_path-response.sh b/t/t0032-close-pipe-to_path-response.sh new file mode 100755 index 0000000..e3d8f1b --- /dev/null +++ b/t/t0032-close-pipe-to_path-response.sh @@ -0,0 +1,101 @@ +#!/bin/sh +. ./test-lib.sh +if ! test -d /dev/fd +then + t_info "skipping $T since /dev/fd is required" + exit 0 +fi + +t_plan 16 "close pipe to_path response for $model" + +t_begin "setup and startup" && { + rtmpfiles err out http_fifo sub_ok + rainbows_setup $model + export fifo + rainbows -E none -D close-pipe-to_path-response.ru -c $unicorn_config + rainbows_wait_start +} + +t_begin "read random blob sha1" && { + random_blob_sha1=$(rsha1 < random_blob) +} + +t_begin "start FIFO reader" && { + cat $fifo > $out & +} + +t_begin "single request matches" && { + sha1=$(curl -sSfv 2> $err http://$listen/ | rsha1) + test -n "$sha1" + test x"$sha1" = x"$random_blob_sha1" +} + +t_begin "body.close called" && { + wait # for cat $fifo + grep CLOSING $out || die "body.close not logged" +} + +t_begin "start FIFO reader for abortive HTTP/1.1 request" && { + cat $fifo > $out & +} + +t_begin "send abortive HTTP/1.1 request" && { + rm -f $ok + ( + printf 'GET /random_blob HTTP/1.1\r\nHost: example.com\r\n\r\n' + dd bs=4096 count=1 < $http_fifo >/dev/null + echo ok > $ok + ) | socat - TCP:$listen > $http_fifo || : + test xok = x$(cat $ok) +} + +t_begin "body.close called for aborted HTTP/1.1 request" && { + wait # for cat $fifo + grep CLOSING $out || die "body.close not logged" +} + +t_begin "start FIFO reader for abortive HTTP/1.0 request" && { + cat $fifo > $out & +} + +t_begin "send abortive HTTP/1.0 request" && { + rm -f $ok + ( + printf 'GET /random_blob HTTP/1.0\r\n\r\n' + dd bs=4096 count=1 < $http_fifo >/dev/null + echo ok > $ok + ) | socat - TCP:$listen > $http_fifo || : + test xok = x$(cat $ok) +} + +t_begin "body.close called for aborted HTTP/1.0 request" && { + wait # for cat $fifo + grep CLOSING $out || die "body.close not logged" +} + +t_begin "start FIFO reader for abortive HTTP/0.9 request" && { + cat $fifo > $out & +} + +t_begin "send abortive HTTP/0.9 request" && { + rm -f $ok + ( + printf 'GET /random_blob\r\n' + dd bs=4096 count=1 < $http_fifo >/dev/null + echo ok > $ok + ) | socat - TCP:$listen > $http_fifo || : + test xok = x$(cat $ok) +} + +t_begin "body.close called for aborted HTTP/0.9 request" && { + wait # for cat $fifo + grep CLOSING $out || die "body.close not logged" +} + +t_begin "shutdown server" && { + kill -QUIT $rainbows_pid +} + +t_begin "check stderr" && check_stderr + +t_done |