Пример #1
0
    def _run(self):
        """
        Run method for this module
        """

        # prepare executor
        progress = not self.arg_options.batch
        executor = BinExecutor(self.arg_options.rest)
        pypy = PyPy(executor, progress=progress)
        n_lines = 0 if self.arg_options.batch else 10

        # set up streams
        log_file = Paths.temp_file('exec-limit-{date}-{time}-{rnd}.log')
        pypy.executor.output = OutputMode.variable_output()
        pypy.full_output = log_file

        # set limits
        pypy.limit_monitor.time_limit = self.arg_options.time_limit
        pypy.limit_monitor.memory_limit = self.arg_options.memory_limit

        # save output to file
        pypy.output_monitor.log_file = log_file

        # start process
        pypy.start()
        pypy.join()

        return pypy
    def run_local_mode_one(self, proc):
        """
        Method runs single job with specified number of CPU
        :param proc:
        """
        if int(proc) == 0:
            command = self.arg_options.rest[1:]
        else:
            command = [self.arg_options.rest[0], '-np', proc
                       ] + self.arg_options.rest[1:]

        n_lines = 0 if self.arg_options.batch else 10
        pypy = PyPy(BinExecutor(command))

        # set limits
        pypy.limit_monitor.time_limit = self.time_limit
        pypy.limit_monitor.memory_limit = self.memory_limit

        # catch output to variable
        # in batched mode we will keep the files
        # otherwise we will keep logs only on error
        log_file = Paths.temp_file('exec-parallel-{date}-{time}-{rnd}.log')
        pypy.executor.output = OutputMode.variable_output()
        pypy.full_output = log_file

        # save output to file
        pypy.output_monitor.log_file = log_file

        # start and wait for exit
        pypy.start()
        pypy.join()

        return pypy
Пример #3
0
    def create_comparisons(self):
        comparisons = ComparisonMultiThread(self.case.fs.ndiff_log)
        comparisons.thread_name_property = True

        for check_rule in self.case.check_rules:
            method = str(check_rule.keys()[0])
            module = self.get_module(method)
            comp_data = check_rule[method]
            if not module:
                Printer.all.err(
                    'Warning! No module for check_rule method "{}"', method)
                continue

            pairs = self._get_ref_output_files(comp_data)
            if pairs:
                for pair in pairs:

                    # load module and determine whether we are dealing with
                    # exec comparison or inplace comparison
                    if issubclass(module.__class__, modules.ExecComparison):
                        command = module.get_command(*pair, **comp_data)
                        pm = PyPy(BinExecutor(command), progress=True)
                        pm.executor.output = OutputMode.variable_output()
                    else:
                        module = self.get_module(method)
                        module.prepare(*pair, **comp_data)
                        pm = PyPy(module, progress=True)
                        pm.executor.output = OutputMode.dummy_output()
                        pm.error_monitor.deactivate()

                    # if we fail, set error to 13
                    pm.custom_error = 13
                    pm.start_monitor.deactivate()
                    pm.end_monitor.deactivate()
                    pm.progress_monitor.deactivate()
                    pm.limit_monitor.deactivate(
                    )  # TODO: maybe some time limit would be useful
                    pm.output_monitor.policy = pm.output_monitor.POLICY_ERROR_ONLY

                    pm.error_monitor.message = 'Comparison using method {} failed!'.format(
                        method)
                    pm.error_monitor.indent = 1
                    pm.full_output = self.case.fs.ndiff_log

                    path = Paths.path_end_until(pair[0], REF_OUTPUT_DIR)
                    test_name = Paths.basename(
                        Paths.dirname(Paths.dirname(self.case.fs.ref_output)))
                    size = Paths.filesize(pair[0], True)
                    pm.name = '{}: {} ({})'.format(test_name, path, size)
                    comparisons.add(pm)

        return comparisons
Пример #4
0
    def create_comparisons(self):
        comparisons = ComparisonMultiThread(
            self.case.fs.ndiff_log,
            progress=printf.verbosity() is printf.OutputVerbosity.FULL)

        for check_rule in self.case.check_rules:
            method = str(list(check_rule.keys())[0])
            module = self.get_module(method)
            comp_data = check_rule[method]
            if not module:
                printf.error('Warning! No module for check_rule method "{}"',
                             method)
                continue

            pairs = self._get_ref_output_files(comp_data)
            if pairs:
                for pair in pairs:

                    # load module and determine whether we are dealing with
                    # exec comparison or inplace comparison
                    if issubclass(module.__class__, modules.ExecComparison):
                        command = module.get_command(*pair, **comp_data)
                        pm = PyPy(BinExecutor(command))
                        pm.executor.output = OutputMode.variable_output()
                    else:
                        module = self.get_module(method)
                        module.prepare(*pair, **comp_data)
                        pm = PyPy(module)
                        pm.executor.output = OutputMode.dummy_output()
                        # pm.error_monitor.deactivate()

                    # if we fail, set error to 13
                    pm.custom_error = 13
                    # TODO: maybe some time limit would be useful
                    pm.full_output = self.case.fs.ndiff_log

                    path = Paths.path_end_until(pair[0], REF_OUTPUT_DIR)
                    test_name = Paths.basename(
                        Paths.dirname(Paths.dirname(self.case.fs.ref_output)))
                    size = Paths.filesize(pair[0], True)
                    pm.name = '{}: {} ({})'.format(test_name, path, size)

                    if printf.verbosity() is printf.OutputVerbosity.FULL:
                        pm.monitor.color_complete_format = '{}: {} ({})'.format(
                            test_name, path, size)
                    else:
                        pm.monitor.error_complete_format = '{}: {} ({})'.format(
                            test_name, path, size)

                    comparisons.add(pm)

        return comparisons
Пример #5
0
    def create_pypy(self, arg_rest):
        executor = BinExecutor(self.get_command(arg_rest))
        pypy = PyPy(executor)
        pypy.case = self.case

        pypy.limit_monitor.set_limits(self.case)
        pypy.end_monitor.deactivate()
        pypy.start_monitor.format = 'Running: {}'.format(self.case)

        pypy.progress = self.progress
        pypy.executor.output = OutputMode.file_write(self.case.fs.job_output)
        pypy.full_output = pypy.executor.output.filename
        return pypy
Пример #6
0
    def create_pypy(self, arg_rest):
        executor = BinExecutor(self.get_command(arg_rest))
        pypy = PyPy(executor)

        if printf.tty():
            pypy.monitor.update_format = _update_format
        else:
            pypy.monitor.start_format = _start_format

        pypy.monitor.color_complete_format = _complete_format
        pypy.case = self.case
        pypy.monitor.set_limits(self.case)
        pypy.executor.output = OutputMode.file_write(self.case.fs.job_output)
        pypy.full_output = pypy.executor.output.filename

        if self.massif:
            import scripts.prescriptions.modules.valgrind as valgrind
            pypy.on_process_complete += valgrind.massif_hook

        return pypy
Пример #7
0
    if not check_modules(*required):
        sys.exit(1)

    from scripts.core.execution import BinExecutor
    from scripts.runtest_module import do_work

    # determine batched mode after parsing
    from scripts.core.base import Printer
    parser.on_parse += Printer.setup_printer

    # import os
    # Paths.init(os.getcwd())

    # run work
    with Timer.app_timer:
        BinExecutor.register_sigint()
        returncode = do_work(parser)

    # collect artifact if not set otherwise
    # parser.parse()
    if parser.simple_options.artifacts:
        if parser.simple_options.artifacts is True:
            artifact_yml = Paths.artifact_yaml()
        else:
            artifact_yml = parser.simple_options.artifacts

        try:
            ap = ArtifactProcessor(artifact_yml)
            ap.run()
        except Exception as e:
            # we catch all error coming from artifact system
Пример #8
0
        or export them to database.
    """)
    argparser.Parser.add(group, '--status-file', action=argparser.Parser.STORE_TRUE, help="""R|
        If set, will also generate status file in test_results directory.
        Status file will have name "runtest.status.json" and will contain
        additional information which cannot be obtained from profiler file
    """)
    return parser


if __name__ == '__main__':
    parser = create_parser()
    arg_options = argparser.Parser.parse_runtest(parser)
    printf.init_logger(verbosity=arg_options.verbosity, logfile=arg_options.log)

    # run work
    with Timer.app_timer:
        BinExecutor.register_sigint()
        returncode, debug = do_work(arg_options)

    # run work
    if arg_options.death:
        if returncode == 0:
            printf.error('Command did exit with 0 but should not (--death flag was set)!')
            sys.exit(1)
        else:
            printf.success('Command did not with 0 (--death flag was set)')
            sys.exit(0)
    else:
        sys.exit(returncode())