This repository has been archived on 2026-11-24. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
radiance-sycl/tests/kernel_report_check.sh
T
keptn42 6436410e63 kbench: the report check reads every plugin's table, not only lib*
The per-library header "N row(s) not reached" was matched as lib\w+. A plugin library such as
spechub has a table of its own; its rows were counted into the library above it, and the headline
sum came out six short. The pattern is \w+ now. docs/KERNELS.md lists spechub from this run.
2026-11-04 22:08:53 +01:00

46 lines
2.0 KiB
Bash
Executable File

#!/bin/sh
# kernel_report_check.sh -- the checked-in kernel report is internally consistent.
#
# docs/KERNELS.md is generated by `rad-kbench --report` and reviewed by hand. A hand-merged
# regeneration can carry a per-library "N row(s) not reached" header from one run and the table
# below it from another, so the section total and the headline "R of D declared row(s) were
# reached" disagree with the tables. One run cannot produce this (header and table come from one
# vector), so a partially regenerated file fails here.
set -u
REPORT=$1
test -f "$REPORT" || { echo "kernel_report_check: no report at $REPORT"; exit 1; }
# The counting is one python3 pass; a host without it skips, like ops_doc's skip codes.
command -v python3 >/dev/null 2>&1 || { echo " SKIP python3 not present"; exit 77; }
python3 - "$REPORT" <<'PY'
import re, sys
lines = open(sys.argv[1]).read().split("\n")
pat = re.compile(r"`\w+`: (\d+) row\(s\) not reached:")
heads = [(i, m.group(1)) for i, l in enumerate(lines) if (m := pat.match(l))]
bad = 0
for j, (a, claimed) in enumerate(heads):
# The library's table ends at the next library header or the next section header.
b = len(lines)
for i in range(a + 1, len(lines)):
if pat.match(lines[i]) or lines[i].startswith("## "):
b = i
break
rows = sum(1 for l in lines[a:b] if l.startswith("| `"))
name = re.match(r"`(\w+)`", lines[a]).group(1)
print(f" {name}: header {claimed}, table {rows}")
if int(claimed) != rows:
bad += 1
text = "\n".join(lines)
m = re.search(r"(\d+) of (\d+) declared row\(s\) were reached", text)
if m:
ran, declared = int(m.group(1)), int(m.group(2))
missed = sum(int(x) for x in pat.findall(text))
if ran + missed != declared:
print(f" headline: {ran} reached + {missed} not reached != {declared} declared")
bad += 1
if bad:
print(f"kernel_report_check: {bad} inconsistent count(s); regenerate the report from one run.")
sys.exit(1)
print("kernel_report_check: the report's counts agree.")
PY