-
Notifications
You must be signed in to change notification settings - Fork 263
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
fix: nonzero return values should produce a fail #469
Conversation
VUnit ignores the return code to be able to end simulation with an assert of severity failure for non VHDL-2008 where std.end.stop exists. Thus failing all test when the exit code is non-zero will break VUnit-support for VHDL 93 and 2002. |
What is your suggestion?
|
An acceptable way forward would be to check the simulator exit code in VHDL 2008. It would prevent people wrapping the simulator binary from using a standard less than 2008 but I guess that would be no problem. |
e83e2bc
to
1459654
Compare
I now added a check for the version.
If someone tries to wrap the binary with a standard less than 2008, the behaviour will be the same as if no fix existed. So, as far as I understand it, they can still do it, but they will have to handle false positives. |
c94d1cc
to
030b259
Compare
@kraigher this is failing because |
The situation is that VUnit supports running all test cases within a test bench in the same simulation using the run_all_in_same_sim comment attribute. In these cases you might have three tests "Test 1", "Test 2" and "Test 3" that are run in sequence. If "Test 1" pass and "Test 2" fails the "Test 3" will be considered skipped as the simulation stops at the failure of "Test 2". The change will make "Test 1" fail also since the exit code will fail all tests that were run in the same simulation. I think the acceptance criteria is correct and should not be changed. One way to solve it would be to only fail all tests if all test pass in the presence of non-zero exit code. Thus if any test fails we let the test results be the way they where even if the exit code was non-zero. This would behave the same way as the current solution for the default case where each test is run in its own simulation. We have a lot of acceptance test in VUnit to ensure things we wanted to work a specific way does not unintentionally break in the future. In this case your PR does not include any comment, unit test or acceptance test so there is a likelyhood that the behavior you want w.r.t the exit code will break in the future. Maybe a unit test with a comment is sufficient in this case. |
I moved the fix after the check now. I am not sure if the check should be kept as
I'm trying to add some unit test, but I am finding it difficult to implement without actually compiling a C file where GHDL is embedded. Any ideas? EDIT If found that |
The rule should be, if non zero exit code and not any status=FAILED and code we flip all PASSED to FAILED Regarding unit test it should be a python test in test/unit/test_test_suites.py at the function level without involving any external tool. This is unlike an acceptable test where VUnit is tested end to end and the simulator is involved. |
Agree. Moreover, now all the tests must be PASSED to execute
I added end if;
end loop;
vunit_lib.runner_pkg.p_disable_simulation_exit(runner_state);
test_runner_cleanup(runner);
assert false severity error;
wait;
end process;
end architecture; The other one, which is the proposed one, is to add option end if;
end loop;
test_runner_cleanup(runner, do_not_exit => true);
assert false severity error;
wait;
end process;
end architecture; I thought that this feature might be implemented already. Maybe through the Python API, instead of the VHDL package. However, I could not find it.
Additionally, I moved the added code to a function named |
f95a9da
to
ac2dd01
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The major things I want to change is that I think a unit test is enough and would like to avoid adding another acceptance test.
Also I think there are missing scenarios in the unit test. See my comments.
vunit/test/acceptance/artificial/vhdl/tb_same_sim_all_pass_nonzero.vhd
Outdated
Show resolved
Hide resolved
5854dbd
to
de3e867
Compare
I applied changes according to the comments above. Now, the following scenarios are tested:
For each of them, four different tests are executed:
I also added a commit where the style of the other tests is modified, just to reduce verbosity. Functionality is untouched. |
b604e9a
to
91e1de4
Compare
This reverts commit 1e5e630.
…iled skipped; passed failed; and passed failed skipped
91e1de4
to
afce667
Compare
afce667
to
bb8d093
Compare
I am hitting this issue while testing #476 with
Running test: lib.tb_external_buffer.test
Running 1 tests
Starting lib.tb_external_buffer.test
Output file: vunit_out/test_output/lib.tb_external_buffer.test_2f235d631488b2560e734c8488d8d48e8d0cd49e/output.txt
0: 11
1: 22
2: 33
3: 44
4: 55
5: 0
6: 0
7: 0
8: 0
9: 0
10: 0
11: 0
12: 0
13: 0
14: 0
0 fs - default - INFO - Init test
0 fs - default - INFO - End test
/src/vunit/vhdl/core/src/stop_body_93-2002.vhd:10:5:@0ms:(report failure): Stopping simulation with status 0
/src/examples/vhdl/external_buffer/vunit_out/test_output/lib.tb_external_buffer.test_2f235d631488b2560e734c8488d8d48e8d0cd49e/ghdl/tb_
external_buffer-tb:error: report failed
/src/examples/vhdl/external_buffer/vunit_out/test_output/lib.tb_external_buffer.test_2f235d631488b2560e734c8488d8d48e8d0cd49e/ghdl/tb_
external_buffer-tb:error: simulation failed
pass (P=1 S=0 F=0 T=1) lib.tb_external_buffer.test (0.4 seconds)
==== Summary =======================================
pass lib.tb_external_buffer.test (0.4 seconds)
====================================================
pass 1 of 1
====================================================
Total time was 0.4 seconds
Elapsed time was 0.4 seconds
====================================================
All passed!
EXCEPT
HELLO But, when the binary is loaded dynamically from Python through
0: 11
1: 22
2: 33
3: 44
4: 55
5: 127
6: 0
7: 0
8: 176
9: 255
10: 41
11: 1
12: 0
13: 0
14: 0
0 fs - default - INFO - Init test
0 fs - default - INFO - End test
/src/vunit/vhdl/core/src/stop_body_93-2002.vhd:10:5:@0ms:(report failure): Stopping simulation with status 0
/src/examples/vhdl/external_buffer/vunit_out/test_output/lib.tb_external_buffer.test_2f235d631488b2560e734c8488d8d48e8d0cd49e/ghdl/tb_
external_buffer-tb:error: report failed
SIGABRT caught!
Aborted
On the other hand, it should be possible to catch the abortion in the shared library and allow python to continue. When data is allocated from python, it should not be relevant how the simulation exited, because data will be written already. Alternatively, I should test if the abortion is produced because an executable binary is loaded dynamically; i.e., compiling the binary as a shared library explicitly might fix this (ghdl/ghdl#800). Note that none of this issues exist with |
Related to #465.
If a GHDL simulation is wrapped in a C application, when the simulation is successful but the application exists with a nonzero code, VUnit still reports the test as passed. This is because it ignores the return code and checks the output file instead.
This PR sets the status of a test to fail if the return code is nonzero.