fix(cocotb): Improve test discovery for tests with arguments The `update_cocotb_tests.py` script previously used a regex that failed to discover cocotb tests defined with arguments in the `@cocotb.test()` decorator (e.g., `@cocotb.test(skip=True)`). This commit updates the regex to correctly parse these definitions. As a result of applying the updated script, several `BUILD` files have been regenerated to: - Create uniquely named testcase lists for each `cocotb_test_suite`. - Correctly list all discovered tests. Change-Id: Id0da034c786f333f731f669e1ee69909b9416c64
diff --git a/tests/cocotb/BUILD b/tests/cocotb/BUILD index 05cac01..3045e5b 100644 --- a/tests/cocotb/BUILD +++ b/tests/cocotb/BUILD
@@ -418,14 +418,20 @@ ], ) +# BEGIN_TESTCASES_FOR_rvv_ml_ops_cocotb_test +RVV_ML_OPS_TESTCASES = [ + "core_mini_rvv_matmul_test", +] +# END_TESTCASES_FOR_rvv_ml_ops_cocotb_test + cocotb_test_suite( name = "rvv_ml_ops_cocotb_test", simulators = [ "verilator", "vcs", ], - testcases = RVV_LOAD_STORE_TESTCASES, - testcases_vname = "RVV_LOAD_STORE_TESTCASES", + testcases = RVV_ML_OPS_TESTCASES, + testcases_vname = "RVV_ML_OPS_TESTCASES", tests_kwargs = { "hdl_toplevel": "RvvCoreMiniAxi", "waves": True,
diff --git a/tests/cocotb/tlul/BUILD b/tests/cocotb/tlul/BUILD index 0e8417c..41cae74 100644 --- a/tests/cocotb/tlul/BUILD +++ b/tests/cocotb/tlul/BUILD
@@ -252,11 +252,16 @@ vcs_defines = VCS_DEFINES, ) +# BEGIN_TESTCASES_FOR_secded_encoder_32_cocotb_test +SECDED_ENCODER_32_TESTCASES = [ + "test_secded_encoder", +] +# END_TESTCASES_FOR_secded_encoder_32_cocotb_test cocotb_test_suite( name = "secded_encoder_32_cocotb_test", simulators = ["verilator", "vcs"], - testcases = SECDED_ENCODER_TESTCASES, - testcases_vname = "SECDED_ENCODER_TESTCASES", + testcases = SECDED_ENCODER_32_TESTCASES, + testcases_vname = "SECDED_ENCODER_32_TESTCASES", tests_kwargs = { "hdl_toplevel": "SecdedEncoderTestbench32", "test_module": ["test_secded_encoder.py"], @@ -272,11 +277,16 @@ vcs_defines = VCS_DEFINES, ) +# BEGIN_TESTCASES_FOR_secded_encoder_57_cocotb_test +SECDED_ENCODER_57_TESTCASES = [ + "test_secded_encoder", +] +# END_TESTCASES_FOR_secded_encoder_57_cocotb_test cocotb_test_suite( name = "secded_encoder_57_cocotb_test", simulators = ["verilator", "vcs"], - testcases = SECDED_ENCODER_TESTCASES, - testcases_vname = "SECDED_ENCODER_TESTCASES", + testcases = SECDED_ENCODER_57_TESTCASES, + testcases_vname = "SECDED_ENCODER_57_TESTCASES", tests_kwargs = { "hdl_toplevel": "SecdedEncoderTestbench57", "test_module": ["test_secded_encoder.py"], @@ -305,12 +315,13 @@ # BEGIN_TESTCASES_FOR_kelvin_xbar_cocotb KELVIN_XBAR_TESTCASES = [ "test_kelvin_core_to_sram", - "test_ibex_d_to_kelvin_device_csr_read", - "test_wide_to_narrow_integrity", - "test_kelvin_core_to_kelvin_device", + "test_ibex_d_to_invalid_addr", "test_kelvin_core_to_uart1", "test_ibex_d_to_kelvin_device", - "test_ibex_d_to_invalid_addr", + "test_kelvin_core_to_kelvin_device", + "test_ibex_d_to_kelvin_device_csr_read", + "test_ibex_d_to_kelvin_device_specific_addr", + "test_wide_to_narrow_integrity", ] # END_TESTCASES_FOR_kelvin_xbar_cocotb
diff --git a/utils/update_cocotb_tests.py b/utils/update_cocotb_tests.py index 9267cbc..3fd2b0e 100644 --- a/utils/update_cocotb_tests.py +++ b/utils/update_cocotb_tests.py
@@ -19,7 +19,7 @@ def find_cocotb_tests(filename): with open(filename, "r") as f: source = f.read() - return re.findall(r"@cocotb\.test\(\)\s+async def\s+(\w+)", source) + return re.findall(r"@cocotb\.test\(.*\)\s+async def\s+(\w+)", source) def update_build_file(build_file, test_file, variable_name, name):