Beispiel #1
0
    def __init__(self,
                 machine_model,
                 log_verbose,
                 additional_options,
                 preprocessor,
                 show_tool_output=False):
        self.machine_model = machine_model
        self.log_verbose = log_verbose
        self.show_tool_output = show_tool_output
        self.cli_options = additional_options
        self.program_preprocessor = preprocessor

        self.statistics = utils.Statistics("Input Generator " +
                                           self.get_name())

        self.timer_file_access = utils.Stopwatch()
        self.timer_prepare = utils.Stopwatch()
        self.timer_input_gen = utils.Stopwatch()
        self.timer_generator = utils.Stopwatch()

        self.statistics.add_value('Time for full input generation',
                                  self.timer_input_gen)
        self.statistics.add_value('Time for test-case generator',
                                  self.timer_generator)
        self.statistics.add_value('Time for controlled file accesses',
                                  self.timer_file_access)
        self.statistics.add_value('Time for file preparation',
                                  self.timer_prepare)
Beispiel #2
0
    def __init__(self, processing_config, extractor: TestConverter):
        self._nondet_var_map = None
        self.machine_model = processing_config.machine_model
        self.config = processing_config
        self.harness_creator = harness_gen.HarnessCreator()
        self._extractor = extractor

        self.naive_verification = processing_config.naive_verification

        # If a void appears in a line, there must be something between
        # the void and the __VERIFIER_error() symbol - otherwise
        # it is a function definition/declaration.
        self.error_method_pattern = re.compile(
            '((?!void).)*(void.*\S.*)?__VERIFIER_error\(\) *;.*')

        self.statistics = utils.Statistics('Test Validator ' + self.get_name())
        self.timer_validation = utils.Stopwatch()
        self.statistics.add_value('Time for validation', self.timer_validation)
        self.timer_execution_validation = utils.Stopwatch()
        self.statistics.add_value('Time for execution validation',
                                  self.timer_execution_validation)
        self.counter_size_harnesses = utils.Counter()
        self.statistics.add_value('Total size of harnesses',
                                  self.counter_size_harnesses)

        self.counter_handled_test_cases = utils.Counter()
        self.statistics.add_value('Number of looked-at test cases',
                                  self.counter_handled_test_cases)

        self.final_test_vector_size = utils.Constant()
        self.statistics.add_value("Size of successful test vector",
                                  self.final_test_vector_size)
Beispiel #3
0
def main():
    timeout_watch = utils.Stopwatch()
    timeout_watch.start()

    args = _parse_cli_args(sys.argv[1:])

    if args.log_verbose:
        logging.getLogger().setLevel(level=logging.DEBUG)
    else:
        logging.getLogger().setLevel(level=logging.INFO)

    stop_event = StopEvent()
    main_run = mp.Process(target=run, args=(args, stop_event))
    try:
        main_run.start()
        while main_run.is_alive() and (
                not args.timelimit or timeout_watch.curr_s() < args.timelimit):
            sleep(0.1)
    finally:
        timeout_watch.stop()
        if args.timelimit and timeout_watch.sum() >= args.timelimit:
            logging.info("Timelimit reached.\n")
        logging.info("Time taken: " + str(timeout_watch.sum()))
        stop_event.set()
        if main_run.is_alive():
            try:
                main_run.join(5)
            except mp.TimeoutError:
                logging.info(
                    "Main run didn't terminate within acceptable limit. Killing it."
                )
                main_run.terminate()
Beispiel #4
0
def main():
    timeout_watch = utils.Stopwatch()
    timeout_watch.start()

    _setup_environment()

    args = _parse_cli_args(sys.argv[1:])

    if args.log_verbose:
        logging.getLogger().setLevel(level=logging.DEBUG)
    else:
        logging.getLogger().setLevel(level=logging.INFO)

    stop_event = Event()
    running_thread = Thread(target=run, args=(args, stop_event))
    try:
        running_thread.start()
        while running_thread.is_alive() and (
                not args.timelimit or timeout_watch.curr_s() < args.timelimit):
            sleep(0.1)
    finally:
        timeout_watch.stop()
        if args.timelimit and timeout_watch.sum() >= args.timelimit:
            logging.error("Timeout error.\n")
        else:
            logging.info("Time taken: " + str(timeout_watch.sum()))
        stop_event.set()
        while running_thread.is_alive():
            running_thread.join(5)
Beispiel #5
0
    def __init__(self, timelimit, machine_model, log_verbose):
        self.machine_model = machine_model
        self.timelimit = int(timelimit) if timelimit else 0
        self.log_verbose = log_verbose
        self.statistics = utils.Statistics("Input Generator " +
                                           self.get_name())

        self.timer_file_access = utils.Stopwatch()
        self.timer_prepare = utils.Stopwatch()
        self.timer_input_gen = utils.Stopwatch()
        self.timer_generator = utils.Stopwatch()

        self.number_generated_tests = utils.Constant()

        self.statistics.add_value('Time for full input generation',
                                  self.timer_input_gen)
        self.statistics.add_value('Time for test case generator',
                                  self.timer_generator)
        self.statistics.add_value('Time for controlled file accesses',
                                  self.timer_file_access)
        self.statistics.add_value('Time for file preparation',
                                  self.timer_prepare)
        self.statistics.add_value('Number of generated test cases',
                                  self.number_generated_tests)