test.sh 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. 8.0.*)
  17. PHPUNIT=phpunit-9.phar
  18. ;;
  19. *)
  20. echo "ERROR: Unsupported PHP version $PHP_VERSION"
  21. exit 1
  22. ;;
  23. esac
  24. [ -f $PHPUNIT ] || wget https://phar.phpunit.de/$PHPUNIT
  25. tests=( ArrayTest.php EncodeDecodeTest.php GeneratedClassTest.php MapFieldTest.php WellKnownTest.php DescriptorsTest.php WrapperTypeSettersTest.php)
  26. for t in "${tests[@]}"
  27. do
  28. echo "****************************"
  29. echo "* $t"
  30. echo "****************************"
  31. php -dextension=../ext/google/protobuf/modules/protobuf.so $PHPUNIT --bootstrap autoload.php $t
  32. echo ""
  33. done
  34. for t in "${tests[@]}"
  35. do
  36. echo "****************************"
  37. echo "* $t persistent"
  38. echo "****************************"
  39. php -d protobuf.keep_descriptor_pool_after_request=1 -dextension=../ext/google/protobuf/modules/protobuf.so $PHPUNIT --bootstrap autoload.php $t
  40. echo ""
  41. done
  42. # # Make sure to run the memory test in debug mode.
  43. # php -dextension=../ext/google/protobuf/modules/protobuf.so memory_leak_test.php
  44. export ZEND_DONT_UNLOAD_MODULES=1
  45. export USE_ZEND_ALLOC=0
  46. valgrind --suppressions=valgrind.supp --leak-check=yes php -dextension=../ext/google/protobuf/modules/protobuf.so memory_leak_test.php
  47. 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
  48. # TODO(teboring): Only for debug (phpunit has memory leak which blocks this beging used by
  49. # regression test.)
  50. # for t in "${tests[@]}"
  51. # do
  52. # echo "****************************"
  53. # echo "* $t (memory leak)"
  54. # echo "****************************"
  55. # valgrind --leak-check=yes php -dextension=../ext/google/protobuf/modules/protobuf.so $PHPUNIT --bootstrap autoload.php $t
  56. # echo ""
  57. # done