Beispiel #1
0
def run(benchmark: Arg(None,
                       help="name of the benchmark to run",
                       action="jbx.benchmarks.byName.{}".format),
        transformers: ListOf(
            "-T",
            help="transformers in order",
            action=nixutils.from_attrset_list("jbx.transformers")) = "[]",
        input_name: Arg("-i", help="the input to the dynamic analysis") = "",
        analysis: Arg("-a", help="the dynamic analyisis to run") = "run.run",
        *args,
        **opts):
    """ run a dynamic analysis """

    if input_name:
        input = "getInput transformed \"{}\"".format(input_name)
    else:
        input_string = "{{ name = \"cmdline\"; args = {}; }}"
        input = input_string.format(nixutils.to_nix_list(args))

    cmd = RUN_CMD.format(benchmark=benchmark,
                         input=input,
                         transformers=transformers,
                         analysis=analysis,
                         **opts)

    nixutils.build(cmd, **opts)
Beispiel #2
0
def analyse(
    benchmarks: OneOf(
        only=ListOf("-o", help="a list of benchmarks", action=from_attrset_list("jbx.benchmarks.byName")),
        tag=Arg("-t", help="a single tag", action="jbx.benchmarks.byTag.{}".format),
    ),
    transformers: ListOf("-T", help="transformers in order", action=from_attrset_list("jbx.transformers")) = "[]",
    analysis: Arg("-a", help="analysis of choice", action="jbx.analyses.{}".format) = "(b: env: b)",  # do nothing
    java: Arg("-j", help="Java version") = 6,
    debug: Arg("-d", help="add debug settings to the run") = False,
    environment: Arg("-E", help="the user environment to run things in") = path.join(JBXFOLDER, "environment.nix"),
    keep_failed: Arg("-K", help="keeps the output even if the output fails.") = False,
    short_curcuit: Arg("-c", help="if one of the test failes stop computing.") = False,
    dry_run: Arg("-n", help="do not execute, print nix command instead.") = False,
    **opts
):
    """ runs a series of analyses one or more benchmarks. """

    cmd = ANALYSE_CMD.format(
        java=java,
        environment=environment,
        benchmarks=benchmarks,
        transformers=transformers,
        analysis=analysis,
        keep_failed=keep_failed,
        dry_run=dry_run,
        **opts
    )
    nixutils.build(cmd, debug=debug, dry_run=dry_run, keep_failed=keep_failed, keep_going=not short_curcuit, **opts)
Beispiel #3
0
def run(
    benchmark: Arg(None, help="name of the benchmark to run", action="jbx.benchmarks.byName.{}".format),
    transformers: ListOf("-T", help="transformers in order", action=from_attrset_list("jbx.transformers")) = "[]",
    input_name: Arg("-i", help="the input to the dynamic analysis") = "",
    analysis: Arg("-a", help="the dynamic analyisis to run") = "run.run",
    java: Arg("-j", help="Java version") = 6,
    debug: Arg("-d", help="add debug settings to the run") = False,
    environment: Arg("-E", help="the user environment to run things in") = path.join(JBXFOLDER, "environment.nix"),
    keep_failed: Arg("-K", help="keeps the output even if the output fails.") = False,
    dry_run: Arg("-n", help="do not execute, print nix command instead.") = False,
    *args,
    **opts
):
    """ run a dynamic analysis """

    if input_name:
        input = 'getInput transformed "{}"'.format(input_name)
    else:
        input = '{{ name = "cmdline"; args = {}; }}'.format(to_nix_list(args))

    cmd = RUN_CMD.format(
        benchmark=benchmark,
        input=input,
        environment=environment,
        transformers=transformers,
        java=java,
        analysis=analysis,
        **opts
    )

    nixutils.build(cmd, debug=debug, dry_run=dry_run, keep_failed=keep_failed, **opts)
Beispiel #4
0
def analyse(
        benchmarks: OneOf(only=ListOf(
            "-o",
            help="a list of benchmarks",
            action=nixutils.from_attrset_list("jbx.benchmarks.byName")),
                          tag=Arg("-t",
                                  help="a single tag",
                                  action="jbx.benchmarks.byTag.{}".format),
                          json=Arg(
                              None,
                              help="a json object representing the benchmark",
                              action=json_to_nix)),
        transformers: ListOf(
            "-T",
            help="transformers in order",
            action=nixutils.from_attrset_list("jbx.transformers")) = "[]",
        analysis: Arg(
            "-a", help="analysis of choice",
            action="jbx.analyses.{}".format) = "(b: env: b)",  # do nothing
        **opts):
    """ runs a series of analyses one or more benchmarks. """

    cmd = ANALYSE_CMD.format(benchmarks=benchmarks,
                             transformers=transformers,
                             analysis=analysis,
                             **opts)
    nixutils.build(cmd, keep_going=not opts["short_curcuit"], **opts)
Beispiel #5
0
def tool(
    tool: Arg(None, help="the tool to install"),
    dry_run: Arg("-n", help="do not execute, print nix command instead.") = False,
    **opts
):
    """ test a tool."""
    cmd = TOOL_CMD.format(tool=tool, **opts)
    nixutils.build(cmd, dry_run, **opts)
Beispiel #6
0
def test(info, opts):
    expr = nixexpr(info);

    test_expr = TEST_EXPR.format(
        expr = "\n".join("    " + e for e in expr.split("\n")),
        **opts
    );
    nixutils.build(test_expr, **opts);
Beispiel #7
0
def main(arguments):
    args = argparser().parse_args(arguments)

    args.fargs = "[{}]".format(' '.join(map('"{}"'.format, args.arg)))
    
    if not args.input:
        args.input_obj = '{{ name="cli"; args={0.args}; }}'.format(args)
    else:
        args.input_obj = '(builtins.elemAt (builtins.filter (i: i.name == "{0.input}") bm.inputs) 0)'.format(args)
    cmd = """
      with (import {0.filename} {{}});
      let bm = benchmarks.byName.{0.benchmark}.withJava java.java{0.java};
      in analyses.run.run (import {0.environment}) bm {0.input_obj}
    """.format(args)
    nixutils.build(cmd, dry_run=args.dry_run);
Beispiel #8
0
def main(arguments):
    args = argparser().parse_args(arguments)

    args.fargs = "[{}]".format(' '.join(map('"{}"'.format, args.arg)))

    if not args.input:
        args.input_obj = '{{ name="cli"; args={0.args}; }}'.format(args)
    else:
        args.input_obj = '(builtins.elemAt (builtins.filter (i: i.name == "{0.input}") bm.inputs) 0)'.format(
            args)
    cmd = """
      with (import {0.filename} {{}});
      let bm = benchmarks.byName.{0.benchmark}.withJava java.java{0.java};
      in analyses.run.run (import {0.environment}) bm {0.input_obj}
    """.format(args)
    nixutils.build(cmd, dry_run=args.dry_run)
Beispiel #9
0
def main(arguments):
    args = argparser().parse_args(arguments)
    args.analyses = to_strarray(args.analysis)
    args.correctedEngine = "tools.{}".format(args.engine) if args.engine != "null" else "null"
    args.bms = to_strarray(args.benchmark)
    cmd = """
      with (import {0.filename} {{}});
      let 
        bms = map (bm: benchmarks.byName.${{bm}}.withJava java.java{0.java}) 
            {0.bms};
      in map (bm: 
        analyses.shared.petablox {{ 
            subanalyses = {0.analyses}; 
            petablox = tools.{0.petablox};
            logicblox = {0.correctedEngine};
            reflection = "{0.reflect}";
            timelimit = {0.timelimit};
        }} (import {0.environment}) bm) 
        bms
    """.format(
        args
    )

    nixutils.build(cmd, dry_run=args.dry_run, keep_failed=args.keep_failed)
Beispiel #10
0
def tool(tool: Arg(None, help="the tool to install"), **opts):
    """ test a tool."""
    cmd = TOOL_CMD.format(tool=tool, **opts)
    nixutils.build(cmd, **opts)