aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCassidy Burden <cburden@google.com>2016-07-07 10:48:04 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-07-12 11:10:41 -0700
commit6bee8a50519fe42aa3c9cf727c1832510c3f0157 (patch)
tree2c40241ce667784f890ead6464fbbf5e5a215a64
parentf56836d4c54b9e7cd09c7d7c681ebac360aa640a (diff)
downloadtoolchain-utils-6bee8a50519fe42aa3c9cf727c1832510c3f0157.tar.gz
binary search tool: Update found_items when prune is not set
Previously when prune was not set found_items would not be updated with the single bad item found. This commit fixed this edge case and adds a unit test for it. TEST=Run unit tests Change-Id: Iac56c53fd4de97fa12b14fc9ea1e05d021cc6495 Reviewed-on: https://chrome-internal-review.googlesource.com/268725 Commit-Ready: Cassidy Burden <cburden@google.com> Tested-by: Cassidy Burden <cburden@google.com> Reviewed-by: Han Shen <shenhan@google.com> Reviewed-by: Luis Lozano <llozano@chromium.org>
-rwxr-xr-xbinary_search_tool/binary_search_state.py20
-rwxr-xr-xbinary_search_tool/test/binary_search_tool_tester.py17
2 files changed, 27 insertions, 10 deletions
diff --git a/binary_search_tool/binary_search_state.py b/binary_search_tool/binary_search_state.py
index 1ee4a2b7..e1e4f00f 100755
--- a/binary_search_tool/binary_search_state.py
+++ b/binary_search_tool/binary_search_state.py
@@ -178,9 +178,6 @@ class BinarySearchState(object):
self.prune_cycles += 1
if not terminated:
break
- if not self.prune:
- self.l.LogOutput('Not continuning further, --prune is not set')
- break
# Prune is set.
prune_index = self.binary_search.current
@@ -204,6 +201,9 @@ class BinarySearchState(object):
str(new_all_items)),
print_to_console=self.verbose)
+ if not self.prune:
+ self.l.LogOutput('Not continuning further, --prune is not set')
+ break
# FIXME: Do we need to Convert the currently good items to bad
self.PopulateItemsUsingList(new_all_items)
@@ -372,13 +372,13 @@ class MockBinarySearchState(BinarySearchState):
'switch_to_bad': None,
'install_script': None,
'test_script': None,
- 'incremental': None,
- 'prune': None,
- 'iterations': None,
- 'prune_iterations': None,
- 'verify_level': None,
- 'file_args': None,
- 'verbose': None
+ 'incremental': True,
+ 'prune': False,
+ 'iterations': 50,
+ 'prune_iterations': 100,
+ 'verify_level': 1,
+ 'file_args': False,
+ 'verbose': False
}
default_kwargs.update(kwargs)
super(MockBinarySearchState, self).__init__(**default_kwargs)
diff --git a/binary_search_tool/test/binary_search_tool_tester.py b/binary_search_tool/test/binary_search_tool_tester.py
index a8a12e7d..c6656f65 100755
--- a/binary_search_tool/test/binary_search_tool_tester.py
+++ b/binary_search_tool/test/binary_search_tool_tester.py
@@ -269,6 +269,22 @@ class BisectingUtilsTest(unittest.TestCase):
bss.DoSearch()
self.assertFalse(bss.found_items)
+ def test_no_prune(self):
+ bss = binary_search_state.MockBinarySearchState(
+ get_initial_items='./gen_init_list.py',
+ switch_to_good='./switch_to_good.py',
+ switch_to_bad='./switch_to_bad.py',
+ test_script='./is_good.py',
+ install_script='./install.py',
+ prune=False,
+ file_args=True)
+ bss.DoSearch()
+ self.assertEquals(len(bss.found_items), 1)
+
+ bad_objs = common.ReadObjectsFile()
+ found_obj = int(bss.found_items.pop())
+ self.assertEquals(bad_objs[found_obj], 1)
+
def check_output(self):
_, out, _ = command_executer.GetCommandExecuter().RunCommandWOutput(
('grep "Bad items are: " logs/binary_search_tool_tester.py.out | '
@@ -306,6 +322,7 @@ def Main(argv):
suite.addTest(BisectingUtilsTest('test_tmp_cleanup'))
suite.addTest(BisectingUtilsTest('test_verify_fail'))
suite.addTest(BisectingUtilsTest('test_early_terminate'))
+ suite.addTest(BisectingUtilsTest('test_no_prune'))
suite.addTest(BisectTest('test_full_bisector'))
runner = unittest.TextTestRunner()
runner.run(suite)