Commit 02c446ba authored by Martin Jeřábek's avatar Martin Jeřábek

testfw: wave for sanity tests

parent af573b82
from textwrap import dedent
from collections.abc import Iterable
from glob import glob
from os.path import join, dirname, abspath
......@@ -21,6 +22,27 @@ class TestsBase:
def add_sources(self): raise NotImplementedError()
def configure(self): raise NotImplementedError()
def add_modelsim_gui_file(self, tb, cfg, name):
if 'wave' in cfg:
tcl = self.base / cfg['wave']
if not tcl.exists():
log.warn('Wave file {} not found'.format(cfg['wave']))
else:
tcl = self.build / 'modelsim_gui_{}.tcl'.format(name)
with tcl.open('wt', encoding='utf-8') as f:
print(dedent('''\
start_CAN_simulation "dummy"
global IgnoreAddWaveErrors
puts "Automatically adding common waves. Failures are handled gracefully."
set IgnoreAddWaveErrors 1
add_test_status_waves
add_system_waves
set IgnoreAddWaveErrors 0
run_simulation
get_test_results
'''.format(name)), file=f)
tb.set_sim_option("modelsim.init_file.gui", str(tcl))
def add_sources(lib, patterns):
for pattern in patterns:
p = join(str(d.parent), pattern)
......
......@@ -41,7 +41,12 @@ class SanityTests(TestsBase):
# TODO: wave
tb = self.lib.get_test_benches('*tb_sanity')[0]
default = self.config['default']
self.add_modelsim_gui_file(tb, default, 'sanity')
for name, cfg in self.config['tests'].items():
if 'wave' in cfg:
log.warn('"wave" in sanity test config {} is ignored' +
' (set it in default instead)'.format(name))
dict_merge(cfg, default)
bm = len_to_matrix(cfg['topology'], cfg['bus_len_v'])
generics = {
......
......@@ -37,27 +37,7 @@ class UnitTests(TestsBase):
init_files = get_common_modelsim_init_files()
init_files += [str(tcl)]
tb.set_sim_option("modelsim.init_files.after_load", init_files)
if 'wave' in cfg:
path = self.base / cfg['wave']
if not path.exists():
log.warn('Wave file {} not found'.format(cfg['wave']))
tb.set_sim_option("modelsim.init_file.gui", str(path))
else:
tcl = build / 'modelsim_gui_{}.tcl'.format(name)
with tcl.open('wt', encoding='utf-8') as f:
print(dedent('''\
start_CAN_simulation "dummy"
global IgnoreAddWaveErrors
puts "Automatically adding common waves. Failures are handled gracefully."
set IgnoreAddWaveErrors 1
add_test_status_waves
add_system_waves
set IgnoreAddWaveErrors 0
run_simulation
get_test_results
'''.format(name)), file=f)
tb.set_sim_option("modelsim.init_file.gui", str(tcl))
self.add_modelsim_gui_file(tb, cfg, name)
self._check_for_unconfigured()
def _check_for_unconfigured(self):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment