Exemple #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)
Exemple #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")
Exemple #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}")
Exemple #4
0
def build(use_ninja=False, threads=1):
    run("ninja" if use_ninja else f"make -j{threads}", capture_output=False)
Exemple #5
0
def record(exe, events, output_file=None):
    return run(record_cmd(exe, events, output_file), check=True)
Exemple #6
0
def stat(exe, events, output_file=None):
    return run(stat_cmd(exe, events, output_file), check=True)
Exemple #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(".")]
Exemple #8
0
def run_test(test, verbose=False, capture_output=False):
    run(test_cmd(cmd, verbose=verbose), capture_output=capture_output)
Exemple #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]]
Exemple #10
0
def hashes(N=1):
    return decode_bytes(
        run(f"git log -{N} --pretty=format:%h").stdout).splitlines()
Exemple #11
0
def current_branch():
    return decode_bytes(run("git branch --show-current").stdout)
Exemple #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
Exemple #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)