Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(324)

Side by Side Diff: build/android/buildbot/buildbot_functions.sh

Issue 11666023: Move android buildbot test logic into python (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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 echo
281 # _bb_android_run_tests -s your_test_here
282 }
283
284 # Run findbugs. 197 # Run findbugs.
285 function bb_run_findbugs { 198 function bb_run_findbugs {
286 echo "@@@BUILD_STEP findbugs@@@" 199 echo "@@@BUILD_STEP findbugs@@@"
287 if [[ $BUILDTYPE = Release ]]; then 200 if [[ $BUILDTYPE = Release ]]; then
288 local BUILDFLAG="--release-build" 201 local BUILDFLAG="--release-build"
289 fi 202 fi
290 bb_run_step build/android/findbugs_diff.py $BUILDFLAG 203 bb_run_step build/android/findbugs_diff.py $BUILDFLAG
291 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 \
292 $BUILDFLAG 205 $BUILDFLAG
293 } 206 }
294 207
295 # 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).
296 function bb_run_step { 209 function bb_run_step {
297 ( 210 (
298 set +e 211 set +e
299 "$@" 212 "$@"
300 if [[ $? != 0 ]]; then 213 if [[ $? != 0 ]]; then
301 echo "@@@STEP_FAILURE@@@" 214 echo "@@@STEP_FAILURE@@@"
302 fi 215 fi
303 ) 216 )
304 } 217 }
305 218
306 # Install a specific APK.
307 # Args:
308 # $1: APK to be installed.
309 # $2: APK_PACKAGE for the APK to be installed.
310 function bb_install_apk {
311 local APK=${1}
312 local APK_PACKAGE=${2}
313 if [[ $BUILDTYPE = Release ]]; then
314 local BUILDFLAG="--release"
315 fi
316
317 echo "@@@BUILD_STEP Install ${APK}@@@"
318 python build/android/adb_install_apk.py --apk ${APK} \
319 --apk_package ${APK_PACKAGE} ${BUILDFLAG}
320 }
321
322 # Run instrumentation tests for a specific APK.
323 # Args:
324 # $1: APK to be installed.
325 # $2: APK_PACKAGE for the APK to be installed.
326 # $3: TEST_APK to run the tests against.
327 # $4: TEST_DATA in format destination:source
328 function bb_run_all_instrumentation_tests_for_apk {
329 local APK=${1}
330 local APK_PACKAGE=${2}
331 local TEST_APK=${3}
332 local TEST_DATA=${4}
333 local FLAGS
334
335 # Install application APK.
336 bb_install_apk ${APK} ${APK_PACKAGE}
337
338 # Run instrumentation tests. Using -I to install the test apk.
339 echo "@@@BUILD_STEP Run instrumentation tests ${TEST_APK}@@@"
340 FLAGS="-vvv"
341 if [[ "${BUILDTYPE}" == Release ]]; then
342 FLAGS="${FLAGS} --release"
343 fi
344 bb_run_step python build/android/run_instrumentation_tests.py \
345 ${FLAGS} ${EXTRA_RUN_TESTS_FLAGS} --test-apk ${TEST_APK} -I \
346 --test_data ${TEST_DATA}
347 }
348
349 # Run instrumentation tests for all relevant APKs on device.
350 function bb_run_instrumentation_tests {
351 bb_run_all_instrumentation_tests_for_apk "ContentShell.apk" \
352 "org.chromium.content_shell" "ContentShellTest" \
353 "content:content/test/data/android/device_files"
354 bb_run_all_instrumentation_tests_for_apk "ChromiumTestShell.apk" \
355 "org.chromium.chrome.testshell" "ChromiumTestShellTest" \
356 "chrome:chrome/test/data/android/device_files"
357 bb_run_all_instrumentation_tests_for_apk "AndroidWebView.apk" \
358 "org.chromium.android_webview" "AndroidWebViewTest" \
359 "webview:android_webview/test/data/device_files"
360 }
361
362 # Run instrumentation tests for experimental APKs on device.
363 function bb_run_experimental_instrumentation_tests {
364 echo "" # Can't have empty functions in bash.
365 }
366
367 # Zip and archive a build. 219 # Zip and archive a build.
368 function bb_zip_build { 220 function bb_zip_build {
369 echo "@@@BUILD_STEP Zip build@@@" 221 echo "@@@BUILD_STEP Zip build@@@"
370 python ../../../../scripts/slave/zip_build.py \ 222 python ../../../../scripts/slave/zip_build.py \
371 --src-dir "$SRC_ROOT" \ 223 --src-dir "$SRC_ROOT" \
372 --exclude-files "lib.target,gen,android_webview,jingle_unittests" \ 224 --exclude-files "lib.target,gen,android_webview,jingle_unittests" \
373 --factory-properties "$FACTORY_PROPERTIES" \ 225 --factory-properties "$FACTORY_PROPERTIES" \
374 --build-properties "$BUILD_PROPERTIES" 226 --build-properties "$BUILD_PROPERTIES"
375 } 227 }
376 228
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 ) 288 )
437 } 289 }
438 290
439 # Retrieve a packed json property using python 291 # Retrieve a packed json property using python
440 function bb_get_json_prop { 292 function bb_get_json_prop {
441 local JSON="$1" 293 local JSON="$1"
442 local PROP="$2" 294 local PROP="$2"
443 295
444 python -c "import json; print json.loads('$JSON').get('$PROP', '')" 296 python -c "import json; print json.loads('$JSON').get('$PROP', '')"
445 } 297 }
OLDNEW
« no previous file with comments | « build/android/buildbot/bb_webkit_latest_webkit_tester.sh ('k') | build/android/buildbot/tests/bb_run_bot_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698