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

testfw: add test timeout

parent e54c2c6e
...@@ -112,7 +112,8 @@ def create_wrapper(lib, fname): ...@@ -112,7 +112,8 @@ def create_wrapper(lib, fname):
iterations : natural := 1; iterations : natural := 1;
log_level : log_lvl_type := info_l; log_level : log_lvl_type := info_l;
error_beh : err_beh_type := quit; error_beh : err_beh_type := quit;
error_tol : natural := 0 error_tol : natural := 0;
timeout : string := "0 ms"
); end entity; ); end entity;
architecture tb of tb_{test} is architecture tb of tb_{test} is
component vunittb_wrapper is generic ( component vunittb_wrapper is generic (
...@@ -120,11 +121,18 @@ def create_wrapper(lib, fname): ...@@ -120,11 +121,18 @@ def create_wrapper(lib, fname):
iterations : natural; iterations : natural;
log_level : log_lvl_type; log_level : log_lvl_type;
error_beh : err_beh_type; error_beh : err_beh_type;
error_tol : natural error_tol : natural;
timeout : string
); end component; ); end component;
for all:vunittb_wrapper use configuration work.tbconf_{test}; for all:vunittb_wrapper use configuration work.tbconf_{test};
begin begin
tb:vunittb_wrapper generic map(nested_runner_cfg => runner_cfg, iterations => iterations, log_level => log_level, error_beh => error_beh, error_tol => error_tol); tb:vunittb_wrapper generic map(
nested_runner_cfg => runner_cfg,
iterations => iterations,
log_level => log_level,
error_beh => error_beh,
error_tol => error_tol,
timeout => timeout);
end architecture; end architecture;
-- ----------------------------------------------------------------------------- -- -----------------------------------------------------------------------------
""".format(test=test) """.format(test=test)
...@@ -252,6 +260,7 @@ def configure_unit_tests(ui, lib, config): ...@@ -252,6 +260,7 @@ def configure_unit_tests(ui, lib, config):
raise RuntimeError('Testbench {}_unit_test does not exist (but specified in config).'.format(name)) raise RuntimeError('Testbench {}_unit_test does not exist (but specified in config).'.format(name))
assert len(tb) == 1 assert len(tb) == 1
tb = tb[0] tb = tb[0]
tb.set_generic('timeout', cfg['timeout'])
tb.set_generic('iterations', cfg['iterations']) tb.set_generic('iterations', cfg['iterations'])
tb.set_generic('log_level', cfg['log_level'] + '_l') tb.set_generic('log_level', cfg['log_level'] + '_l')
tb.set_generic('error_tol', cfg['error_tolerance']) tb.set_generic('error_tol', cfg['error_tolerance'])
......
...@@ -3,6 +3,7 @@ unit: ...@@ -3,6 +3,7 @@ unit:
log_level: warning log_level: warning
error_tolerance: 0 error_tolerance: 0
iterations: 50 iterations: 50
timeout: 100 ms
tests: tests:
bit_stuffing: bit_stuffing:
iterations: 10 iterations: 10
......
...@@ -57,8 +57,9 @@ entity vunittb_wrapper is ...@@ -57,8 +57,9 @@ entity vunittb_wrapper is
iterations : natural := 50; iterations : natural := 50;
log_level : log_lvl_type := info_l; log_level : log_lvl_type := info_l;
error_beh : err_beh_type := quit; -- Test behaviour when error occurs: Quit, or Go on error_beh : err_beh_type := quit; -- Test behaviour when error occurs: Quit, or Go on
error_tol : natural := 0 -- Error tolerance, error counter should not error_tol : natural := 0; -- Error tolerance, error counter should not
-- exceed this value in order for the test to pass -- exceed this value in order for the test to pass
timeout : string := "0 ms" -- Timeout in simulation time. 0 means no limit.
); );
end entity; end entity;
...@@ -92,4 +93,9 @@ begin ...@@ -92,4 +93,9 @@ begin
end loop; end loop;
test_runner_cleanup(runner, t_errors > error_tol); test_runner_cleanup(runner, t_errors > error_tol);
end process; end process;
watchdog: if time'value(timeout) > 0 ns generate
test_runner_watchdog(runner, time'value(timeout));
end generate;
end architecture; end architecture;
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