diff --git a/docs/test/README.md b/docs/test/README.md index 84f2a8a3..26525188 100644 --- a/docs/test/README.md +++ b/docs/test/README.md @@ -34,3 +34,8 @@ end sh test.sh ``` +If you want to run with valgrind, set the environment variables `NGINX_RUNNER` and `NGINX_HEATTIME`. + +```console +$ NGINX_RUNNER=valgrind NGINX_HEATTIME=10 sh test.sh +``` diff --git a/test.sh b/test.sh index 20ec575c..f369ace9 100755 --- a/test.sh +++ b/test.sh @@ -119,6 +119,9 @@ do fi done +: ${NGINX_RUNNER:=exec} +: ${NGINX_HEATTIME:=2} + echo "=====================================" echo "" echo "ngx_mruby starting and logging" @@ -126,12 +129,13 @@ echo "" echo "=====================================" echo "" echo "" -${NGINX_INSTALL_DIR}/sbin/nginx & +${NGINX_RUNNER} ${NGINX_INSTALL_DIR}/sbin/nginx & +nginx_pid=$! +trap "kill $nginx_pid; wait" EXIT echo "" echo "" -sleep 2 # waiting for nginx +sleep ${NGINX_HEATTIME} # waiting for nginx ./mruby/build/test/bin/mruby ./test/t/ngx_mruby.rb 2> ${NGINX_INSTALL_DIR}/logs/stderr.log -$KILLALL nginx echo "ngx_mruby testing ... Done" echo "test.sh ... successful"