3 STRACE
=$
(which strace
2>/dev
/null ||
:)
6 t_info
"strace not found, skipping $T"
9 if test x
"$(uname -s)" != xLinux
11 t_info
"Linux is the only supported OS for $T"
15 # these buffer internally in external libraries, so we can't detect when
17 skip_models EventMachine NeverBlock
18 skip_models StreamResponseEpoll
19 skip_models Coolio CoolioThreadPool CoolioThreadSpawn
20 skip_models Revactor Rev RevThreadPool RevThreadSpawn
22 # not sure why, but we don't have time to care about Ruby 1.8 too much
24 1.8.
*) skip_models WriterThreadSpawn WriterThreadPool
;;
27 t_plan
13 "Kgio autopush tests"
33 strace
-p $worker_pid -e '!futex' -f -o $strace_out &
35 while ! test -s $strace_out; do sleep 1; done
40 while test 2 -gt $
(grep TCP_CORK
$strace_out | count_lines
)
46 die
"waited too long ($nr seconds) for TCP_CORK"
51 test 2 -eq $
(grep TCP_CORK
$strace_out | count_lines
)
52 fgrep
'SOL_TCP, TCP_CORK, [0],' $strace_out
53 fgrep
'SOL_TCP, TCP_CORK, [1],' $strace_out
56 t_begin
"setup and start" && {
57 rainbows_setup
$model 1 1
59 ed
-s $unicorn_config <<EOF
60 ,s/^listen.*/listen "$listen", :tcp_nodelay => true, :tcp_nopush => true/
63 rainbows
-D large-file-response.ru
-c $unicorn_config -E none
67 t_begin
"read worker pid" && {
68 worker_pid
=$
(curl
-sSf http
://$listen/pid
)
72 t_begin
"start strace on worker" && start_strace
74 t_begin
"reading RSS uncorks" && {
75 curl
-sSf http
://$listen/rss
>/dev
/null
78 t_begin
"restart strace on worker" && {
84 t_begin
"reading static file uncorks" && {
85 curl
-sSf http
://$listen/random_blob
>/dev
/null
89 t_begin
"stop strace on worker" && {
94 t_begin
"enable sendfile" && {
95 echo >> $unicorn_config 'require "sendfile"'
96 kill -HUP $rainbows_pid
97 test xSTART
= x
"$(cat $fifo)"
100 t_begin
"reread worker pid" && {
101 worker_pid
=$
(curl
-sSf http
://$listen/pid
)
105 t_begin
"restart strace on the worker" && start_strace
107 t_begin
"HTTP/1.x GET on static file with sendfile uncorks" && {
108 curl
-sSf http
://$listen/random_blob
>/dev
/null
112 t_begin
"killing succeeds" && {
119 t_begin
"check stderr" && check_stderr