test.sh 2.1 KB

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