End-to-end evaluation: load sample -> package -> compile (if C++) -> execute -> assert PASSED.
(tmp_path: Path, case: Sample)
| 182 | [pytest.param(c, id=c.test_id, marks=_mark_case(c)) for c in _CASES], |
| 183 | ) |
| 184 | def test_e2e(tmp_path: Path, case: Sample): |
| 185 | """End-to-end evaluation: load sample -> package -> compile (if C++) -> execute -> assert PASSED.""" |
| 186 | definition, solution, workloads = _load_sample(case.sample, case.solution_file) |
| 187 | config = BenchmarkConfig(lock_clocks=False) |
| 188 | |
| 189 | pkg = ProblemPackager( |
| 190 | definition=definition, |
| 191 | workloads=workloads, |
| 192 | solution=solution, |
| 193 | config=config, |
| 194 | output_dir=tmp_path / "staging", |
| 195 | keep_output_dir=True, |
| 196 | ) |
| 197 | |
| 198 | # Phase 1 (CUDA/C++ only): compile |
| 199 | languages = {lang.value for lang in solution.spec.languages} |
| 200 | if languages & _CPP_LANGUAGES: |
| 201 | cmd, artifact_path = pkg.compile() |
| 202 | result = _run_subprocess(cmd, cwd=pkg.output_dir) |
| 203 | assert result.returncode == 0, ( |
| 204 | f"Compilation failed for {case.test_id}:\n" |
| 205 | f" stdout={result.stdout}\n stderr={result.stderr}" |
| 206 | ) |
| 207 | assert Path(artifact_path).exists(), ( |
| 208 | f"benchmark_kernel.so not produced for {case.test_id}" |
| 209 | ) |
| 210 | |
| 211 | # Phase 2: GPU evaluation |
| 212 | cmd = pkg.execute() |
| 213 | result = _run_subprocess(cmd, cwd=pkg.output_dir) |
| 214 | assert result.returncode == 0, ( |
| 215 | f"Execution failed for {case.test_id}:\n" |
| 216 | f" stdout={result.stdout}\n stderr={result.stderr}" |
| 217 | ) |
| 218 | |
| 219 | traces = pkg.convert_stdout_to_traces(result.stdout) |
| 220 | assert len(traces) == case.expected_count, ( |
| 221 | f"Expected {case.expected_count} traces for {case.test_id}, got {len(traces)}" |
| 222 | ) |
| 223 | |
| 224 | failed = [t for t in traces if not t.is_successful()] |
| 225 | assert not failed, ( |
| 226 | f"{case.test_id}: {len(failed)}/{case.expected_count} workloads did not pass:\n" |
| 227 | + "\n".join( |
| 228 | f" [{t.evaluation.status.value}] uuid={t.workload.uuid} " |
| 229 | f"log={t.evaluation.log}" |
| 230 | for t in failed |
| 231 | ) |
| 232 | ) |
| 233 | |
| 234 | # Per-trace invariants for PASSED workloads |
| 235 | for trace in traces: |
| 236 | assert trace.definition == definition.name |
| 237 | |
| 238 | ev = trace.evaluation |
| 239 | assert ev.correctness is not None, ( |
| 240 | f"PASSED trace missing correctness (uuid={trace.workload.uuid})" |
| 241 | ) |
nothing calls this directly
no test coverage detected