Commit 8140fe83 authored by Martin Jeřábek's avatar Martin Jeřábek

allow tests to be run standalone, properly scan test cases from unit tests

parent dcd5d13d
......@@ -55,14 +55,16 @@ def create_wrapper(lib):
))
tbs.append(dedent("""\
library work;
USE work.CANtestLib.All;
use work.CANtestLib.All;
library vunit_lib;
context vunit_lib.vunit_context;
entity tb_{test} is generic (runner_cfg : string); end entity;
entity tb_{test} is generic (runner_cfg : string := runner_cfg_default); end entity;
architecture tb of tb_{test} is
component vunittb_wrapper is generic (xrunner_cfg : string); end component;
component vunittb_wrapper is generic (nested_runner_cfg : string); end component;
for all:vunittb_wrapper use configuration work.tbconf_{test};
begin
tb:vunittb_wrapper generic map(xrunner_cfg => runner_cfg);
tb:vunittb_wrapper generic map(nested_runner_cfg => runner_cfg);
end architecture;
-- -----------------------------------------------------------------------------
""".format(test=test)
......@@ -99,6 +101,9 @@ for pattern in ['../src/**/*.vhd', '*.vhd', 'unit/**/*.vhd', 'sanity/*.vhd', 'li
lib.add_source_file(str(f))
create_wrapper(lib)
unit_tests = lib.get_test_benches('*_unit_test')
for ut in unit_tests:
ut.scan_tests_from_file("../unit/vunittb_wrapper.vhd")
#lib.add_compile_option("ghdl.flags", ["-Wc,-g"])
......
......@@ -53,7 +53,7 @@ USE work.CANtestLib.All;
entity tb_sanity is
generic (
runner_cfg : string;
runner_cfg : string := runner_cfg_default;
log_level : log_lvl_type := info_l;
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
......
......@@ -53,7 +53,7 @@ USE work.CANtestLib.All;
entity vunittb_wrapper is
generic (
xrunner_cfg : string;
nested_runner_cfg : string;
iterations : natural := 50;
log_level : log_lvl_type := info_l;
error_beh : err_beh_type := quit; -- Test behaviour when error occurs: Quit, or Go on
......@@ -79,9 +79,9 @@ begin
);
main:process
begin
test_runner_setup(runner, xrunner_cfg);
--while test_suite loop
if true or run("all") then
test_runner_setup(runner, nested_runner_cfg);
while test_suite loop
if run("all") then
t_run <= true;
wait until t_status = passed or t_status = failed;
report "Done";
......@@ -89,7 +89,7 @@ begin
wait for 100 ns;
t_run <= false;
end if;
--end loop;
end loop;
test_runner_cleanup(runner, t_errors > error_tol);
end process;
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