tests.sh 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924
  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 "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. # This local installation avoids the problem caused by a new version not yet in Maven Central
  185. cd java/bom && $MVN install
  186. cd ../..
  187. cd java && $MVN test && $MVN install
  188. cd util && $MVN package assembly:single
  189. cd ../..
  190. cd conformance && make test_java && cd ..
  191. }
  192. build_java_jdk7() {
  193. use_java jdk7
  194. build_java_with_conformance_tests
  195. }
  196. build_java_oracle7() {
  197. use_java oracle7
  198. build_java oracle7
  199. }
  200. build_java_compatibility() {
  201. use_java jdk7
  202. internal_build_cpp
  203. # Use the unit-tests extraced from 2.5.0 to test the compatibilty between
  204. # 3.0.0-beta-4 and the current version.
  205. cd java/compatibility_tests/v2.5.0
  206. ./test.sh 3.0.0-beta-4
  207. # Test the last released and current version.
  208. ./test.sh $LAST_RELEASED
  209. }
  210. build_java_linkage_monitor() {
  211. # Linkage Monitor checks compatibility with other Google libraries
  212. # https://github.com/GoogleCloudPlatform/cloud-opensource-java/tree/master/linkage-monitor
  213. use_java jdk8
  214. internal_build_cpp
  215. # Linkage Monitor uses $HOME/.m2 local repository
  216. MVN="mvn -e -B -Dhttps.protocols=TLSv1.2"
  217. cd java
  218. # Sets java artifact version with SNAPSHOT, as Linkage Monitor looks for SNAPSHOT versions.
  219. # Example: "3.9.0" (without 'rc')
  220. VERSION=`grep '<version>' pom.xml |head -1 |perl -nle 'print $1 if m/<version>(\d+\.\d+.\d+)/'`
  221. cd bom
  222. # This local installation avoids the problem caused by a new version not yet in Maven Central
  223. # https://github.com/protocolbuffers/protobuf/issues/6627
  224. $MVN install
  225. $MVN versions:set -DnewVersion=${VERSION}-SNAPSHOT
  226. cd ..
  227. $MVN versions:set -DnewVersion=${VERSION}-SNAPSHOT
  228. # Installs the snapshot version locally
  229. $MVN install -Dmaven.test.skip=true
  230. # Linkage Monitor uses the snapshot versions installed in $HOME/.m2 to verify compatibility
  231. JAR=linkage-monitor-latest-all-deps.jar
  232. curl -v -O "https://storage.googleapis.com/cloud-opensource-java-linkage-monitor/${JAR}"
  233. # Fails if there's new linkage errors compared with baseline
  234. java -jar $JAR com.google.cloud:libraries-bom
  235. }
  236. build_objectivec_ios() {
  237. # Reused the build script that takes care of configuring and ensuring things
  238. # are up to date. The OS X test runs the objc conformance test, so skip it
  239. # here.
  240. objectivec/DevTools/full_mac_build.sh \
  241. --core-only --skip-xcode-osx --skip-xcode-tvos --skip-objc-conformance "$@"
  242. }
  243. build_objectivec_ios_debug() {
  244. build_objectivec_ios --skip-xcode-release
  245. }
  246. build_objectivec_ios_release() {
  247. build_objectivec_ios --skip-xcode-debug
  248. }
  249. build_objectivec_osx() {
  250. # Reused the build script that takes care of configuring and ensuring things
  251. # are up to date.
  252. objectivec/DevTools/full_mac_build.sh \
  253. --core-only --skip-xcode-ios --skip-xcode-tvos
  254. }
  255. build_objectivec_tvos() {
  256. # Reused the build script that takes care of configuring and ensuring things
  257. # are up to date. The OS X test runs the objc conformance test, so skip it
  258. # here.
  259. objectivec/DevTools/full_mac_build.sh \
  260. --core-only --skip-xcode-ios --skip-xcode-osx --skip-objc-conformance "$@"
  261. }
  262. build_objectivec_tvos_debug() {
  263. build_objectivec_tvos --skip-xcode-release
  264. }
  265. build_objectivec_tvos_release() {
  266. build_objectivec_tvos --skip-xcode-debug
  267. }
  268. build_objectivec_cocoapods_integration() {
  269. # Update pod to the latest version.
  270. gem install cocoapods --no_document
  271. objectivec/Tests/CocoaPods/run_tests.sh
  272. }
  273. build_python() {
  274. internal_build_cpp
  275. cd python
  276. if [ $(uname -s) == "Linux" ]; then
  277. envlist=py\{27,33,34,35,36\}-python
  278. else
  279. envlist=py27-python
  280. fi
  281. tox -e $envlist
  282. cd ..
  283. }
  284. build_python_version() {
  285. internal_build_cpp
  286. cd python
  287. envlist=$1
  288. tox -e $envlist
  289. cd ..
  290. }
  291. build_python27() {
  292. build_python_version py27-python
  293. }
  294. build_python33() {
  295. build_python_version py33-python
  296. }
  297. build_python34() {
  298. build_python_version py34-python
  299. }
  300. build_python35() {
  301. build_python_version py35-python
  302. }
  303. build_python36() {
  304. build_python_version py36-python
  305. }
  306. build_python37() {
  307. build_python_version py37-python
  308. }
  309. build_python38() {
  310. build_python_version py38-python
  311. }
  312. build_python_cpp() {
  313. internal_build_cpp
  314. export LD_LIBRARY_PATH=../src/.libs # for Linux
  315. export DYLD_LIBRARY_PATH=../src/.libs # for OS X
  316. cd python
  317. if [ $(uname -s) == "Linux" ]; then
  318. envlist=py\{27,33,34,35,36\}-cpp
  319. else
  320. envlist=py27-cpp
  321. fi
  322. tox -e $envlist
  323. cd ..
  324. }
  325. build_python_cpp_version() {
  326. internal_build_cpp
  327. export LD_LIBRARY_PATH=../src/.libs # for Linux
  328. export DYLD_LIBRARY_PATH=../src/.libs # for OS X
  329. cd python
  330. envlist=$1
  331. tox -e $envlist
  332. cd ..
  333. }
  334. build_python27_cpp() {
  335. build_python_cpp_version py27-cpp
  336. }
  337. build_python33_cpp() {
  338. build_python_cpp_version py33-cpp
  339. }
  340. build_python34_cpp() {
  341. build_python_cpp_version py34-cpp
  342. }
  343. build_python35_cpp() {
  344. build_python_cpp_version py35-cpp
  345. }
  346. build_python36_cpp() {
  347. build_python_cpp_version py36-cpp
  348. }
  349. build_python37_cpp() {
  350. build_python_cpp_version py37-cpp
  351. }
  352. build_python38_cpp() {
  353. build_python_cpp_version py38-cpp
  354. }
  355. build_python_compatibility() {
  356. internal_build_cpp
  357. # Use the unit-tests extraced from 2.5.0 to test the compatibilty.
  358. cd python/compatibility_tests/v2.5.0
  359. # Test between 2.5.0 and the current version.
  360. ./test.sh 2.5.0
  361. # Test between 3.0.0-beta-1 and the current version.
  362. ./test.sh 3.0.0-beta-1
  363. # Test between last released and current version.
  364. ./test.sh $LAST_RELEASED
  365. }
  366. build_ruby23() {
  367. internal_build_cpp # For conformance tests.
  368. cd ruby && bash travis-test.sh ruby-2.3.8 && cd ..
  369. }
  370. build_ruby24() {
  371. internal_build_cpp # For conformance tests.
  372. cd ruby && bash travis-test.sh ruby-2.4 && cd ..
  373. }
  374. build_ruby25() {
  375. internal_build_cpp # For conformance tests.
  376. cd ruby && bash travis-test.sh ruby-2.5.1 && cd ..
  377. }
  378. build_ruby26() {
  379. internal_build_cpp # For conformance tests.
  380. cd ruby && bash travis-test.sh ruby-2.6.0 && cd ..
  381. }
  382. build_javascript() {
  383. internal_build_cpp
  384. cd js && npm install && npm test && cd ..
  385. cd conformance && make test_nodejs && cd ..
  386. }
  387. generate_php_test_proto() {
  388. internal_build_cpp
  389. pushd php/tests
  390. # Generate test file
  391. rm -rf generated
  392. mkdir generated
  393. ../../src/protoc --php_out=generated \
  394. -I../../src -I. \
  395. proto/empty/echo.proto \
  396. proto/test.proto \
  397. proto/test_include.proto \
  398. proto/test_no_namespace.proto \
  399. proto/test_prefix.proto \
  400. proto/test_php_namespace.proto \
  401. proto/test_empty_php_namespace.proto \
  402. proto/test_reserved_enum_lower.proto \
  403. proto/test_reserved_enum_upper.proto \
  404. proto/test_reserved_enum_value_lower.proto \
  405. proto/test_reserved_enum_value_upper.proto \
  406. proto/test_reserved_message_lower.proto \
  407. proto/test_reserved_message_upper.proto \
  408. proto/test_service.proto \
  409. proto/test_service_namespace.proto \
  410. proto/test_wrapper_type_setters.proto \
  411. proto/test_descriptors.proto
  412. pushd ../../src
  413. ./protoc --php_out=../php/tests/generated -I../php/tests -I. \
  414. ../php/tests/proto/test_import_descriptor_proto.proto
  415. popd
  416. popd
  417. }
  418. use_php() {
  419. VERSION=$1
  420. export PATH=/usr/local/php-${VERSION}/bin:$PATH
  421. export CPLUS_INCLUDE_PATH=/usr/local/php-${VERSION}/include/php/main:/usr/local/php-${VERSION}/include/php/:$CPLUS_INCLUDE_PATH
  422. export C_INCLUDE_PATH=/usr/local/php-${VERSION}/include/php/main:/usr/local/php-${VERSION}/include/php/:$C_INCLUDE_PATH
  423. generate_php_test_proto
  424. }
  425. use_php_zts() {
  426. VERSION=$1
  427. export PATH=/usr/local/php-${VERSION}-zts/bin:$PATH
  428. export CPLUS_INCLUDE_PATH=/usr/local/php-${VERSION}-zts/include/php/main:/usr/local/php-${VERSION}-zts/include/php/:$CPLUS_INCLUDE_PATH
  429. export C_INCLUDE_PATH=/usr/local/php-${VERSION}-zts/include/php/main:/usr/local/php-${VERSION}-zts/include/php/:$C_INCLUDE_PATH
  430. generate_php_test_proto
  431. }
  432. use_php_bc() {
  433. VERSION=$1
  434. export PATH=/usr/local/php-${VERSION}-bc/bin:$PATH
  435. export CPLUS_INCLUDE_PATH=/usr/local/php-${VERSION}-bc/include/php/main:/usr/local/php-${VERSION}-bc/include/php/:$CPLUS_INCLUDE_PATH
  436. export C_INCLUDE_PATH=/usr/local/php-${VERSION}-bc/include/php/main:/usr/local/php-${VERSION}-bc/include/php/:$C_INCLUDE_PATH
  437. generate_php_test_proto
  438. }
  439. build_php5.5() {
  440. use_php 5.5
  441. pushd php
  442. rm -rf vendor
  443. composer update
  444. ./vendor/bin/phpunit
  445. popd
  446. pushd conformance
  447. make test_php
  448. popd
  449. }
  450. build_php5.5_c() {
  451. IS_64BIT=$1
  452. use_php 5.5
  453. pushd php/tests
  454. /bin/bash ./test.sh 5.5
  455. popd
  456. pushd conformance
  457. if [ "$IS_64BIT" = "true" ]
  458. then
  459. make test_php_c
  460. else
  461. make test_php_c_32
  462. fi
  463. popd
  464. }
  465. build_php5.5_mixed() {
  466. use_php 5.5
  467. pushd php
  468. rm -rf vendor
  469. composer update
  470. pushd tests
  471. /bin/bash ./compile_extension.sh 5.5
  472. popd
  473. php -dextension=./ext/google/protobuf/modules/protobuf.so ./vendor/bin/phpunit
  474. popd
  475. }
  476. build_php5.5_zts_c() {
  477. IS_64BIT=$1
  478. use_php_zts 5.5
  479. cd php/tests && /bin/bash ./test.sh 5.5-zts && cd ../..
  480. pushd conformance
  481. if [ "$IS_64BIT" = "true" ]
  482. then
  483. make test_php_c
  484. else
  485. make test_php_c_32
  486. fi
  487. popd
  488. }
  489. build_php5.6() {
  490. use_php 5.6
  491. pushd php
  492. rm -rf vendor
  493. composer update
  494. ./vendor/bin/phpunit
  495. popd
  496. pushd conformance
  497. make test_php
  498. popd
  499. }
  500. build_php5.6_c() {
  501. IS_64BIT=$1
  502. use_php 5.6
  503. cd php/tests && /bin/bash ./test.sh 5.6 && cd ../..
  504. pushd conformance
  505. if [ "$IS_64BIT" = "true" ]
  506. then
  507. make test_php_c
  508. else
  509. make test_php_c_32
  510. fi
  511. popd
  512. }
  513. build_php5.6_mixed() {
  514. use_php 5.6
  515. pushd php
  516. rm -rf vendor
  517. composer update
  518. pushd tests
  519. /bin/bash ./compile_extension.sh 5.6
  520. popd
  521. php -dextension=./ext/google/protobuf/modules/protobuf.so ./vendor/bin/phpunit
  522. popd
  523. }
  524. build_php5.6_zts_c() {
  525. IS_64BIT=$1
  526. use_php_zts 5.6
  527. cd php/tests && /bin/bash ./test.sh 5.6-zts && cd ../..
  528. pushd conformance
  529. if [ "$IS_64BIT" = "true" ]
  530. then
  531. make test_php_c
  532. else
  533. make test_php_c_32
  534. fi
  535. popd
  536. }
  537. build_php5.6_mac() {
  538. generate_php_test_proto
  539. # Install PHP
  540. curl -s https://php-osx.liip.ch/install.sh | bash -s 5.6
  541. PHP_FOLDER=`find /usr/local -type d -name "php5-5.6*"` # The folder name may change upon time
  542. export PATH="$PHP_FOLDER/bin:$PATH"
  543. # Install phpunit
  544. curl https://phar.phpunit.de/phpunit-5.6.8.phar -L -o phpunit.phar
  545. chmod +x phpunit.phar
  546. sudo mv phpunit.phar /usr/local/bin/phpunit
  547. # Install valgrind
  548. echo "#! /bin/bash" > valgrind
  549. chmod ug+x valgrind
  550. sudo mv valgrind /usr/local/bin/valgrind
  551. # Test
  552. cd php/tests && /bin/bash ./test.sh && cd ../..
  553. pushd conformance
  554. make test_php_c
  555. popd
  556. }
  557. build_php7.0() {
  558. use_php 7.0
  559. pushd php
  560. rm -rf vendor
  561. composer update
  562. ./vendor/bin/phpunit
  563. popd
  564. pushd conformance
  565. make test_php
  566. popd
  567. }
  568. build_php7.0_c() {
  569. IS_64BIT=$1
  570. use_php 7.0
  571. cd php/tests && /bin/bash ./test.sh 7.0 && cd ../..
  572. pushd conformance
  573. if [ "$IS_64BIT" = "true" ]
  574. then
  575. make test_php_c
  576. else
  577. make test_php_c_32
  578. fi
  579. popd
  580. }
  581. build_php7.0_mixed() {
  582. use_php 7.0
  583. pushd php
  584. rm -rf vendor
  585. composer update
  586. pushd tests
  587. /bin/bash ./compile_extension.sh 7.0
  588. popd
  589. php -dextension=./ext/google/protobuf/modules/protobuf.so ./vendor/bin/phpunit
  590. popd
  591. }
  592. build_php7.0_zts_c() {
  593. IS_64BIT=$1
  594. use_php_zts 7.0
  595. cd php/tests && /bin/bash ./test.sh 7.0-zts && cd ../..
  596. pushd conformance
  597. if [ "$IS_64BIT" = "true" ]
  598. then
  599. make test_php_c
  600. else
  601. make test_php_c_32
  602. fi
  603. popd
  604. }
  605. build_php7.0_mac() {
  606. generate_php_test_proto
  607. # Install PHP
  608. curl -s https://php-osx.liip.ch/install.sh | bash -s 7.0
  609. PHP_FOLDER=`find /usr/local -type d -name "php7-7.0*"` # The folder name may change upon time
  610. export PATH="$PHP_FOLDER/bin:$PATH"
  611. # Install phpunit
  612. curl https://phar.phpunit.de/phpunit-5.6.0.phar -L -o phpunit.phar
  613. chmod +x phpunit.phar
  614. sudo mv phpunit.phar /usr/local/bin/phpunit
  615. # Install valgrind
  616. echo "#! /bin/bash" > valgrind
  617. chmod ug+x valgrind
  618. sudo mv valgrind /usr/local/bin/valgrind
  619. # Test
  620. cd php/tests && /bin/bash ./test.sh && cd ../..
  621. pushd conformance
  622. make test_php_c
  623. popd
  624. }
  625. build_php_compatibility() {
  626. internal_build_cpp
  627. php/tests/compatibility_test.sh $LAST_RELEASED
  628. }
  629. build_php_multirequest() {
  630. use_php 7.4
  631. pushd php/tests
  632. ./multirequest.sh
  633. popd
  634. }
  635. build_php7.1() {
  636. use_php 7.1
  637. pushd php
  638. rm -rf vendor
  639. composer update
  640. ./vendor/bin/phpunit
  641. popd
  642. pushd conformance
  643. make test_php
  644. popd
  645. }
  646. build_php7.1_c() {
  647. IS_64BIT=$1
  648. use_php 7.1
  649. cd php/tests && /bin/bash ./test.sh 7.1 && cd ../..
  650. pushd conformance
  651. if [ "$IS_64BIT" = "true" ]
  652. then
  653. make test_php_c
  654. else
  655. make test_php_c_32
  656. fi
  657. popd
  658. }
  659. build_php7.1_mixed() {
  660. use_php 7.1
  661. pushd php
  662. rm -rf vendor
  663. composer update
  664. pushd tests
  665. /bin/bash ./compile_extension.sh 7.1
  666. popd
  667. php -dextension=./ext/google/protobuf/modules/protobuf.so ./vendor/bin/phpunit
  668. popd
  669. }
  670. build_php7.1_zts_c() {
  671. IS_64BIT=$1
  672. use_php_zts 7.1
  673. cd php/tests && /bin/bash ./test.sh 7.1-zts && cd ../..
  674. pushd conformance
  675. if [ "$IS_64BIT" = "true" ]
  676. then
  677. make test_php_c
  678. else
  679. make test_php_c_32
  680. fi
  681. popd
  682. }
  683. build_php7.4() {
  684. use_php 7.4
  685. pushd php
  686. rm -rf vendor
  687. composer update
  688. ./vendor/bin/phpunit
  689. popd
  690. pushd conformance
  691. make test_php
  692. popd
  693. }
  694. build_php7.4_c() {
  695. IS_64BIT=$1
  696. use_php 7.4
  697. cd php/tests && /bin/bash ./test.sh 7.4 && cd ../..
  698. pushd conformance
  699. if [ "$IS_64BIT" = "true" ]
  700. then
  701. make test_php_c
  702. else
  703. make test_php_c_32
  704. fi
  705. popd
  706. pushd php/ext/google/protobuf
  707. phpize --clean
  708. popd
  709. }
  710. build_php7.4_mixed() {
  711. use_php 7.4
  712. pushd php
  713. rm -rf vendor
  714. composer update
  715. pushd tests
  716. /bin/bash ./compile_extension.sh 7.4
  717. popd
  718. php -dextension=./ext/google/protobuf/modules/protobuf.so ./vendor/bin/phpunit
  719. popd
  720. pushd php/ext/google/protobuf
  721. phpize --clean
  722. popd
  723. }
  724. build_php7.4_zts_c() {
  725. IS_64BIT=$1
  726. use_php_zts 7.4
  727. cd php/tests && /bin/bash ./test.sh 7.4-zts && cd ../..
  728. pushd conformance
  729. if [ "$IS_64BIT" = "true" ]
  730. then
  731. make test_php_c
  732. else
  733. make test_php_c_32
  734. fi
  735. popd
  736. pushd php/ext/google/protobuf
  737. phpize --clean
  738. popd
  739. }
  740. build_php_all_32() {
  741. build_php5.5
  742. build_php5.6
  743. build_php7.0
  744. build_php7.1
  745. build_php7.4
  746. build_php5.5_c $1
  747. build_php5.6_c $1
  748. build_php7.0_c $1
  749. build_php7.1_c $1
  750. build_php7.4_c $1
  751. build_php5.5_mixed
  752. build_php5.6_mixed
  753. build_php7.0_mixed
  754. build_php7.1_mixed
  755. build_php7.4_mixed
  756. build_php5.5_zts_c $1
  757. build_php5.6_zts_c $1
  758. build_php7.0_zts_c $1
  759. build_php7.1_zts_c $1
  760. build_php7.4_zts_c $1
  761. }
  762. build_php_all() {
  763. build_php_all_32 true
  764. build_php_multirequest
  765. build_php_compatibility
  766. }
  767. build_benchmark() {
  768. use_php 7.2
  769. cd kokoro/linux/benchmark && ./run.sh
  770. }
  771. # -------- main --------
  772. if [ "$#" -ne 1 ]; then
  773. echo "
  774. Usage: $0 { cpp |
  775. cpp_distcheck |
  776. csharp |
  777. java_jdk7 |
  778. java_oracle7 |
  779. java_compatibility |
  780. java_linkage_monitor |
  781. objectivec_ios |
  782. objectivec_ios_debug |
  783. objectivec_ios_release |
  784. objectivec_osx |
  785. objectivec_tvos |
  786. objectivec_tvos_debug |
  787. objectivec_tvos_release |
  788. objectivec_cocoapods_integration |
  789. python |
  790. python_cpp |
  791. python_compatibility |
  792. ruby23 |
  793. ruby24 |
  794. ruby25 |
  795. ruby26 |
  796. jruby |
  797. ruby_all |
  798. php5.5 |
  799. php5.5_c |
  800. php5.6 |
  801. php5.6_c |
  802. php7.0 |
  803. php7.0_c |
  804. php_compatibility |
  805. php7.1 |
  806. php7.1_c |
  807. php_all |
  808. dist_install |
  809. benchmark)
  810. "
  811. exit 1
  812. fi
  813. set -e # exit immediately on error
  814. set -x # display all commands
  815. cd $(dirname $0)
  816. eval "build_$1"