Skip to content

Commit

Permalink
Check tool versions at beginning of run
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Troiber committed Sep 27, 2023
1 parent c729092 commit afd94bb
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 12 deletions.
12 changes: 12 additions & 0 deletions siliconcompiler/core.py
Expand Up @@ -4211,6 +4211,18 @@ def _local_process(self, flow, status, steplist, indexlist):
for (step, index) in flowgraph_nodes:
# Setting up tool is optional
self._setup_node(step, index)
# Env vars are necessary as test_multiple_tools.py requires it for its version check
self._set_env_vars(step, index)
tool, task = self._get_tool_task(step, index, flow)
# Icarus compiles its executable during the run so we can't check its version
if (tool, task) != ('execute', 'exec_input'):
run_func = getattr(self._get_task_module(step, index, flow=flow), 'run', None)
try:
self._check_tool_version(step, index, run_func)
# Convert sys.exit(1) from haltstep() in version check to SilicoCompilerError
except SystemExit:
self.error('Pre-run version check failed. Please update your tools.',
fatal=True)

# Check validity of setup
self.logger.info("Checking manifest before running.")
Expand Down
14 changes: 8 additions & 6 deletions tests/core/test_error_manifest.py
@@ -1,9 +1,12 @@
import siliconcompiler
from siliconcompiler.tools.surelog import parse
from siliconcompiler._common import SiliconCompilerError
import os

import pytest


@pytest.mark.quick
@pytest.mark.eda
def test_error_manifest():
'''
Executing a node with errors should still produce an output manifest
Expand All @@ -18,9 +21,8 @@ def test_error_manifest():
index = '0'
chip.node(flow, step, parse, index=index)

try:
with pytest.raises(siliconcompiler.SiliconCompilerError):
chip.run()
except SiliconCompilerError:
workdir = chip._getworkdir(jobname=chip._get_in_job(step, index), step=step, index=index)
cfg = os.path.join(workdir, 'outputs', f'{chip.top()}.pkg.json')
assert os.path.isfile(cfg)
workdir = chip._getworkdir(jobname=chip._get_in_job(step, index), step=step, index=index)
cfg = os.path.join(workdir, 'outputs', f'{chip.top()}.pkg.json')
assert os.path.isfile(cfg)
15 changes: 9 additions & 6 deletions tests/core/test_fail_early.py
@@ -1,9 +1,12 @@
import siliconcompiler
from siliconcompiler.tools.yosys import syn_asic
from siliconcompiler.tools.surelog import parse
from siliconcompiler._common import SiliconCompilerError

import pytest


@pytest.mark.quick
@pytest.mark.eda
def test_fail_early(capfd):
chip = siliconcompiler.Chip('test')
chip.set('input', 'rtl', 'verilog', 'fake.v')
Expand All @@ -15,9 +18,9 @@ def test_fail_early(capfd):
chip.node(flow, 'syn', syn_asic)
chip.edge(flow, 'import', 'syn')

try:
with pytest.raises(siliconcompiler.SiliconCompilerError):
chip.run()
except SiliconCompilerError:
# Fail if 'syn' step is run
out, _ = capfd.readouterr()
assert "Halting step 'syn'" not in out
# Fail if 'syn' step is run
out, _ = capfd.readouterr()
assert "Halting step 'import'" in out
assert "Halting step 'syn'" not in out
23 changes: 23 additions & 0 deletions tests/core/test_version_early.py
@@ -0,0 +1,23 @@
import siliconcompiler
from siliconcompiler.tools.surelog import parse

import pytest


def test_version_early(capfd):
chip = siliconcompiler.Chip('test')
chip.set('input', 'rtl', 'verilog', 'fake.v')
chip.load_target('freepdk45_demo')
chip.set('option', 'mode', 'asic')
flow = 'test'
chip.set('option', 'flow', flow)
chip.node(flow, 'import', parse)
chip.set('tool', 'surelog', 'version', '==100.0')

with pytest.raises(siliconcompiler.SiliconCompilerError,
match='Pre-run version check failed. Please update your tools.'):
chip.run()
# Fail if 'syn' step is run
out, _ = capfd.readouterr()
assert "Halting step 'import'" in out
assert "Finished task in" not in out

0 comments on commit afd94bb

Please sign in to comment.