Esempio n. 1
0
def config(path,
           samrai_dir=None,
           cxx_flags=None,
           use_ninja=False,
           use_ccache=False,
           extra=""):
    cmd = make_config_str(path, samrai_dir, cxx_flags, use_ninja, extra)
    run(cmd, capture_output=False)
Esempio n. 2
0
def check(force_kernel_space=False):
    """ perf can require some system config / read the error if thrown """
    kernel_space_opt = "a" if force_kernel_space else ""
    run(f"perf stat -{kernel_space_opt}d sleep 1",
        shell=True,
        capture_output=True,
        check=True)
    record("ls", [], "/tmp/perf_record_check.dat")
Esempio n. 3
0
def checkout(branch, create=False, recreate=False):
    if recreate:
        delete_branch(branch)
        create = True

    if create and not branch_exists(branch):
        run(f"git checkout -b {branch}")
    else:
        run(f"git checkout {branch}")
Esempio n. 4
0
def build(use_ninja=False, threads=1):
    run("ninja" if use_ninja else f"make -j{threads}", capture_output=False)
Esempio n. 5
0
def record(exe, events, output_file=None):
    return run(record_cmd(exe, events, output_file), check=True)
Esempio n. 6
0
def stat(exe, events, output_file=None):
    return run(stat_cmd(exe, events, output_file), check=True)
Esempio n. 7
0
def version():
    # validated on perf version: 5.19
    proc = run("perf -v", shell=True, capture_output=True)
    if " " not in proc or "." not in proc:
        raise ValueError("Unparsable result from 'perf -v'")
    return [int(digit) for digit in proc.split(" ").split(".")]
Esempio n. 8
0
def run_test(test, verbose=False, capture_output=False):
    run(test_cmd(cmd, verbose=verbose), capture_output=capture_output)
Esempio n. 9
0
def list_tests():
    proc = run("ctest -N", capture_output=True)
    out = decode_bytes(proc.stdout)
    return [line.split(" ")[-1] for line in out.splitlines()[1:-2]]
Esempio n. 10
0
def hashes(N=1):
    return decode_bytes(
        run(f"git log -{N} --pretty=format:%h").stdout).splitlines()
Esempio n. 11
0
def current_branch():
    return decode_bytes(run("git branch --show-current").stdout)
Esempio n. 12
0
def branch_exists(branch):
    try:
        run(f"git show-branch {branch}", check=True)
    except subprocess.CalledProcessError as e:
        return False  # exit failure means branch does not exist
    return True
Esempio n. 13
0
def log(N=10, use_short=False):
    """ enjoy """
    short = '--pretty=format:"%h%x09%an%x09%ad%x09%s"' if use_short else ""
    return decode_bytes(run(f"git log -{N} {short}").stdout)