aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaroline Tice <cmtice@google.com>2017-07-12 12:22:43 -0700
committerchrome-bot <chrome-bot@chromium.org>2017-07-13 10:48:37 -0700
commitc600e4e6f2ffc7459a3a56b0bcb3d3f6842b4fbe (patch)
tree21f4955e4efe99e3be7febe89e176b91c367574e
parentfcf26b3b89a7893c7430841ab153e1a58d657c12 (diff)
downloadtoolchain-utils-c600e4e6f2ffc7459a3a56b0bcb3d3f6842b4fbe.tar.gz
[bisect tool] Fix full test to work with ChromeOS as well as Android.
The run_bisect_test.py script worked well for Android but had a few hiccups for testing the ChromeOS compiler wrapper. This CL fixes that. BUG=chromium:741812 TEST=Ran test successfully outside the chroot with Android compiler wrapper; ran test succesfully inside chroot with ChromeOS compiler wrapper. Change-Id: Id5f737932064497e0dfaff9ba3ac53b4c1c87373 Reviewed-on: https://chromium-review.googlesource.com/568407 Commit-Ready: Caroline Tice <cmtice@chromium.org> Tested-by: Caroline Tice <cmtice@chromium.org> Reviewed-by: Caroline Tice <cmtice@chromium.org>
-rw-r--r--binary_search_tool/README.testing24
-rwxr-xr-xbinary_search_tool/full_bisect_test/chromeos_build.sh21
-rwxr-xr-xbinary_search_tool/full_bisect_test/switch_to_bad.sh1
-rwxr-xr-xbinary_search_tool/full_bisect_test/switch_to_good.sh1
-rwxr-xr-xbinary_search_tool/run_bisect_test.py40
5 files changed, 71 insertions, 16 deletions
diff --git a/binary_search_tool/README.testing b/binary_search_tool/README.testing
index bb98dd35..6c81ab96 100644
--- a/binary_search_tool/README.testing
+++ b/binary_search_tool/README.testing
@@ -32,11 +32,10 @@ Running the bisection tests, testing the compiler wrapper.
If you want to run the bisection tests, and test the compiler wrapper
(to make sure the POPULATE_GOOD and POPULATE_BAD stages are still
-working properly) you can do something like the following. The steps
-below illustrate how to test with the Android compiler wrapper, but
-the steps for testing with the ChromeOS compiler wrapper would be very
-similar.
+working properly) you can do the following.
+If you are testing with the ANDROID COMPILER WRAPPER, you need to to some
+preliminary setup:
Set up the compiler wrapper to replace GCC:
@@ -56,6 +55,23 @@ Move to the correct directory, then run the test script:
$ ./run_bisect_test.py
+If you are testing with the CHROMEOS COMPILER WRAPPER, you MUST run the
+tests from INSIDE your CHROOT (but you don't need to do any special setup):
+
+ $ cd <path-to-chromeos-root>
+ $ cros_sdk
+ $ cd ~/trunk/src/third_party/toolchain-utils
+
+ Set up your PYTHONPATH:
+
+ $ export PYTHONPATH=`pwd`:${PYTHONPATH}
+ $ cd binary_search_tool
+ $ export PYTHONPATH=`pwd`:${PYTHONPATH}
+
+ Run the test script:
+
+ $ ./run_bisect_test.py
+
Running the bisection tests, without testing the compiler wrapper.
------------------------------------------------------------------
diff --git a/binary_search_tool/full_bisect_test/chromeos_build.sh b/binary_search_tool/full_bisect_test/chromeos_build.sh
new file mode 100755
index 00000000..f072bd07
--- /dev/null
+++ b/binary_search_tool/full_bisect_test/chromeos_build.sh
@@ -0,0 +1,21 @@
+#!/bin/bash
+
+# This file compiles all the source files into .o files, then links them to form
+# the test binary, 'bin-trees'. The .o files all go into the 'work' directory.
+# There are 'good' and 'bad' versions of inorder_norecurse and preorder_norecurse
+# (e.g. inorder_norecurse.c.good and inorder_norecurse.c.bad). This script
+# assumes that the desired versions of those files have been copied into
+# inorder_norecurse.c and preorder_norecurse.c. The script files
+# make_sources_good.sh and make_sources_bad.sh are meant to handle this.
+#
+# This script is meant to be run directly in the full_bisect_test directory.
+# Most other scripts assume they are being run from the parent directory.
+
+x86_64-cros-linux-gnu-gcc -c build.c -o work/build.o
+x86_64-cros-linux-gnu-gcc -c preorder.c -o work/preorder.o
+x86_64-cros-linux-gnu-gcc -c inorder.c -o work/inorder.o
+x86_64-cros-linux-gnu-gcc -c main.c -o work/main.o
+x86_64-cros-linux-gnu-gcc -c stack.c -o work/stack.o
+x86_64-cros-linux-gnu-gcc -c preorder_norecurse.c -o work/preorder_norecurse.o
+x86_64-cros-linux-gnu-gcc -c inorder_norecurse.c -o work/inorder_norecurse.o
+x86_64-cros-linux-gnu-gcc -o bin-trees work/main.o work/preorder.o work/inorder.o work/build.o work/preorder_norecurse.o work/inorder_norecurse.o work/stack.o
diff --git a/binary_search_tool/full_bisect_test/switch_to_bad.sh b/binary_search_tool/full_bisect_test/switch_to_bad.sh
index f5ae79d7..d88a4aa2 100755
--- a/binary_search_tool/full_bisect_test/switch_to_bad.sh
+++ b/binary_search_tool/full_bisect_test/switch_to_bad.sh
@@ -9,6 +9,7 @@
source full_bisect_test/common.sh
pushd ${BISECT_WORK_BUILD}
+chmod 644 *
OBJ_LIST_FILES=$1
FILE_ARGS=0
diff --git a/binary_search_tool/full_bisect_test/switch_to_good.sh b/binary_search_tool/full_bisect_test/switch_to_good.sh
index ed7b822a..9d8c29bc 100755
--- a/binary_search_tool/full_bisect_test/switch_to_good.sh
+++ b/binary_search_tool/full_bisect_test/switch_to_good.sh
@@ -10,6 +10,7 @@
source full_bisect_test/common.sh
pushd ${BISECT_WORK_BUILD}
+chmod 644 *
OBJ_LIST_FILES=$1
FILE_ARGS=0
diff --git a/binary_search_tool/run_bisect_test.py b/binary_search_tool/run_bisect_test.py
index 53acc805..d4ff4f73 100755
--- a/binary_search_tool/run_bisect_test.py
+++ b/binary_search_tool/run_bisect_test.py
@@ -10,7 +10,7 @@ import sys
from cros_utils import command_executer
TEST_DIR = 'full_bisect_test'
-DEFAULT_BISECT_DIR = os.path.expanduser('~/ANDROID_BISECT')
+DEFAULT_BISECT_DIR = '/tmp/sysroot_bisect'
def populate_good_files(top_dir, ce, bisect_dir=DEFAULT_BISECT_DIR):
@@ -29,13 +29,15 @@ def populate_good_files(top_dir, ce, bisect_dir=DEFAULT_BISECT_DIR):
print('Error setting up "good" source files: %s' % script)
return status
- export_bisect = ''
- if bisect_dir != DEFAULT_BISECT_DIR:
- export_bisect = 'export BISECT_DIR=%s; ' % bisect_dir
+ export_bisect = 'export BISECT_DIR=%s; ' % bisect_dir
# build the good source files
script_path = os.path.join(top_dir, TEST_DIR)
- cmd = ('%s export BISECT_STAGE=POPULATE_GOOD; pushd %s; ./build.sh; popd' %
- (export_bisect, script_path))
+ if os.path.exists('/usr/bin/x86_64-cros-linux-gnu-gcc'):
+ build_script = 'chromeos_build.sh'
+ else:
+ build_script = 'build.sh'
+ cmd = ('%s export BISECT_STAGE=POPULATE_GOOD; pushd %s; ./%s; popd' %
+ (export_bisect, script_path, build_script))
status = ce.RunCommand(cmd)
return status
@@ -56,13 +58,15 @@ def populate_bad_files(top_dir, ce, bisect_dir=DEFAULT_BISECT_DIR):
print('Error setting up "bad" source files: %s' % script)
return status
- export_bisect = ''
- if bisect_dir != DEFAULT_BISECT_DIR:
- export_bisect = 'export BISECT_DIR=%s; ' % bisect_dir
+ export_bisect = 'export BISECT_DIR=%s; ' % bisect_dir
# build the bad source files
script_path = os.path.join(top_dir, TEST_DIR)
- cmd = ('%s export BISECT_STAGE=POPULATE_BAD; pushd %s; ./build.sh ; popd' %
- (export_bisect, script_path))
+ if os.path.exists('/usr/bin/x86_64-cros-linux-gnu-gcc'):
+ build_script = 'chromeos_build.sh'
+ else:
+ build_script = 'build.sh'
+ cmd = ('%s export BISECT_STAGE=POPULATE_BAD; pushd %s; ./%s ; popd' %
+ (export_bisect, script_path, build_script))
status = ce.RunCommand(cmd)
return status
@@ -74,6 +78,11 @@ def run_main_bisection_test(top_dir, ce):
def verify_compiler_and_wrapper():
+ # We don't need to do any special setup if running inside a ChromeOS
+ # chroot.
+ if os.path.exists('/usr/bin/x86_64-cros-linux-gnu-gcc'):
+ return
+
message = """
*** IMPORTANT --- READ THIS CAREFULLY!! ***
@@ -99,7 +108,7 @@ def Main(argv):
'--dir',
dest='directory',
help='Bisection work tree, where good & bad object '
- 'files go. Default is ~/ANDROID_BISECT')
+ 'files go. Default is /tmp/sysroot_bisect')
options = parser.parse_args(argv)
@@ -122,6 +131,13 @@ def Main(argv):
if not bisect_dir:
bisect_dir = DEFAULT_BISECT_DIR
+ # Make sure BISECT_DIR is clean
+ if os.path.exists(bisect_dir):
+ cmd = 'rm -Rf %s/*' % bisect_dir
+ retv = ce.RunCommand(cmd)
+ if retv != 0:
+ return retv
+
retv = populate_good_files(cwd, ce, bisect_dir)
if retv != 0:
return retv