test.sh 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/bin/bash
  2. set -ex
  3. cd $(dirname $0)
  4. ./generate_protos.sh
  5. ./compile_extension.sh
  6. PHP_VERSION=$(php -r "echo PHP_VERSION;")
  7. # Each version of PHPUnit supports a fairly narrow range of PHP versions.
  8. case "$PHP_VERSION" in
  9. 5.6.*) PHPUNIT=phpunit-5.6.8.phar;;
  10. 7.0.*) PHPUNIT=phpunit-5.6.0.phar;; # Oddly older than for 5.6. Not sure the reason.
  11. 7.3.*) PHPUNIT=phpunit-8.phar;;
  12. esac
  13. [ -f $PHPUNIT ] || wget https://phar.phpunit.de/$PHPUNIT
  14. tests=( array_test.php encode_decode_test.php generated_class_test.php map_field_test.php well_known_test.php descriptors_test.php wrapper_type_setters_test.php)
  15. for t in "${tests[@]}"
  16. do
  17. echo "****************************"
  18. echo "* $t"
  19. echo "****************************"
  20. php -dextension=../ext/google/protobuf/modules/protobuf.so $PHPUNIT --bootstrap autoload.php $t
  21. echo ""
  22. done
  23. for t in "${tests[@]}"
  24. do
  25. echo "****************************"
  26. echo "* $t persistent"
  27. echo "****************************"
  28. php -d protobuf.keep_descriptor_pool_after_request=1 -dextension=../ext/google/protobuf/modules/protobuf.so $PHPUNIT --bootstrap autoload.php $t
  29. echo ""
  30. done
  31. # # Make sure to run the memory test in debug mode.
  32. # php -dextension=../ext/google/protobuf/modules/protobuf.so memory_leak_test.php
  33. export ZEND_DONT_UNLOAD_MODULES=1
  34. export USE_ZEND_ALLOC=0
  35. valgrind --leak-check=yes php -dextension=../ext/google/protobuf/modules/protobuf.so memory_leak_test.php
  36. valgrind --leak-check=yes php -d protobuf.keep_descriptor_pool_after_request=1 -dextension=../ext/google/protobuf/modules/protobuf.so memory_leak_test.php
  37. # TODO(teboring): Only for debug (phpunit has memory leak which blocks this beging used by
  38. # regresssion test.)
  39. # for t in "${tests[@]}"
  40. # do
  41. # echo "****************************"
  42. # echo "* $t (memory leak)"
  43. # echo "****************************"
  44. # valgrind --leak-check=yes php -dextension=../ext/google/protobuf/modules/protobuf.so $PHPUNIT --bootstrap autoload.php $t
  45. # echo ""
  46. # done