Files
python-bpf/tests/framework/bpf_test_case.py
Pragyansh Chaturvedi a7e2bc39ef Tests: Add a verifier level to the expected-failure tiers
test_config.toml could only declare a failure at the "ir" or "llc" level, and
test_verifier.py dropped every declared-xfail case from the level-3 run
outright. A program that generates IR and compiles cleanly but that the kernel
verifier rejects therefore had no way to be declared: it was silently treated
as must-pass at all three levels.

Levels now form an ordered pipeline (ir < llc < verifier) and a declared level
marks that level and every later one xfail, which is what the old
ir-implies-llc special case was expressing. Level 3 runs every test file and
reports declared failures as expected ones rather than skipping them.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-07 17:07:23 +05:30

32 lines
915 B
Python

from dataclasses import dataclass
from pathlib import Path
# The three test levels, in pipeline order. A test declared as failing at one
# level is also expected to fail at every later level: a program that cannot
# generate IR cannot reach llc, and one that llc rejects never reaches the
# kernel. Used by conftest to decide which items to mark xfail.
LEVELS = ("ir", "llc", "verifier")
def level_index(level: str) -> int:
"""Position of a level in the pipeline. Unknown levels sort first ("ir")."""
try:
return LEVELS.index(level)
except ValueError:
return 0
@dataclass
class BpfTestCase:
path: Path
rel_path: str
is_expected_fail: bool = False
xfail_reason: str = ""
xfail_level: str = "ir" # one of LEVELS
needs_vmlinux: bool = False
skip_reason: str = ""
@property
def test_id(self) -> str:
return self.rel_path.replace("/", "::")