Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List of tests #51

Closed
qarlosalberto opened this issue Sep 17, 2019 · 9 comments
Closed

List of tests #51

qarlosalberto opened this issue Sep 17, 2019 · 9 comments
Labels
question Further information is requested

Comments

@qarlosalberto
Copy link

Hi!
Is there a way to list the tests? Similar to VUnit:
https://vunit.github.io/python_interface.html


get_tests(pattern='*')

    Get a list of tests
    Parameters
        pattern – A wildcard pattern matching the test name
    Returns
        A list of Test objects
@themperek
Copy link
Owner

themperek commented Sep 19, 2019

Something like this: https://docs.pytest.org/en/latest/example/special.html ?

If use pytest can use all stand procedures

@themperek themperek added the question Further information is requested label Sep 19, 2019
@themperek
Copy link
Owner

BTW: What is the use case for this?

@qarlosalberto
Copy link
Author

We are working in a cocotb-test front-end for TerosHDL:

https://github.com/TerosTechnology/triel

We would like to get two things that we already have implemented with VUnit:

  • Test selection: the user has the possibility to list the tests and choose which test to run.

vunit

  • Independent output by simulator (.vcd): the user can open the waveform of each test. Un ejemplo sería este:
def test_adder_vhdl():
    tests = list("test_adder")
    for x in tests:
        run(vhdl_sources=["../../../hdl/adder.vhd"],
            simulation_args=["--vcd=func"+x[name]+".vcd"],
            toplevel="adder",
            module="test_adder",
            test=x["name"]
            toplevel_lang="vhdl"
        )

vunit2

@themperek
Copy link
Owner

There is no explicit list of test it is handled by pytest and there are ways to get it (see: pytest-dev/pytest#1613) some IDE are doing this.

Verilog simulator typically does not take VCD output as a parameter it can be defined in Verilog file itself. As far as I can see one would need to do this via define or similar.

@qarlosalberto
Copy link
Author

I think that I can't list the cocotb tests with pytest. In this example:

https://github.com/qarlosalberto/cocotbExamples/blob/master/tools/cocotb/simple/cocotest_test_adder.py
https://github.com/qarlosalberto/cocotbExamples/blob/master/tools/cocotb/simple/test_adder.py

I can discover: def test_adder_vhdl()
But I cant discover: def adder_basic_test(dut), def adder_basic2_test(dut), def adder_random_test(dut

I would like to be able to define with cocotb-test a different output folder (SIM_BUILD) for each cocotb test (adder_basic_test,adder_basic2_test,adder_random_test).

It would also be nice if I could select the tests (TESTCASE)

@themperek
Copy link
Owner

themperek commented Sep 23, 2019

You can set testcase and sim_build now.

For the list of tests you can try to do something like below and parse std (looks bit ugly):

import py                                                                                                                                                                                                                                                                                                             
import pytest

capture = py.io.StdCapture() 
pytest.main(['--collect-only', '-q']) 
std, err = capture.reset() 
print(std.split("\n")) 

@qarlosalberto
Copy link
Author

Ok! I will try, thank you!

@themperek
Copy link
Owner

Did this work?

@themperek
Copy link
Owner

I will close. Feel free to re-open if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants