aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJian Cai <jiancai@google.com>2020-01-22 17:50:16 -0800
committerJian Cai <jiancai@google.com>2020-02-04 22:31:28 +0000
commit360774425d0160d12cbf49f9f68d021c3967641b (patch)
tree6e6fc4e0c62b7bd693e29f23a43c1b6acce16f4f
parentff4c61b6fa6a4b1a10e070b4bd49b99e9594a3cc (diff)
downloadtoolchain-utils-360774425d0160d12cbf49f9f68d021c3967641b.tar.gz
bisection: add support of kernel
Fix issues and add support to kernel bisection. BUG=chromium:1042452 TEST=verified locally Change-Id: I1103aea0302a3f365c450aabbb8cabc097b2bd52 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/2016158 Tested-by: Jian Cai <jiancai@google.com> Reviewed-by: Manoj Gupta <manojgupta@chromium.org> Reviewed-by: Luis Lozano <llozano@chromium.org>
-rw-r--r--binary_search_tool/bisect_driver.py16
-rwxr-xr-xbinary_search_tool/common/test_setup.sh15
2 files changed, 27 insertions, 4 deletions
diff --git a/binary_search_tool/bisect_driver.py b/binary_search_tool/bisect_driver.py
index 6a69fbf4..82df15d6 100644
--- a/binary_search_tool/bisect_driver.py
+++ b/binary_search_tool/bisect_driver.py
@@ -5,6 +5,7 @@
#
# pylint: disable=not-callable
# pylint: disable=indentation
+
"""Utilities for bisection of ChromeOS and Android object files.
This module contains a set of utilities to allow bisection between
@@ -25,6 +26,7 @@ import fcntl
import os
import shutil
import subprocess
+import stat
import sys
VALID_MODES = ('POPULATE_GOOD', 'POPULATE_BAD', 'TRIAGE')
@@ -33,6 +35,8 @@ BAD_CACHE = 'bad'
LIST_FILE = os.path.join(GOOD_CACHE, '_LIST')
CONTINUE_ON_MISSING = os.environ.get('BISECT_CONTINUE_ON_MISSING', None) == '1'
+CONTINUE_ON_REDUNDANCY = os.environ.get('BISECT_CONTINUE_ON_REDUNDANCY',
+ None) == '1'
WRAPPER_SAFE_MODE = os.environ.get('BISECT_WRAPPER_SAFE_MODE', None) == '1'
@@ -260,8 +264,13 @@ def cache_file(execargs, bisect_dir, cache, abs_file_path):
with lock_file(os.path.join(population_dir, '_DUPS'),
'a') as dup_object_list:
dup_object_list.write('%s\n' % abs_file_path)
+ if CONTINUE_ON_REDUNDANCY:
+ return True
raise Exception(
- 'Trying to cache file %s multiple times.' % abs_file_path)
+ 'Trying to cache file %s multiple times. To avoid the error, set \
+ CONTINUE_ON_REDUNDANCY to 1. For reference, the list of such files \
+ will be written to %s' % (abs_file_path,
+ os.path.join(population_dir, '_DUPS')))
shutil.copy2(abs_file_path, bisect_path)
# Set cache object to be read-only so later compilations can't
@@ -289,7 +298,10 @@ def restore_file(bisect_dir, cache, abs_file_path):
if os.path.exists(cached_path):
if os.path.exists(abs_file_path):
os.remove(abs_file_path)
- os.link(cached_path, abs_file_path)
+ shutil.copy2(cached_path, abs_file_path)
+ # Add write permission to the restored object files as some packages
+ # (such as kernels) may need write permission to delete files.
+ os.chmod(abs_file_path, os.stat(abs_file_path).st_mode | stat.S_IWUSR)
else:
raise Error(('%s is missing from %s cache! Unsure how to proceed. Make '
'will now crash.' % (cache, cached_path)))
diff --git a/binary_search_tool/common/test_setup.sh b/binary_search_tool/common/test_setup.sh
index c4f5f698..56b8944a 100755
--- a/binary_search_tool/common/test_setup.sh
+++ b/binary_search_tool/common/test_setup.sh
@@ -94,6 +94,10 @@ echo
if [[ "${BISECT_MODE}" == "OBJECT_MODE" ]]; then
echo "EMERGING ${BISECT_PACKAGE}"
+ echo "sudo rm -rf /build/${BISECT_BOARD}/var/cache/portage/*"
+ sudo rm -rf /build/${BISECT_BOARD}/var/cache/portage/*
+ echo "sudo rm -rf /build/${BISECT_BOARD}/tmp/portage/${BISECT_PACKAGE}*"
+ sudo rm -rf /build/${BISECT_BOARD}/tmp/portage/${BISECT_PACKAGE}*
CLEAN_DELAY=0 emerge-${BISECT_BOARD} -C ${BISECT_PACKAGE}
emerge-${BISECT_BOARD} ${BISECT_PACKAGE}
emerge_status=$?
@@ -105,8 +109,15 @@ if [[ "${BISECT_MODE}" == "OBJECT_MODE" ]]; then
echo
echo "DEPLOYING"
- echo "cros deploy ${BISECT_REMOTE} ${BISECT_PACKAGE}"
- cros deploy ${BISECT_REMOTE} ${BISECT_PACKAGE} --log-level=info
+ if [[ ${PACKAGE} == sys-kernel/chromeos-kernel-* ]]; then
+ echo "/mnt/host/source/src/scripts/update_kernel.sh \
+ --remote=${BISECT_REMOTE}"
+ /mnt/host/source/src/scripts/update_kernel.sh --remote=${BISECT_REMOTE}
+ else
+ echo "cros deploy ${BISECT_REMOTE} ${BISECT_PACKAGE}"
+ cros deploy ${BISECT_REMOTE} ${BISECT_PACKAGE} --log-level=info
+ fi
+
deploy_status=$?
if [[ ${deploy_status} -eq 0 ]] ; then