• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3# Copyright 2020 The ChromiumOS Authors
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7"""Switch part of the objects file in working set to (possible) bad ones.
8
9This script is meant to be specifically used with the set_file test. This uses
10the set files generated by binary_search_state to do the switching.
11"""
12
13
14import os
15import sys
16
17from binary_search_tool.test import common
18
19
20def Main(_):
21    """Switch part of the objects file in working set to (possible) bad ones."""
22    working_set = common.ReadWorkingSet()
23    objects_file = common.ReadObjectsFile()
24
25    if not os.path.exists(os.environ["BISECT_BAD_SET"]):
26        print("Bad set file does not exist!")
27        return 1
28
29    object_index = common.ReadObjectIndex(os.environ["BISECT_BAD_SET"])
30
31    for oi in object_index:
32        working_set[int(oi)] = objects_file[oi]
33
34    common.WriteWorkingSet(working_set)
35
36    return 0
37
38
39if __name__ == "__main__":
40    retval = Main(sys.argv)
41    sys.exit(retval)
42