rev: add sendfile support
[rainbows.git] / t / t0020-large-sendfile-response.sh
blob822a23f002607ca28181fbd7697955e84a2ab851
1 #!/bin/sh
2 . ./test-lib.sh
3 test -r random_blob || die "random_blob required, run with 'make $0'"
4 case $RUBY_ENGINE in
5 ruby) ;;
6 *)
7 t_info "skipping $T since it can't load the sendfile gem, yet"
8 exit 0
9 ;;
10 esac
12 t_plan 7 "large sendfile response for $model"
14 t_begin "setup and startup" && {
15 rtmpfiles curl_out a b c
16 rainbows_setup $model 2
18 # FIXME: allow "require 'sendfile'" to work in $unicorn_config
19 RUBYOPT="-rsendfile"
20 export RUBYOPT
22 # can't load Rack::Lint here since it clobbers body#to_path
23 rainbows -E none -D large-file-response.ru -c $unicorn_config
24 rainbows_wait_start
27 t_begin "read random blob sha1" && {
28 random_blob_sha1=$(rsha1 < random_blob)
31 t_begin "send a series of HTTP/1.1 requests in parallel" && {
32 for i in $a $b $c
35 curl -sSf http://$listen/random_blob | rsha1 > $i
36 ) &
37 done
38 wait
39 for i in $a $b $c
41 test x$(cat $i) = x$random_blob_sha1
42 done
45 # this was a problem during development
46 t_begin "HTTP/1.0 test" && {
47 sha1=$( (curl -0 -sSfv http://$listen/random_blob &&
48 echo ok >$ok) | rsha1)
49 test $sha1 = $random_blob_sha1
50 test xok = x$(cat $ok)
53 t_begin "HTTP/0.9 test" && {
55 printf 'GET /random_blob\r\n'
56 rsha1 < $fifo > $tmp &
57 wait
58 echo ok > $ok
59 ) | socat - TCP:$listen > $fifo
60 test $(cat $tmp) = $random_blob_sha1
61 test xok = x$(cat $ok)
64 t_begin "shutdown server" && {
65 kill -QUIT $rainbows_pid
68 dbgcat r_err
70 t_begin "check stderr" && check_stderr
72 t_done