Ejemplo n.º 1
0
def print_task_cmdline(tool, executable, task_def_file):
    """Print command lines resulting for tasks from the given task-definition file."""
    no_limits = CURRENT_BASETOOL.ResourceLimits()

    task = yaml.safe_load(task_def_file)
    input_files = model.handle_files_from_task_definition(
        task.get("input_files"), task_def_file.name
    )

    def print_cmdline(task_description, property_file):
        task_description = task_def_file.name + " " + task_description
        with log_if_unsupported("task from " + task_description):
            cmdline = model.cmdline_for_run(
                tool,
                executable,
                [],
                input_files,
                task_def_file.name,
                property_file,
                copy.deepcopy(task.get("options")),
                no_limits,
            )
            print_list("Command line for " + task_description, cmdline)

    print_cmdline("without property file", None)

    for prop in task.get("properties", []):
        property_file = prop.get("property_file")
        if property_file:
            property_file = util.expand_filename_pattern(
                property_file, os.path.dirname(task_def_file.name)
            )[0]
            print_cmdline("with property " + property_file, property_file)
Ejemplo n.º 2
0
def analyze_tool_output(tool, file, dummy_cmdline):
    try:
        output = file.readlines()
    except (OSError, UnicodeDecodeError) as e:
        logging.warning("Cannot read tool output from “%s”: %s", file.name, e)
        return

    try:
        exit_code = util.ProcessExitCode.create(value=0)
        output = CURRENT_BASETOOL.RunOutput(output)
        run = CURRENT_BASETOOL.Run(dummy_cmdline, exit_code, output, None)
        result = tool.determine_result(run)
        print_value(
            "Result of analyzing tool output in “" + file.name + "”",
            result,
            extra_line=True,
        )
    except BaseException:
        logging.warning(
            "Tool module failed to analyze result in “%s”:", file.name, exc_info=1
        )
Ejemplo n.º 3
0
def print_standard_task_cmdlines(tool, executable):
    """Print command lines resulting from a few different dummy tasks"""
    no_limits = CURRENT_BASETOOL.ResourceLimits()

    with log_if_unsupported(
        "tasks without options, property file, and resource limits"
    ):
        cmdline = model.cmdline_for_run(
            tool, executable, [], ["INPUT.FILE"], None, None, None, no_limits
        )
        print_list("Minimal command line", cmdline)
        if "INPUT.FILE" not in " ".join(cmdline):
            logging.warning("Tool module ignores input file.")

    with log_if_unsupported("tasks with command-line options"):
        cmdline = model.cmdline_for_run(
            tool,
            executable,
            ["-SOME_OPTION"],
            ["INPUT.FILE"],
            None,
            None,
            None,
            no_limits,
        )
        print_list("Command line with parameter", cmdline)
        if "-SOME_OPTION" not in cmdline:
            logging.warning("Tool module ignores command-line options.")

    with log_if_unsupported("tasks with property file"):
        cmdline = model.cmdline_for_run(
            tool, executable, [], ["INPUT.FILE"], None, "PROPERTY.PRP", None, no_limits
        )
        print_list("Command line with property file", cmdline)
        if "PROPERTY.PRP" not in " ".join(cmdline):
            logging.warning("Tool module ignores property file.")

    with log_if_unsupported("tasks with multiple input files"):
        cmdline = model.cmdline_for_run(
            tool,
            executable,
            [],
            ["INPUT1.FILE", "INPUT2.FILE"],
            None,
            None,
            None,
            no_limits,
        )
        print_list("Command line with multiple input files", cmdline)
        if "INPUT1.FILE" in " ".join(cmdline) and "INPUT2.FILE" not in " ".join(
            cmdline
        ):
            logging.warning("Tool module ignores all but first input file.")

    with log_if_unsupported("tasks with CPU-time limit"):
        cmdline = model.cmdline_for_run(
            tool,
            executable,
            [],
            ["INPUT.FILE"],
            None,
            None,
            None,
            CURRENT_BASETOOL.ResourceLimits(cputime=123),
        )
        print_list("Command line CPU-time limit", cmdline)

    with log_if_unsupported("SV-Benchmarks task"):
        cmdline = model.cmdline_for_run(
            tool,
            executable,
            [],
            ["INPUT.FILE"],
            None,
            "PROPERTY.PRP",
            {"language": "C", "data_model": "ILP32"},
            CURRENT_BASETOOL.ResourceLimits(cputime=900, cputime_hard=1000),
        )
        print_list("Command line SV-Benchmarks task", cmdline)

    # This will return the last command line that did not trigger an exception
    return cmdline