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

Side by Side Diff: sync_build_test.sh

Issue 4104004: crosutils: enable learning board type and setting localaccount (Closed) Base URL: http://git.chromium.org/git/crosutils.git
Patch Set: Created 10 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/bin/bash 1 #!/bin/bash
2 2
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 # Script to sync your checkout, build a Chromium OS image, and test it all 7 # Script to sync your checkout, build a Chromium OS image, and test it all
8 # with one command. Can also check out a new Chromium OS checkout and 8 # with one command. Can also check out a new Chromium OS checkout and
9 # perform a subset of the above operations. 9 # perform a subset of the above operations.
10 # 10 #
(...skipping 26 matching lines...) Expand all
37 # 37 #
38 # Environment variables that may be useful: 38 # Environment variables that may be useful:
39 # BUILDBOT_URI - default value for --buildbot_uri 39 # BUILDBOT_URI - default value for --buildbot_uri
40 # CHROMIUM_REPO - default value for --repo 40 # CHROMIUM_REPO - default value for --repo
41 # CHRONOS_PASSWD - default value for --chronos_passwd 41 # CHRONOS_PASSWD - default value for --chronos_passwd
42 # 42 #
43 43
44 # Load common constants. This should be the first executable line. 44 # Load common constants. This should be the first executable line.
45 # The path to common.sh should be relative to your script's location. 45 # The path to common.sh should be relative to your script's location.
46 . "$(dirname "$0")/common.sh" 46 . "$(dirname "$0")/common.sh"
47 # Allow remote access (for learning board type)
48 . "$(dirname "$0")/remote_access.sh"
47 49
48 50 DEFINE_string board "" "Board setting"
49 DEFINE_string board "x86-generic" "Board setting"
50 DEFINE_boolean build ${FLAGS_TRUE} \ 51 DEFINE_boolean build ${FLAGS_TRUE} \
51 "Build all code (but not necessarily master image)" 52 "Build all code (but not necessarily master image)"
52 DEFINE_boolean build_autotest ${FLAGS_FALSE} "Build autotest" 53 DEFINE_boolean build_autotest ${FLAGS_FALSE} "Build autotest"
53 DEFINE_string buildbot_uri "${BUILDBOT_URI}" \ 54 DEFINE_string buildbot_uri "${BUILDBOT_URI}" \
54 "Base URI to buildbot build location which contains LATEST file" 55 "Base URI to buildbot build location which contains LATEST file"
55 DEFINE_string chrome_root "" \ 56 DEFINE_string chrome_root "" \
56 "The root of your chrome browser source. Should contain a 'src' subdir. \ 57 "The root of your chrome browser source. Should contain a 'src' subdir. \
57 If this is set, chrome browser will be built from source." 58 If this is set, chrome browser will be built from source."
58 DEFINE_string chronos_passwd "${CHRONOS_PASSWD}" \ 59 DEFINE_string chronos_passwd "${CHRONOS_PASSWD}" \
59 "Use this as the chronos user passwd (defaults to \$CHRONOS_PASSWD)" 60 "Use this as the chronos user passwd (defaults to \$CHRONOS_PASSWD)"
(...skipping 11 matching lines...) Expand all
71 DEFINE_string image_to_usb "" \ 72 DEFINE_string image_to_usb "" \
72 "Treat this device as USB and put the image on it after build" 73 "Treat this device as USB and put the image on it after build"
73 # You can set jobs > 1 but then your build may break and you may need 74 # You can set jobs > 1 but then your build may break and you may need
74 # to retry. Setting it to 1 is best for non-interactive sessions. 75 # to retry. Setting it to 1 is best for non-interactive sessions.
75 DEFINE_boolean interactive ${FLAGS_FALSE} \ 76 DEFINE_boolean interactive ${FLAGS_FALSE} \
76 "Tell user what we plan to do and wait for input to proceed" i 77 "Tell user what we plan to do and wait for input to proceed" i
77 DEFINE_integer jobs -1 "Concurrent build jobs" 78 DEFINE_integer jobs -1 "Concurrent build jobs"
78 DEFINE_boolean master ${FLAGS_TRUE} "Master an image from built code" 79 DEFINE_boolean master ${FLAGS_TRUE} "Master an image from built code"
79 DEFINE_boolean minilayout ${FLAGS_FALSE} "Use minimal code checkout" 80 DEFINE_boolean minilayout ${FLAGS_FALSE} "Use minimal code checkout"
80 DEFINE_boolean mod_image_for_test ${FLAGS_FALSE} "Modify the image for testing" 81 DEFINE_boolean mod_image_for_test ${FLAGS_FALSE} "Modify the image for testing"
81 DEFINE_string remote "" \
82 "Use this hostname/IP for live updating and running tests"
83 DEFINE_string repo "${CHROMIUMOS_REPO}" "gclient repo for chromiumos" 82 DEFINE_string repo "${CHROMIUMOS_REPO}" "gclient repo for chromiumos"
84 DEFINE_boolean sync ${FLAGS_TRUE} "Sync the checkout" 83 DEFINE_boolean sync ${FLAGS_TRUE} "Sync the checkout"
85 DEFINE_string test "" \ 84 DEFINE_string test "" \
86 "Test the built image with the given params to run_remote_tests" 85 "Test the built image with the given params to run_remote_tests"
87 DEFINE_string top "" \ 86 DEFINE_string top "" \
88 "Root directory of your checkout (defaults to determining from your cwd)" 87 "Root directory of your checkout (defaults to determining from your cwd)"
89 DEFINE_boolean withdev ${FLAGS_TRUE} "Build development packages" 88 DEFINE_boolean withdev ${FLAGS_TRUE} "Build development packages"
90 DEFINE_boolean usepkg ${FLAGS_TRUE} "Use binary packages" 89 DEFINE_boolean usepkg ${FLAGS_TRUE} "Use binary packages"
91 DEFINE_boolean useworkon ${FLAGS_TRUE} "Use cros_workon/repo workflow" 90 DEFINE_boolean useworkon ${FLAGS_TRUE} "Use cros_workon/repo workflow"
92 DEFINE_boolean unittest ${FLAGS_TRUE} "Run unit tests" 91 DEFINE_boolean unittest ${FLAGS_TRUE} "Run unit tests"
93 92
94 # Returns a heuristic indicating if we believe this to be a google internal 93 # Returns a heuristic indicating if we believe this to be a google internal
95 # development environment. 94 # development environment.
96 # Returns: 95 # Returns:
97 # 0 if so, 1 otherwise 96 # 0 if so, 1 otherwise
98 function is_google_environment() { 97 function is_google_environment() {
99 hostname | egrep -q .google.com\$ 98 hostname | egrep -q .google.com\$
100 return $? 99 return $?
101 } 100 }
102 101
103 102
104 # Validates parameters and sets "intelligent" defaults based on other 103 # Validates parameters and sets "intelligent" defaults based on other
105 # parameters. 104 # parameters.
106 function validate_and_set_param_defaults() { 105 function validate_and_set_param_defaults() {
106 TMP=$(mktemp -d "/tmp/sync_build_test.XXXX")
107
107 if [[ -z "${FLAGS_top}" ]]; then 108 if [[ -z "${FLAGS_top}" ]]; then
108 local test_dir=$(pwd) 109 local test_dir=$(pwd)
109 while [[ "${test_dir}" != "/" ]]; do 110 while [[ "${test_dir}" != "/" ]]; do
110 if [[ -d "${test_dir}/src/platform/dev" ]]; then 111 if [[ -d "${test_dir}/src/platform/dev" ]]; then
111 FLAGS_top="${test_dir}" 112 FLAGS_top="${test_dir}"
112 break 113 break
113 fi 114 fi
114 test_dir=$(dirname "${test_dir}") 115 test_dir=$(dirname "${test_dir}")
115 done 116 done
116 fi 117 fi
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 # built during run_remote_tests, so we need to build them all 168 # built during run_remote_tests, so we need to build them all
168 # beforehand. 169 # beforehand.
169 FLAGS_build_autotest=${FLAGS_TRUE} 170 FLAGS_build_autotest=${FLAGS_TRUE}
170 fi 171 fi
171 fi 172 fi
172 173
173 # If they gave us a remote host, then we assume they want us to do a live 174 # If they gave us a remote host, then we assume they want us to do a live
174 # update. 175 # update.
175 if [[ -n "${FLAGS_remote}" ]]; then 176 if [[ -n "${FLAGS_remote}" ]]; then
176 FLAGS_image_to_live=${FLAGS_TRUE} 177 FLAGS_image_to_live=${FLAGS_TRUE}
178 remote_access_init
179 fi
180
181 # Figure out board.
182 if [[ -z "${FLAGS_board}" ]]; then
183 if [[ -n "${FLAGS_remote}" ]]; then
184 learn_board
185 else
186 FLAGS_board="${DEFAULT_BOARD}"
187 fi
177 fi 188 fi
178 189
179 # Grabbing a buildbot build is exclusive with syncing and building 190 # Grabbing a buildbot build is exclusive with syncing and building
180 if [[ -n "${FLAGS_grab_buildbot}" ]]; then 191 if [[ -n "${FLAGS_grab_buildbot}" ]]; then
181 if [[ "${FLAGS_grab_buildbot}" == "LATEST" ]]; then 192 if [[ "${FLAGS_grab_buildbot}" == "LATEST" ]]; then
182 if [[ -z "${FLAGS_buildbot_uri}" ]]; then 193 if [[ -z "${FLAGS_buildbot_uri}" ]]; then
183 echo "--grab_buildbot=LATEST requires --buildbot_uri or setting " 194 echo "--grab_buildbot=LATEST requires --buildbot_uri or setting "
184 echo "BUILDBOT_URI" 195 echo "BUILDBOT_URI"
185 exit 1 196 exit 1
186 fi 197 fi
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 # $1 - phase description 344 # $1 - phase description
334 function describe_phase() { 345 function describe_phase() {
335 local desc="$1" 346 local desc="$1"
336 echo "" 347 echo ""
337 echo "#" 348 echo "#"
338 echo "#" 349 echo "#"
339 echo "# ${desc}" 350 echo "# ${desc}"
340 echo "#" 351 echo "#"
341 } 352 }
342 353
354 function cleanup() {
355 [ -n "${TMP}" ] && rm -rf "${TMP}"
356 cleanup_remote_access
357 }
343 358
344 # Called when there is a failure and we exit early 359 # Called when there is a failure and we exit early
345 function failure() { 360 function failure() {
346 trap - EXIT 361 trap - EXIT
347 # Clear these out just in case. 362 # Clear these out just in case.
348 export GSDCURL_USERNAME="" 363 export GSDCURL_USERNAME=""
349 export GSDCURL_PASSWORD="" 364 export GSDCURL_PASSWORD=""
350 describe_phase "Failure during: ${LAST_PHASE}" 365 describe_phase "Failure during: ${LAST_PHASE}"
351 show_duration 366 show_duration
367 cleanup
352 } 368 }
353 369
354 370
355 # Runs a phase, describing it first, and also updates the sudo timeout 371 # Runs a phase, describing it first, and also updates the sudo timeout
356 # afterwards. 372 # afterwards.
357 # Arguments: 373 # Arguments:
358 # $1 - phase description 374 # $1 - phase description
359 # $2.. - command/params to run 375 # $2.. - command/params to run
360 function run_phase() { 376 function run_phase() {
361 local desc="$1" 377 local desc="$1"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 export GSDCURL_PASSWORD 480 export GSDCURL_PASSWORD
465 CURL="$(dirname $0)/bin/cros_gsdcurl.py" 481 CURL="$(dirname $0)/bin/cros_gsdcurl.py"
466 if [[ "${FLAGS_grab_buildbot}" == "LATEST" ]]; then 482 if [[ "${FLAGS_grab_buildbot}" == "LATEST" ]]; then
467 local latest=$(${CURL} "${FLAGS_buildbot_uri}/LATEST") 483 local latest=$(${CURL} "${FLAGS_buildbot_uri}/LATEST")
468 if [[ -z "${latest}" ]]; then 484 if [[ -z "${latest}" ]]; then
469 echo "Error finding latest." 485 echo "Error finding latest."
470 exit 1 486 exit 1
471 fi 487 fi
472 FLAGS_grab_buildbot="${FLAGS_buildbot_uri}/${latest}/image.zip" 488 FLAGS_grab_buildbot="${FLAGS_buildbot_uri}/${latest}/image.zip"
473 fi 489 fi
474 local dl_dir=$(mktemp -d "/tmp/image.XXXX") 490 local dl_dir="${TMP}/image"
475 491
476 echo "Grabbing image from ${FLAGS_grab_buildbot} to ${dl_dir}" 492 echo "Grabbing image from ${FLAGS_grab_buildbot} to ${dl_dir}"
477 run_phase "Downloading image" ${CURL} "${FLAGS_grab_buildbot}" \ 493 run_phase "Downloading image" ${CURL} "${FLAGS_grab_buildbot}" \
478 -o "${dl_dir}/image.zip" 494 -o "${dl_dir}/image.zip"
479 # Clear out the credentials so they can't be used later. 495 # Clear out the credentials so they can't be used later.
480 export GSDCURL_USERNAME="" 496 export GSDCURL_USERNAME=""
481 export GSDCURL_PASSWORD="" 497 export GSDCURL_PASSWORD=""
482 498
483 cd "${dl_dir}" 499 cd "${dl_dir}"
484 unzip image.zip 500 unzip image.zip
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 589
574 if [[ ${FLAGS_force_make_chroot} -eq ${FLAGS_TRUE} ]]; then 590 if [[ ${FLAGS_force_make_chroot} -eq ${FLAGS_TRUE} ]]; then
575 chdir_relative src/scripts 591 chdir_relative src/scripts
576 local extra_flags="--nouseworkon" 592 local extra_flags="--nouseworkon"
577 [[ ${FLAGS_useworkon} -eq ${FLAGS_TRUE} ]] && extra_flags="--useworkon" 593 [[ ${FLAGS_useworkon} -eq ${FLAGS_TRUE} ]] && extra_flags="--useworkon"
578 run_phase "Replacing chroot" ./make_chroot ${extra_flags} --replace \ 594 run_phase "Replacing chroot" ./make_chroot ${extra_flags} --replace \
579 "--chroot=${FLAGS_chroot}" ${jobs_param} 595 "--chroot=${FLAGS_chroot}" ${jobs_param}
580 fi 596 fi
581 597
582 if [[ ${FLAGS_build} -eq ${FLAGS_TRUE} ]]; then 598 if [[ ${FLAGS_build} -eq ${FLAGS_TRUE} ]]; then
599 # It's necessary to enable localaccount for BVT tests to pass.
600 chdir_relative src/scripts
601 run_phase "Enable local account" \
602 ./enable_localaccount.sh chronos "${FLAGS_chroot}"
603
583 local pkg_param="" 604 local pkg_param=""
584 if [[ ${FLAGS_usepkg} -eq ${FLAGS_FALSE} ]]; then 605 if [[ ${FLAGS_usepkg} -eq ${FLAGS_FALSE} ]]; then
585 pkg_param="--nousepkg" 606 pkg_param="--nousepkg"
586 fi 607 fi
587 608
588 chdir_relative src/scripts 609 chdir_relative src/scripts
589 # Only setup board target if the directory does not exist 610 # Only setup board target if the directory does not exist
590 if [[ ! -d "${FLAGS_top}/chroot/build/${FLAGS_board}" ]]; then 611 if [[ ! -d "${FLAGS_top}/chroot/build/${FLAGS_board}" ]]; then
591 run_phase_in_chroot "Setting up board target" \ 612 run_phase_in_chroot "Setting up board target" \
592 ./setup_board ${pkg_param} "${board_param}" 613 ./setup_board ${pkg_param} "${board_param}"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 if ! run_phase "Running tests on Chromium OS machine ${FLAGS_remote}" \ 677 if ! run_phase "Running tests on Chromium OS machine ${FLAGS_remote}" \
657 ./run_remote_tests.sh "--remote=${FLAGS_remote}" ${FLAGS_test} \ 678 ./run_remote_tests.sh "--remote=${FLAGS_remote}" ${FLAGS_test} \
658 "${board_param}"; then 679 "${board_param}"; then
659 if [[ ${FLAGS_ignore_remote_test_failures} -eq ${FLAGS_FALSE} ]]; then 680 if [[ ${FLAGS_ignore_remote_test_failures} -eq ${FLAGS_FALSE} ]]; then
660 echo "Remote tests failed and --ignore_remote_test_failures not passed" 681 echo "Remote tests failed and --ignore_remote_test_failures not passed"
661 false 682 false
662 fi 683 fi
663 fi 684 fi
664 fi 685 fi
665 686
666 trap - EXIT 687 trap cleanup EXIT
667 echo "Successfully used ${FLAGS_top} to:" 688 echo "Successfully used ${FLAGS_top} to:"
668 describe_steps 689 describe_steps
669 show_duration 690 show_duration
670 } 691 }
671 692
672 693
673 main $@ 694 main $@
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698