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"""Change portions of the object files to good.
8
9The "portion" is defined by the file (which is passed as the only argument to
10this script) content. Every line in the file is an object index, which will be
11set to good (mark as 0).
12
13This script is meant to be specifically used with the set_file test. This uses
14the set files generated by binary_search_state to do the switching.
15"""
16
17from __future__ import print_function
18
19import os
20import sys
21
22from binary_search_tool.test import common
23
24
25def Main(_):
26  working_set = common.ReadWorkingSet()
27
28  if not os.path.exists(os.environ['BISECT_GOOD_SET']):
29    print('Good set file does not exist!')
30    return 1
31
32  object_index = common.ReadObjectIndex(os.environ['BISECT_GOOD_SET'])
33
34  for oi in object_index:
35    working_set[int(oi)] = 0
36
37  common.WriteWorkingSet(working_set)
38
39  return 0
40
41
42if __name__ == '__main__':
43  retval = Main(sys.argv)
44  sys.exit(retval)
45