Add scripts for usb-only flashing for cros package bisecting.

BUG=None
TEST=None

Change-Id: I0927bdb69d80c55cfccf0ea9c0ae3ad4ef554f2f
Reviewed-on: https://chromium-review.googlesource.com/525840
Commit-Ready: Caroline Tice <cmtice@chromium.org>
Tested-by: Caroline Tice <cmtice@chromium.org>
Reviewed-by: Rahul Chaudhry <rahulchaudhry@chromium.org>
diff --git a/binary_search_tool/common/interactive_test_noping.sh b/binary_search_tool/common/interactive_test_noping.sh
new file mode 100755
index 0000000..bb01b95
--- /dev/null
+++ b/binary_search_tool/common/interactive_test_noping.sh
@@ -0,0 +1,27 @@
+#!/bin/bash -u
+#
+# Copyright 2016 Google Inc. All Rights Reserved.
+#
+# This script 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 package and object files. It
+# waits for the test setup 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 '125'
+# if it could not determine (does not apply in this case).
+#
+
+source common/common.sh
+
+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 125
diff --git a/binary_search_tool/cros_pkg/interactive_test_noping.sh b/binary_search_tool/cros_pkg/interactive_test_noping.sh
new file mode 120000
index 0000000..c76f940
--- /dev/null
+++ b/binary_search_tool/cros_pkg/interactive_test_noping.sh
@@ -0,0 +1 @@
+../common/interactive_test_noping.sh
\ No newline at end of file
diff --git a/binary_search_tool/cros_pkg/test_setup_usb.sh b/binary_search_tool/cros_pkg/test_setup_usb.sh
new file mode 100755
index 0000000..fec66f8
--- /dev/null
+++ b/binary_search_tool/cros_pkg/test_setup_usb.sh
@@ -0,0 +1,56 @@
+#!/bin/bash
+#
+# Copyright 2016 Google Inc. All Rights Reserved.
+#
+# This is a generic ChromeOS package/image test setup script. It is meant to
+# be used for the package bisection tool, in particular when there is a booting
+# issue with the image, so the image MUST be 'flashed' via USB.
+#
+# This script is intended to be used by binary_search_state.py, as
+# part of the binary search triage on ChromeOS objects and packages. It should
+# return '0' if the setup succeeds; and '1' if the setup fails (the image
+# could not built or be flashed).
+#
+
+export PYTHONUNBUFFERED=1
+
+source common/common.sh
+
+echo "BUILDING IMAGE"
+pushd ~/trunk/src/scripts
+./build_image test --board=${BISECT_BOARD} --noenable_rootfs_verification --noeclean
+build_status=$?
+popd
+
+if [[ ${build_status} -eq 0 ]] ; then
+    echo
+    echo "INSTALLING IMAGE VIA USB (requires some manual intervention)"
+    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]*) exit 0;;
+        [Nn]*) exit 1;;
+        *) echo "Please answer y or n.";;
+      esac
+    done
+else
+    echo "build_image returned a non-zero status: ${build_status}"
+    exit 1
+fi
+
+exit 0