summaryrefslogtreecommitdiffstats
path: root/yql/essentials/tools/purebench/test/test.py
blob: d2324907654b3d4c3ca628c58862239267f74445 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import yatest.common
import re

PUREBENCH = yatest.common.build_path('yql/essentials/tools/purebench/purebench')


def test_purebench_smoke():
    result = yatest.common.execute([PUREBENCH, '--ndebug', '-r', '1'],
                                   text=True, check_exit_code=True)
    # Mask elapsed time and duration, since both can change in
    # different environments.
    stdout = result.stdout
    stdout = re.sub(r'(Elapsed: )(\d+[.]\d+)', r'\1<DURATION>', stdout)
    stdout = re.sub(r'(Bench score: )(\d+[.]\d+)', r'\1<SCORE>', stdout)
    # Dump the masked stdout.
    outfile = yatest.common.output_path('out')
    with open(outfile, "w") as dump:
        dump.write(stdout)
    # Dump the raw stderr, since all the diagnostic is precise.
    errfile = yatest.common.output_path('err')
    with open(errfile, "w") as dump:
        dump.write(result.stderr)
    # Canonize both stdout and stderr dumps locally.
    return [
        yatest.common.canonical_file(outfile, local=True),
        yatest.common.canonical_file(errfile, local=True),
    ]