|
|
@@ -1,6 +1,5 @@
|
|
|
from __future__ import annotations
|
|
|
|
|
|
-import inspect
|
|
|
import sys
|
|
|
from unittest import mock
|
|
|
|
|
|
@@ -8,15 +7,37 @@ from tools import fw_cli
|
|
|
|
|
|
|
|
|
def test_fw_test_6400_uses_current_v1_runner() -> None:
|
|
|
- expected_actions = ["unit"] if sys.platform == "win32" else ["all"]
|
|
|
+ expected_action = "unit" if sys.platform == "win32" else "all"
|
|
|
|
|
|
with (
|
|
|
mock.patch("tools.fw_cli._generate_one"),
|
|
|
- mock.patch("tools.run_6400_v1.main", return_value=0) as current_runner,
|
|
|
+ mock.patch("tools.fw_cli._python", return_value="/test/python"),
|
|
|
+ mock.patch("tools.fw_cli.subprocess.call", return_value=0) as current_runner,
|
|
|
):
|
|
|
assert fw_cli.main(["test", "6400"]) == 0
|
|
|
|
|
|
- current_runner.assert_called_once_with(expected_actions)
|
|
|
- dispatch_source = inspect.getsource(fw_cli._run_6400_verify)
|
|
|
- assert "from tools.run_6400_v1 import" in dispatch_source
|
|
|
- assert "from tools.run_6400_verify import" not in dispatch_source
|
|
|
+ argv = current_runner.call_args.args[0]
|
|
|
+ assert argv[:2] == ["/test/python", "-B"]
|
|
|
+ assert argv[-2].endswith("tools/run_6400_v1.py")
|
|
|
+ assert argv[-1] == expected_action
|
|
|
+ assert current_runner.call_args.kwargs["env"]["PYTHONDONTWRITEBYTECODE"] == "1"
|
|
|
+
|
|
|
+
|
|
|
+def test_fw_test_6400_returns_runner_failure_code() -> None:
|
|
|
+ with (
|
|
|
+ mock.patch("tools.fw_cli._generate_one"),
|
|
|
+ mock.patch("tools.fw_cli._python", return_value="/test/python"),
|
|
|
+ mock.patch("tools.fw_cli.subprocess.call", return_value=7),
|
|
|
+ ):
|
|
|
+ assert fw_cli.main(["test", "6400"]) == 7
|
|
|
+
|
|
|
+
|
|
|
+def test_fw_test_all_continues_after_6400_failure() -> None:
|
|
|
+ with (
|
|
|
+ mock.patch("tools.fw_cli._generate_one"),
|
|
|
+ mock.patch("tools.fw_cli._run_6400_verify", return_value=7),
|
|
|
+ mock.patch("tools.fw_cli._run_mrdimm_matrix", return_value=0) as mrdimm,
|
|
|
+ ):
|
|
|
+ assert fw_cli.main(["test", "all"]) == 7
|
|
|
+
|
|
|
+ mrdimm.assert_called_once_with("python,icarus,verilator,cocotb,formal")
|