Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ jobs:
run: tools/private-lint.sh
- name: skill-lint
run: tools/skill-lint.sh
- name: Smoke evidence fixtures (no device)
run: python3 tools/farm/test_farm.py ValguestEvidence ShellRoute SmokeRoute
# On main the "progress" job refreshes a stale diagram instead of failing the run.
- name: progress diagram is current
if: github.event_name == 'pull_request'
Expand Down
3 changes: 3 additions & 0 deletions tools/farm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ thermal_stop thermal_resume`. A gated device keeps its jobs pending, writes one
state/battery/temp, run JSON has battery_pct_/temp_c_ start+end. qdeqp stops with rc 75 and resumes from its TSV.

## Result integrity
- Smoke requires a fresh, successfully transferred log for every shell-route invocation and a complete terminal
`{"pass":true}` record from each test binary. Missing/empty/incomplete logs and summaries without the full suite's
draw, compute and meta records cannot pass. Explicit feature skips remain valid when the binary completes normally.
- The driver `.so` is verified by sha256 ON THE PHONE against the job's `so_sha256` before every dEQP chunk (qdeqp, `QDEQP_SO_SHA256`),
after valrun's push and after each run; a mismatch makes the run `invalid` (kept as `runs/<job>-<class>.invalid-N.json`, alert line, re-queued).
- Each dEQP run uses its own on-phone ICD paths (`QDEQP_RUN`), so concurrent runs cannot swap each other's driver.
Expand Down
20 changes: 16 additions & 4 deletions tools/farm/farmd
Original file line number Diff line number Diff line change
Expand Up @@ -881,18 +881,30 @@ class Farm:
for l in out.splitlines():
if l.startswith("{"):
try:
recs.append(json.loads(l))
rec = json.loads(l)
if isinstance(rec, dict):
recs.append(rec)
except ValueError:
pass
self.keep_log(job, dev, "smoke", out, rc)
summ = next((r for r in reversed(recs) if r.get("test") == "summary"), None)
tests = [r for r in recs if "rc" in r]
failed = [[r["test"], f"rc={r['rc']} fail_lines={r.get('fail_lines')}"] for r in tests if r["rc"] != 0 or r.get("fail_lines")]
counts = {"tests": len(tests), "failed": len(failed), "pass_lines": sum(r.get("pass_lines", 0) for r in tests)}
def pass_count(rec):
n = rec.get("pass_lines")
return n if type(n) is int and n > 0 else 0
failed = [[r.get("test", "unknown"), f"rc={r['rc']} fail_lines={r.get('fail_lines')} pass_lines={r.get('pass_lines')}"]
for r in tests if r["rc"] != 0 or r.get("fail_lines") or not pass_count(r)]
counts = {"tests": len(tests), "failed": len(failed), "pass_lines": sum(pass_count(r) for r in tests)}
if summ is None:
return {"verdict": "error", "counts": counts, "new_failures": failed, "newly_passing": [],
"notes": f"no summary (rc={rc}): {out.strip()[-200:]!r}"}
ok = summ.get("ok") and not failed
# A summary is not execution evidence. Full runs always invoke these three binaries; feature cases may
# legitimately be absent on older trees. Selected subsets still need at least one completed binary.
missing = sorted({"t_vk_draw", "t_vk_compute", "t_vk_meta"} - {r.get("test") for r in tests}) if not job.get("only") else []
if not tests or missing:
return {"verdict": "error", "counts": counts, "new_failures": failed, "newly_passing": [],
"notes": "incomplete smoke evidence: " + (", ".join(missing) if missing else "no test records")}
ok = rc == 0 and summ.get("ok") is True and not failed
note = "" if route == "guest" else f"route={route}" + (f" ({why})" if why else "") + (" skipped: " + "; ".join(smokeroute.SKIPPED) if route == "shell-fallback" else "")
return {"verdict": "pass" if ok else "fail", "counts": counts, "new_failures": failed, "newly_passing": [], "notes": note}

Expand Down
37 changes: 31 additions & 6 deletions tools/farm/shellroute.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ def smoke(a):
for c in a.only.split(","): # --only: one run per case this binary knows, binaries without a match are skipped
if c in (ONLY_DRAW if n == "t_vk_draw" else feat if n == "t_vk_feat" else ONLY_META):
runs.append((n, f"{extra} --only {c}", c))
for n, extra, oc in runs:
for run_index, (n, extra, oc) in enumerate(runs):
if gated(a.lock):
sys.exit(75)
if sha_phone(f"{d}/libvulkan_mali.so") != a.sha:
Expand All @@ -542,18 +542,43 @@ def smoke(a):
sys.exit(83)
print("phone unreachable: " + o.strip()[-120:], flush=True)
sys.exit(79)
lp = os.path.join(tmp, n + ".log")
adb("pull", f"{d}/{n}.log", lp, timeout=60)
log = open(lp, errors="replace").read() if os.path.exists(lp) else ""
# A binary can run repeatedly (draw suite, then many_draws, or several --only cases). A failed transfer must
# never inherit a previous invocation's result, even if adb returned success without creating the file.
lp = os.path.join(tmp, f"{run_index}-{n}.log")
pull_rc, pull_out = adb("pull", f"{d}/{n}.log", lp, timeout=60)
try:
if pull_rc:
raise OSError(f"adb pull rc={pull_rc}: {pull_out.strip()[-120:]}")
with open(lp, errors="replace") as fh:
log = fh.read()
except OSError as exc:
print(f"smoke log unavailable for {n}: {exc}", flush=True)
sys.exit(79)
fl = [x for x in log.splitlines() if '"fail"' in x]
# Every t_vk_* binary emits a final {"pass":true|false}, including completed feature-gated skips.
# Count complete JSON records, not a substring that also appears in a truncated log.
passes, terminal = [], None
for line in log.splitlines():
if not line.strip():
continue
terminal = None # an earlier pass does not complete a later, truncated log
try:
rec = json.loads(line)
except ValueError:
continue
if isinstance(rec, dict) and "pass" in rec:
passes.append(rec["pass"])
if set(rec) == {"pass"}:
terminal = rec["pass"]
pass_lines = sum(p is True for p in passes)
for x in log.splitlines()[-200:]: # kept by farmd (farm log)
print(json.dumps({"log": n + (":" + oc if oc else ""), "line": x[:400]}), flush=True)
r = int(m.group(1))
if r == 134 and OOM_RE.search(log): # the memory bound, not a QPA crash: never let BurstGuard retry it
print("verdict: memory_cap rc=134 in %s: the smoke run hit its memory bound; shard smaller" % n, flush=True)
sys.exit(83)
ok = ok and r == 0
print('{"test":"%s","rc":%d,"fail_lines":%d,"pass_lines":%d}' % (n, r, len(fl), log.count('"pass":true')), flush=True)
ok = ok and r == 0 and not fl and terminal is True and all(p is True for p in passes)
print('{"test":"%s","rc":%d,"fail_lines":%d,"pass_lines":%d}' % (n, r, len(fl), pass_lines), flush=True)
print('{"test":"summary","ok":%s}' % ("true" if ok else "false"), flush=True)
print(f"SO_ON_PHONE {d}/libvulkan_mali.so", flush=True)

Expand Down
133 changes: 132 additions & 1 deletion tools/farm/test_farm.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,14 @@ class = "v13"
else:
shutil.copy(a[1], P(a[2]))
elif op == "pull":
if a[1].endswith(".log") and "/t_vk_" in a[1]:
counter = R + "/smoke-pulls"
n = int(open(counter).read()) + 1 if os.path.exists(counter) else 1
open(counter, "w").write(str(n))
if os.environ.get("FAKE_ADB_PULL_FAIL_AT") == str(n):
print("error: simulated log transfer failure"); sys.exit(1)
if os.environ.get("FAKE_ADB_PULL_MISSING_AT") == str(n):
sys.exit(0) # a successful transport status alone is not a local log
if os.path.exists(P(a[1])):
shutil.copy(P(a[1]), a[2])
else:
Expand Down Expand Up @@ -135,7 +143,14 @@ class = "v13"
elif "./t_vk_" in c:
d = re.split(r";|&&", c[len("cd "):])[0].strip()
n = re.search(r"\./(t_vk_\w+)", c).group(1)
open(P(d) + "/" + n + ".log", "w").write('{"pass":true}\n{"pass":true}\n')
logs = {"empty": "", "incomplete": '{"test":"triangle","ok":true}\n',
"earlier": '{"pass":true}\n{"test":"unfinished"',
"truncated": '{"pass":true',
"skipped": '{"test":"triangle","skipped":"feature not advertised","ok":true}\n{"pass":true}\n',
"failed": '{"pass":false}\n'}
mode = os.environ.get("FAKE_ADB_SMOKE_LOG", "")
if mode != "missing":
open(P(d) + "/" + n + ".log", "w").write(logs.get(mode, '{"pass":true}\n{"pass":true}\n'))
print("rc=0")
else:
for m in re.finditer(r"rm -(?:rf|f) ([^;&]+)", c):
Expand All @@ -146,6 +161,52 @@ class = "v13"
'''


class ValguestEvidence(unittest.TestCase):
def guest(self, mode):
# Exercise the actual guest harness with only its two fixed directories
# redirected to a private fixture. No driver, device, ADB or network.
from pathlib import Path
script = (Path(HERE).parents[1] / "vk/tests/valguest.sh").read_text()
roots = "D=/storage/emulated/0/Download; T=/tmp/val;"
self.assertEqual(script.count(roots), 1)
script = script.replace(roots, 'D="$1"; T="$2";')
with tempfile.TemporaryDirectory() as temp:
root = Path(temp)
source = root / "in"
source.mkdir()
for name, value in (("val_libvulkan_mali.so", ""), ("val_stub.spv", ""),
("val_loop.txt", "1"), ("val_env.txt", ""),
("val_only.txt", "triangle,rot")):
(source / name).write_text(value)
fake = r'''#!/bin/sh
case "$*" in
*"--only rot") case "$EVIDENCE_MODE" in
truncated) printf '%s\n' '{"pass":true'; exit 0 ;;
empty) exit 0 ;;
earlier) printf '%s\n' '{"pass":true}' 'incomplete'; exit 0 ;;
skipped) printf '%s\n' '{"test":"rot","skipped":"feature unavailable"}' ;;
esac ;;
esac
printf '%s\n' '{"pass":true}'
'''
for n in ("t_vk_draw", "t_vk_compute", "t_vk_meta", "t_vk_feat"):
(source / ("val_" + n)).write_text(fake)
run = subprocess.run(["sh", "-s", "--", str(source), str(root / "scratch")],
input=script, capture_output=True, text=True, timeout=10,
env={"PATH": os.defpath, "EVIDENCE_MODE": mode})
self.assertEqual(run.returncode, 0, run.stderr)
rows = [json.loads(line) for line in run.stdout.splitlines()]
return next(row for row in rows if row.get("test") == "summary")

def test_guest_requires_a_terminal_result_from_each_selected_case(self):
for mode in ("truncated", "empty", "earlier"):
with self.subTest(mode=mode):
self.assertIs(self.guest(mode)["ok"], False)

def test_guest_accepts_a_completed_feature_skip(self):
self.assertIs(self.guest("skipped")["ok"], True)


class ShellRoute(unittest.TestCase):
"""shellroute.py against a fake adb (the phone is a temp dir): per-run .so path, sha256 on the phone, lock guard, resume"""
def setUp(self):
Expand Down Expand Up @@ -311,6 +372,38 @@ def test_smoke(self):
rc, o = self.run_sr("smoke", "a64-bionic", env={"FAKE_ADB_CORRUPT": "1"})
self.assertEqual(rc, 77)

def test_smoke_missing_log_is_transport_failure(self):
rc, out = self.run_sr("smoke", "a64-bionic", env={"FAKE_ADB_SMOKE_LOG": "missing"})
self.assertEqual(rc, 79, out)
self.assertIn("smoke log unavailable", out)
self.assertNotIn('"test":"summary","ok":true', out)

def test_smoke_failed_pull_cannot_reuse_previous_draw_log(self):
# Full-suite draw is followed by many_draws using the same binary name.
rc, out = self.run_sr("smoke", "a64-bionic", env={"FAKE_ADB_PULL_FAIL_AT": "2"})
self.assertEqual(rc, 79, out)
self.assertIn("smoke log unavailable", out)
self.assertNotIn('"test":"summary","ok":true', out)

def test_smoke_missing_local_file_cannot_reuse_previous_draw_log(self):
rc, out = self.run_sr("smoke", "a64-bionic", env={"FAKE_ADB_PULL_MISSING_AT": "2"})
self.assertEqual(rc, 79, out)
self.assertIn("smoke log unavailable", out)
self.assertNotIn('"test":"summary","ok":true', out)

def test_smoke_requires_complete_terminal_pass_record(self):
for mode in ("empty", "incomplete", "truncated", "failed", "earlier"):
with self.subTest(mode=mode):
rc, out = self.run_sr("smoke", "a64-bionic", env={"FAKE_ADB_SMOKE_LOG": mode})
self.assertIn('"test":"summary","ok":false', out)
self.assertNotIn('"test":"summary","ok":true', out)

def test_smoke_preserves_explicit_feature_skips(self):
rc, out = self.run_sr("smoke", "a64-bionic", env={"FAKE_ADB_SMOKE_LOG": "skipped"})
self.assertEqual(rc, 0, out)
self.assertIn('"test":"summary","ok":true', out)
self.assertIn('"pass_lines":1', out)


# ---- resource guards: the 2026-11-19 kernel panic (oom_score_adj=-1000 inherited from adbd, unbounded deqp, blind retry after the reboot)
def test_oom_protection_is_cleared_memory_capped_and_work_sharded(self):
Expand Down Expand Up @@ -2397,6 +2490,44 @@ def test_shell_route_failing_test_is_a_fail(self):
f.run_shellroute = lambda job, dev, mode, rid, extra, tmo, nodim=False: (0, bad)
self.assertEqual(f.suite_smoke(dict(self.JOB), self.dev)["verdict"], "fail")

def smoke_result(self, out, rc=0, only=""):
f = self.farm(fallback=False)
f.smoke_guest = lambda *a, **k: (rc, out)
return f.suite_smoke(dict(self.JOB, only=only), self.dev)

def test_smoke_summary_alone_is_not_evidence(self):
result = self.smoke_result('{"test":"summary","ok":true}')
self.assertEqual(result["verdict"], "error", result)
self.assertEqual(result["counts"]["tests"], 0)

def test_smoke_each_binary_needs_terminal_pass_evidence(self):
for value in (0, -1, None, "1", True):
with self.subTest(pass_lines=value):
rows = [json.loads(line) for line in SMOKE_OUT.splitlines()]
rows[1]["pass_lines"] = value
result = self.smoke_result("\n".join(json.dumps(r) for r in rows))
self.assertEqual(result["verdict"], "fail", result)
self.assertEqual(result["counts"]["failed"], 1)

def test_smoke_incomplete_suite_is_not_a_pass(self):
for binary in ("t_vk_draw", "t_vk_compute", "t_vk_meta"):
with self.subTest(binary=binary):
out = "\n".join(line for line in SMOKE_OUT.splitlines() if binary not in line)
result = self.smoke_result(out)
self.assertEqual(result["verdict"], "error", result)
self.assertIn(binary, result["notes"])

def test_smoke_nonzero_runner_status_cannot_pass(self):
result = self.smoke_result(SMOKE_OUT, rc=1)
self.assertEqual(result["verdict"], "fail", result)

def test_smoke_selected_subset_with_completed_skip_still_passes(self):
# A feature-gated skip still reaches the binary's final {"pass":true}.
out = '\n'.join(['{"test":"t_vk_feat","rc":0,"fail_lines":0,"pass_lines":1}',
'{"test":"summary","ok":true}'])
result = self.smoke_result(out, only="ycbcr")
self.assertEqual(result["verdict"], "pass", result)

def test_job_built_before_the_fallback_gets_its_bionic_build_on_demand(self):
f = self.farm()
f.tree = lambda jid: tempfile.gettempdir()
Expand Down
16 changes: 13 additions & 3 deletions vk/tests/valguest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,22 @@ for c in "t_vk_draw --loop $LOOP" "t_vk_compute --loop 5" "t_vk_meta" "t_vk_feat
if [ -z "$ONLY" ]; then CASES="-"; [ $n = t_vk_feat ] && CASES=$FEAT; else CASES=""; K=$META; [ $n = t_vk_draw ] && K=$DRAW; [ $n = t_vk_feat ] && K=$FEAT
for o in $ONLY; do m=0; case "$K" in *" $o "*) m=1;; esac; case "$n:$o" in t_vk_draw:fx_*) m=1;; esac # fx_<name>: one t_vk_draw fx case
[ $m = 1 ] && CASES="$CASES $o" && RAN="$RAN $o"; done; [ -n "$CASES" ] || continue; fi
: >$T/$n.log; rc=0
: >$T/$n.log; rc=0; pass_lines=0
for o in $CASES; do OA=""; [ $o = - ] || OA="--only $o"
timeout 120 $T/$n --direct $T/libvulkan_mali.so $sp "$@" $OA >>$T/$n.log 2>&1 || rc=$?
# Each invocation must have its own terminal result, even if an earlier
# --only case from the same binary passed. All four harnesses emit this
# exact standalone JSON line after cleanup, including completed skips.
timeout 120 $T/$n --direct $T/libvulkan_mali.so $sp "$@" $OA >$T/$n.case.log 2>&1 || rc=$?
cat $T/$n.case.log >>$T/$n.log || { rc=1; ok=0; }
if awk 'NF { last=$0 } END { exit !(last == "{\"pass\":true}") }' $T/$n.case.log; then
pass_lines=$((pass_lines + 1))
else
printf '%s\n' '{"fail":"valguest: missing final passing record for an invocation"}' >>$T/$n.log
ok=0
fi
done
[ $rc = 0 ] || ok=0
echo "{\"test\":\"$n\",\"rc\":$rc,\"fail_lines\":$(grep -c '"fail"' $T/$n.log),\"pass_lines\":$(grep -c '"pass":true' $T/$n.log)}"
echo "{\"test\":\"$n\",\"rc\":$rc,\"fail_lines\":$(grep -c '"fail"' $T/$n.log),\"pass_lines\":$pass_lines}"
grep '"fail"' $T/$n.log | head -3 | sed 's/\\/\\\\/g; s/"/\\"/g; s/^\(.*\)$/{"line":"\1"}/'
tail -200 $T/$n.log | sed 's/\\/\\\\/g; s/"/\\"/g; s/^\(.*\)$/{"log":"'$n'","line":"\1"}/'
done
Expand Down