Skip to content

Commit af53f90

Browse files
committed
tests(yosys): use target-aware, configurable synthesis timeouts
Replace the fixed 300s Yosys timeout with target-aware defaults to avoid false failures on slower synthesis paths. - add _get_timeout_seconds(synth_command) - default non-Xilinx timeout to 600s - default synth_xilinx* timeout to 900s - support env overrides: - FROST_YOSYS_TIMEOUT_SEC - FROST_YOSYS_XILINX_TIMEOUT_SEC - print effective timeout in run logs for visibility - use computed timeout for both captured and streamed subprocess runs This keeps faster targets unchanged in behavior while allowing longer-running Xilinx and large generic runs to complete instead of timing out.
1 parent b641d24 commit af53f90

File tree

1 file changed

+44
-2
lines changed

1 file changed

+44
-2
lines changed

tests/test_run_yosys.py

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
This ensures FROST can be synthesized for any FPGA vendor or ASIC flow.
2121
"""
2222

23+
import os
2324
import subprocess
2425
import sys
2526
from pathlib import Path
@@ -48,6 +49,45 @@ def _compile_hello_world(root_dir: Path) -> bool:
4849
sys.path.pop(0)
4950

5051

52+
def _get_timeout_seconds(synth_command: str) -> int:
53+
"""Get synthesis timeout in seconds, with target-aware defaults.
54+
55+
Defaults:
56+
- Non-Xilinx targets: 600s
57+
- Xilinx targets (synth_xilinx*): 900s
58+
59+
Environment overrides:
60+
- FROST_YOSYS_TIMEOUT_SEC
61+
- FROST_YOSYS_XILINX_TIMEOUT_SEC
62+
"""
63+
default_timeout = 600
64+
default_xilinx_timeout = 900
65+
66+
env_name = (
67+
"FROST_YOSYS_XILINX_TIMEOUT_SEC"
68+
if synth_command.startswith("synth_xilinx")
69+
else "FROST_YOSYS_TIMEOUT_SEC"
70+
)
71+
fallback = (
72+
default_xilinx_timeout
73+
if synth_command.startswith("synth_xilinx")
74+
else default_timeout
75+
)
76+
77+
raw = os.environ.get(env_name)
78+
if raw is None:
79+
return fallback
80+
81+
try:
82+
timeout = int(raw)
83+
if timeout <= 0:
84+
raise ValueError
85+
return timeout
86+
except ValueError:
87+
print(f"Warning: invalid {env_name}={raw!r}; using {fallback}s")
88+
return fallback
89+
90+
5191
# Synthesis targets for pytest runs
5292
# Additional targets can be run manually: ./test_run_yosys.py --target <name>
5393
SYNTHESIS_TARGETS = [
@@ -174,6 +214,8 @@ def run_synthesis(
174214
print(f"Parsing filelist: {self.filelist}")
175215
print(f"Using ROOT: {self.root_dir}")
176216
print(f"Found {len(verilog_files)} Verilog files")
217+
timeout_sec = _get_timeout_seconds(synth_command)
218+
print(f"Using timeout: {timeout_sec}s")
177219

178220
shell_cmd = ["yosys", "-p", script_content]
179221

@@ -183,14 +225,14 @@ def run_synthesis(
183225
capture_output=True,
184226
text=True,
185227
cwd=self.test_dir,
186-
timeout=300, # 5 minute timeout
228+
timeout=timeout_sec,
187229
)
188230
else:
189231
# Let output stream to console
190232
result = subprocess.run(
191233
shell_cmd,
192234
cwd=self.test_dir,
193-
timeout=300, # 5 minute timeout
235+
timeout=timeout_sec,
194236
text=True,
195237
)
196238

0 commit comments

Comments
 (0)