def closing(self): prefix = 'window' CONF.set('main', prefix + '/is_maximized', self.isMaximized()) CONF.set('main', prefix + '/is_fullscreen', self.isFullScreen()) if not self.isMaximized() and not self.isFullScreen(): size = self.size() CONF.set('main', prefix + '/size', (size.width(), size.height())) pos = self.pos() CONF.set('main', prefix + '/position', (pos.x(), pos.y()))
def main(): parser = ArgumentParser(description='', add_help=False) subparsers = parser.add_subparsers(dest='subparser_name') # Fuzzing parser_fuzz = subparsers.add_parser('fuzz') parser_fuzz.add_argument("-s", "--instruction-set", type=str, required=True) parser_fuzz.add_argument("-c", "--config", type=str, required=False) parser_fuzz.add_argument( "-n", "--num-test-cases", type=int, default=1, help="Number of test cases.", ) parser_fuzz.add_argument( "-i", "--num-inputs", type=int, default=100, help="Number of inputs per test case.", ) parser_fuzz.add_argument( '-w', '--working-directory', type=str, default='', ) parser_fuzz.add_argument('-t', '--testcase', type=str, default=None, help="Use an existing test case") parser_fuzz.add_argument( '--timeout', type=int, default=0, help= "Run fuzzing with a time limit [seconds]. No timeout when set to zero." ) parser_fuzz.add_argument( '--nonstop', action='store_true', help="Don't stop after detecting an unexpected result") parser_mini = subparsers.add_parser('minimize') parser_mini.add_argument( '--infile', '-i', type=str, required=True, ) parser_mini.add_argument( '--outfile', '-o', type=str, required=True, ) parser_mini.add_argument("-c", "--config", type=str, required=False) parser_mini.add_argument( "-n", "--num-inputs", type=int, default=100, help="Number of inputs per test case.", ) parser_mini.add_argument( "-f", "--add-fences", action='store_true', default=False, help="Add as many LFENCEs as possible, while preserving the violation.", ) parser_mini.add_argument("-s", "--instruction-set", type=str, required=True) args = parser.parse_args() # Update configuration if args.config: CONF.config_path = args.config with open(args.config, "r") as f: config_update: Dict = yaml.safe_load(f) for var, value in config_update.items(): CONF.set(var, value) CONF.sanity_check() LOGGER.set_logging_modes() # Fuzzing if args.subparser_name == 'fuzz': # Make sure we're ready for fuzzing if args.working_directory and not os.path.isdir( args.working_directory): SystemExit("The working directory does not exist") # Normal fuzzing mode fuzzer = Fuzzer(args.instruction_set, args.working_directory, args.testcase) fuzzer.start( args.num_test_cases, args.num_inputs, args.timeout, args.nonstop, ) return # Test Case minimisation if args.subparser_name == "minimize": CONF.coverage_type = 'none' postprocessor = Postprocessor(args.instruction_set) postprocessor.minimize(args.infile, args.outfile, args.num_inputs, args.add_fences) return raise Exception("Unreachable")