1#!/bin/bash 2 3set -ex 4 5cd $(dirname $0) 6 7./generate_protos.sh 8./compile_extension.sh 9 10PHP_VERSION=$(php -r "echo PHP_VERSION;") 11 12# Each version of PHPUnit supports a fairly narrow range of PHP versions. 13case "$PHP_VERSION" in 14 7.0.*|7.1.*|7.2.*) 15 # Oddly older than for 5.6. Not sure the reason. 16 PHPUNIT=phpunit-5.6.0.phar 17 ;; 18 7.3.*|7.4.*) 19 PHPUNIT=phpunit-8.phar 20 ;; 21 8.0.*) 22 PHPUNIT=phpunit-9.phar 23 ;; 24 *) 25 echo "ERROR: Unsupported PHP version $PHP_VERSION" 26 exit 1 27 ;; 28esac 29 30[ -f $PHPUNIT ] || wget https://phar.phpunit.de/$PHPUNIT 31 32tests=( ArrayTest.php EncodeDecodeTest.php GeneratedClassTest.php MapFieldTest.php WellKnownTest.php DescriptorsTest.php WrapperTypeSettersTest.php) 33 34for t in "${tests[@]}" 35do 36 echo "****************************" 37 echo "* $t" 38 echo "****************************" 39 php -dextension=../ext/google/protobuf/modules/protobuf.so $PHPUNIT --bootstrap autoload.php $t 40 echo "" 41done 42 43for t in "${tests[@]}" 44do 45 echo "****************************" 46 echo "* $t persistent" 47 echo "****************************" 48 php -d protobuf.keep_descriptor_pool_after_request=1 -dextension=../ext/google/protobuf/modules/protobuf.so $PHPUNIT --bootstrap autoload.php $t 49 echo "" 50done 51 52# # Make sure to run the memory test in debug mode. 53# php -dextension=../ext/google/protobuf/modules/protobuf.so memory_leak_test.php 54 55export ZEND_DONT_UNLOAD_MODULES=1 56export USE_ZEND_ALLOC=0 57valgrind --suppressions=valgrind.supp --leak-check=yes php -dextension=../ext/google/protobuf/modules/protobuf.so memory_leak_test.php 58valgrind --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 59 60# TODO(teboring): Only for debug (phpunit has memory leak which blocks this beging used by 61# regresssion test.) 62 63# for t in "${tests[@]}" 64# do 65# echo "****************************" 66# echo "* $t (memory leak)" 67# echo "****************************" 68# valgrind --leak-check=yes php -dextension=../ext/google/protobuf/modules/protobuf.so $PHPUNIT --bootstrap autoload.php $t 69# echo "" 70# done 71