diff --git a/.github/workflows/host-tests.yml b/.github/workflows/host-tests.yml index 71bff62d35ee1..b68a20990fdec 100644 --- a/.github/workflows/host-tests.yml +++ b/.github/workflows/host-tests.yml @@ -132,10 +132,20 @@ jobs: - name: Run the host tests run: python3 -I tools/asahi/run-host-tests.py --jobs "$(nproc)" --work "$RUNNER_TEMP/host-tests" + - name: Show memory and out-of-memory kills after a failure + # A test killed by SIGKILL with no timeout is most often the OOM killer (an infrastructure failure, re-run it). + if: failure() + run: | + free -m + sudo dmesg 2>/dev/null | grep -iE 'out of memory|oom-kill|killed process' | tail -n 20 || true + - name: Keep the logs of a failed run if: failure() uses: actions/upload-artifact@v4 with: name: host-test-logs - path: ${{ runner.temp }}/host-tests/**/log + # A suite's per-case reasons (apple-dcp out/-failure.log) ride along with the run logs. + path: | + ${{ runner.temp }}/host-tests/**/log + ${{ runner.temp }}/host-tests/**/*-failure.log retention-days: 14 diff --git a/tools/asahi/run-host-tests.py b/tools/asahi/run-host-tests.py index ed3ae0c762582..580c3f98dc9cc 100755 --- a/tools/asahi/run-host-tests.py +++ b/tools/asahi/run-host-tests.py @@ -28,6 +28,7 @@ import shlex import shutil import signal +import stat import subprocess import sys import tempfile @@ -727,13 +728,46 @@ def run(job, timeout): (d / 'log').write_text(f'$ {shlex.join(cmd)}\n{text}\nexit: {rc}\n') if expect == PASS: ok = rc == 0 - why = '' if ok else f'exit {rc}' + why = '' if ok else died(rc) or f'exit {rc}' else: ok = rc not in (0, 'timeout') and KILL_SIGN.search(text) and not BROKEN_SIGN.search(text) - why = '' if ok else (f'mutant survived (exit {rc})' if rc == 0 else f'exit {rc} without a control failure') + why = '' if ok else (f'mutant survived (exit {rc})' if rc == 0 else died(rc) or f'exit {rc} without a control failure') return label, bool(ok), why, took, d / 'log' +def died(rc): + """Name a signal death: SIGKILL with no timeout is most often the out-of-memory killer, not a test failure.""" + if not isinstance(rc, int) or rc >= 0: + return '' + try: + name = signal.Signals(-rc).name + except ValueError: + name = f'signal {-rc}' + hint = ' (likely the out-of-memory killer: an infrastructure failure, re-run it)' if rc == -signal.SIGKILL else '' + return f'killed by {name}{hint}' + + +def case_reasons(log, not_ok, lines=20): + """A suite that keeps one '-failure.log' per failing TAP case (apple-dcp) gets its tail printed here.""" + out = [] + for line in not_ok: + name = line.split(' - ', 1)[1].strip() if ' - ' in line else '' + path = log.parent / 'out' / f'{name}-failure.log' + if not name or '/' in name: + continue + # Best effort: a missing, unreadable or non-regular reason file (a FIFO would block the read) must never hide + # the normal failure report. + try: + if not stat.S_ISREG(path.lstat().st_mode): + continue + text = path.read_text(errors='replace').splitlines() + except OSError: + continue + out.append(f'--- {line}: {path}') + out.extend(text[-lines:]) + return out + + def main(): ap = argparse.ArgumentParser(description=__doc__.split('\n', 1)[0]) ap.add_argument('--jobs', type=int, default=os.cpu_count() or 2) @@ -802,6 +836,10 @@ def run_all(args, work): if not_ok: print(f'\n=== {label}: failing TAP cases ({len(not_ok)})') print('\n'.join(not_ok[:40])) + reasons = case_reasons(log, not_ok[:10]) + if reasons: + print(f'\n=== {label}: why they failed') + print('\n'.join(reasons)) print(f'\n=== {label}: last lines of {log}') print('\n'.join(text[-40:])) return failed