tests.sh 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796
  1. #!/bin/bash
  2. #
  3. # Build and runs tests for the protobuf project. We use this script to run
  4. # tests on kokoro (Ubuntu and MacOS). It can run locally as well but you
  5. # will need to make sure the required compilers/tools are available.
  6. # For when some other test needs the C++ main build, including protoc and
  7. # libprotobuf.
  8. LAST_RELEASED=3.9.0
  9. internal_build_cpp() {
  10. if [ -f src/protoc ]; then
  11. # Already built.
  12. return
  13. fi
  14. # Initialize any submodules.
  15. git submodule update --init --recursive
  16. ./autogen.sh
  17. ./configure CXXFLAGS="-fPIC -std=c++11" # -fPIC is needed for python cpp test.
  18. # See python/setup.py for more details
  19. make -j$(nproc)
  20. }
  21. build_cpp() {
  22. internal_build_cpp
  23. make check -j$(nproc) || (cat src/test-suite.log; false)
  24. cd conformance && make test_cpp && cd ..
  25. # The benchmark code depends on cmake, so test if it is installed before
  26. # trying to do the build.
  27. if [[ $(type cmake 2>/dev/null) ]]; then
  28. # Verify benchmarking code can build successfully.
  29. cd benchmarks && make cpp-benchmark && cd ..
  30. else
  31. echo ""
  32. echo "WARNING: Skipping validation of the bench marking code, cmake isn't installed."
  33. echo ""
  34. fi
  35. }
  36. build_cpp_tcmalloc() {
  37. internal_build_cpp
  38. ./configure LIBS=-ltcmalloc && make clean && make \
  39. PTHREAD_CFLAGS='-pthread -DGOOGLE_PROTOBUF_HEAP_CHECK_DRACONIAN' \
  40. check
  41. cd src
  42. PPROF_PATH=/usr/bin/google-pprof HEAPCHECK=strict ./protobuf-test
  43. }
  44. build_cpp_distcheck() {
  45. grep -q -- "-Og" src/Makefile.am &&
  46. echo "The -Og flag is incompatible with Clang versions older than 4.0." &&
  47. exit 1
  48. # Initialize any submodules.
  49. git submodule update --init --recursive
  50. ./autogen.sh
  51. ./configure
  52. make dist
  53. # List all files that should be included in the distribution package.
  54. git ls-files | grep "^\(java\|python\|objectivec\|csharp\|js\|ruby\|php\|cmake\|examples\|src/google/protobuf/.*\.proto\)" |\
  55. grep -v ".gitignore" | grep -v "java/compatibility_tests" |\
  56. grep -v "python/compatibility_tests" | grep -v "csharp/compatibility_tests" > dist.lst
  57. # Unzip the dist tar file.
  58. DIST=`ls *.tar.gz`
  59. tar -xf $DIST
  60. cd ${DIST//.tar.gz}
  61. # Check if every file exists in the dist tar file.
  62. FILES_MISSING=""
  63. for FILE in $(<../dist.lst); do
  64. [ -f "$FILE" ] || {
  65. echo "$FILE is not found!"
  66. FILES_MISSING="$FILE $FILES_MISSING"
  67. }
  68. done
  69. cd ..
  70. if [ ! -z "$FILES_MISSING" ]; then
  71. echo "Missing files in EXTRA_DIST: $FILES_MISSING"
  72. exit 1
  73. fi
  74. # Do the regular dist-check for C++.
  75. make distcheck -j$(nproc)
  76. }
  77. build_dist_install() {
  78. # Initialize any submodules.
  79. git submodule update --init --recursive
  80. ./autogen.sh
  81. ./configure
  82. make dist
  83. # Unzip the dist tar file and install it.
  84. DIST=`ls *.tar.gz`
  85. tar -xf $DIST
  86. pushd ${DIST//.tar.gz}
  87. ./configure && make check -j4 && make install
  88. export LD_LIBRARY_PATH=/usr/local/lib
  89. # Try to install Java
  90. pushd java
  91. use_java jdk7
  92. $MVN install
  93. popd
  94. # Try to install Python
  95. virtualenv --no-site-packages venv
  96. source venv/bin/activate
  97. pushd python
  98. python setup.py clean build sdist
  99. pip install dist/protobuf-*.tar.gz
  100. popd
  101. deactivate
  102. rm -rf python/venv
  103. }
  104. build_csharp() {
  105. # Required for conformance tests and to regenerate protos.
  106. internal_build_cpp
  107. NUGET=/usr/local/bin/nuget.exe
  108. # Disable some unwanted dotnet options
  109. export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true
  110. export DOTNET_CLI_TELEMETRY_OPTOUT=true
  111. # TODO(jtattermusch): is this still needed with "first time experience"
  112. # disabled?
  113. # Perform "dotnet new" once to get the setup preprocessing out of the
  114. # way. That spews a lot of output (including backspaces) into logs
  115. # otherwise, and can cause problems. It doesn't matter if this step
  116. # is performed multiple times; it's cheap after the first time anyway.
  117. # (It also doesn't matter if it's unnecessary, which it will be on some
  118. # systems. It's necessary on Jenkins in order to avoid unprintable
  119. # characters appearing in the JUnit output.)
  120. mkdir dotnettmp
  121. (cd dotnettmp; dotnet new > /dev/null)
  122. rm -rf dotnettmp
  123. # Check that the protos haven't broken C# codegen.
  124. # TODO(jonskeet): Fail if regenerating creates any changes.
  125. csharp/generate_protos.sh
  126. csharp/buildall.sh
  127. cd conformance && make test_csharp && cd ..
  128. # Run csharp compatibility test between 3.0.0 and the current version.
  129. csharp/compatibility_tests/v3.0.0/test.sh 3.0.0
  130. # Run csharp compatibility test between last released and the current version.
  131. csharp/compatibility_tests/v3.0.0/test.sh $LAST_RELEASED
  132. }
  133. build_golang() {
  134. # Go build needs `protoc`.
  135. internal_build_cpp
  136. # Add protoc to the path so that the examples build finds it.
  137. export PATH="`pwd`/src:$PATH"
  138. export GOPATH="$HOME/gocode"
  139. mkdir -p "$GOPATH/src/github.com/protocolbuffers"
  140. rm -f "$GOPATH/src/github.com/protocolbuffers/protobuf"
  141. ln -s "`pwd`" "$GOPATH/src/github.com/protocolbuffers/protobuf"
  142. export PATH="$GOPATH/bin:$PATH"
  143. go get github.com/golang/protobuf/protoc-gen-go
  144. cd examples && PROTO_PATH="-I../src -I." make gotest && cd ..
  145. }
  146. use_java() {
  147. version=$1
  148. case "$version" in
  149. jdk8)
  150. export PATH=/usr/lib/jvm/java-8-openjdk-amd64/bin:$PATH
  151. export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
  152. ;;
  153. jdk7)
  154. export PATH=/usr/lib/jvm/java-7-openjdk-amd64/bin:$PATH
  155. export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
  156. ;;
  157. oracle7)
  158. export PATH=/usr/lib/jvm/java-7-oracle/bin:$PATH
  159. export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
  160. ;;
  161. esac
  162. MAVEN_LOCAL_REPOSITORY=/var/maven_local_repository
  163. MVN="$MVN -e -X -Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=$MAVEN_LOCAL_REPOSITORY"
  164. which java
  165. java -version
  166. $MVN -version
  167. }
  168. # --batch-mode supresses download progress output that spams the logs.
  169. MVN="mvn --batch-mode"
  170. build_java() {
  171. version=$1
  172. dir=java_$version
  173. # Java build needs `protoc`.
  174. internal_build_cpp
  175. cp -r java $dir
  176. cd $dir && $MVN clean && $MVN test
  177. cd ../..
  178. }
  179. # The conformance tests are hard-coded to work with the $ROOT/java directory.
  180. # So this can't run in parallel with two different sets of tests.
  181. build_java_with_conformance_tests() {
  182. # Java build needs `protoc`.
  183. internal_build_cpp
  184. cd java && $MVN test && $MVN install
  185. cd util && $MVN package assembly:single
  186. cd ../..
  187. cd conformance && make test_java && cd ..
  188. }
  189. build_java_jdk7() {
  190. use_java jdk7
  191. build_java_with_conformance_tests
  192. }
  193. build_java_oracle7() {
  194. use_java oracle7
  195. build_java oracle7
  196. }
  197. build_java_compatibility() {
  198. use_java jdk7
  199. internal_build_cpp
  200. # Use the unit-tests extraced from 2.5.0 to test the compatibilty between
  201. # 3.0.0-beta-4 and the current version.
  202. cd java/compatibility_tests/v2.5.0
  203. ./test.sh 3.0.0-beta-4
  204. # Test the last released and current version.
  205. ./test.sh $LAST_RELEASED
  206. }
  207. build_java_linkage_monitor() {
  208. # Linkage Monitor checks compatibility with other Google libraries
  209. # https://github.com/GoogleCloudPlatform/cloud-opensource-java/tree/master/linkage-monitor
  210. use_java jdk8
  211. internal_build_cpp
  212. # Linkage Monitor uses $HOME/.m2 local repository
  213. MVN="mvn -e -B -Dhttps.protocols=TLSv1.2"
  214. cd java
  215. # Sets java artifact version with SNAPSHOT, as Linkage Monitor looks for SNAPSHOT versions.
  216. # Example: "3.9.0" (without 'rc')
  217. VERSION=`grep '<version>' pom.xml |head -1 |perl -nle 'print $1 if m/<version>(\d+\.\d+.\d+)/'`
  218. cd bom
  219. # This local installation avoids the problem caused by a new version not yet in Maven Central
  220. # https://github.com/protocolbuffers/protobuf/issues/6627
  221. $MVN install
  222. $MVN versions:set -DnewVersion=${VERSION}-SNAPSHOT
  223. cd ..
  224. $MVN versions:set -DnewVersion=${VERSION}-SNAPSHOT
  225. # Installs the snapshot version locally
  226. $MVN install -Dmaven.test.skip=true
  227. # Linkage Monitor uses the snapshot versions installed in $HOME/.m2 to verify compatibility
  228. JAR=linkage-monitor-latest-all-deps.jar
  229. curl -v -O "https://storage.googleapis.com/cloud-opensource-java-linkage-monitor/${JAR}"
  230. # Fails if there's new linkage errors compared with baseline
  231. java -jar $JAR com.google.cloud:libraries-bom
  232. }
  233. build_objectivec_ios() {
  234. # Reused the build script that takes care of configuring and ensuring things
  235. # are up to date. The OS X test runs the objc conformance test, so skip it
  236. # here.
  237. objectivec/DevTools/full_mac_build.sh \
  238. --core-only --skip-xcode-osx --skip-xcode-tvos --skip-objc-conformance "$@"
  239. }
  240. build_objectivec_ios_debug() {
  241. build_objectivec_ios --skip-xcode-release
  242. }
  243. build_objectivec_ios_release() {
  244. build_objectivec_ios --skip-xcode-debug
  245. }
  246. build_objectivec_osx() {
  247. # Reused the build script that takes care of configuring and ensuring things
  248. # are up to date.
  249. objectivec/DevTools/full_mac_build.sh \
  250. --core-only --skip-xcode-ios --skip-xcode-tvos
  251. }
  252. build_objectivec_tvos() {
  253. # Reused the build script that takes care of configuring and ensuring things
  254. # are up to date. The OS X test runs the objc conformance test, so skip it
  255. # here.
  256. objectivec/DevTools/full_mac_build.sh \
  257. --core-only --skip-xcode-ios --skip-xcode-osx --skip-objc-conformance "$@"
  258. }
  259. build_objectivec_tvos_debug() {
  260. build_objectivec_tvos --skip-xcode-release
  261. }
  262. build_objectivec_tvos_release() {
  263. build_objectivec_tvos --skip-xcode-debug
  264. }
  265. build_objectivec_cocoapods_integration() {
  266. # Update pod to the latest version.
  267. gem install cocoapods --no_document
  268. objectivec/Tests/CocoaPods/run_tests.sh
  269. }
  270. build_python() {
  271. internal_build_cpp
  272. cd python
  273. if [ $(uname -s) == "Linux" ]; then
  274. envlist=py\{27,33,34,35,36\}-python
  275. else
  276. envlist=py27-python
  277. fi
  278. tox -e $envlist
  279. cd ..
  280. }
  281. build_python_version() {
  282. internal_build_cpp
  283. cd python
  284. envlist=$1
  285. tox -e $envlist
  286. cd ..
  287. }
  288. build_python27() {
  289. build_python_version py27-python
  290. }
  291. build_python33() {
  292. build_python_version py33-python
  293. }
  294. build_python34() {
  295. build_python_version py34-python
  296. }
  297. build_python35() {
  298. build_python_version py35-python
  299. }
  300. build_python36() {
  301. build_python_version py36-python
  302. }
  303. build_python37() {
  304. build_python_version py37-python
  305. }
  306. build_python_cpp() {
  307. internal_build_cpp
  308. export LD_LIBRARY_PATH=../src/.libs # for Linux
  309. export DYLD_LIBRARY_PATH=../src/.libs # for OS X
  310. cd python
  311. if [ $(uname -s) == "Linux" ]; then
  312. envlist=py\{27,33,34,35,36\}-cpp
  313. else
  314. envlist=py27-cpp
  315. fi
  316. tox -e $envlist
  317. cd ..
  318. }
  319. build_python_cpp_version() {
  320. internal_build_cpp
  321. export LD_LIBRARY_PATH=../src/.libs # for Linux
  322. export DYLD_LIBRARY_PATH=../src/.libs # for OS X
  323. cd python
  324. envlist=$1
  325. tox -e $envlist
  326. cd ..
  327. }
  328. build_python27_cpp() {
  329. build_python_cpp_version py27-cpp
  330. }
  331. build_python33_cpp() {
  332. build_python_cpp_version py33-cpp
  333. }
  334. build_python34_cpp() {
  335. build_python_cpp_version py34-cpp
  336. }
  337. build_python35_cpp() {
  338. build_python_cpp_version py35-cpp
  339. }
  340. build_python36_cpp() {
  341. build_python_cpp_version py36-cpp
  342. }
  343. build_python37_cpp() {
  344. build_python_cpp_version py37-cpp
  345. }
  346. build_python_compatibility() {
  347. internal_build_cpp
  348. # Use the unit-tests extraced from 2.5.0 to test the compatibilty.
  349. cd python/compatibility_tests/v2.5.0
  350. # Test between 2.5.0 and the current version.
  351. ./test.sh 2.5.0
  352. # Test between 3.0.0-beta-1 and the current version.
  353. ./test.sh 3.0.0-beta-1
  354. # Test between last released and current version.
  355. ./test.sh $LAST_RELEASED
  356. }
  357. build_ruby23() {
  358. internal_build_cpp # For conformance tests.
  359. cd ruby && bash travis-test.sh ruby-2.3.8 && cd ..
  360. }
  361. build_ruby24() {
  362. internal_build_cpp # For conformance tests.
  363. cd ruby && bash travis-test.sh ruby-2.4 && cd ..
  364. }
  365. build_ruby25() {
  366. internal_build_cpp # For conformance tests.
  367. cd ruby && bash travis-test.sh ruby-2.5.1 && cd ..
  368. }
  369. build_ruby26() {
  370. internal_build_cpp # For conformance tests.
  371. cd ruby && bash travis-test.sh ruby-2.6.0 && cd ..
  372. }
  373. build_javascript() {
  374. internal_build_cpp
  375. cd js && npm install && npm test && cd ..
  376. cd conformance && make test_nodejs && cd ..
  377. }
  378. generate_php_test_proto() {
  379. internal_build_cpp
  380. pushd php/tests
  381. # Generate test file
  382. rm -rf generated
  383. mkdir generated
  384. ../../src/protoc --php_out=generated \
  385. -I../../src -I. \
  386. proto/empty/echo.proto \
  387. proto/test.proto \
  388. proto/test_include.proto \
  389. proto/test_no_namespace.proto \
  390. proto/test_prefix.proto \
  391. proto/test_php_namespace.proto \
  392. proto/test_empty_php_namespace.proto \
  393. proto/test_reserved_enum_lower.proto \
  394. proto/test_reserved_enum_upper.proto \
  395. proto/test_reserved_enum_value_lower.proto \
  396. proto/test_reserved_enum_value_upper.proto \
  397. proto/test_reserved_message_lower.proto \
  398. proto/test_reserved_message_upper.proto \
  399. proto/test_service.proto \
  400. proto/test_service_namespace.proto \
  401. proto/test_wrapper_type_setters.proto \
  402. proto/test_descriptors.proto
  403. pushd ../../src
  404. ./protoc --php_out=../php/tests/generated -I../php/tests -I. \
  405. ../php/tests/proto/test_import_descriptor_proto.proto
  406. popd
  407. popd
  408. }
  409. use_php() {
  410. VERSION=$1
  411. export PATH=/usr/local/php-${VERSION}/bin:$PATH
  412. export CPLUS_INCLUDE_PATH=/usr/local/php-${VERSION}/include/php/main:/usr/local/php-${VERSION}/include/php/:$CPLUS_INCLUDE_PATH
  413. export C_INCLUDE_PATH=/usr/local/php-${VERSION}/include/php/main:/usr/local/php-${VERSION}/include/php/:$C_INCLUDE_PATH
  414. generate_php_test_proto
  415. }
  416. use_php_zts() {
  417. VERSION=$1
  418. export PATH=/usr/local/php-${VERSION}-zts/bin:$PATH
  419. export CPLUS_INCLUDE_PATH=/usr/local/php-${VERSION}-zts/include/php/main:/usr/local/php-${VERSION}-zts/include/php/:$CPLUS_INCLUDE_PATH
  420. export C_INCLUDE_PATH=/usr/local/php-${VERSION}-zts/include/php/main:/usr/local/php-${VERSION}-zts/include/php/:$C_INCLUDE_PATH
  421. generate_php_test_proto
  422. }
  423. use_php_bc() {
  424. VERSION=$1
  425. export PATH=/usr/local/php-${VERSION}-bc/bin:$PATH
  426. export CPLUS_INCLUDE_PATH=/usr/local/php-${VERSION}-bc/include/php/main:/usr/local/php-${VERSION}-bc/include/php/:$CPLUS_INCLUDE_PATH
  427. export C_INCLUDE_PATH=/usr/local/php-${VERSION}-bc/include/php/main:/usr/local/php-${VERSION}-bc/include/php/:$C_INCLUDE_PATH
  428. generate_php_test_proto
  429. }
  430. build_php5.5() {
  431. use_php 5.5
  432. pushd php
  433. rm -rf vendor
  434. composer update
  435. ./vendor/bin/phpunit
  436. popd
  437. pushd conformance
  438. make test_php
  439. popd
  440. }
  441. build_php5.5_c() {
  442. use_php 5.5
  443. pushd php/tests
  444. /bin/bash ./test.sh 5.5
  445. popd
  446. # TODO(teboring): Add it back
  447. # pushd conformance
  448. # make test_php_c
  449. # popd
  450. }
  451. build_php5.5_mixed() {
  452. use_php 5.5
  453. pushd php
  454. rm -rf vendor
  455. composer update
  456. /bin/bash ./tests/compile_extension.sh ./ext/google/protobuf
  457. php -dextension=./ext/google/protobuf/modules/protobuf.so ./vendor/bin/phpunit
  458. popd
  459. }
  460. build_php5.5_zts_c() {
  461. use_php_zts 5.5
  462. cd php/tests && /bin/bash ./test.sh 5.5-zts && cd ../..
  463. # TODO(teboring): Add it back
  464. # pushd conformance
  465. # make test_php_zts_c
  466. # popd
  467. }
  468. build_php5.6() {
  469. use_php 5.6
  470. pushd php
  471. rm -rf vendor
  472. composer update
  473. ./vendor/bin/phpunit
  474. popd
  475. pushd conformance
  476. make test_php
  477. popd
  478. }
  479. build_php5.6_c() {
  480. use_php 5.6
  481. cd php/tests && /bin/bash ./test.sh 5.6 && cd ../..
  482. # TODO(teboring): Add it back
  483. # pushd conformance
  484. # make test_php_c
  485. # popd
  486. }
  487. build_php5.6_mixed() {
  488. use_php 5.6
  489. pushd php
  490. rm -rf vendor
  491. composer update
  492. /bin/bash ./tests/compile_extension.sh ./ext/google/protobuf
  493. php -dextension=./ext/google/protobuf/modules/protobuf.so ./vendor/bin/phpunit
  494. popd
  495. }
  496. build_php5.6_zts_c() {
  497. use_php_zts 5.6
  498. cd php/tests && /bin/bash ./test.sh 5.6-zts && cd ../..
  499. # TODO(teboring): Add it back
  500. # pushd conformance
  501. # make test_php_zts_c
  502. # popd
  503. }
  504. build_php5.6_mac() {
  505. generate_php_test_proto
  506. # Install PHP
  507. curl -s https://php-osx.liip.ch/install.sh | bash -s 5.6
  508. PHP_FOLDER=`find /usr/local -type d -name "php5-5.6*"` # The folder name may change upon time
  509. export PATH="$PHP_FOLDER/bin:$PATH"
  510. # Install phpunit
  511. curl https://phar.phpunit.de/phpunit-5.6.8.phar -L -o phpunit.phar
  512. chmod +x phpunit.phar
  513. sudo mv phpunit.phar /usr/local/bin/phpunit
  514. # Install valgrind
  515. echo "#! /bin/bash" > valgrind
  516. chmod ug+x valgrind
  517. sudo mv valgrind /usr/local/bin/valgrind
  518. # Test
  519. cd php/tests && /bin/bash ./test.sh && cd ../..
  520. # TODO(teboring): Add it back
  521. # pushd conformance
  522. # make test_php_c
  523. # popd
  524. }
  525. build_php7.0() {
  526. use_php 7.0
  527. pushd php
  528. rm -rf vendor
  529. composer update
  530. ./vendor/bin/phpunit
  531. popd
  532. pushd conformance
  533. make test_php
  534. popd
  535. }
  536. build_php7.0_c() {
  537. use_php 7.0
  538. cd php/tests && /bin/bash ./test.sh 7.0 && cd ../..
  539. # TODO(teboring): Add it back
  540. # pushd conformance
  541. # make test_php_c
  542. # popd
  543. }
  544. build_php7.0_mixed() {
  545. use_php 7.0
  546. pushd php
  547. rm -rf vendor
  548. composer update
  549. /bin/bash ./tests/compile_extension.sh ./ext/google/protobuf
  550. php -dextension=./ext/google/protobuf/modules/protobuf.so ./vendor/bin/phpunit
  551. popd
  552. }
  553. build_php7.0_zts_c() {
  554. use_php_zts 7.0
  555. cd php/tests && /bin/bash ./test.sh 7.0-zts && cd ../..
  556. # TODO(teboring): Add it back.
  557. # pushd conformance
  558. # make test_php_zts_c
  559. # popd
  560. }
  561. build_php7.0_mac() {
  562. generate_php_test_proto
  563. # Install PHP
  564. curl -s https://php-osx.liip.ch/install.sh | bash -s 7.0
  565. PHP_FOLDER=`find /usr/local -type d -name "php7-7.0*"` # The folder name may change upon time
  566. export PATH="$PHP_FOLDER/bin:$PATH"
  567. # Install phpunit
  568. curl https://phar.phpunit.de/phpunit-5.6.0.phar -L -o phpunit.phar
  569. chmod +x phpunit.phar
  570. sudo mv phpunit.phar /usr/local/bin/phpunit
  571. # Install valgrind
  572. echo "#! /bin/bash" > valgrind
  573. chmod ug+x valgrind
  574. sudo mv valgrind /usr/local/bin/valgrind
  575. # Test
  576. cd php/tests && /bin/bash ./test.sh && cd ../..
  577. # TODO(teboring): Add it back
  578. # pushd conformance
  579. # make test_php_c
  580. # popd
  581. }
  582. build_php_compatibility() {
  583. internal_build_cpp
  584. php/tests/compatibility_test.sh $LAST_RELEASED
  585. }
  586. build_php7.1() {
  587. use_php 7.1
  588. pushd php
  589. rm -rf vendor
  590. composer update
  591. ./vendor/bin/phpunit
  592. popd
  593. pushd conformance
  594. make test_php
  595. popd
  596. }
  597. build_php7.1_c() {
  598. ENABLE_CONFORMANCE_TEST=$1
  599. use_php 7.1
  600. cd php/tests && /bin/bash ./test.sh 7.1 && cd ../..
  601. if [ "$ENABLE_CONFORMANCE_TEST" = "true" ]
  602. then
  603. pushd conformance
  604. make test_php_c
  605. popd
  606. fi
  607. }
  608. build_php7.1_mixed() {
  609. use_php 7.1
  610. pushd php
  611. rm -rf vendor
  612. composer update
  613. /bin/bash ./tests/compile_extension.sh ./ext/google/protobuf
  614. php -dextension=./ext/google/protobuf/modules/protobuf.so ./vendor/bin/phpunit
  615. popd
  616. }
  617. build_php7.1_zts_c() {
  618. use_php_zts 7.1
  619. cd php/tests && /bin/bash ./test.sh 7.1-zts && cd ../..
  620. pushd conformance
  621. # make test_php_c
  622. popd
  623. }
  624. build_php_all_32() {
  625. build_php5.5
  626. build_php5.6
  627. build_php7.0
  628. build_php7.1
  629. build_php5.5_c
  630. build_php5.6_c
  631. build_php7.0_c
  632. build_php7.1_c $1
  633. build_php5.5_mixed
  634. build_php5.6_mixed
  635. build_php7.0_mixed
  636. build_php7.1_mixed
  637. build_php5.5_zts_c
  638. build_php5.6_zts_c
  639. build_php7.0_zts_c
  640. build_php7.1_zts_c
  641. }
  642. build_php_all() {
  643. build_php_all_32 true
  644. build_php_compatibility
  645. }
  646. build_benchmark() {
  647. use_php 7.2
  648. cd kokoro/linux/benchmark && ./run.sh
  649. }
  650. # -------- main --------
  651. if [ "$#" -ne 1 ]; then
  652. echo "
  653. Usage: $0 { cpp |
  654. cpp_distcheck |
  655. csharp |
  656. java_jdk7 |
  657. java_oracle7 |
  658. java_compatibility |
  659. java_linkage_monitor |
  660. objectivec_ios |
  661. objectivec_ios_debug |
  662. objectivec_ios_release |
  663. objectivec_osx |
  664. objectivec_tvos |
  665. objectivec_tvos_debug |
  666. objectivec_tvos_release |
  667. objectivec_cocoapods_integration |
  668. python |
  669. python_cpp |
  670. python_compatibility |
  671. ruby23 |
  672. ruby24 |
  673. ruby25 |
  674. ruby26 |
  675. jruby |
  676. ruby_all |
  677. php5.5 |
  678. php5.5_c |
  679. php5.6 |
  680. php5.6_c |
  681. php7.0 |
  682. php7.0_c |
  683. php_compatibility |
  684. php7.1 |
  685. php7.1_c |
  686. php_all |
  687. dist_install |
  688. benchmark)
  689. "
  690. exit 1
  691. fi
  692. set -e # exit immediately on error
  693. set -x # display all commands
  694. cd $(dirname $0)
  695. eval "build_$1"