diff --git a/sync_build_test.sh b/sync_build_test.sh index 9473205e67..16934419c0 100755 --- a/sync_build_test.sh +++ b/sync_build_test.sh @@ -58,10 +58,14 @@ If this is set, chrome browser will be built from source." DEFINE_string chronos_passwd "${CHRONOS_PASSWD}" \ "Use this as the chronos user passwd (defaults to \$CHRONOS_PASSWD)" DEFINE_string chroot "" "Chroot to build/use" +DEFINE_boolean enable_rootfs_verification ${FLAGS_TRUE} \ + "Enable rootfs verification when building image" DEFINE_boolean force_make_chroot ${FLAGS_FALSE} "Run make_chroot indep of sync" DEFINE_string grab_buildbot "" \ "Instead of building, grab this full image.zip URI generated by the \ buildbot" +DEFINE_boolean ignore_remote_test_failures ${FLAGS_FALSE} \ + "Ignore any remote tests that failed and don't return failure" DEFINE_boolean image_to_live ${FLAGS_FALSE} \ "Put the resulting image on live instance (requires --remote)" DEFINE_string image_to_usb "" \ @@ -183,6 +187,7 @@ function validate_and_set_param_defaults() { fi FLAGS_sync=${FLAGS_FALSE} FLAGS_build=${FLAGS_FALSE} + FLAGS_unittest=${FLAGS_FALSE} FLAGS_master=${FLAGS_FALSE} fi @@ -339,6 +344,9 @@ function describe_phase() { # Called when there is a failure and we exit early function failure() { trap - EXIT + # Clear these out just in case. + export GSDCURL_USERNAME="" + export GSDCURL_PASSWORD="" describe_phase "Failure during: ${LAST_PHASE}" show_duration } @@ -450,8 +458,13 @@ EOF # Downloads a buildbot image function grab_buildbot() { + read -p "Username [${LOGNAME}]: " GSDCURL_USERNAME + export GSDCURL_USERNAME + read -s -p "Password: " GSDCURL_PASSWORD + export GSDCURL_PASSWORD + CURL="$(dirname $0)/bin/cros_gsdcurl.py" if [[ "${FLAGS_grab_buildbot}" == "LATEST" ]]; then - local latest=$(curl "${FLAGS_buildbot_uri}/LATEST") + local latest=$(${CURL} "${FLAGS_buildbot_uri}/LATEST") if [[ -z "${latest}" ]]; then echo "Error finding latest." exit 1 @@ -459,9 +472,14 @@ function grab_buildbot() { FLAGS_grab_buildbot="${FLAGS_buildbot_uri}/${latest}/image.zip" fi local dl_dir=$(mktemp -d "/tmp/image.XXXX") + echo "Grabbing image from ${FLAGS_grab_buildbot} to ${dl_dir}" - run_phase "Downloading image" curl "${FLAGS_grab_buildbot}" \ - -o "${dl_dir}/image.zip" + run_phase "Downloading image" ${CURL} "${FLAGS_grab_buildbot}" \ + -o "${dl_dir}/image.zip" + # Clear out the credentials so they can't be used later. + export GSDCURL_USERNAME="" + export GSDCURL_PASSWORD="" + cd "${dl_dir}" unzip image.zip local image_basename=$(basename $(dirname "${FLAGS_grab_buildbot}")) @@ -474,6 +492,15 @@ function grab_buildbot() { run_phase "Installing buildbot test modified image" \ mv chromiumos_test_image.bin "${image_dir}/chromiumos_image.bin" FLAGS_mod_image_for_test=${FLAGS_FALSE} + else + run_phase "Installing buildbot base image" \ + mv chromiumos_base_image.bin "${image_dir}/chromiumos_image.bin" + fi + + if [[ -n "${FLAGS_test}" ]]; then + if [[ ! -d "${FLAGS_top}/chroot/build/${FLAGS_board}" ]]; then + die "To run tests on a buildbot image, run setup_board first." + fi if [[ -e "autotest.tgz" || -e "autotest.tar.bz2" ]]; then # pull in autotest local dir="${FLAGS_chroot}/build/${FLAGS_board}/usr/local" @@ -491,8 +518,6 @@ function grab_buildbot() { run_phase "Installing buildbot autotest cross-compiled binaries" \ sudo mv autotest ${dir} fi - else - mv chromiumos_image.bin "${image_dir}" fi chdir_relative . run_phase "Removing downloaded image" rm -rf "${dl_dir}" @@ -569,16 +594,6 @@ function main() { local build_autotest_param="" if [[ ${FLAGS_build_autotest} -eq ${FLAGS_TRUE} ]]; then build_autotest_param="--withautotest" - if [[ ${FLAGS_useworkon} -eq ${FLAGS_TRUE} ]]; then - # In workon flow, you must workon packages to run tests - run_phase_in_chroot "Setting workon for autotest" \ - ./cros_workon --board=${FLAGS_board} start autotest \ - autotest-tests autotest-deps - # In minilayout you may not yet have autotest. - if [[ ! -d "${FLAGS_top}/src/third_party/autotest/files" ]]; then - run_phase "Syncing autotest repo" repo sync autotest - fi - fi fi run_phase_in_chroot "Building packages" \ @@ -595,6 +610,7 @@ function main() { if [[ ${FLAGS_unittest} -eq ${FLAGS_TRUE} ]] && [[ "${FLAGS_board}" == \ "x86-generic" ]] ; then + chdir_relative src/scripts run_phase_in_chroot "Running unit tests" ./cros_run_unit_tests \ ${board_param} fi @@ -606,9 +622,13 @@ function main() { ./enter_chroot.sh "echo '${FLAGS_chronos_passwd}' | \ ~/trunk/src/scripts/set_shared_user_password.sh" fi + local other_params="--enable_rootfs_verification" + if [[ ${FLAGS_enable_rootfs_verification} -eq ${FLAGS_FALSE} ]]; then + other_params="--noenable_rootfs_verification" + fi run_phase_in_chroot "Mastering image" ./build_image \ "${board_param}" --replace ${withdev_param} \ - ${jobs_param} + ${jobs_param} ${other_params} fi if [[ ${FLAGS_mod_image_for_test} -eq ${FLAGS_TRUE} ]]; then @@ -633,9 +653,14 @@ function main() { chdir_relative src/scripts # We purposefully do not quote FLAGS_test below as we expect it may # have multiple parameters - run_phase "Running tests on Chromium OS machine ${FLAGS_remote}" \ + if ! run_phase "Running tests on Chromium OS machine ${FLAGS_remote}" \ ./run_remote_tests.sh "--remote=${FLAGS_remote}" ${FLAGS_test} \ - "${board_param}" + "${board_param}"; then + if [[ ${FLAGS_ignore_remote_test_failures} -eq ${FLAGS_FALSE} ]]; then + echo "Remote tests failed and --ignore_remote_test_failures not passed" + false + fi + fi fi trap - EXIT