diff options
author | Cassidy Burden <cburden@google.com> | 2016-06-30 15:24:20 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-07-01 11:58:13 -0700 |
commit | c4671bdd601ff945b2cccbfe1aee9f931dc908c7 (patch) | |
tree | 4cdec6fd367b6f8a9162f4c56f18d3232a494b63 /binary_search_tool/sysroot_wrapper | |
parent | 63f13489b1a02bbbc75b46fec6ae7a817442df94 (diff) | |
download | toolchain-utils-c4671bdd601ff945b2cccbfe1aee9f931dc908c7.tar.gz |
binary search tool: (Refactor) Extract common scripts into common folder
Refactor warning! Move install.sh, boot_test.sh, and interactive_test.sh
into common folder so they can be shared by both package and object
bisectors. To allow this sharing, sysroot_wrapper now has a setup script
similar to cros_pkg. All scripts now source common/common.sh.
TEST=Run unit tests, run system tests, run couple iterations of install
script for both bisectors.
Change-Id: I9e164b4e6b842ff321c2400201e6ac0984f99088
Reviewed-on: https://chrome-internal-review.googlesource.com/268027
Commit-Ready: Cassidy Burden <cburden@google.com>
Tested-by: Cassidy Burden <cburden@google.com>
Reviewed-by: Caroline Tice <cmtice@google.com>
Diffstat (limited to 'binary_search_tool/sysroot_wrapper')
-rw-r--r-- | binary_search_tool/sysroot_wrapper/README | 12 | ||||
l---------[-rwxr-xr-x] | binary_search_tool/sysroot_wrapper/boot_test.sh | 23 | ||||
-rwxr-xr-x | binary_search_tool/sysroot_wrapper/cleanup.sh | 11 | ||||
-rwxr-xr-x | binary_search_tool/sysroot_wrapper/common.sh | 3 | ||||
-rwxr-xr-x | binary_search_tool/sysroot_wrapper/get_initial_items.sh | 2 | ||||
-rwxr-xr-x | binary_search_tool/sysroot_wrapper/glibc_test_script.sh | 2 | ||||
l---------[-rwxr-xr-x] | binary_search_tool/sysroot_wrapper/install.sh | 161 | ||||
l---------[-rwxr-xr-x] | binary_search_tool/sysroot_wrapper/interactive_test.sh | 38 | ||||
-rwxr-xr-x | binary_search_tool/sysroot_wrapper/setup.sh | 71 | ||||
-rwxr-xr-x | binary_search_tool/sysroot_wrapper/switch_to_bad.sh | 2 | ||||
-rwxr-xr-x | binary_search_tool/sysroot_wrapper/switch_to_good.sh | 2 | ||||
-rwxr-xr-x | binary_search_tool/sysroot_wrapper/test_script.sh | 2 |
12 files changed, 102 insertions, 227 deletions
diff --git a/binary_search_tool/sysroot_wrapper/README b/binary_search_tool/sysroot_wrapper/README index 132c03d3..599d700d 100644 --- a/binary_search_tool/sysroot_wrapper/README +++ b/binary_search_tool/sysroot_wrapper/README @@ -3,10 +3,22 @@ the bisecting functionality included in the sysroot_wrapper.hardened. The only script that you need to create for your triaging problem is the test_script.sh (The ones in this directory are here only as an example). +Before running the binary searcher tool you will need to run the setup script: + +./sysroot_wrapper/setup.sh ${board} ${remote_ip} ${package} + +This setup script will ensure your $BISECT_DIR is properly populated and +generate a common variable script for the convenience of the scripts in +./sysroot_wrapper + To run the binary searcher tool with these scripts, execute it like this: ./binary_search_state.py --get_initial_items=./sysroot_wrapper/get_initial_items.sh --switch_to_good=./sysroot_wrapper/switch_to_good.sh --switch_to_bad=./sysroot_wrapper/switch_to_bad.sh --test_script=./sysroot_wrapper/test_script.sh --noincremental --file_args 2>&1 | tee /tmp/binary_search.log +Finally once done you will want to run the cleanup script: + +./sysroot_wrapper/cleanup.sh + For more information on how to use the sysroot_wrapper to do object file triaging see: diff --git a/binary_search_tool/sysroot_wrapper/boot_test.sh b/binary_search_tool/sysroot_wrapper/boot_test.sh index a3de2dec..9a345617 100755..120000 --- a/binary_search_tool/sysroot_wrapper/boot_test.sh +++ b/binary_search_tool/sysroot_wrapper/boot_test.sh @@ -1,22 +1 @@ -#!/bin/bash -u -# -# Copyright 2016 Google Inc. All Rights Reserved. -# -# This script pings the chromebook to determine if it has successfully booted. -# -# This script is intended to be used by binary_search_state.py, as -# part of the binary search triage on ChromeOS object files. It waits for the -# install script to build and install the image, then pings the machine. -# It should return '0' if the test succeeds (the image booted); '1' if the test -# fails (the image did not boot); and '2' if it could not determine (does not -# apply in this case). -# - -source sysroot_wrapper/common.sh - -# Send 3 pings and wait 3 seconds for any responsed (then timeout). -ping -c 3 -W 3 ${BISECT_REMOTE} -retval=$? - - -exit $retval +../common/boot_test.sh
\ No newline at end of file diff --git a/binary_search_tool/sysroot_wrapper/cleanup.sh b/binary_search_tool/sysroot_wrapper/cleanup.sh new file mode 100755 index 00000000..5066d638 --- /dev/null +++ b/binary_search_tool/sysroot_wrapper/cleanup.sh @@ -0,0 +1,11 @@ +#!/bin/bash +# +# Copyright 2016 Google Inc. All Rights Reserved. +# +# This script is part of the ChromeOS object binary search triage process. +# It should be the last script called by the user, after the user has +# successfully run the bisection tool and found their bad items. This script +# will perform all necessary cleanup for the bisection tool. +# + +rm common/common.sh diff --git a/binary_search_tool/sysroot_wrapper/common.sh b/binary_search_tool/sysroot_wrapper/common.sh deleted file mode 100755 index 0d60b9a6..00000000 --- a/binary_search_tool/sysroot_wrapper/common.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -u - -bisect_dir=${BISECT_DIR:-/tmp/sysroot_bisect} diff --git a/binary_search_tool/sysroot_wrapper/get_initial_items.sh b/binary_search_tool/sysroot_wrapper/get_initial_items.sh index 85d6942d..c1beb972 100755 --- a/binary_search_tool/sysroot_wrapper/get_initial_items.sh +++ b/binary_search_tool/sysroot_wrapper/get_initial_items.sh @@ -1,5 +1,5 @@ #!/bin/bash -u -source ./sysroot_wrapper/common.sh +source common/common.sh cat ${bisect_dir}/good/_LIST diff --git a/binary_search_tool/sysroot_wrapper/glibc_test_script.sh b/binary_search_tool/sysroot_wrapper/glibc_test_script.sh index 74e492ad..8e9ae8e4 100755 --- a/binary_search_tool/sysroot_wrapper/glibc_test_script.sh +++ b/binary_search_tool/sysroot_wrapper/glibc_test_script.sh @@ -7,7 +7,7 @@ # Note it returns 0 only when the installation of the image succeeded # (ie: the machine booted after installation) -source ./sysroot_wrapper/common.sh +source common/common.sh #export BISECT_STAGE=TRIAGE echo "BISECT_STAGE=${BISECT_STAGE}" diff --git a/binary_search_tool/sysroot_wrapper/install.sh b/binary_search_tool/sysroot_wrapper/install.sh index 7cf62168..562f7bbe 100755..120000 --- a/binary_search_tool/sysroot_wrapper/install.sh +++ b/binary_search_tool/sysroot_wrapper/install.sh @@ -1,160 +1 @@ -#!/bin/bash -# -# Copyright 2016 Google Inc. All Rights Reserved. -# -# This script calls build_image to generate a new ChromeOS image, -# using whatever packages are currently in the build tree. If -# build_images succeeeds, then it pushes the new ChromeOS image onto a -# chromebook. If pushing the ChromeOS image onto the chromebook fails it -# will walk the user through troubleshooting the problem. -# -# This script is intended to be used by binary_search_state.py, as -# part of the binary search triage on ChromeOS objects. It should return '0' -# if the install succeeds; and '1' if the install fails (the image could not -# build or be flashed). -# -# This script requires $BISECT_BOARD, $BISECT_REMOTE, and $BISECT_PACKAGE to be -# set. If they are not set the script will exit. -# - -export PYTHONUNBUFFERED=1 - -source sysroot_wrapper/common.sh - -usb_flash() -{ - echo - echo "Insert a usb stick into the current machine" - echo "Note: The cros flash will take time and doesn't give much output." - echo " Be patient. If your usb access light is flashing it's working." - sleep 1 - read -p "Press enter to continue" notused - - cros flash --board=${BISECT_BOARD} --clobber-stateful usb:// ~/trunk/src/build/images/${BISECT_BOARD}/latest/chromiumos_test_image.bin - - echo - echo "Flash to usb complete!" - echo "Plug the usb into your chromebook and install the image." - echo "Refer to the ChromiumOS Developer's Handbook for more details." - echo "http://www.chromium.org/chromium-os/developer-guide#TOC-Boot-from-your-USB-disk" - while true; do - sleep 1 - read -p "Was the installation of the image successful? " choice - case $choice in - [Yy]*) return 0;; - [Nn]*) return 1;; - *) echo "Please answer y or n.";; - esac - done -} - -ethernet_flash() -{ - echo - echo "Please ensure your Chromebook is up and running Chrome so" - echo "cros flash may run." - echo "If your Chromebook has a broken image you can try:" - echo "1. Rebooting your Chromebook 6 times to install the last working image" - echo "2. Alternatively, running the following command on the Chromebook" - echo " will also rollback to the last working image:" - echo " 'update_engine_client --rollback --nopowerwash --reboot'" - echo "3. Flashing a new image through USB" - echo - sleep 1 - read -p $'Press enter to continue and retry the ethernet flash' notused - cros flash --board=${BISECT_BOARD} --clobber-stateful ${BISECT_REMOTE} ~/trunk/src/build/images/${BISECT_BOARD}/latest/chromiumos_test_image.bin -} - -reboot() -{ - ret_val=0 - pushd ~/trunk/src/scripts > /dev/null - set -- --remote=${BISECT_REMOTE} - . ./common.sh || ret_val=1 - . ./remote_access.sh || ret_val=1 - TMP=$(mktemp -d) - FLAGS "$@" || ret_val=1 - remote_access_init || ret_val=1 - remote_reboot || ret_val=1 - popd > /dev/null - - return $ret_val -} - -if [[ -z "${BISECT_BOARD}" || -z "${BISECT_REMOTE}" || -z "${BISECT_PACKAGE}" ]] -then - echo "ERROR: Environment variables not properly setup. Please ensure that " - echo "\$BISECT_BOARD, \$BISECT_REMOTE, and \$BISECT_PACKAGE are set" - exit 3 -fi - -echo -echo "INSTALLATION BEGIN" -echo -echo "EMERGING ${BISECT_PACKAGE}" -CLEAN_DELAY=0 emerge-${BISECT_BOARD} -C ${BISECT_PACKAGE} -emerge-${BISECT_BOARD} ${BISECT_PACKAGE} -emerge_status=$? - -if [[ ${emerge_status} -ne 0 ]] ; then - echo "emerging ${BISECT_PACKAGE} returned a non-zero status: $emerge_status" - exit 1 -fi - -echo -echo "DEPLOYING" -echo "cros deploy ${BISECT_REMOTE} ${BISECT_PACKAGE}" -cros deploy ${BISECT_REMOTE} ${BISECT_PACKAGE} --log-level=info -deploy_status=$? - -if [[ ${deploy_status} -eq 0 ]] ; then - echo "Deploy successful. Rebooting device..." - reboot - if [[ $? -ne 0 ]] ; then - echo - echo "Could not automatically reboot device!" - read -p "Please manually reboot device and press enter to continue" notused - fi - exit 0 -fi - -echo "Deploy failed! Trying build_image/cros flash instead..." -echo -echo "BUILDING IMAGE" -pushd ~/trunk/src/scripts -./build_image test --board=${BISECT_BOARD} --noenable_rootfs_verification -build_status=$? -popd - -if [[ ${build_status} -eq 0 ]] ; then - echo - echo "FLASHING" - echo "Pushing built image onto device." - echo "cros flash --board=${BISECT_BOARD} --clobber-stateful ${BISECT_REMOTE} ~/trunk/src/build/images/${BISECT_BOARD}/latest/chromiumos_test_image.bin" - cros flash --board=${BISECT_BOARD} --clobber-stateful ${BISECT_REMOTE} ~/trunk/src/build/images/${BISECT_BOARD}/latest/chromiumos_test_image.bin - cros_flash_status=$? - while [[ ${cros_flash_status} -ne 0 ]] ; do - while true; do - echo - echo "cros flash has failed! From here you can:" - echo "1. Flash through USB" - echo "2. Retry flashing over ethernet" - echo "3. Abort this installation and skip this image" - sleep 1 - read -p "Which method would you like to do? " choice - case $choice in - 1) usb_flash && break;; - 2) ethernet_flash && break;; - 3) exit 1;; - *) echo "Please answer 1, 2, or 3.";; - esac - done - - cros_flash_status=$? - done -else - echo "build_image returned a non-zero status: ${build_status}" - exit 1 -fi - -exit 0 +../common/install.sh
\ No newline at end of file diff --git a/binary_search_tool/sysroot_wrapper/interactive_test.sh b/binary_search_tool/sysroot_wrapper/interactive_test.sh index 1b5b7e19..18fe3958 100755..120000 --- a/binary_search_tool/sysroot_wrapper/interactive_test.sh +++ b/binary_search_tool/sysroot_wrapper/interactive_test.sh @@ -1,37 +1 @@ -#!/bin/bash -u -# -# Copyright 2016 Google Inc. All Rights Reserved. -# -# This script pings the chromebook to determine if it successfully booted. -# It then asks the user if the image is good or not, allowing the user to -# conduct whatever tests the user wishes, and waiting for a response. -# -# This script is intended to be used by binary_search_state.py, as -# part of the binary search triage on ChromeOS object files. It waits for the -# install script to build and install the image, then asks the user if the -# image is good or not. It should return '0' if the test succeeds (the image -# is 'good'); '1' if the test fails (the image is 'bad'); and '2' if it could -# not determine (does not apply in this case). -# - -source cros_pkg/common.sh - -ping -c 3 -W 3 ${BISECT_REMOTE} -retval=$? - -if [[ ${retval} -eq 0 ]]; then - echo "ChromeOS image has been built and installed on ${BISECT_REMOTE}." -else - exit 1 -fi - -while true; do - read -p "Is this a good ChromeOS image?" yn - case $yn in - [Yy]* ) exit 0;; - [Nn]* ) exit 1;; - * ) echo "Please answer yes or no.";; - esac -done - -exit 2 +../common/interactive_test.sh
\ No newline at end of file diff --git a/binary_search_tool/sysroot_wrapper/setup.sh b/binary_search_tool/sysroot_wrapper/setup.sh new file mode 100755 index 00000000..d000b3b5 --- /dev/null +++ b/binary_search_tool/sysroot_wrapper/setup.sh @@ -0,0 +1,71 @@ +#!/bin/bash -u +# +# Copyright 2016 Google Inc. All Rights Reserved. +# +# This script is part of the ChromeOS object binary search triage process. +# It should be the first script called by the user, after the user has set up +# the two necessary build tree directories (see sysroot_wrapper/README). +# +# This script requires three arguments. The first argument must be the name of +# the board for which this work is being done (e.g. 'daisy', 'lumpy','parrot', +# etc.). The second argument must be the name or IP address of the chromebook +# on which the ChromeOS images will be pushed and tested. The third argument +# must be the name of the package being bisected (e.g. 'chromeos-chrome', +# 'cryptohome', etc.). +# +# This script generates common/common.sh, which generates enviroment variables +# used by the other scripts in the object file binary search triage process. +# + +# Set up basic variables. +bisect_dir=${BISECT_DIR:-/tmp/sysroot_bisect} + +BOARD=$1 +REMOTE=$2 +PACKAGE=$3 + +GOOD_BUILD=${bisect_dir}/good +BAD_BUILD=${bisect_dir}/bad +GOOD_LIST=${GOOD_BUILD}/_LIST +BAD_LIST=${BAD_BUILD}/_LIST + +# +# Verify that the necessary directories exist. +# + +if [[ ! -d ${GOOD_BUILD} ]] ; then + echo "Error: ${GOOD_BUILD} does not exist." + exit 1 +fi + +if [[ ! -d ${BAD_BUILD} ]] ; then + echo "Error: ${BAD_BUILD} does not exist." + exit 1 +fi + +if [[ ! -e ${GOOD_LIST} ]] ; then + echo "Error: ${GOOD_LIST} does not exist." + exit 1 +fi + +if [[ ! -e ${BAD_LIST} ]] ; then + echo "Error: ${BAD_LIST} does not exist." + exit 1 +fi + +COMMON_FILE="common/common.sh" + +cat <<-EOF > ${COMMON_FILE} + +BISECT_BOARD=${BOARD} +BISECT_REMOTE=${REMOTE} +BISECT_PACKAGE=${PACKAGE} +BISECT_MODE="OBJECT_MODE" + +bisect_dir=${bisect_dir} + +EOF + +chmod 755 ${COMMON_FILE} + +exit 0 diff --git a/binary_search_tool/sysroot_wrapper/switch_to_bad.sh b/binary_search_tool/sysroot_wrapper/switch_to_bad.sh index 62a908f4..7aae3504 100755 --- a/binary_search_tool/sysroot_wrapper/switch_to_bad.sh +++ b/binary_search_tool/sysroot_wrapper/switch_to_bad.sh @@ -1,6 +1,6 @@ #!/bin/bash -u -source ./sysroot_wrapper/common.sh +source common/common.sh cat $1 > ${bisect_dir}/BAD_SET diff --git a/binary_search_tool/sysroot_wrapper/switch_to_good.sh b/binary_search_tool/sysroot_wrapper/switch_to_good.sh index 3db8a9c6..7b3c98c4 100755 --- a/binary_search_tool/sysroot_wrapper/switch_to_good.sh +++ b/binary_search_tool/sysroot_wrapper/switch_to_good.sh @@ -1,6 +1,6 @@ #!/bin/bash -u -source ./sysroot_wrapper/common.sh +source common/common.sh cat $1 > ${bisect_dir}/GOOD_SET diff --git a/binary_search_tool/sysroot_wrapper/test_script.sh b/binary_search_tool/sysroot_wrapper/test_script.sh index ef6b4d40..8b424825 100755 --- a/binary_search_tool/sysroot_wrapper/test_script.sh +++ b/binary_search_tool/sysroot_wrapper/test_script.sh @@ -7,7 +7,7 @@ # Note it returns 0 only when the installation of the image succeeded # (ie: the machine booted after installation) -source ./sysroot_wrapper/common.sh +source common/common.sh export BISECT_STAGE=TRIAGE echo "BISECT_STAGE=${BISECT_STAGE}" |