From c41a08821bf11eefebda3ea3e536eda8f4b4629b Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 18 Oct 2009 22:05:13 -0700 Subject: tests: more reliable error checking We now check for SIGKILL, too --- t/lib-async-response.sh | 2 +- t/lib-graceful.sh | 2 +- t/lib-input-trailer.sh | 8 +++----- t/lib-parser-error.sh | 2 +- t/lib-rack-input-hammer.sh | 2 +- t/lib-reopen-logs.sh | 12 ++++++------ t/lib-simple-http.sh | 5 ++--- t/t9000-rack-app-pool.sh | 5 ++--- t/test-lib.sh | 13 +++++++++++++ 9 files changed, 30 insertions(+), 21 deletions(-) diff --git a/t/lib-async-response.sh b/t/lib-async-response.sh index 925455b..285751d 100644 --- a/t/lib-async-response.sh +++ b/t/lib-async-response.sh @@ -35,7 +35,7 @@ dbgcat c dbgcat r_err dbgcat curl_err test ! -s $curl_err -grep Error $r_err && die "errors in $r_err" +check_stderr while kill -0 $rainbows_pid >/dev/null 2>&1 do diff --git a/t/lib-graceful.sh b/t/lib-graceful.sh index b130341..38eaa55 100644 --- a/t/lib-graceful.sh +++ b/t/lib-graceful.sh @@ -35,7 +35,7 @@ nr=$(sort < $curl_out | uniq | wc -l) test "$nr" -eq 1 test x$(sort < $curl_out | uniq) = xHello -! grep Error $r_err +check_stderr while kill -0 $rainbows_pid >/dev/null 2>&1 do sleep 1 diff --git a/t/lib-input-trailer.sh b/t/lib-input-trailer.sh index e20bebc..90b76a7 100644 --- a/t/lib-input-trailer.sh +++ b/t/lib-input-trailer.sh @@ -28,8 +28,7 @@ echo "small blob" fgrep 'HTTP/1.1 200 OK' $tmp test xok = x"$(cat $ok)" -! grep Error $r_err - +check_stderr echo "big blob" ( @@ -41,7 +40,7 @@ echo "big blob" fgrep 'HTTP/1.1 200 OK' $tmp test xok = x"$(cat $ok)" -! grep Error $r_err +check_stderr echo "staggered blob" ( @@ -61,7 +60,6 @@ echo "staggered blob" fgrep 'HTTP/1.1 200 OK' $tmp test xok = x"$(cat $ok)" -! grep Error $r_err - +check_stderr kill $(cat $pid) diff --git a/t/lib-parser-error.sh b/t/lib-parser-error.sh index d540a22..f2ec373 100644 --- a/t/lib-parser-error.sh +++ b/t/lib-parser-error.sh @@ -28,4 +28,4 @@ kill $(cat $pid) dbgcat tmp grep -F 'HTTP/1.1 400 Bad Request' $tmp -! grep Error $r_err +check_stderr diff --git a/t/lib-rack-input-hammer.sh b/t/lib-rack-input-hammer.sh index 11f0479..cb3f8c1 100644 --- a/t/lib-rack-input-hammer.sh +++ b/t/lib-rack-input-hammer.sh @@ -35,4 +35,4 @@ test 1 -eq $(sort < $curl_out | uniq | wc -l) blob_sha1=$( expr "$(sha1sum < random_blob)" : '\([a-f0-9]\+\)') echo blob_sha1=$blob_sha1 test x"$blob_sha1" = x"$(sort < $curl_out | uniq)" -! grep Error $r_err +check_stderr diff --git a/t/lib-reopen-logs.sh b/t/lib-reopen-logs.sh index ace223a..1bfa3a0 100644 --- a/t/lib-reopen-logs.sh +++ b/t/lib-reopen-logs.sh @@ -23,7 +23,7 @@ for i in $(awk "BEGIN{for(i=0;i<$nr_client;++i) print i}" > $curl_out 2>> $curl_err ) & done -! grep Error $r_err +check_stderr rm $r_rot mv $r_err $r_rot @@ -36,14 +36,14 @@ dbgcat r_err wait echo elapsed=$(( $(date +%s) - $start )) -! test -s $curl_err +test ! -s $curl_err test x"$(wc -l < $curl_out)" = x$nr_client nr=$(sort < $curl_out | uniq | wc -l) test "$nr" -eq 1 test x$(sort < $curl_out | uniq) = xHello -! grep Error $r_err -! grep Error $r_rot +check_stderr +check_stderr $r_rot before_rot=$(wc -c < $r_rot) before_err=$(wc -c < $r_err) @@ -56,5 +56,5 @@ test $after_err -gt $before_err && echo "before_err -gt after_err" kill $(cat $pid) dbgcat r_err -! grep Error $r_err -! grep Error $r_rot +check_stderr +check_stderr $r_rot diff --git a/t/lib-simple-http.sh b/t/lib-simple-http.sh index 8d09082..330fe53 100644 --- a/t/lib-simple-http.sh +++ b/t/lib-simple-http.sh @@ -53,7 +53,7 @@ test 2 -eq $(grep '^HTTP/1.1 200 OK' $tmp | wc -l) test 1 -eq $(grep '^Connection: keep-alive' $tmp | wc -l) test 1 -eq $(grep '^Connection: close' $tmp | wc -l) test x"$(cat $ok)" = xok -! grep Error $r_err +check_stderr echo "burst pipelining" @@ -74,8 +74,7 @@ test 1 -eq $(grep '^Connection: keep-alive' $tmp | wc -l) test 1 -eq $(grep '^Connection: close' $tmp | wc -l) test x"$(cat $ok)" = xok -! grep Error $r_err - +check_stderr echo "HTTP/0.9 request should not return headers" ( diff --git a/t/t9000-rack-app-pool.sh b/t/t9000-rack-app-pool.sh index 41402d9..5530b9d 100755 --- a/t/t9000-rack-app-pool.sh +++ b/t/t9000-rack-app-pool.sh @@ -31,7 +31,6 @@ echo elapsed=$(( $(date +%s) - $start )) kill $(cat $pid) test $APP_POOL_SIZE -eq $(sort < $curl_out | uniq | wc -l) -! test -s $curl_err +test ! -s $curl_err -! grep Error $r_err -# +check_stderr diff --git a/t/test-lib.sh b/t/test-lib.sh index 54d1b2d..403e252 100755 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -85,6 +85,19 @@ dbgcat () { sed -e "s/^/$id:/" < $_file } +check_stderr () { + set +u + _r_err=${1-${r_err}} + set -u + if grep Error $_r_err + then + die "Errors found in $_r_err" + elif grep SIGKILL $_r_err + then + die "SIGKILL found in $_r_err" + fi +} + case $model in Rev) require_check rev Rev::VERSION ;; Revactor) require_check revactor Revactor::VERSION ;; -- cgit v1.2.3-24-ge0c7