• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3# Copyright 2020 The Chromium OS Authors. All rights reserved.
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
13from __future__ import print_function
14
15import os
16import sys
17
18from binary_search_tool.test import common
19
20
21def Main(_):
22  """Switch part of the objects file in working set to (possible) bad ones."""
23  working_set = common.ReadWorkingSet()
24  objects_file = common.ReadObjectsFile()
25
26  if not os.path.exists(os.environ['BISECT_BAD_SET']):
27    print('Bad set file does not exist!')
28    return 1
29
30  object_index = common.ReadObjectIndex(os.environ['BISECT_BAD_SET'])
31
32  for oi in object_index:
33    working_set[int(oi)] = objects_file[oi]
34
35  common.WriteWorkingSet(working_set)
36
37  return 0
38
39
40if __name__ == '__main__':
41  retval = Main(sys.argv)
42  sys.exit(retval)
43