1#!/usr/bin/python2 2"""Switch part of the objects file in working set to (possible) bad ones. 3 4This script is meant to be specifically used with the set_file test. This uses 5the set files generated by binary_search_state to do the switching. 6""" 7 8from __future__ import print_function 9 10import os 11import sys 12 13import common 14 15 16def Main(_): 17 """Switch part of the objects file in working set to (possible) bad ones.""" 18 working_set = common.ReadWorkingSet() 19 objects_file = common.ReadObjectsFile() 20 21 if not os.path.exists(os.environ['BISECT_BAD_SET']): 22 print('Bad set file does not exist!') 23 return 1 24 25 object_index = common.ReadObjectIndex(os.environ['BISECT_BAD_SET']) 26 27 for oi in object_index: 28 working_set[int(oi)] = objects_file[oi] 29 30 common.WriteWorkingSet(working_set) 31 32 return 0 33 34 35if __name__ == '__main__': 36 retval = Main(sys.argv) 37 sys.exit(retval) 38