test.sh 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. 7.0.*|7.1.*|7.2.*)
  10. # Oddly older than for 5.6. Not sure the reason.
  11. PHPUNIT=phpunit-5.6.0.phar
  12. ;;
  13. 7.3.*|7.4.*)
  14. PHPUNIT=phpunit-8.phar
  15. ;;
  16. *)
  17. echo "ERROR: Unsupported PHP version $PHP_VERSION"
  18. exit 1
  19. ;;
  20. esac
  21. [ -f $PHPUNIT ] || wget https://phar.phpunit.de/$PHPUNIT
  22. 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)
  23. for t in "${tests[@]}"
  24. do
  25. echo "****************************"
  26. echo "* $t"
  27. echo "****************************"
  28. php -dextension=../ext/google/protobuf/modules/protobuf.so $PHPUNIT --bootstrap autoload.php $t
  29. echo ""
  30. done
  31. for t in "${tests[@]}"
  32. do
  33. echo "****************************"
  34. echo "* $t persistent"
  35. echo "****************************"
  36. php -d protobuf.keep_descriptor_pool_after_request=1 -dextension=../ext/google/protobuf/modules/protobuf.so $PHPUNIT --bootstrap autoload.php $t
  37. echo ""
  38. done
  39. # # Make sure to run the memory test in debug mode.
  40. # php -dextension=../ext/google/protobuf/modules/protobuf.so memory_leak_test.php
  41. export ZEND_DONT_UNLOAD_MODULES=1
  42. export USE_ZEND_ALLOC=0
  43. valgrind --suppressions=valgrind.supp --leak-check=yes php -dextension=../ext/google/protobuf/modules/protobuf.so memory_leak_test.php
  44. valgrind --suppressions=valgrind.supp --leak-check=yes php -d protobuf.keep_descriptor_pool_after_request=1 -dextension=../ext/google/protobuf/modules/protobuf.so memory_leak_test.php
  45. # TODO(teboring): Only for debug (phpunit has memory leak which blocks this beging used by
  46. # regresssion test.)
  47. # for t in "${tests[@]}"
  48. # do
  49. # echo "****************************"
  50. # echo "* $t (memory leak)"
  51. # echo "****************************"
  52. # valgrind --leak-check=yes php -dextension=../ext/google/protobuf/modules/protobuf.so $PHPUNIT --bootstrap autoload.php $t
  53. # echo ""
  54. # done