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 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 21 22import shutil 23import sys 24 25from binary_search_tool.test import common 26 27 28def Main(argv): 29 """Switch part of the objects file in working set to (possible) bad ones.""" 30 working_set = common.ReadWorkingSet() 31 objects_file = common.ReadObjectsFile() 32 object_index = common.ReadObjectIndex(argv[1]) 33 34 for oi in object_index: 35 working_set[oi] = objects_file[oi] 36 37 shutil.copy(argv[1], "./noinc_prune_bad") 38 39 common.WriteWorkingSet(working_set) 40 41 return 0 42 43 44if __name__ == "__main__": 45 retval = Main(sys.argv) 46 sys.exit(retval) 47