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

Semihosting and Unit testing #19

Open
fpedd opened this issue Oct 28, 2021 · 5 comments
Open

Semihosting and Unit testing #19

fpedd opened this issue Oct 28, 2021 · 5 comments

Comments

@fpedd
Copy link

fpedd commented Oct 28, 2021

I am using CTest to run some unit tests on OVPsimPlus. Every unit test consists of an independent .elf and its main returns 0 on success, and 1 on failure. Is there a way, using semihosting, to forward this return value to the OVPsimPlus executable, so that OVPsimPlus itself returns 0 on success and 1 on failure of the unit test? Currently, OVPsimPlus returns 0 regardless.

@duncangraham-Imperas
Copy link
Contributor

The riscvOVPsimPlus executable is a fixed virtual platform containing specific functionality. Part of this functionality is support for various test infrastructures and semihosting capabilities. What you are looking for is simple to realize using the OVP APIs (used to create riscvOVPsimPlus) but as it is a specifc custom feature is not included by the fixed virtual platform (riscvOVPsimPlus).
The return code from riscvOVPsimPlus is the return state of the execution of the virtual platform and will return 0 on sucessfuly runing the application to exit()

@PhilippvK
Copy link

@duncangraham-Imperas I have a very similar issue. If my target software terminates with a exit(1) statement the exit code of the OVPsimPlus executable would still be zero.


I found out about the option

--override riscvOVPsim/cpu/pk/reportExitErrors=F (Boolean) (default=F) (default) Report non-zero exit() return codes as simulator errors

which seems to be related with what we are trying to achieve.

However adding --override riscvOVPsim/cpu/pk/reportExitErrors=T to the cmdline did not result in the expected behavior.

Could you please provide some details on this option and how is is intended to be used?

@duncangraham-Imperas
Copy link
Contributor

Looking at the implementation there appears to be some confusion on how this is implemented. I do not see that this is used in the PK semihosting. Instead if tracing is enabled, using strace argument, then the code provided to the call to exit is output.

I will ask our engineering group to look into this to see if an update is required

@duncangraham-Imperas
Copy link
Contributor

We see that although the parameter is available the code to display the exit code was not added to the PK semihost library. This has now been fixed and will be available in the next version of riscvOVPsim.

@fpedd
Copy link
Author

fpedd commented Jul 21, 2022

@duncangraham-Imperas Thank you very much for getting this fixed! This makes running unit tests on OVPsim a lot easier.

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

No branches or pull requests

3 participants