| OLD | NEW |
| 1 #!/bin/bash | 1 #!/bin/bash |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 # | 5 # |
| 6 # Bash functions used by buildbot annotator scripts for the android | 6 # Bash functions used by buildbot annotator scripts for the android |
| 7 # build of chromium. Executing this script should not perform actions | 7 # build of chromium. Executing this script should not perform actions |
| 8 # other than setting variables and defining of functions. | 8 # other than setting variables and defining of functions. |
| 9 | 9 |
| 10 # Number of jobs on the compile line; e.g. make -j"${JOBS}" | 10 # Number of jobs on the compile line; e.g. make -j"${JOBS}" |
| 11 JOBS="${JOBS:-4}" | 11 JOBS="${JOBS:-4}" |
| 12 | 12 |
| 13 # Parse named arguments passed into the annotator script | 13 # Parse named arguments passed into the annotator script |
| 14 # and assign them global variable names. | 14 # and assign them global variable names. |
| 15 function bb_parse_args { | 15 function bb_parse_args { |
| 16 while [[ $1 ]]; do | 16 while [[ $1 ]]; do |
| 17 case "$1" in | 17 case "$1" in |
| 18 --factory-properties=*) | 18 --factory-properties=*) |
| 19 FACTORY_PROPERTIES="$(echo "$1" | sed 's/^[^=]*=//')" | 19 FACTORY_PROPERTIES="$(echo "$1" | sed 's/^[^=]*=//')" |
| 20 BUILDTYPE=$(bb_get_json_prop "$FACTORY_PROPERTIES" target) | 20 BUILDTYPE=$(bb_get_json_prop "$FACTORY_PROPERTIES" target) |
| 21 ;; | 21 ;; |
| 22 --build-properties=*) | 22 --build-properties=*) |
| 23 BUILD_PROPERTIES="$(echo "$1" | sed 's/^[^=]*=//')" | 23 BUILD_PROPERTIES="$(echo "$1" | sed 's/^[^=]*=//')" |
| 24 ;; | 24 ;; |
| 25 --slave-properties=*) |
| 26 SLAVE_PROPERTIES="$(echo "$1" | sed 's/^[^=]*=//')" |
| 27 ;; |
| 25 *) | 28 *) |
| 26 echo "@@@STEP_WARNINGS@@@" | 29 echo "@@@STEP_WARNINGS@@@" |
| 27 echo "Warning, unparsed input argument: '$1'" | 30 echo "Warning, unparsed input argument: '$1'" |
| 28 ;; | 31 ;; |
| 29 esac | 32 esac |
| 30 shift | 33 shift |
| 31 done | 34 done |
| 32 } | 35 } |
| 33 | 36 |
| 34 # Function to force-green a bot. | |
| 35 function bb_force_bot_green_and_exit { | |
| 36 echo "@@@BUILD_STEP Bot forced green.@@@" | |
| 37 exit 0 | |
| 38 } | |
| 39 | |
| 40 # Basic setup for all bots to run after a source tree checkout. | 37 # Basic setup for all bots to run after a source tree checkout. |
| 41 # Args: | 38 # Args: |
| 42 # $1: source root. | 39 # $1: source root. |
| 43 # $2 and beyond: key value pairs which are parsed by bb_parse_args. | 40 # $2 and beyond: key value pairs which are parsed by bb_parse_args. |
| 44 function bb_baseline_setup { | 41 function bb_baseline_setup { |
| 45 SRC_ROOT="$1" | 42 SRC_ROOT="$1" |
| 46 # Remove SRC_ROOT param | 43 # Remove SRC_ROOT param |
| 47 shift | 44 shift |
| 48 cd $SRC_ROOT | 45 cd $SRC_ROOT |
| 49 | 46 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 # crbug.com/145860 | 80 # crbug.com/145860 |
| 84 rm -rf ~/.android | 81 rm -rf ~/.android |
| 85 rm -rf "$build_path" | 82 rm -rf "$build_path" |
| 86 if [[ -e $build_path ]] ; then | 83 if [[ -e $build_path ]] ; then |
| 87 echo "Clobber appeared to fail? $build_path still exists." | 84 echo "Clobber appeared to fail? $build_path still exists." |
| 88 echo "@@@STEP_WARNINGS@@@" | 85 echo "@@@STEP_WARNINGS@@@" |
| 89 fi | 86 fi |
| 90 fi | 87 fi |
| 91 } | 88 } |
| 92 | 89 |
| 93 # Used internally to buildbot_functions.sh. | |
| 94 function _bb_android_run_tests () { | |
| 95 local FLAGS | |
| 96 FLAGS="--xvfb --verbose" | |
| 97 if [[ ${BUILDTYPE} == Release ]]; then | |
| 98 FLAGS="${FLAGS} --release" | |
| 99 fi | |
| 100 build/android/run_tests.py ${FLAGS} ${EXTRA_RUN_TESTS_FLAGS} "$@" | |
| 101 } | |
| 102 | |
| 103 function bb_compile_setup { | 90 function bb_compile_setup { |
| 104 bb_setup_goma_internal | 91 bb_setup_goma_internal |
| 105 # Should be called only after envsetup is done. | 92 # Should be called only after envsetup is done. |
| 106 gclient runhooks | 93 gclient runhooks |
| 107 } | 94 } |
| 108 | 95 |
| 109 # Setup goma. Used internally to buildbot_functions.sh. | 96 # Setup goma. Used internally to buildbot_functions.sh. |
| 110 function bb_setup_goma_internal { | 97 function bb_setup_goma_internal { |
| 111 export GOMA_API_KEY_FILE=${GOMA_DIR}/goma.key | 98 export GOMA_API_KEY_FILE=${GOMA_DIR}/goma.key |
| 112 export GOMA_COMPILER_PROXY_DAEMON_MODE=true | 99 export GOMA_COMPILER_PROXY_DAEMON_MODE=true |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 else | 187 else |
| 201 bb_goma_make -k "${target}" | 188 bb_goma_make -k "${target}" |
| 202 fi | 189 fi |
| 203 if [ $? -ne 0 ] ; then | 190 if [ $? -ne 0 ] ; then |
| 204 echo "@@@STEP_WARNINGS@@@" | 191 echo "@@@STEP_WARNINGS@@@" |
| 205 fi | 192 fi |
| 206 set -e | 193 set -e |
| 207 done | 194 done |
| 208 } | 195 } |
| 209 | 196 |
| 210 # Run tests on an emulator. | |
| 211 function bb_run_tests_emulator { | |
| 212 echo "@@@BUILD_STEP Run Tests on an Emulator@@@" | |
| 213 _bb_android_run_tests -e | |
| 214 } | |
| 215 | |
| 216 function bb_spawn_logcat_monitor_and_status { | |
| 217 adb start-server | |
| 218 sleep 1 | |
| 219 python build/android/device_status_check.py | |
| 220 LOGCAT_DUMP_DIR="$CHROME_SRC/out/logcat" | |
| 221 rm -rf "$LOGCAT_DUMP_DIR" | |
| 222 python build/android/adb_logcat_monitor.py "$LOGCAT_DUMP_DIR" & | |
| 223 } | |
| 224 | |
| 225 function bb_print_logcat { | |
| 226 echo "@@@BUILD_STEP Logcat dump@@@" | |
| 227 python build/android/adb_logcat_printer.py "$LOGCAT_DUMP_DIR" | |
| 228 } | |
| 229 | |
| 230 # Run tests on an actual device. (Better have one plugged in!) | |
| 231 function bb_run_unit_tests { | |
| 232 echo "@@@BUILD_STEP Run unit tests@@@" | |
| 233 _bb_android_run_tests | |
| 234 } | |
| 235 | |
| 236 # Run WebKit's test suites: webkit_unit_tests and TestWebKitAPI | |
| 237 function bb_run_webkit_unit_tests { | |
| 238 echo "@@@BUILD_STEP Run webkit unit tests@@@" | |
| 239 _bb_android_run_tests -s webkit_unit_tests | |
| 240 _bb_android_run_tests -s TestWebKitAPI | |
| 241 } | |
| 242 | |
| 243 # Lint WebKit's TestExpectation files. | |
| 244 function bb_lint_webkit_expectation_files { | |
| 245 echo "@@@BUILD_STEP webkit_lint@@@" | |
| 246 bb_run_step python webkit/tools/layout_tests/run_webkit_tests.py \ | |
| 247 --lint-test-files \ | |
| 248 --chromium | |
| 249 } | |
| 250 | |
| 251 # Run layout tests on an actual device. | |
| 252 function bb_run_webkit_layout_tests { | |
| 253 echo "@@@BUILD_STEP webkit_tests@@@" | |
| 254 local BUILDERNAME="$(bb_get_json_prop "$BUILD_PROPERTIES" buildername)" | |
| 255 local BUILDNUMBER="$(bb_get_json_prop "$BUILD_PROPERTIES" buildnumber)" | |
| 256 local MASTERNAME="$(bb_get_json_prop "$BUILD_PROPERTIES" mastername)" | |
| 257 local RESULTSERVER=\ | |
| 258 "$(bb_get_json_prop "$FACTORY_PROPERTIES" test_results_server)" | |
| 259 | |
| 260 bb_run_step python webkit/tools/layout_tests/run_webkit_tests.py \ | |
| 261 --no-show-results \ | |
| 262 --no-new-test-results \ | |
| 263 --full-results-html \ | |
| 264 --clobber-old-results \ | |
| 265 --exit-after-n-failures 5000 \ | |
| 266 --exit-after-n-crashes-or-timeouts 100 \ | |
| 267 --debug-rwt-logging \ | |
| 268 --results-directory "../layout-test-results" \ | |
| 269 --target "$BUILDTYPE" \ | |
| 270 --builder-name "$BUILDERNAME" \ | |
| 271 --build-number "$BUILDNUMBER" \ | |
| 272 --master-name "$MASTERNAME" \ | |
| 273 --build-name "$BUILDERNAME" \ | |
| 274 --platform=chromium-android \ | |
| 275 --test-results-server "$RESULTSERVER" | |
| 276 } | |
| 277 | |
| 278 # Run experimental unittest bundles. | |
| 279 function bb_run_experimental_unit_tests { | |
| 280 _bb_android_run_tests -s sandbox_linux_unittests | |
| 281 } | |
| 282 | |
| 283 # Run findbugs. | 197 # Run findbugs. |
| 284 function bb_run_findbugs { | 198 function bb_run_findbugs { |
| 285 echo "@@@BUILD_STEP findbugs@@@" | 199 echo "@@@BUILD_STEP findbugs@@@" |
| 286 if [[ $BUILDTYPE = Release ]]; then | 200 if [[ $BUILDTYPE = Release ]]; then |
| 287 local BUILDFLAG="--release-build" | 201 local BUILDFLAG="--release-build" |
| 288 fi | 202 fi |
| 289 bb_run_step build/android/findbugs_diff.py $BUILDFLAG | 203 bb_run_step build/android/findbugs_diff.py $BUILDFLAG |
| 290 bb_run_step tools/android/findbugs_plugin/test/run_findbugs_plugin_tests.py \ | 204 bb_run_step tools/android/findbugs_plugin/test/run_findbugs_plugin_tests.py \ |
| 291 $BUILDFLAG | 205 $BUILDFLAG |
| 292 } | 206 } |
| 293 | 207 |
| 294 # Run a buildbot step and handle failure (failure will not halt build). | 208 # Run a buildbot step and handle failure (failure will not halt build). |
| 295 function bb_run_step { | 209 function bb_run_step { |
| 296 ( | 210 ( |
| 297 set +e | 211 set +e |
| 298 "$@" | 212 "$@" |
| 299 if [[ $? != 0 ]]; then | 213 if [[ $? != 0 ]]; then |
| 300 echo "@@@STEP_FAILURE@@@" | 214 echo "@@@STEP_FAILURE@@@" |
| 301 fi | 215 fi |
| 302 ) | 216 ) |
| 303 } | 217 } |
| 304 | 218 |
| 305 # Install a specific APK. | |
| 306 # Args: | |
| 307 # $1: APK to be installed. | |
| 308 # $2: APK_PACKAGE for the APK to be installed. | |
| 309 function bb_install_apk { | |
| 310 local APK=${1} | |
| 311 local APK_PACKAGE=${2} | |
| 312 if [[ $BUILDTYPE = Release ]]; then | |
| 313 local BUILDFLAG="--release" | |
| 314 fi | |
| 315 | |
| 316 echo "@@@BUILD_STEP Install ${APK}@@@" | |
| 317 python build/android/adb_install_apk.py --apk ${APK} \ | |
| 318 --apk_package ${APK_PACKAGE} ${BUILDFLAG} | |
| 319 } | |
| 320 | |
| 321 # Run instrumentation tests for a specific APK. | |
| 322 # Args: | |
| 323 # $1: APK to be installed. | |
| 324 # $2: APK_PACKAGE for the APK to be installed. | |
| 325 # $3: TEST_APK to run the tests against. | |
| 326 # $4: TEST_DATA in format destination:source | |
| 327 function bb_run_all_instrumentation_tests_for_apk { | |
| 328 local APK=${1} | |
| 329 local APK_PACKAGE=${2} | |
| 330 local TEST_APK=${3} | |
| 331 local TEST_DATA=${4} | |
| 332 local FLAGS | |
| 333 | |
| 334 # Install application APK. | |
| 335 bb_install_apk ${APK} ${APK_PACKAGE} | |
| 336 | |
| 337 # Run instrumentation tests. Using -I to install the test apk. | |
| 338 echo "@@@BUILD_STEP Run instrumentation tests ${TEST_APK}@@@" | |
| 339 FLAGS="-vvv" | |
| 340 if [[ "${BUILDTYPE}" == Release ]]; then | |
| 341 FLAGS="${FLAGS} --release" | |
| 342 fi | |
| 343 bb_run_step python build/android/run_instrumentation_tests.py \ | |
| 344 ${FLAGS} ${EXTRA_RUN_TESTS_FLAGS} --test-apk ${TEST_APK} -I \ | |
| 345 --test_data ${TEST_DATA} | |
| 346 } | |
| 347 | |
| 348 # Run instrumentation tests for all relevant APKs on device. | |
| 349 function bb_run_instrumentation_tests { | |
| 350 bb_run_all_instrumentation_tests_for_apk "ContentShell.apk" \ | |
| 351 "org.chromium.content_shell" "ContentShellTest" \ | |
| 352 "content:content/test/data/android/device_files" | |
| 353 bb_run_all_instrumentation_tests_for_apk "ChromiumTestShell.apk" \ | |
| 354 "org.chromium.chrome.testshell" "ChromiumTestShellTest" \ | |
| 355 "chrome:chrome/test/data/android/device_files" | |
| 356 bb_run_all_instrumentation_tests_for_apk "AndroidWebView.apk" \ | |
| 357 "org.chromium.android_webview" "AndroidWebViewTest" \ | |
| 358 "webview:android_webview/test/data/device_files" | |
| 359 } | |
| 360 | |
| 361 # Run instrumentation tests for experimental APKs on device. | |
| 362 function bb_run_experimental_instrumentation_tests { | |
| 363 echo "" # Can't have empty functions in bash. | |
| 364 } | |
| 365 | |
| 366 # Zip and archive a build. | 219 # Zip and archive a build. |
| 367 function bb_zip_build { | 220 function bb_zip_build { |
| 368 echo "@@@BUILD_STEP Zip build@@@" | 221 echo "@@@BUILD_STEP Zip build@@@" |
| 369 python ../../../../scripts/slave/zip_build.py \ | 222 python ../../../../scripts/slave/zip_build.py \ |
| 370 --src-dir "$SRC_ROOT" \ | 223 --src-dir "$SRC_ROOT" \ |
| 371 --exclude-files "lib.target,gen,android_webview,jingle_unittests" \ | 224 --exclude-files "lib.target,gen,android_webview,jingle_unittests" \ |
| 372 --factory-properties "$FACTORY_PROPERTIES" \ | 225 --factory-properties "$FACTORY_PROPERTIES" \ |
| 373 --build-properties "$BUILD_PROPERTIES" | 226 --build-properties "$BUILD_PROPERTIES" |
| 374 } | 227 } |
| 375 | 228 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 ) | 288 ) |
| 436 } | 289 } |
| 437 | 290 |
| 438 # Retrieve a packed json property using python | 291 # Retrieve a packed json property using python |
| 439 function bb_get_json_prop { | 292 function bb_get_json_prop { |
| 440 local JSON="$1" | 293 local JSON="$1" |
| 441 local PROP="$2" | 294 local PROP="$2" |
| 442 | 295 |
| 443 python -c "import json; print json.loads('$JSON').get('$PROP', '')" | 296 python -c "import json; print json.loads('$JSON').get('$PROP', '')" |
| 444 } | 297 } |
| OLD | NEW |