Commit b5d52ea1 authored by Martin Jeřábek's avatar Martin Jeřábek

testwf: fixes, formatting

Status: compiles, but does not run (hangs)
parent e5f01c39
......@@ -36,7 +36,7 @@ package pkg_feature_exec_dispath is
procedure exec_feature_test(
--Common test parameters
signal test_name : in string;
constant test_name : in string;
variable o : out feature_outputs_t;
signal so : out feature_signal_outputs_t;
signal rand_ctr : inout natural range 0 to RAND_POOL_SIZE;
......
......@@ -92,7 +92,7 @@ entity CAN_feature_test is
signal bl_force : in boolean;
-- Internal signals; TODO: direction
signal iteration_done : out boolean := false;
signal iteration_done : in boolean := false;
signal hw_reset_on_new_test : in boolean := true;
signal iin : in instance_inputs_arr_t;
......@@ -421,8 +421,10 @@ begin
o => o,
rand_ctr => rand_ctr,
mem_bus => mem_bus,
iout => iout,
so => so);
iout => iin,
so => so,
bus_level => bus_level
);
if o.outcome = false then
process_error(error_ctr, error_beh, exit_imm);
......
......@@ -20,7 +20,7 @@ package body pkg_feature_exec_dispath is
--Procedure for processing the feature tests!
procedure exec_feature_test(
--Common test parameters
signal test_name : in string;
constant test_name : in string;
variable o : out feature_outputs_t;
signal so : out feature_signal_outputs_t;
signal rand_ctr : inout natural range 0 to RAND_POOL_SIZE;
......
from textwrap import dedent
from collections.abc import Iterable
from glob import glob
from os.path import join, dirname, abspath
from os.path import join, abspath
import logging
from pathlib import Path
from jinja2 import Environment, PackageLoader
from pprint import pprint
__all__ = ['add_sources', 'add_common_sources', 'get_common_modelsim_init_files',
'add_flags', 'dict_merge', 'vhdl_serialize', 'dump_sim_options', 'TestsBase']
......@@ -14,6 +15,7 @@ log = logging.getLogger(__name__)
jinja_env = Environment(loader=PackageLoader(__package__, 'data'), autoescape=False)
class TestsBase:
def __init__(self, ui, lib, config, build, base):
self.ui = ui
......@@ -26,8 +28,11 @@ class TestsBase:
def jinja_env(self):
return jinja_env
def add_sources(self): raise NotImplementedError()
def configure(self): raise NotImplementedError()
def add_sources(self):
raise NotImplementedError()
def configure(self):
raise NotImplementedError()
def add_modelsim_gui_file(self, tb, cfg, name):
if 'wave' in cfg:
......@@ -50,6 +55,7 @@ class TestsBase:
'''.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)
......@@ -58,14 +64,17 @@ def add_sources(lib, patterns):
if f != "tb_wrappers.vhd":
lib.add_source_file(str(f))
def add_common_sources(lib):
return add_sources(lib, ['../src/**/*.vhd', '*.vhd', 'lib/*.vhd'])
def get_common_modelsim_init_files():
modelsim_init_files = '../lib/test_lib.tcl,modelsim_init.tcl'
modelsim_init_files = [str(d/x) for x in modelsim_init_files.split(',')]
return modelsim_init_files
def add_flags(ui, lib, build):
unit_tests = lib.get_test_benches('*_unit_test', allow_empty=True)
for ut in unit_tests:
......@@ -78,12 +87,14 @@ def add_flags(ui, lib, build):
modelsim_init_files = get_common_modelsim_init_files()
ui.set_sim_option("modelsim.init_files.after_load", modelsim_init_files)
def dict_merge(up, *lowers):
for lower in lowers:
for k, v in lower.items():
if k not in up:
up[k] = v
def vhdl_serialize(o):
if isinstance(o, Iterable):
ss = []
......@@ -93,6 +104,7 @@ def vhdl_serialize(o):
else:
return str(o)
def dump_sim_options(lib):
for tb in lib.get_test_benches('*'):
for cfgs in tb._test_bench.get_configuration_dicts():
......
import logging
from pathlib import Path
from .test_common import *
from .test_common import add_sources, TestsBase, dict_merge, vhdl_serialize
log = logging.getLogger(__name__)
class FeatureTests(TestsBase):
def __init__(self, *args, **kwds):
super().__init__(*args, **kwds)
......@@ -15,18 +16,36 @@ class FeatureTests(TestsBase):
sources.append('feature/pkg_feature_exec_dispatch.vhd')
add_sources(self.lib, sources)
wrname = self.build / 'pkg_feature_exec_dispatch-body.vhd';
wrname = self.build / 'pkg_feature_exec_dispatch-body.vhd'
self._create_wrapper(wrname)
#add_sources(self.lib, [str(wrname)])
# add_sources(self.lib, [str(wrname)])
self.lib.add_source_file(str(wrname))
tb = self.lib.get_test_benches('*tb_feature')[0]
tb.scan_tests_from_file(str(wrname))
def configure(self) -> None:
# TODO: iterations ...
pass
tb = self.lib.get_test_benches('*tb_feature')[0]
default = self.config['default']
self.add_modelsim_gui_file(tb, default, 'feature')
for name, cfg in self.config['tests'].items():
if cfg is None:
cfg = dict()
if 'wave' in cfg:
log.warn('"wave" in feature test config {} is ignored' +
' (set it in default instead)'.format(name))
dict_merge(cfg, default)
generics = {
'timeout' : cfg['timeout'],
'iterations' : cfg['iterations'],
'log_level' : cfg['log_level'] + '_l',
'error_tol' : cfg['error_tolerance'],
'test_name' : name
}
tb.add_config(name, generics=generics)
def _create_wrapper(self, ofile : Path) -> None:
def _create_wrapper(self, ofile: Path) -> None:
template = self.jinja_env.get_template('pkg_feature_exec_dispath-body.vhd')
c = template.render(tests=self._tests)
with ofile.open('wt', encoding='utf-8') as f:
......
import logging
from .test_common import *
from .test_common import TestsBase, add_sources, dict_merge, vhdl_serialize
log = logging.getLogger(__name__)
def len_to_matrix(topology, bus_len):
l = bus_len
if topology == 'bus':
......@@ -33,6 +34,7 @@ def len_to_matrix(topology, bus_len):
return bm
class SanityTests(TestsBase):
def add_sources(self):
add_sources(self.lib, ['sanity/**/*.vhd'])
......@@ -48,7 +50,7 @@ class SanityTests(TestsBase):
' (set it in default instead)'.format(name))
dict_merge(cfg, default)
bm = len_to_matrix(cfg['topology'], cfg['bus_len_v'])
# bm = len_to_matrix(cfg['topology'], cfg['bus_len_v'])
generics = {
'timeout' : cfg['timeout'],
'iterations' : cfg['iterations'],
......
......@@ -33,6 +33,10 @@
wave: unit/TX_Buffer/txbf_unit.tcl
feature:
default:
log_level: warning
error_tolerance: 0
iterations: 50
timeout: 100 ms
tests:
abort_transmittion:
arbitration:
......
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