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

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: Created 7 years, 12 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=*)
xusydoc (do not use) 2013/01/04 17:09:21 I feel like this is better handled by factory prop
Isaac (away) 2013/01/04 17:21:38 SG. This part isn't from a port actually. The issu
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 python build/android/device_status_check.py
218 LOGCAT_DUMP_DIR="$CHROME_SRC/out/logcat"
219 rm -rf "$LOGCAT_DUMP_DIR"
220 python build/android/adb_logcat_monitor.py "$LOGCAT_DUMP_DIR" &
221 }
222
223 function bb_print_logcat {
224 echo "@@@BUILD_STEP Logcat dump@@@"
225 python build/android/adb_logcat_printer.py "$LOGCAT_DUMP_DIR"
226 }
227
228 # Run tests on an actual device. (Better have one plugged in!)
229 function bb_run_unit_tests {
230 echo "@@@BUILD_STEP Run unit tests@@@"
231 _bb_android_run_tests
232 }
233
234 # Run WebKit's test suites: webkit_unit_tests and TestWebKitAPI
235 function bb_run_webkit_unit_tests {
236 echo "@@@BUILD_STEP Run webkit unit tests@@@"
237 _bb_android_run_tests -s webkit_unit_tests
238 _bb_android_run_tests -s TestWebKitAPI
239 }
240
241 # Lint WebKit's TestExpectation files.
242 function bb_lint_webkit_expectation_files {
243 echo "@@@BUILD_STEP webkit_lint@@@"
244 bb_run_step python webkit/tools/layout_tests/run_webkit_tests.py \
245 --lint-test-files \
246 --chromium
247 }
248
249 # Run layout tests on an actual device.
250 function bb_run_webkit_layout_tests {
251 echo "@@@BUILD_STEP webkit_tests@@@"
252 local BUILDERNAME="$(bb_get_json_prop "$BUILD_PROPERTIES" buildername)"
253 local BUILDNUMBER="$(bb_get_json_prop "$BUILD_PROPERTIES" buildnumber)"
254 local MASTERNAME="$(bb_get_json_prop "$BUILD_PROPERTIES" mastername)"
255 local RESULTSERVER=\
256 "$(bb_get_json_prop "$FACTORY_PROPERTIES" test_results_server)"
257
258 bb_run_step python webkit/tools/layout_tests/run_webkit_tests.py \
259 --no-show-results \
260 --no-new-test-results \
261 --full-results-html \
262 --clobber-old-results \
263 --exit-after-n-failures 5000 \
264 --exit-after-n-crashes-or-timeouts 100 \
265 --debug-rwt-logging \
266 --results-directory "../layout-test-results" \
267 --target "$BUILDTYPE" \
268 --builder-name "$BUILDERNAME" \
269 --build-number "$BUILDNUMBER" \
270 --master-name "$MASTERNAME" \
271 --build-name "$BUILDERNAME" \
272 --platform=chromium-android \
273 --test-results-server "$RESULTSERVER"
274 }
275
276 # Run experimental unittest bundles.
277 function bb_run_experimental_unit_tests {
278 echo
279 }
280
281 # Run findbugs. 197 # Run findbugs.
282 function bb_run_findbugs { 198 function bb_run_findbugs {
283 echo "@@@BUILD_STEP findbugs@@@" 199 echo "@@@BUILD_STEP findbugs@@@"
284 if [[ $BUILDTYPE = Release ]]; then 200 if [[ $BUILDTYPE = Release ]]; then
285 local BUILDFLAG="--release-build" 201 local BUILDFLAG="--release-build"
286 fi 202 fi
287 bb_run_step build/android/findbugs_diff.py $BUILDFLAG 203 bb_run_step build/android/findbugs_diff.py $BUILDFLAG
288 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 \
289 $BUILDFLAG 205 $BUILDFLAG
290 } 206 }
291 207
292 # 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).
293 function bb_run_step { 209 function bb_run_step {
294 ( 210 (
295 set +e 211 set +e
296 "$@" 212 "$@"
297 if [[ $? != 0 ]]; then 213 if [[ $? != 0 ]]; then
298 echo "@@@STEP_FAILURE@@@" 214 echo "@@@STEP_FAILURE@@@"
299 fi 215 fi
300 ) 216 )
301 } 217 }
302 218
303 # Install a specific APK.
304 # Args:
305 # $1: APK to be installed.
306 # $2: APK_PACKAGE for the APK to be installed.
307 function bb_install_apk {
308 local APK=${1}
309 local APK_PACKAGE=${2}
310 if [[ $BUILDTYPE = Release ]]; then
311 local BUILDFLAG="--release"
312 fi
313
314 echo "@@@BUILD_STEP Install ${APK}@@@"
315 python build/android/adb_install_apk.py --apk ${APK} \
316 --apk_package ${APK_PACKAGE} ${BUILDFLAG}
317 }
318
319 # Run instrumentation tests for a specific APK.
320 # Args:
321 # $1: APK to be installed.
322 # $2: APK_PACKAGE for the APK to be installed.
323 # $3: TEST_APK to run the tests against.
324 # $4: TEST_DATA in format destination:source
325 function bb_run_all_instrumentation_tests_for_apk {
326 local APK=${1}
327 local APK_PACKAGE=${2}
328 local TEST_APK=${3}
329 local TEST_DATA=${4}
330 local FLAGS
331
332 # Install application APK.
333 bb_install_apk ${APK} ${APK_PACKAGE}
334
335 # Run instrumentation tests. Using -I to install the test apk.
336 echo "@@@BUILD_STEP Run instrumentation tests ${TEST_APK}@@@"
337 FLAGS="-vvv"
338 if [[ "${BUILDTYPE}" == Release ]]; then
339 FLAGS="${FLAGS} --release"
340 fi
341 bb_run_step python build/android/run_instrumentation_tests.py \
342 ${FLAGS} ${EXTRA_RUN_TESTS_FLAGS} --test-apk ${TEST_APK} -I \
343 --test_data ${TEST_DATA}
344 }
345
346 # Run instrumentation tests for all relevant APKs on device.
347 function bb_run_instrumentation_tests {
348 bb_run_all_instrumentation_tests_for_apk "ContentShell.apk" \
349 "org.chromium.content_shell" "ContentShellTest" \
350 "content:content/test/data/android/device_files"
351 bb_run_all_instrumentation_tests_for_apk "ChromiumTestShell.apk" \
352 "org.chromium.chrome.testshell" "ChromiumTestShellTest" \
353 "chrome:chrome/test/data/android/device_files"
354 bb_run_all_instrumentation_tests_for_apk "AndroidWebView.apk" \
355 "org.chromium.android_webview" "AndroidWebViewTest" \
356 "webview:android_webview/test/data/device_files"
357 }
358
359 # Run instrumentation tests for experimental APKs on device.
360 function bb_run_experimental_instrumentation_tests {
361 echo "" # Can't have empty functions in bash.
362 }
363
364 # Zip and archive a build. 219 # Zip and archive a build.
365 function bb_zip_build { 220 function bb_zip_build {
366 echo "@@@BUILD_STEP Zip build@@@" 221 echo "@@@BUILD_STEP Zip build@@@"
367 python ../../../../scripts/slave/zip_build.py \ 222 python ../../../../scripts/slave/zip_build.py \
368 --src-dir "$SRC_ROOT" \ 223 --src-dir "$SRC_ROOT" \
369 --exclude-files "lib.target,gen,android_webview,jingle_unittests" \ 224 --exclude-files "lib.target,gen,android_webview,jingle_unittests" \
370 --factory-properties "$FACTORY_PROPERTIES" \ 225 --factory-properties "$FACTORY_PROPERTIES" \
371 --build-properties "$BUILD_PROPERTIES" 226 --build-properties "$BUILD_PROPERTIES"
372 } 227 }
373 228
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 ) 288 )
434 } 289 }
435 290
436 # Retrieve a packed json property using python 291 # Retrieve a packed json property using python
437 function bb_get_json_prop { 292 function bb_get_json_prop {
438 local JSON="$1" 293 local JSON="$1"
439 local PROP="$2" 294 local PROP="$2"
440 295
441 python -c "import json; print json.loads('$JSON').get('$PROP', '')" 296 python -c "import json; print json.loads('$JSON').get('$PROP', '')"
442 } 297 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698