diff --git a/crates/celox-vpi/src/bin/celox.rs b/crates/celox-vpi/src/bin/celox.rs index 99295fba55a..46d2a3882eb 100644 --- a/crates/celox-vpi/src/bin/celox.rs +++ b/crates/celox-vpi/src/bin/celox.rs @@ -571,7 +571,19 @@ fn discover_vpi(python: &Path) -> Result { fn check_results(python: &Path, results_file: &Path) -> Result<(), String> { let output = Command::new(python) - .args([OsStr::new("-m"), OsStr::new("cocotb_tools.check_results")]) + .args(["-c", r#" +import sys +from xml.etree import ElementTree + +cases = list(ElementTree.parse(sys.argv[1]).getroot().iter("testcase")) +executed = [case for case in cases if case.find("skipped") is None] +failed = [case for case in executed if case.find("failure") is not None or case.find("error") is not None] +if not executed: + sys.exit("no cocotb tests were executed (check the test filter and skip settings)") +if failed: + names = ", ".join(case.get("name", "") for case in failed[:8]) + sys.exit(f"{len(failed)} cocotb test(s) failed: {names}") +"#]) .arg(results_file) .output() .map_err(|error| format!("failed to check cocotb results: {error}"))?; diff --git a/crates/celox-vpi/tests/cocotb_e2e.rs b/crates/celox-vpi/tests/cocotb_e2e.rs index ba7ef9a8ff6..d2049d78e88 100644 --- a/crates/celox-vpi/tests/cocotb_e2e.rs +++ b/crates/celox-vpi/tests/cocotb_e2e.rs @@ -155,6 +155,31 @@ fn check_cocotb_native_design(source: &[&str], module: &str, filter: &str) { assert!(results.is_file()); + let unmatched = Command::new(&executable) + .args([ + "--test-module", + module, + "--test-filter", + "^no_such_cocotb_test$", + "--python", + &python, + ]) + .arg("--results-file") + .arg(&results) + .current_dir(&fixture) + .env("PYTHONPATH", &python_path) + .output() + .unwrap(); + assert!( + !unmatched.status.success(), + "an empty test selection was reported as successful" + ); + assert!( + String::from_utf8_lossy(&unmatched.stderr).contains("no cocotb tests were executed"), + "{}", + String::from_utf8_lossy(&unmatched.stderr) + ); + let failed_runtime = Command::new(&executable) .args(["--test-module", "missing_test_module", "--python", &python]) .arg("--results-file")