def __init__(self, working_dir, src, buggy, oracle, tests, golden, asserts, lines, build, configure, config): self.working_dir = working_dir self.config = config self.repair_test_suite = tests[:] self.validation_test_suite = tests[:] extracted = join(working_dir, 'extracted') os.mkdir(extracted) angelic_forest_file = join(working_dir, 'last-angelic-forest.json') tester = Tester(config, oracle, abspath(working_dir)) self.run_test = tester self.get_suspicious_groups = Localizer(config, lines) self.reduce = Reducer(config) if self.config['use_semfix_syn']: self.synthesize_fix = Semfix_Synthesizer(working_dir, config, extracted, angelic_forest_file) self.infer_spec = Semfix_Inferrer(working_dir, config, tester) else: self.synthesize_fix = Synthesizer(config, extracted, angelic_forest_file) self.infer_spec = Inferrer(config, tester, Load(working_dir)) self.instrument_for_localization = RepairableTransformer(config) self.instrument_for_inference = SuspiciousTransformer(config, extracted) self.apply_patch = FixInjector(config) validation_dir = join(working_dir, "validation") shutil.copytree(src, validation_dir, symlinks=True) self.validation_src = Validation(config, validation_dir, buggy, build, configure) self.validation_src.configure() compilation_db = self.validation_src.export_compilation_db() self.validation_src.import_compilation_db(compilation_db) self.validation_src.initialize() frontend_dir = join(working_dir, "frontend") shutil.copytree(src, frontend_dir, symlinks=True) self.frontend_src = Frontend(config, frontend_dir, buggy, build, configure) self.frontend_src.import_compilation_db(compilation_db) self.frontend_src.initialize() backend_dir = join(working_dir, "backend") shutil.copytree(src, backend_dir, symlinks=True) self.backend_src = Backend(config, backend_dir, buggy, build, configure) self.backend_src.import_compilation_db(compilation_db) self.backend_src.initialize() if golden is not None: golden_dir = join(working_dir, "golden") shutil.copytree(golden, golden_dir, symlinks=True) self.golden_src = Frontend(config, golden_dir, buggy, build, configure) self.golden_src.import_compilation_db(compilation_db) self.golden_src.initialize() else: self.golden_src = None self.dump = Dump(working_dir, asserts) self.trace = Trace(working_dir)
import subprocess import tempfile # Declare variables BOARD_SIZE = int( input("Enter the size of the Sudoku Board: ")) # size of the Sudoku board K_VALUE = int(input("Enter the number of random values to generate: ") ) # number of random values generated PATH_NAME = 'output' # name of the file to store generated board # Generate a random Sudoku board using Generation file generator = Generator(PATH_NAME, BOARD_SIZE, K_VALUE) generator.generate() # Pass this file name and reduce to CNF using Reduction file reducer = Reducer(PATH_NAME, BOARD_SIZE) reducer.create_cnf_file() # Create a Solver to test if the CNF file is Satisfiable or Unsatisfiable. # Note that you need minisat on your computer to run this bashCommand = 'minisat %s %s' # command to run on the terminal # Our temporary output file output_file = tempfile.NamedTemporaryFile() # Call the bash terminal subprocess.call(bashCommand % (PATH_NAME + ".cnf", output_file.name), shell=True, stdout=subprocess.PIPE) # Print result