Commit 3428d425 authored by Martin Jeřábek's avatar Martin Jeřábek

testfw: sanity test

parent eef57ebd
This diff is collapsed.
......@@ -10,6 +10,7 @@ import re
import sys
from textwrap import dedent
from pprint import pprint
from collections.abc import Iterable
from .log import MyLogRecord
from . import vunit_ifc
from vunit.ui import VUnit
......@@ -67,7 +68,7 @@ def get_common_modelsim_init_files():
return modelsim_init_files
def add_flags(ui, lib, build):
unit_tests = lib.get_test_benches('*_unit_test')
unit_tests = lib.get_test_benches('*_unit_test', allow_empty=True)
for ut in unit_tests:
ut.scan_tests_from_file(str(build / "../unit/vunittb_wrapper.vhd"))
......@@ -297,8 +298,82 @@ def configure_unit_tests(ui, lib, config):
'''.format(name)), file=f)
tb.set_sim_option("modelsim.init_file.gui", str(tcl))
# --- sanity
def len_to_matrix(topology, bus_len):
l = bus_len
if topology == 'bus':
bm = [[0.0, l[1], l[1]+l[2], l[1]+l[2]+l[3]],
[l[1], 0.0, l[2], l[2]+l[3]],
[l[1]+l[2], l[2], 0.0, l[3]],
[l[1]+l[2]+l[3], l[2]+l[3], l[3], 0.0]]
elif topology == 'star':
bm = [[0.0, l[1]+l[2], l[1]+l[3], l[1]+l[4]],
[l[1]+l[2], 0.0, l[2]+l[3], l[2]+l[4]],
[l[1]+l[3], l[2]+l[3], 0.0, l[3]+l[4]],
[l[1]+l[4], l[2]+l[4], l[3]+l[4], 0.0]]
elif topology == 'tree':
bm = [[0.0, l[1]+l[2], l[1]+l[3]+l[5], l[1]+l[4]+l[5]],
[l[1]+l[2], 0.0, l[2]+l[3]+l[5], l[2]+l[4]+l[5]],
[l[1]+l[3]+l[5], l[2]+l[3]+l[5], 0.0, l[3]+l[4]],
[l[1]+l[4]+l[5], l[2]+l[4]+l[5], l[3]+l[4], 0.0]]
elif topology == 'ring':
raise RuntimeError("Ring topology not implemented.")
# TODO: Ring topology with min functions
elif topology == 'custom':
bm = [[0.0, l[1], l[2], l[3]],
[l[1], 0.0, l[4], l[5]],
[l[2], l[4], 0.0, l[6]],
[l[3], l[6], l[6], 0.0]]
else:
raise ValueError("Invalid bus topology.")
return bm
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 = []
for x in o:
ss.append(vhdl_serialize(x))
return ''.join(['(', ', '.join(ss), ')'])
else:
return str(o)
def configure_sanity_tests(ui, lib, config):
pass
tb = lib.get_test_benches('*tb_sanity')[0]
default = config['default']
for name, cfg in config['tests'].items():
dict_merge(cfg, default)
bm = len_to_matrix(cfg['topology'], cfg['bus_len_v'])
generics = {
'timeout' : cfg['timeout'],
'iterations' : cfg['iterations'],
'log_level' : cfg['log_level'] + '_l',
'error_tol' : cfg['error_tolerance'],
'topology' : cfg['topology'],
#'bm' : vhdl_serialize(bm),
'bus_len_v' : vhdl_serialize(cfg['bus_len_v']),
'trv_del_v' : vhdl_serialize(cfg['trv_del_v']),
'osc_tol_v' : vhdl_serialize(cfg['osc_tol_v']),
'nw_mean' : vhdl_serialize(cfg['nw_mean']),
'nw_var' : vhdl_serialize(cfg['nw_var']),
'ng_mean' : vhdl_serialize(cfg['ng_mean']),
'ng_var' : vhdl_serialize(cfg['ng_var']),
'timing_config': vhdl_serialize(cfg['timing_config']),
'gauss_iter' : vhdl_serialize(cfg['gauss_iter']),
}
tb.add_config(name, generics=generics)
def configure_feature_tests(ui, lib, config):
pass
......@@ -317,6 +392,10 @@ def configure_feature_tests(ui, lib, config):
- pass encoded composite generics (sanity test)
- use watchdog - pass the time in config: test_runner_watchdog(runner, 10 ms);
- bash completion for files & tests:
- click._bashcompletion.get_choices -> extend the if to check if the given argument is an instance of XXX
and implement completion method for that instance. Complete test names.
"""
def dump_sim_options(lib):
......
......@@ -31,9 +31,13 @@ unit:
wave: unit/TX_Arbitrator/txar_unit.tcl
tx_buf:
wave: unit/TX_Buffer/txbf_unit.tcl
.sanity:
sanity:
default:
iterations: 1
timeout: 2 sec
log_level: info
error_tolerance: 0
gauss_iter: 40
tests:
"1Mb/10Mb 20 m Star":
topology: star
......@@ -45,4 +49,3 @@ unit:
ng_mean: 300000.0
ng_var: 100000.0
timing_config: [4, 1, 8, 8, 8, 3, 3, 1, 5, 2]
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