multirequest.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #!/bin/bash
  2. cd $(dirname $0)
  3. set -e
  4. PORT=12345
  5. TIMEOUT=10
  6. ./compile_extension.sh
  7. run_test() {
  8. echo
  9. echo "Running multirequest test, args: $@"
  10. RUN_UNDER=""
  11. EXTRA_ARGS=""
  12. ARGS="-d xdebug.profiler_enable=0 -d display_errors=on -dextension=../ext/google/protobuf/modules/protobuf.so"
  13. for i in "$@"; do
  14. case $i in
  15. --valgrind)
  16. RUN_UNDER="valgrind --error-exitcode=1"
  17. shift
  18. ;;
  19. --keep_descriptors)
  20. EXTRA_ARGS=-dprotobuf.keep_descriptor_pool_after_request=1
  21. shift
  22. ;;
  23. esac
  24. done
  25. export ZEND_DONT_UNLOAD_MODULES=1
  26. export USE_ZEND_ALLOC=0
  27. rm -f nohup.out
  28. nohup $RUN_UNDER php $ARGS $EXTRA_ARGS -S localhost:$PORT multirequest.php >nohup.out 2>&1 &
  29. PID=$!
  30. if ! timeout $TIMEOUT bash -c "until echo > /dev/tcp/localhost/$PORT; do sleep 0.1; done" > /dev/null 2>&1; then
  31. echo "Server failed to come up after $TIMEOUT seconds"
  32. cat nohup.out
  33. exit 1
  34. fi
  35. seq 2 | xargs -I{} wget -nv http://localhost:$PORT/multirequest.result -O multirequest{}.result
  36. REQUESTS_SUCCEEDED=$?
  37. if kill $PID > /dev/null 2>&1 && [[ $REQUESTS_SUCCEEDED == "0" ]]; then
  38. wait
  39. echo "Multirequest test SUCCEEDED"
  40. else
  41. echo "Multirequest test FAILED"
  42. cat nohup.out
  43. exit 1
  44. fi
  45. }
  46. run_test
  47. run_test --keep_descriptors
  48. run_test --valgrind
  49. run_test --valgrind --keep_descriptors