OLD | NEW |
---|---|
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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
55 DEFINE_boolean force_make_chroot ${FLAGS_FALSE} "Run make_chroot indep of sync" | 55 DEFINE_boolean force_make_chroot ${FLAGS_FALSE} "Run make_chroot indep of sync" |
56 DEFINE_boolean build ${FLAGS_TRUE} \ | 56 DEFINE_boolean build ${FLAGS_TRUE} \ |
57 "Build all code (but not necessarily master image)" | 57 "Build all code (but not necessarily master image)" |
58 DEFINE_boolean master ${FLAGS_TRUE} "Master an image from built code" | 58 DEFINE_boolean master ${FLAGS_TRUE} "Master an image from built code" |
59 DEFINE_string grab_buildbot "" \ | 59 DEFINE_string grab_buildbot "" \ |
60 "Instead of building, grab this full image.zip URI generated by the \ | 60 "Instead of building, grab this full image.zip URI generated by the \ |
61 buildbot" | 61 buildbot" |
62 DEFINE_string chronos_passwd "${CHRONOS_PASSWD}" \ | 62 DEFINE_string chronos_passwd "${CHRONOS_PASSWD}" \ |
63 "Use this as the chronos user passwd (defaults to \$CHRONOS_PASSWD)" | 63 "Use this as the chronos user passwd (defaults to \$CHRONOS_PASSWD)" |
64 DEFINE_boolean mod_image_for_test ${FLAGS_FALSE} "Modify the image for testing" | 64 DEFINE_boolean mod_image_for_test ${FLAGS_FALSE} "Modify the image for testing" |
65 DEFINE_boolean build_autotest ${FLAGS_FALSE} "Build autotest" | |
65 DEFINE_boolean image_to_live ${FLAGS_FALSE} \ | 66 DEFINE_boolean image_to_live ${FLAGS_FALSE} \ |
66 "Put the resulting image on live instance (requires --remote)" | 67 "Put the resulting image on live instance (requires --remote)" |
67 DEFINE_string remote "" \ | 68 DEFINE_string remote "" \ |
68 "Use this hostname/IP for live updating and running tests" | 69 "Use this hostname/IP for live updating and running tests" |
69 DEFINE_string image_to_usb "" \ | 70 DEFINE_string image_to_usb "" \ |
70 "Treat this device as USB and put the image on it after build" | 71 "Treat this device as USB and put the image on it after build" |
71 DEFINE_string test "" \ | 72 DEFINE_string test "" \ |
72 "Test the built image with the given params to run_remote_tests" | 73 "Test the built image with the given params to run_remote_tests" |
73 DEFINE_string buildbot_uri "${BUILDBOT_URI}" \ | 74 DEFINE_string buildbot_uri "${BUILDBOT_URI}" \ |
74 "Base URI to buildbot build location which contains LATEST file" | 75 "Base URI to buildbot build location which contains LATEST file" |
(...skipping 24 matching lines...) Expand all Loading... | |
99 fi | 100 fi |
100 test_dir=$(dirname "${test_dir}") | 101 test_dir=$(dirname "${test_dir}") |
101 done | 102 done |
102 fi | 103 fi |
103 | 104 |
104 if [[ -z "${FLAGS_top}" ]]; then | 105 if [[ -z "${FLAGS_top}" ]]; then |
105 # Use the top directory based on where this script runs from | 106 # Use the top directory based on where this script runs from |
106 FLAGS_top=$(dirname $(dirname $(dirname $0))) | 107 FLAGS_top=$(dirname $(dirname $(dirname $0))) |
107 fi | 108 fi |
108 | 109 |
110 # Canonicalize any symlinks | |
111 FLAGS_top=$(readlink -f "${FLAGS_top}") | |
112 | |
109 if [[ -z "${FLAGS_repo}" ]]; then | 113 if [[ -z "${FLAGS_repo}" ]]; then |
110 if is_google_environment; then | 114 if is_google_environment; then |
111 FLAGS_repo="ssh://git@chromiumos-git//chromeos" | 115 FLAGS_repo="ssh://git@chromiumos-git//chromeos" |
112 else | 116 else |
113 FLAGS_repo="http://src.chromium.org/git/chromiumos.git" | 117 FLAGS_repo="http://src.chromium.org/git/chromiumos.git" |
114 fi | 118 fi |
115 fi | 119 fi |
116 | 120 |
117 if [[ -n "${FLAGS_test}" ]]; then | 121 if [[ -n "${FLAGS_test}" ]]; then |
118 # If you specify that tests should be run, we assume the image | 122 # If you specify that tests should be run, we assume the image |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
152 if [[ -z "${FLAGS_remote}" ]]; then | 156 if [[ -z "${FLAGS_remote}" ]]; then |
153 echo "Please specify --remote with --image_to_live" | 157 echo "Please specify --remote with --image_to_live" |
154 exit 1 | 158 exit 1 |
155 fi | 159 fi |
156 fi | 160 fi |
157 | 161 |
158 if [[ ${FLAGS_mod_image_for_test} -eq ${FLAGS_TRUE} ]]; then | 162 if [[ ${FLAGS_mod_image_for_test} -eq ${FLAGS_TRUE} ]]; then |
159 # Override any specified chronos password with the test one | 163 # Override any specified chronos password with the test one |
160 local test_file=$(dirname $0)"/mod_for_test_scripts/test_account.passwd" | 164 local test_file=$(dirname $0)"/mod_for_test_scripts/test_account.passwd" |
161 FLAGS_chronos_passwd=$(head -1 "${test_file}") | 165 FLAGS_chronos_passwd=$(head -1 "${test_file}") |
166 # Default to building autotests whenever we mod image for test. | |
167 # TODO(kmixter): Make this more efficient by either doing incremental | |
168 # building, or only building if the tests we're running needs to be. | |
sosa
2010/01/29 02:43:12
True, we probably should parametrize build_autotes
| |
169 FLAGS_build_autotest=${FLAGS_TRUE} | |
162 fi | 170 fi |
163 | 171 |
164 if [[ -n "${FLAGS_image_to_usb}" ]]; then | 172 if [[ -n "${FLAGS_image_to_usb}" ]]; then |
165 local device=${FLAGS_image_to_usb#/dev/} | 173 local device=${FLAGS_image_to_usb#/dev/} |
166 if [[ -z "${device}" ]]; then | 174 if [[ -z "${device}" ]]; then |
167 echo "Expected --image_to_usb option of /dev/* format" | 175 echo "Expected --image_to_usb option of /dev/* format" |
168 exit 1 | 176 exit 1 |
169 fi | 177 fi |
170 local is_removable=$(cat /sys/block/${device}/removable) | 178 local is_removable=$(cat /sys/block/${device}/removable) |
171 if [[ "${is_removable}" != "1" ]]; then | 179 if [[ "${is_removable}" != "1" ]]; then |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
209 echo " * Make image able to run tests (mod_image_for_test)" | 217 echo " * Make image able to run tests (mod_image_for_test)" |
210 set_passwd=${FLAGS_TRUE} | 218 set_passwd=${FLAGS_TRUE} |
211 fi | 219 fi |
212 if [[ ${set_passwd} -eq ${FLAGS_TRUE} ]]; then | 220 if [[ ${set_passwd} -eq ${FLAGS_TRUE} ]]; then |
213 if [[ -n "${FLAGS_chronos_passwd}" ]]; then | 221 if [[ -n "${FLAGS_chronos_passwd}" ]]; then |
214 echo " * Set chronos password to ${FLAGS_chronos_passwd}" | 222 echo " * Set chronos password to ${FLAGS_chronos_passwd}" |
215 else | 223 else |
216 echo " * Set chronos password randomly" | 224 echo " * Set chronos password randomly" |
217 fi | 225 fi |
218 fi | 226 fi |
227 if [[ ${FLAGS_build_autotest} -eq ${FLAGS_TRUE} ]]; then | |
228 echo " * Build autotest" | |
229 fi | |
219 if [[ -n "${FLAGS_image_to_usb}" ]]; then | 230 if [[ -n "${FLAGS_image_to_usb}" ]]; then |
220 echo " * Write the image to USB device ${FLAGS_image_to_usb}" | 231 echo " * Write the image to USB device ${FLAGS_image_to_usb}" |
221 fi | 232 fi |
222 if [[ ${FLAGS_image_to_live} -eq ${FLAGS_TRUE} ]]; then | 233 if [[ ${FLAGS_image_to_live} -eq ${FLAGS_TRUE} ]]; then |
223 echo " * Reimage live test Chromium OS instance at ${FLAGS_remote}" | 234 echo " * Reimage live test Chromium OS instance at ${FLAGS_remote}" |
224 fi | 235 fi |
225 if [[ -n "${FLAGS_test}" ]]; then | 236 if [[ -n "${FLAGS_test}" ]]; then |
226 echo " * Run tests (${FLAGS_test}) on machine at ${FLAGS_remote}" | 237 echo " * Run tests (${FLAGS_test}) on machine at ${FLAGS_remote}" |
227 fi | 238 fi |
228 } | 239 } |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
453 run_phase "Installing image to USB" \ | 464 run_phase "Installing image to USB" \ |
454 ./image_to_usb.sh --yes "--to=${FLAGS_image_to_usb}" | 465 ./image_to_usb.sh --yes "--to=${FLAGS_image_to_usb}" |
455 fi | 466 fi |
456 | 467 |
457 if [[ ${FLAGS_image_to_live} -eq ${FLAGS_TRUE} ]]; then | 468 if [[ ${FLAGS_image_to_live} -eq ${FLAGS_TRUE} ]]; then |
458 chdir_relative src/scripts | 469 chdir_relative src/scripts |
459 run_phase "Re-imaging live Chromium OS machine ${FLAGS_remote}" \ | 470 run_phase "Re-imaging live Chromium OS machine ${FLAGS_remote}" \ |
460 ./image_to_live.sh "--remote=${FLAGS_remote}" --update_known_hosts | 471 ./image_to_live.sh "--remote=${FLAGS_remote}" --update_known_hosts |
461 fi | 472 fi |
462 | 473 |
474 if [[ ${FLAGS_build_autotest} -eq ${FLAGS_TRUE} ]]; then | |
475 chdir_relative src/scripts | |
476 run_phase "Building autotest" ./enter_chroot.sh "./build_autotest.sh" | |
477 fi | |
478 | |
463 if [[ -n "${FLAGS_test}" ]]; then | 479 if [[ -n "${FLAGS_test}" ]]; then |
464 chdir_relative src/scripts | 480 chdir_relative src/scripts |
465 # We purposefully do not quote FLAGS_test below as we expect it may | 481 # We purposefully do not quote FLAGS_test below as we expect it may |
466 # have multiple parameters | 482 # have multiple parameters |
467 run_phase "Running tests on Chromium OS machine ${FLAGS_remote}" \ | 483 run_phase "Running tests on Chromium OS machine ${FLAGS_remote}" \ |
468 ./run_remote_tests.sh --remote="${FLAGS_remote}" ${FLAGS_test} | 484 ./run_remote_tests.sh --remote="${FLAGS_remote}" ${FLAGS_test} |
469 fi | 485 fi |
470 | 486 |
471 echo "Successfully used ${FLAGS_top} to:" | 487 echo "Successfully used ${FLAGS_top} to:" |
472 describe_steps | 488 describe_steps |
473 } | 489 } |
474 | 490 |
475 | 491 |
476 main $@ | 492 main $@ |
OLD | NEW |