tests.sh 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939
  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" | grep -v "java/lite/proguard.pgcfg" |\
  56. grep -v "python/compatibility_tests" | grep -v "python/docs" | grep -v "python/.repo-metadata.json" |\
  57. grep -v "csharp/compatibility_tests" > dist.lst
  58. # Unzip the dist tar file.
  59. DIST=`ls *.tar.gz`
  60. tar -xf $DIST
  61. cd ${DIST//.tar.gz}
  62. # Check if every file exists in the dist tar file.
  63. FILES_MISSING=""
  64. for FILE in $(<../dist.lst); do
  65. [ -f "$FILE" ] || {
  66. echo "$FILE is not found!"
  67. FILES_MISSING="$FILE $FILES_MISSING"
  68. }
  69. done
  70. cd ..
  71. if [ ! -z "$FILES_MISSING" ]; then
  72. echo "Missing files in EXTRA_DIST: $FILES_MISSING"
  73. exit 1
  74. fi
  75. # Do the regular dist-check for C++.
  76. make distcheck -j$(nproc)
  77. }
  78. build_dist_install() {
  79. # Initialize any submodules.
  80. git submodule update --init --recursive
  81. ./autogen.sh
  82. ./configure
  83. make dist
  84. # Unzip the dist tar file and install it.
  85. DIST=`ls *.tar.gz`
  86. tar -xf $DIST
  87. pushd ${DIST//.tar.gz}
  88. ./configure && make check -j4 && make install
  89. export LD_LIBRARY_PATH=/usr/local/lib
  90. # Try to install Java
  91. pushd java
  92. use_java jdk7
  93. $MVN install
  94. popd
  95. # Try to install Python
  96. virtualenv --no-site-packages venv
  97. source venv/bin/activate
  98. pushd python
  99. python setup.py clean build sdist
  100. pip install dist/protobuf-*.tar.gz
  101. popd
  102. deactivate
  103. rm -rf python/venv
  104. }
  105. build_csharp() {
  106. # Required for conformance tests and to regenerate protos.
  107. internal_build_cpp
  108. NUGET=/usr/local/bin/nuget.exe
  109. # Disable some unwanted dotnet options
  110. export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true
  111. export DOTNET_CLI_TELEMETRY_OPTOUT=true
  112. # TODO(jtattermusch): is this still needed with "first time experience"
  113. # disabled?
  114. # Perform "dotnet new" once to get the setup preprocessing out of the
  115. # way. That spews a lot of output (including backspaces) into logs
  116. # otherwise, and can cause problems. It doesn't matter if this step
  117. # is performed multiple times; it's cheap after the first time anyway.
  118. # (It also doesn't matter if it's unnecessary, which it will be on some
  119. # systems. It's necessary on Jenkins in order to avoid unprintable
  120. # characters appearing in the JUnit output.)
  121. mkdir dotnettmp
  122. (cd dotnettmp; dotnet new > /dev/null)
  123. rm -rf dotnettmp
  124. # Check that the protos haven't broken C# codegen.
  125. # TODO(jonskeet): Fail if regenerating creates any changes.
  126. csharp/generate_protos.sh
  127. csharp/buildall.sh
  128. cd conformance && make test_csharp && cd ..
  129. # Run csharp compatibility test between 3.0.0 and the current version.
  130. csharp/compatibility_tests/v3.0.0/test.sh 3.0.0
  131. # Run csharp compatibility test between last released and the current version.
  132. csharp/compatibility_tests/v3.0.0/test.sh $LAST_RELEASED
  133. }
  134. build_golang() {
  135. # Go build needs `protoc`.
  136. internal_build_cpp
  137. # Add protoc to the path so that the examples build finds it.
  138. export PATH="`pwd`/src:$PATH"
  139. export GOPATH="$HOME/gocode"
  140. mkdir -p "$GOPATH/src/github.com/protocolbuffers"
  141. rm -f "$GOPATH/src/github.com/protocolbuffers/protobuf"
  142. ln -s "`pwd`" "$GOPATH/src/github.com/protocolbuffers/protobuf"
  143. export PATH="$GOPATH/bin:$PATH"
  144. go get github.com/golang/protobuf/protoc-gen-go
  145. cd examples && PROTO_PATH="-I../src -I." make gotest && cd ..
  146. }
  147. use_java() {
  148. version=$1
  149. case "$version" in
  150. jdk8)
  151. export PATH=/usr/lib/jvm/java-8-openjdk-amd64/bin:$PATH
  152. export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
  153. ;;
  154. jdk7)
  155. export PATH=/usr/lib/jvm/java-7-openjdk-amd64/bin:$PATH
  156. export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
  157. ;;
  158. oracle7)
  159. export PATH=/usr/lib/jvm/java-7-oracle/bin:$PATH
  160. export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
  161. ;;
  162. esac
  163. MAVEN_LOCAL_REPOSITORY=/var/maven_local_repository
  164. MVN="$MVN -e -X -Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=$MAVEN_LOCAL_REPOSITORY"
  165. which java
  166. java -version
  167. $MVN -version
  168. }
  169. # --batch-mode suppresses download progress output that spams the logs.
  170. MVN="mvn --batch-mode"
  171. build_java() {
  172. version=$1
  173. dir=java_$version
  174. # Java build needs `protoc`.
  175. internal_build_cpp
  176. cp -r java $dir
  177. cd $dir && $MVN clean && $MVN test
  178. cd ../..
  179. }
  180. # The conformance tests are hard-coded to work with the $ROOT/java directory.
  181. # So this can't run in parallel with two different sets of tests.
  182. build_java_with_conformance_tests() {
  183. # Java build needs `protoc`.
  184. internal_build_cpp
  185. # This local installation avoids the problem caused by a new version not yet in Maven Central
  186. cd java/bom && $MVN install
  187. cd ../..
  188. cd java && $MVN test && $MVN install
  189. cd util && $MVN package assembly:single
  190. cd ../..
  191. cd conformance && make test_java && cd ..
  192. }
  193. build_java_jdk7() {
  194. use_java jdk7
  195. build_java_with_conformance_tests
  196. }
  197. build_java_oracle7() {
  198. use_java oracle7
  199. build_java oracle7
  200. }
  201. build_java_compatibility() {
  202. use_java jdk7
  203. internal_build_cpp
  204. # Use the unit-tests extracted from 2.5.0 to test the compatibility between
  205. # 3.0.0-beta-4 and the current version.
  206. cd java/compatibility_tests/v2.5.0
  207. ./test.sh 3.0.0-beta-4
  208. # Test the last released and current version.
  209. ./test.sh $LAST_RELEASED
  210. }
  211. build_java_linkage_monitor() {
  212. # Linkage Monitor checks compatibility with other Google libraries
  213. # https://github.com/GoogleCloudPlatform/cloud-opensource-java/tree/master/linkage-monitor
  214. use_java jdk8
  215. internal_build_cpp
  216. # Linkage Monitor uses $HOME/.m2 local repository
  217. MVN="mvn -e -B -Dhttps.protocols=TLSv1.2"
  218. cd java
  219. # Installs the snapshot version locally
  220. $MVN install -Dmaven.test.skip=true
  221. # Linkage Monitor uses the snapshot versions installed in $HOME/.m2 to verify compatibility
  222. JAR=linkage-monitor-latest-all-deps.jar
  223. curl -v -O "https://storage.googleapis.com/cloud-opensource-java-linkage-monitor/${JAR}"
  224. # Fails if there's new linkage errors compared with baseline
  225. java -jar $JAR com.google.cloud:libraries-bom
  226. }
  227. build_objectivec_ios() {
  228. # Reused the build script that takes care of configuring and ensuring things
  229. # are up to date. The OS X test runs the objc conformance test, so skip it
  230. # here.
  231. objectivec/DevTools/full_mac_build.sh \
  232. --core-only --skip-xcode-osx --skip-xcode-tvos --skip-objc-conformance "$@"
  233. }
  234. build_objectivec_ios_debug() {
  235. build_objectivec_ios --skip-xcode-release
  236. }
  237. build_objectivec_ios_release() {
  238. build_objectivec_ios --skip-xcode-debug
  239. }
  240. build_objectivec_osx() {
  241. # Reused the build script that takes care of configuring and ensuring things
  242. # are up to date.
  243. objectivec/DevTools/full_mac_build.sh \
  244. --core-only --skip-xcode-ios --skip-xcode-tvos
  245. }
  246. build_objectivec_tvos() {
  247. # Reused the build script that takes care of configuring and ensuring things
  248. # are up to date. The OS X test runs the objc conformance test, so skip it
  249. # here.
  250. objectivec/DevTools/full_mac_build.sh \
  251. --core-only --skip-xcode-ios --skip-xcode-osx --skip-objc-conformance "$@"
  252. }
  253. build_objectivec_tvos_debug() {
  254. build_objectivec_tvos --skip-xcode-release
  255. }
  256. build_objectivec_tvos_release() {
  257. build_objectivec_tvos --skip-xcode-debug
  258. }
  259. build_objectivec_cocoapods_integration() {
  260. # Update pod to the latest version.
  261. gem install cocoapods --no_document
  262. objectivec/Tests/CocoaPods/run_tests.sh
  263. }
  264. build_python() {
  265. internal_build_cpp
  266. cd python
  267. if [ $(uname -s) == "Linux" ]; then
  268. envlist=py\{27,33,34,35,36\}-python
  269. else
  270. envlist=py27-python
  271. fi
  272. tox -e $envlist
  273. cd ..
  274. }
  275. build_python_version() {
  276. internal_build_cpp
  277. cd python
  278. envlist=$1
  279. tox -e $envlist
  280. cd ..
  281. }
  282. build_python27() {
  283. build_python_version py27-python
  284. }
  285. build_python33() {
  286. build_python_version py33-python
  287. }
  288. build_python34() {
  289. build_python_version py34-python
  290. }
  291. build_python35() {
  292. build_python_version py35-python
  293. }
  294. build_python36() {
  295. build_python_version py36-python
  296. }
  297. build_python37() {
  298. build_python_version py37-python
  299. }
  300. build_python38() {
  301. build_python_version py38-python
  302. }
  303. build_python_cpp() {
  304. internal_build_cpp
  305. export LD_LIBRARY_PATH=../src/.libs # for Linux
  306. export DYLD_LIBRARY_PATH=../src/.libs # for OS X
  307. cd python
  308. if [ $(uname -s) == "Linux" ]; then
  309. envlist=py\{27,33,34,35,36\}-cpp
  310. else
  311. envlist=py27-cpp
  312. fi
  313. tox -e $envlist
  314. cd ..
  315. }
  316. build_python_cpp_version() {
  317. internal_build_cpp
  318. export LD_LIBRARY_PATH=../src/.libs # for Linux
  319. export DYLD_LIBRARY_PATH=../src/.libs # for OS X
  320. cd python
  321. envlist=$1
  322. tox -e $envlist
  323. cd ..
  324. }
  325. build_python27_cpp() {
  326. build_python_cpp_version py27-cpp
  327. }
  328. build_python33_cpp() {
  329. build_python_cpp_version py33-cpp
  330. }
  331. build_python34_cpp() {
  332. build_python_cpp_version py34-cpp
  333. }
  334. build_python35_cpp() {
  335. build_python_cpp_version py35-cpp
  336. }
  337. build_python36_cpp() {
  338. build_python_cpp_version py36-cpp
  339. }
  340. build_python37_cpp() {
  341. build_python_cpp_version py37-cpp
  342. }
  343. build_python38_cpp() {
  344. build_python_cpp_version py38-cpp
  345. }
  346. build_python_compatibility() {
  347. internal_build_cpp
  348. # Use the unit-tests extracted from 2.5.0 to test the compatibility.
  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. IS_64BIT=$1
  443. use_php 5.5
  444. pushd php/tests
  445. /bin/bash ./test.sh 5.5
  446. popd
  447. pushd conformance
  448. if [ "$IS_64BIT" = "true" ]
  449. then
  450. make test_php_c
  451. else
  452. make test_php_c_32
  453. fi
  454. popd
  455. }
  456. build_php5.5_mixed() {
  457. use_php 5.5
  458. pushd php
  459. rm -rf vendor
  460. composer update
  461. pushd tests
  462. /bin/bash ./compile_extension.sh 5.5
  463. popd
  464. php -dextension=./ext/google/protobuf/modules/protobuf.so ./vendor/bin/phpunit
  465. popd
  466. }
  467. build_php5.5_zts_c() {
  468. IS_64BIT=$1
  469. use_php_zts 5.5
  470. cd php/tests && /bin/bash ./test.sh 5.5-zts && cd ../..
  471. pushd conformance
  472. if [ "$IS_64BIT" = "true" ]
  473. then
  474. make test_php_c
  475. else
  476. make test_php_c_32
  477. fi
  478. popd
  479. }
  480. build_php5.6() {
  481. use_php 5.6
  482. pushd php
  483. rm -rf vendor
  484. composer update
  485. ./vendor/bin/phpunit
  486. popd
  487. pushd conformance
  488. make test_php
  489. popd
  490. }
  491. build_php5.6_c() {
  492. IS_64BIT=$1
  493. use_php 5.6
  494. cd php/tests && /bin/bash ./test.sh 5.6 && cd ../..
  495. pushd conformance
  496. if [ "$IS_64BIT" = "true" ]
  497. then
  498. make test_php_c
  499. else
  500. make test_php_c_32
  501. fi
  502. popd
  503. }
  504. build_php5.6_mixed() {
  505. use_php 5.6
  506. pushd php
  507. rm -rf vendor
  508. composer update
  509. pushd tests
  510. /bin/bash ./compile_extension.sh 5.6
  511. popd
  512. php -dextension=./ext/google/protobuf/modules/protobuf.so ./vendor/bin/phpunit
  513. popd
  514. }
  515. build_php5.6_zts_c() {
  516. IS_64BIT=$1
  517. use_php_zts 5.6
  518. cd php/tests && /bin/bash ./test.sh 5.6-zts && cd ../..
  519. pushd conformance
  520. if [ "$IS_64BIT" = "true" ]
  521. then
  522. make test_php_c
  523. else
  524. make test_php_c_32
  525. fi
  526. popd
  527. }
  528. build_php5.6_mac() {
  529. generate_php_test_proto
  530. # Install PHP
  531. curl -s https://php-osx.liip.ch/install.sh | bash -s 5.6
  532. PHP_FOLDER=`find /usr/local -type d -name "php5-5.6*"` # The folder name may change upon time
  533. export PATH="$PHP_FOLDER/bin:$PATH"
  534. # Install phpunit
  535. curl https://phar.phpunit.de/phpunit-5.6.8.phar -L -o phpunit.phar
  536. chmod +x phpunit.phar
  537. sudo mv phpunit.phar /usr/local/bin/phpunit
  538. # Install valgrind
  539. echo "#! /bin/bash" > valgrind
  540. chmod ug+x valgrind
  541. sudo mv valgrind /usr/local/bin/valgrind
  542. # Test
  543. cd php/tests && /bin/bash ./test.sh && cd ../..
  544. pushd conformance
  545. make test_php_c
  546. popd
  547. }
  548. build_php7.0() {
  549. use_php 7.0
  550. pushd php
  551. rm -rf vendor
  552. composer update
  553. ./vendor/bin/phpunit
  554. popd
  555. pushd conformance
  556. make test_php
  557. popd
  558. }
  559. build_php7.0_c() {
  560. IS_64BIT=$1
  561. use_php 7.0
  562. cd php/tests && /bin/bash ./test.sh 7.0 && cd ../..
  563. pushd conformance
  564. if [ "$IS_64BIT" = "true" ]
  565. then
  566. make test_php_c
  567. else
  568. make test_php_c_32
  569. fi
  570. popd
  571. }
  572. build_php7.0_mixed() {
  573. use_php 7.0
  574. pushd php
  575. rm -rf vendor
  576. composer update
  577. pushd tests
  578. /bin/bash ./compile_extension.sh 7.0
  579. popd
  580. php -dextension=./ext/google/protobuf/modules/protobuf.so ./vendor/bin/phpunit
  581. popd
  582. }
  583. build_php7.0_zts_c() {
  584. IS_64BIT=$1
  585. use_php_zts 7.0
  586. cd php/tests && /bin/bash ./test.sh 7.0-zts && cd ../..
  587. pushd conformance
  588. if [ "$IS_64BIT" = "true" ]
  589. then
  590. make test_php_c
  591. else
  592. make test_php_c_32
  593. fi
  594. popd
  595. }
  596. build_php7.0_mac() {
  597. generate_php_test_proto
  598. # Install PHP
  599. curl -s https://php-osx.liip.ch/install.sh | bash -s 7.0
  600. PHP_FOLDER=`find /usr/local -type d -name "php7-7.0*"` # The folder name may change upon time
  601. export PATH="$PHP_FOLDER/bin:$PATH"
  602. # Install phpunit
  603. curl https://phar.phpunit.de/phpunit-5.6.0.phar -L -o phpunit.phar
  604. chmod +x phpunit.phar
  605. sudo mv phpunit.phar /usr/local/bin/phpunit
  606. # Install valgrind
  607. echo "#! /bin/bash" > valgrind
  608. chmod ug+x valgrind
  609. sudo mv valgrind /usr/local/bin/valgrind
  610. # Test
  611. cd php/tests && /bin/bash ./test.sh && cd ../..
  612. pushd conformance
  613. make test_php_c
  614. popd
  615. }
  616. build_php7.4_mac() {
  617. generate_php_test_proto
  618. # Install PHP
  619. curl -s https://php-osx.liip.ch/install.sh | bash -s 7.4
  620. PHP_FOLDER=`find /usr/local -type d -name "php7-7.4*"` # The folder name may change upon time
  621. export PATH="$PHP_FOLDER/bin:$PATH"
  622. # Install phpunit
  623. curl https://phar.phpunit.de/phpunit-8.phar -L -o phpunit.phar
  624. chmod +x phpunit.phar
  625. sudo mv phpunit.phar /usr/local/bin/phpunit
  626. # Install valgrind
  627. echo "#! /bin/bash" > valgrind
  628. chmod ug+x valgrind
  629. sudo mv valgrind /usr/local/bin/valgrind
  630. # Test
  631. cd php/tests && /bin/bash ./test.sh && cd ../..
  632. pushd conformance
  633. make test_php_c
  634. popd
  635. }
  636. build_php_compatibility() {
  637. internal_build_cpp
  638. php/tests/compatibility_test.sh $LAST_RELEASED
  639. }
  640. build_php_multirequest() {
  641. use_php 7.4
  642. pushd php/tests
  643. ./multirequest.sh
  644. popd
  645. }
  646. build_php7.1() {
  647. use_php 7.1
  648. pushd php
  649. rm -rf vendor
  650. composer update
  651. ./vendor/bin/phpunit
  652. popd
  653. pushd conformance
  654. make test_php
  655. popd
  656. }
  657. build_php7.1_c() {
  658. IS_64BIT=$1
  659. use_php 7.1
  660. cd php/tests && /bin/bash ./test.sh 7.1 && cd ../..
  661. pushd conformance
  662. if [ "$IS_64BIT" = "true" ]
  663. then
  664. make test_php_c
  665. else
  666. make test_php_c_32
  667. fi
  668. popd
  669. }
  670. build_php7.1_mixed() {
  671. use_php 7.1
  672. pushd php
  673. rm -rf vendor
  674. composer update
  675. pushd tests
  676. /bin/bash ./compile_extension.sh 7.1
  677. popd
  678. php -dextension=./ext/google/protobuf/modules/protobuf.so ./vendor/bin/phpunit
  679. popd
  680. }
  681. build_php7.1_zts_c() {
  682. IS_64BIT=$1
  683. use_php_zts 7.1
  684. cd php/tests && /bin/bash ./test.sh 7.1-zts && cd ../..
  685. pushd conformance
  686. if [ "$IS_64BIT" = "true" ]
  687. then
  688. make test_php_c
  689. else
  690. make test_php_c_32
  691. fi
  692. popd
  693. }
  694. build_php7.4() {
  695. use_php 7.4
  696. pushd php
  697. rm -rf vendor
  698. composer update
  699. ./vendor/bin/phpunit
  700. popd
  701. pushd conformance
  702. make test_php
  703. popd
  704. }
  705. build_php7.4_c() {
  706. IS_64BIT=$1
  707. use_php 7.4
  708. cd php/tests && /bin/bash ./test.sh 7.4 && cd ../..
  709. pushd conformance
  710. if [ "$IS_64BIT" = "true" ]
  711. then
  712. make test_php_c
  713. else
  714. make test_php_c_32
  715. fi
  716. popd
  717. pushd php/ext/google/protobuf
  718. phpize --clean
  719. popd
  720. }
  721. build_php7.4_mixed() {
  722. use_php 7.4
  723. pushd php
  724. rm -rf vendor
  725. composer update
  726. pushd tests
  727. /bin/bash ./compile_extension.sh 7.4
  728. popd
  729. php -dextension=./ext/google/protobuf/modules/protobuf.so ./vendor/bin/phpunit
  730. popd
  731. pushd php/ext/google/protobuf
  732. phpize --clean
  733. popd
  734. }
  735. build_php7.4_zts_c() {
  736. IS_64BIT=$1
  737. use_php_zts 7.4
  738. cd php/tests && /bin/bash ./test.sh 7.4-zts && cd ../..
  739. pushd conformance
  740. if [ "$IS_64BIT" = "true" ]
  741. then
  742. make test_php_c
  743. else
  744. make test_php_c_32
  745. fi
  746. popd
  747. pushd php/ext/google/protobuf
  748. phpize --clean
  749. popd
  750. }
  751. build_php_all_32() {
  752. build_php5.5
  753. build_php5.6
  754. build_php7.0
  755. build_php7.1
  756. build_php7.4
  757. build_php5.5_c $1
  758. build_php5.6_c $1
  759. build_php7.0_c $1
  760. build_php7.1_c $1
  761. build_php7.4_c $1
  762. build_php5.5_mixed
  763. build_php5.6_mixed
  764. build_php7.0_mixed
  765. build_php7.1_mixed
  766. build_php7.4_mixed
  767. build_php5.5_zts_c $1
  768. build_php5.6_zts_c $1
  769. build_php7.0_zts_c $1
  770. build_php7.1_zts_c $1
  771. build_php7.4_zts_c $1
  772. }
  773. build_php_all() {
  774. build_php_all_32 true
  775. build_php_multirequest
  776. build_php_compatibility
  777. }
  778. build_benchmark() {
  779. use_php 7.2
  780. cd kokoro/linux/benchmark && ./run.sh
  781. }
  782. # -------- main --------
  783. if [ "$#" -ne 1 ]; then
  784. echo "
  785. Usage: $0 { cpp |
  786. cpp_distcheck |
  787. csharp |
  788. java_jdk7 |
  789. java_oracle7 |
  790. java_compatibility |
  791. java_linkage_monitor |
  792. objectivec_ios |
  793. objectivec_ios_debug |
  794. objectivec_ios_release |
  795. objectivec_osx |
  796. objectivec_tvos |
  797. objectivec_tvos_debug |
  798. objectivec_tvos_release |
  799. objectivec_cocoapods_integration |
  800. python |
  801. python_cpp |
  802. python_compatibility |
  803. ruby23 |
  804. ruby24 |
  805. ruby25 |
  806. ruby26 |
  807. jruby |
  808. ruby_all |
  809. php5.5 |
  810. php5.5_c |
  811. php5.6 |
  812. php5.6_c |
  813. php7.0 |
  814. php7.0_c |
  815. php_compatibility |
  816. php7.1 |
  817. php7.1_c |
  818. php_all |
  819. dist_install |
  820. benchmark)
  821. "
  822. exit 1
  823. fi
  824. set -e # exit immediately on error
  825. set -x # display all commands
  826. cd $(dirname $0)
  827. eval "build_$1"