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 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 switch script is made for the noincremental-prune test. This makes sure 14that, after pruning starts (>1 bad item is found), that the number of args sent 15to the switch scripts is equals to the actual number of items (i.e. checking 16that noincremental always holds). 17 18Warning: This switch script assumes the --file_args option 19""" 20 21from __future__ import print_function 22 23import shutil 24import sys 25 26from binary_search_tool.test import common 27 28 29def Main(argv): 30 """Switch part of the objects file in working set to (possible) bad ones.""" 31 working_set = common.ReadWorkingSet() 32 objects_file = common.ReadObjectsFile() 33 object_index = common.ReadObjectIndex(argv[1]) 34 35 for oi in object_index: 36 working_set[oi] = objects_file[oi] 37 38 shutil.copy(argv[1], './noinc_prune_bad') 39 40 common.WriteWorkingSet(working_set) 41 42 return 0 43 44 45if __name__ == '__main__': 46 retval = Main(sys.argv) 47 sys.exit(retval) 48