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

Programatic procedure to retrieve the output path of a test #478

Closed
umarcor opened this issue Apr 17, 2019 · 6 comments · Fixed by #578
Closed

Programatic procedure to retrieve the output path of a test #478

umarcor opened this issue Apr 17, 2019 · 6 comments · Fixed by #578

Comments

@umarcor
Copy link
Member

umarcor commented Apr 17, 2019

Ref #467.

@umarcor:
Is it possible to read test_name_to_path_mapping.txt directly as some Python type (dict or list)?

@kraigher:
The file was intended for human use. The format is folder_name SPACE test_name.
I do not recommend that you use it. It is better we add this to --export-json instead.

@kraigher:
Currently the commands are logged if you use --log-level=DEBUG for human use. If an external tool needs this information we need to add it to --export-json.

@umarcor:
IMHO, there should be a simple and realiable programatic procedure to retrieve the output/log of a test. It don't really mind if I need to set some stdout in the python script, or get it as a return field from vu.main(), or parse some output file. I am trying to process test_name_to_path_mapping.txt just because I didn't find a better way to 'see' the content in output.txt.

About adding it to --export-json, although useful, I'd rather avoid it for this specific use case. Using JSON is a better approach when it is to be used from Python, Go, etc. But, with Bash or C I find it easier not to require a JSON parsing library. The current format, as you described it, is straighforward, as one only needs to search for the first space.

@kraigher
Copy link
Collaborator

Are you aware that the output path is accessible as an attribute on the post_check and pre_config hooks as well? Depending on the use case this might be what you need rather than having it written in the export-json file.

@umarcor
Copy link
Member Author

umarcor commented Apr 17, 2019

No, I was not. And I can very probably use it to retrieve the path in the run.py file, without actually running the simulation. I will give it a try. Thanks!

@kraigher
Copy link
Collaborator

It will only be accessible when running the pre config hook before simulation. So you need to run the simulation.

@umarcor
Copy link
Member Author

umarcor commented Apr 17, 2019

It will only be accessible when running the pre config hook before simulation. So you need to run the simulation.

I think I should be able to 'run the simulation' as --elaborate with sim_option ghdl.elab_e, so the pre config hook is triggered and the binary is compiled (thus, the output path needs to be created), but no simulation is executed. What do you think?

@kraigher
Copy link
Collaborator

That would work.

@umarcor
Copy link
Member Author

umarcor commented Apr 21, 2019

I implemented it in #568 as follows:

def preconf(output_path):
    global opath
    opath = output_path
    return True

for tb in lib.get_test_benches(pattern='*', allow_empty=False):
    tb.set_pre_config(preconf)

ui.set_sim_option("ghdl.elab_e", True)
ui._args.elaborate = True
try:
    ui.main()
except SystemExit as exc:
    if exc.code is not 0:
        exit(exc.code)

args = [line.rstrip('\n') for line in open(join(opath, 'ghdl', 'args.txt'))]

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

Successfully merging a pull request may close this issue.

2 participants