|
| 1 | +""" |
| 2 | +Attempts building & running all CTS category targets in an existing build directory and compares |
| 3 | +their passing / failing with the info from `cts_state.csv`. If the two sources differ, reports |
| 4 | +their disparities and exits with a non-zero code. |
| 5 | +""" |
| 6 | + |
| 7 | +from argparse import ArgumentParser |
| 8 | +from operator import itemgetter |
| 9 | +import os |
| 10 | +import subprocess |
| 11 | +import sys |
| 12 | + |
| 13 | +import pandas as pd |
| 14 | + |
| 15 | +parser = ArgumentParser() |
| 16 | +parser.add_argument('cts_root', type=str, help='SYCL-CTS repository path') |
| 17 | +parser.add_argument('cts_build_dir', type=str, help='SYCL-CTS + SimSYCL build directory') |
| 18 | +args = parser.parse_args() |
| 19 | +cts_root = os.path.realpath(args.cts_root) |
| 20 | +cts_build_dir = os.path.realpath(args.cts_build_dir) |
| 21 | + |
| 22 | +state_file = pd.read_csv('ci/cts_state.csv', delimiter=';') |
| 23 | +tests_in_state_file = set(state_file['suite']) |
| 24 | + |
| 25 | +tests_dir = os.path.join(cts_root, 'tests') |
| 26 | +tests_in_cts = set(t for t in os.listdir(tests_dir) |
| 27 | + if os.path.isdir(os.path.join(tests_dir, t)) |
| 28 | + and t not in ['common', 'extension']) |
| 29 | + |
| 30 | +n_build_failed = 0 |
| 31 | +n_run_failed = 0 |
| 32 | +n_passed = 0 |
| 33 | +changed = [] |
| 34 | +for test in sorted(tests_in_cts): |
| 35 | + status_in_state_file = state_file['status'][state_file['suite'] == test].values |
| 36 | + status_in_state_file = status_in_state_file[0] if status_in_state_file.size > 0 else 'not in list' |
| 37 | + if status_in_state_file == 'not applicable': continue |
| 38 | + |
| 39 | + print('testing', test, end='... ', flush=True) |
| 40 | + r = subprocess.run(['cmake', '--build', cts_build_dir, '--target', f'test_{test}'], |
| 41 | + cwd=cts_root, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) |
| 42 | + if r.returncode == 0: |
| 43 | + r = subprocess.run(os.path.join(cts_build_dir, 'bin', f'test_{test}'), cwd=cts_root, |
| 44 | + stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) |
| 45 | + if r.returncode == 0: |
| 46 | + status_now = 'passed' |
| 47 | + n_passed += 1 |
| 48 | + else: |
| 49 | + status_now = 'run failed' |
| 50 | + n_run_failed += 1 |
| 51 | + else: |
| 52 | + status_now = 'build failed' |
| 53 | + n_build_failed += 1 |
| 54 | + |
| 55 | + if status_now == status_in_state_file: |
| 56 | + print(status_now) |
| 57 | + else: |
| 58 | + print(f'{status_now}, but was {status_in_state_file}') |
| 59 | + changed.append((test, status_in_state_file, status_now)) |
| 60 | + |
| 61 | +print(f'\n{n_passed} passed, {n_run_failed} failed to run, {n_build_failed} failed to build') |
| 62 | + |
| 63 | +for test in tests_in_state_file - tests_in_cts: |
| 64 | + status_in_state_file = state_file['status'][state_file['suite'] == test].values[0] |
| 65 | + changed.append((test, status_in_state_file, 'not in SYCL-CTS')) |
| 66 | + |
| 67 | +if changed: |
| 68 | + print(f'\n{len(changed)} change(s) compared to cts_state.csv:') |
| 69 | + changed.sort(key=itemgetter(0)) |
| 70 | + for test, status_in_state_file, status_now in changed: |
| 71 | + print(f' - {test}: {status_in_state_file} -> {status_now}') |
| 72 | + sys.exit(1) |
0 commit comments