thread_timeout: fix bad comparison
[rainbows.git] / t / t0031-close-pipe-response.sh
blobc863d4a91ac95eea53868fcb2b3b08d0b35edd41
1 #!/bin/sh
2 . ./test-lib.sh
4 t_plan 16 "close pipe response for $model"
6 t_begin "setup and startup" && {
7 rtmpfiles err out http_fifo sub_ok
8 rainbows_setup $model
9 export fifo
10 rainbows -E none -D close-pipe-response.ru -c $unicorn_config
11 rainbows_wait_start
14 t_begin "read random blob sha1" && {
15 random_blob_sha1=$(rsha1 < random_blob)
18 t_begin "start FIFO reader" && {
19 cat $fifo > $out &
22 t_begin "single request matches" && {
23 sha1=$(curl -sSfv 2> $err http://$listen/ | rsha1)
24 test -n "$sha1"
25 test x"$sha1" = x"$random_blob_sha1"
28 t_begin "body.close called" && {
29 wait # for cat $fifo
30 grep CLOSING $out || die "body.close not logged"
33 t_begin "start FIFO reader for abortive HTTP/1.1 request" && {
34 cat $fifo > $out &
37 t_begin "send abortive HTTP/1.1 request" && {
38 rm -f $ok
40 printf 'GET /random_blob HTTP/1.1\r\nHost: example.com\r\n\r\n'
41 dd bs=4096 count=1 < $http_fifo >/dev/null
42 echo ok > $ok
43 ) | socat - TCP:$listen > $http_fifo || :
44 test xok = x$(cat $ok)
47 t_begin "body.close called for aborted HTTP/1.1 request" && {
48 wait # for cat $fifo
49 grep CLOSING $out || die "body.close not logged"
52 t_begin "start FIFO reader for abortive HTTP/1.0 request" && {
53 cat $fifo > $out &
56 t_begin "send abortive HTTP/1.0 request" && {
57 rm -f $ok
59 printf 'GET /random_blob HTTP/1.0\r\n\r\n'
60 dd bs=4096 count=1 < $http_fifo >/dev/null
61 echo ok > $ok
62 ) | socat - TCP:$listen > $http_fifo || :
63 test xok = x$(cat $ok)
66 t_begin "body.close called for aborted HTTP/1.0 request" && {
67 wait # for cat $fifo
68 grep CLOSING $out || die "body.close not logged"
71 t_begin "start FIFO reader for abortive HTTP/0.9 request" && {
72 cat $fifo > $out &
75 t_begin "send abortive HTTP/0.9 request" && {
76 rm -f $ok
78 printf 'GET /random_blob\r\n'
79 dd bs=4096 count=1 < $http_fifo >/dev/null
80 echo ok > $ok
81 ) | socat - TCP:$listen > $http_fifo || :
82 test xok = x$(cat $ok)
85 t_begin "body.close called for aborted HTTP/0.9 request" && {
86 wait # for cat $fifo
87 grep CLOSING $out || die "body.close not logged"
90 t_begin "shutdown server" && {
91 kill -QUIT $rainbows_pid
94 t_begin "check stderr" && check_stderr
96 t_done