diff options
author | Cassidy Burden <cburden@google.com> | 2016-06-22 11:17:00 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-06-22 13:35:10 -0700 |
commit | 61ace4c75764cbab29bc0bcddf40d6c2d71996a6 (patch) | |
tree | 2adb394c31e32b8268c91da3870bda142ba6ffd6 /binary_search_tool/test | |
parent | 88c8aac3277c6fd841cb774f6815a14e37f3182f (diff) | |
download | toolchain-utils-61ace4c75764cbab29bc0bcddf40d6c2d71996a6.tar.gz |
binary search tool: Make BST tester check output more robust
Updated binary_search_tool_tester's output checking to be more robust,
and fully check the state of the reported good/bad sets.
Change-Id: Id7ab8c006133d67b75ed902a437ca817e62cd219
Reviewed-on: https://chrome-internal-review.googlesource.com/266029
Commit-Ready: Cassidy Burden <cburden@google.com>
Tested-by: Cassidy Burden <cburden@google.com>
Reviewed-by: Caroline Tice <cmtice@google.com>
Diffstat (limited to 'binary_search_tool/test')
-rwxr-xr-x | binary_search_tool/test/binary_search_tool_tester.py | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/binary_search_tool/test/binary_search_tool_tester.py b/binary_search_tool/test/binary_search_tool_tester.py index 5b9c9f85..5a108f8e 100755 --- a/binary_search_tool/test/binary_search_tool_tester.py +++ b/binary_search_tool/test/binary_search_tool_tester.py @@ -152,7 +152,8 @@ class BisectingUtilsTest(unittest.TestCase): def test_tmp_cleanup(self): bss = binary_search_state.MockBinarySearchState( - get_initial_items='echo "0\n1\n2\n3"', switch_to_good='./switch_tmp.py', + get_initial_items='echo "0\n1\n2\n3"', + switch_to_good='./switch_tmp.py', file_args=True) bss.SwitchToGood(['0', '1', '2', '3']) @@ -168,15 +169,22 @@ class BisectingUtilsTest(unittest.TestCase): def check_output(self): _, out, _ = command_executer.GetCommandExecuter().RunCommandWOutput( - 'tail -n 10 logs/binary_search_tool_tester.py.out') + ('grep "Bad items are: " logs/binary_search_tool_tester.py.out | ' + 'tail -n1')) ls = out.splitlines() - for l in ls: - t = l.find('Bad items are: ') - if t > 0: - bad_ones = l[(t + len('Bad items are: ')):].split() - objects_file = common.ReadObjectsFile() - for b in bad_ones: - self.assertEqual(objects_file[int(b)], 1) + self.assertEqual(len(ls), 1) + line = ls[0] + + _, _, bad_ones = line.partition('Bad items are: ') + bad_ones = bad_ones.split() + expected_result = common.ReadObjectsFile() + + # Reconstruct objects file from bad_ones and compare + actual_result = [0] * len(expected_result) + for bad_obj in bad_ones: + actual_result[int(bad_obj)] = 1 + + self.assertEqual(actual_result, expected_result) def Main(argv): |