aboutsummaryrefslogtreecommitdiff
path: root/binary_search_tool/sysroot_wrapper
diff options
context:
space:
mode:
Diffstat (limited to 'binary_search_tool/sysroot_wrapper')
-rw-r--r--binary_search_tool/sysroot_wrapper/README28
l---------binary_search_tool/sysroot_wrapper/boot_test.sh1
-rwxr-xr-xbinary_search_tool/sysroot_wrapper/cleanup.sh11
-rwxr-xr-xbinary_search_tool/sysroot_wrapper/get_initial_items.sh5
-rwxr-xr-xbinary_search_tool/sysroot_wrapper/glibc_test_script.sh49
l---------binary_search_tool/sysroot_wrapper/interactive_test.sh1
-rwxr-xr-xbinary_search_tool/sysroot_wrapper/setup.sh73
-rwxr-xr-xbinary_search_tool/sysroot_wrapper/switch_to_bad.sh9
-rwxr-xr-xbinary_search_tool/sysroot_wrapper/switch_to_good.sh9
-rwxr-xr-xbinary_search_tool/sysroot_wrapper/test_script.sh34
l---------binary_search_tool/sysroot_wrapper/test_setup.sh1
-rwxr-xr-xbinary_search_tool/sysroot_wrapper/testing_test.py37
12 files changed, 258 insertions, 0 deletions
diff --git a/binary_search_tool/sysroot_wrapper/README b/binary_search_tool/sysroot_wrapper/README
new file mode 100644
index 00000000..599d700d
--- /dev/null
+++ b/binary_search_tool/sysroot_wrapper/README
@@ -0,0 +1,28 @@
+This is a set of scripts to use when triaging compiler problem by using
+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:
+
+https://sites.google.com/a/google.com/chromeos-toolchain-team-home2/home/team-tools-and-scripts/bisecting-compiler-problems
+
+
+
diff --git a/binary_search_tool/sysroot_wrapper/boot_test.sh b/binary_search_tool/sysroot_wrapper/boot_test.sh
new file mode 120000
index 00000000..9a345617
--- /dev/null
+++ b/binary_search_tool/sysroot_wrapper/boot_test.sh
@@ -0,0 +1 @@
+../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/get_initial_items.sh b/binary_search_tool/sysroot_wrapper/get_initial_items.sh
new file mode 100755
index 00000000..c1beb972
--- /dev/null
+++ b/binary_search_tool/sysroot_wrapper/get_initial_items.sh
@@ -0,0 +1,5 @@
+#!/bin/bash -u
+
+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
new file mode 100755
index 00000000..58413ad1
--- /dev/null
+++ b/binary_search_tool/sysroot_wrapper/glibc_test_script.sh
@@ -0,0 +1,49 @@
+#!/bin/bash -u
+
+# This is an example execution script.
+# This script changes with the problem you are trying to fix.
+# This particular script was used to triage a problem where a glibc
+# compiled with a new compiler would expose a problem in piglit.
+# Note it returns 0 only when the installation of the image succeeded
+# (ie: the machine booted after installation)
+
+source common/common.sh
+
+#export BISECT_STAGE=TRIAGE
+echo "BISECT_STAGE=${BISECT_STAGE}"
+
+echo "State of sets"
+wc -l ${bisect_dir}/*_SET
+
+board=x86-alex
+DUT=172.17.186.180
+
+echo "Cleaning up"
+{ sudo emerge -C cross-i686-pc-linux-gnu/glibc || exit 125; } &>> /tmp/glibc_triage.log
+
+echo "Building"
+{ sudo -E emerge cross-i686-pc-linux-gnu/glibc || exit 125; } &>> /tmp/glibc_triage.log
+
+echo "Building image"
+{ /home/llozano/trunk/src/scripts/build_image --board=${board} test || exit 125; } &>> /tmp/glibc_triage.log
+
+echo "Installing image"
+cros flash ${DUT} latest &> /tmp/tmp_cros_flash_result.log
+
+cat /tmp/tmp_cros_flash_result.log >> /tmp/cros_flash_result.log
+
+grep "Cros Flash completed successfully" /tmp/tmp_cros_flash_result.log || exit 125
+
+echo "Trying piglit"
+
+echo "export DISPLAY=:0.0; echo \$DISPLAY; /usr/local/piglit/lib/piglit/bin/glx-close-display -auto" > /tmp/repro.sh
+SSH_OPTS="-oUserKnownHostsFile=/dev/null -oStrictHostKeyChecking=no -oServerAliveInterval=10 -i /var/cache/chromeos-cache/distfiles/target/./chrome-src/src/third_party/chromite/ssh_keys/testing_rsa"
+scp ${SSH_OPTS} /tmp/repro.sh root@${DUT}:/tmp
+
+# notice the bash -l here. Otherwise the DISPLAY cannot be set
+( ssh ${SSH_OPTS} root@${DUT} -- /bin/bash -l /tmp/repro.sh ) > /tmp/result
+grep pass /tmp/result || { echo "PIGLIT FAILED"; exit 1; }
+
+echo "PIGLIT PASSED"
+
+exit 0
diff --git a/binary_search_tool/sysroot_wrapper/interactive_test.sh b/binary_search_tool/sysroot_wrapper/interactive_test.sh
new file mode 120000
index 00000000..18fe3958
--- /dev/null
+++ b/binary_search_tool/sysroot_wrapper/interactive_test.sh
@@ -0,0 +1 @@
+../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..f5907f59
--- /dev/null
+++ b/binary_search_tool/sysroot_wrapper/setup.sh
@@ -0,0 +1,73 @@
+#!/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}
+
+export BISECT_STAGE=TRIAGE
+
+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
new file mode 100755
index 00000000..32f96780
--- /dev/null
+++ b/binary_search_tool/sysroot_wrapper/switch_to_bad.sh
@@ -0,0 +1,9 @@
+#!/bin/bash -u
+
+source common/common.sh
+
+# Remove file, signaling to emerge that it needs to be rebuilt. The compiler
+# wrapper will insert the correct object file based on $BISECT_BAD_SET
+cat $1 | sudo xargs rm -f
+
+exit 0
diff --git a/binary_search_tool/sysroot_wrapper/switch_to_good.sh b/binary_search_tool/sysroot_wrapper/switch_to_good.sh
new file mode 100755
index 00000000..f59b278d
--- /dev/null
+++ b/binary_search_tool/sysroot_wrapper/switch_to_good.sh
@@ -0,0 +1,9 @@
+#!/bin/bash -u
+
+source common/common.sh
+
+# Remove file, signaling to emerge that it needs to be rebuilt. The compiler
+# wrapper will insert the correct object file based on $BISECT_GOOD_SET
+cat $1 | sudo xargs rm -f
+
+exit 0
diff --git a/binary_search_tool/sysroot_wrapper/test_script.sh b/binary_search_tool/sysroot_wrapper/test_script.sh
new file mode 100755
index 00000000..2629a187
--- /dev/null
+++ b/binary_search_tool/sysroot_wrapper/test_script.sh
@@ -0,0 +1,34 @@
+#!/bin/bash -u
+
+# This is an example execution script.
+# This script changes with the problem you are trying to fix.
+# This particular script was used to triage a problem where the kernel
+# would not boot while migrating to GCC 4.9.
+# Note it returns 0 only when the installation of the image succeeded
+# (ie: the machine booted after installation)
+
+source common/common.sh
+
+export BISECT_STAGE=TRIAGE
+echo "BISECT_STAGE=${BISECT_STAGE}"
+
+echo "State of sets"
+wc -l ${bisect_dir}/*_SET
+
+echo "Cleaning up"
+{ /usr/bin/sudo rm -rf /build/falco/var/cache/portage/sys-kernel && emerge-falco -C sys-kernel/chromeos-kernel-3_8-3.8.11-r96 || exit 125; } &>> /tmp/kernel_triage.log
+
+echo "Building"
+{ /usr/local/bin/emerge-falco =sys-kernel/chromeos-kernel-3_8-3.8.11-r96 || exit 125; } &>> /tmp/kernel_triage.log
+
+echo "Building image"
+{ /home/llozano/trunk/src/scripts/build_image --board=falco test || exit 125; } &>> /tmp/kernel_triage.log
+
+echo "Installing image"
+cros flash 172.17.187.150 latest &> /tmp/tmp_cros_flash_result.log
+
+cat /tmp/tmp_cros_flash_result.log >> /tmp/cros_flash_result.log
+
+grep "Cros Flash completed successfully" /tmp/tmp_cros_flash_result.log || exit 1
+
+exit 0
diff --git a/binary_search_tool/sysroot_wrapper/test_setup.sh b/binary_search_tool/sysroot_wrapper/test_setup.sh
new file mode 120000
index 00000000..39e715f6
--- /dev/null
+++ b/binary_search_tool/sysroot_wrapper/test_setup.sh
@@ -0,0 +1 @@
+../common/test_setup.sh \ No newline at end of file
diff --git a/binary_search_tool/sysroot_wrapper/testing_test.py b/binary_search_tool/sysroot_wrapper/testing_test.py
new file mode 100755
index 00000000..2f7bc4c3
--- /dev/null
+++ b/binary_search_tool/sysroot_wrapper/testing_test.py
@@ -0,0 +1,37 @@
+#!/usr/bin/python2
+"""Test for sysroot_wrapper bisector.
+
+All files in bad_files will be determined to be bad. This test was made for
+chromeos-chrome built for a daisy board, if you are using another package you
+will need to change the base_path accordingly.
+"""
+
+from __future__ import print_function
+
+import subprocess
+import sys
+import os
+
+base_path = ('/var/cache/chromeos-chrome/chrome-src-internal/src/out_daisy/'
+ 'Release/obj/')
+bad_files = [
+ os.path.join(base_path, 'base/base.cpu.o'),
+ os.path.join(base_path, 'base/base.version.o'),
+ os.path.join(base_path, 'apps/apps.launcher.o')
+]
+
+bisect_dir = os.environ.get('BISECT_DIR', '/tmp/sysroot_bisect')
+
+
+def Main(_):
+ for test_file in bad_files:
+ test_file = test_file.strip()
+ cmd = ['grep', test_file, os.path.join(bisect_dir, 'BAD_SET')]
+ ret = subprocess.call(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ if not ret:
+ return 1
+ return 0
+
+
+if __name__ == '__main__':
+ sys.exit(Main(sys.argv[1:]))