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
14 changes: 13 additions & 1 deletion crates/celox-vpi/src/bin/celox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,19 @@ fn discover_vpi(python: &Path) -> Result<PathBuf, String> {

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", "<unnamed>") 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}"))?;
Expand Down
25 changes: 25 additions & 0 deletions crates/celox-vpi/tests/cocotb_e2e.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Loading