Beispiel #1
0
def Main(argv):
    """Switch part of the objects file in working set to (possible) bad ones."""
    working_set = common.ReadWorkingSet()
    objects_file = common.ReadObjectsFile()
    object_index = common.ReadObjectIndex(argv[1])

    for oi in object_index:
        working_set[oi] = objects_file[oi]

    common.WriteWorkingSet(working_set)

    return 0
    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',
            test_setup_script='./test_setup.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 Main(_):
    """Switch part of the objects file in working set to (possible) bad ones."""
    working_set = common.ReadWorkingSet()
    objects_file = common.ReadObjectsFile()

    if not os.path.exists(os.environ['BISECT_BAD_SET']):
        print('Bad set file does not exist!')
        return 1

    object_index = common.ReadObjectIndex(os.environ['BISECT_BAD_SET'])

    for oi in object_index:
        working_set[int(oi)] = objects_file[oi]

    common.WriteWorkingSet(working_set)

    return 0
    def check_output(self):
        _, out, _ = command_executer.GetCommandExecuter().RunCommandWOutput(
            ('grep "Bad items are: " logs/binary_search_tool_tester.py.out | '
             'tail -n1'))
        ls = out.splitlines()
        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)