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

Prevent Additional Error Count Increment in UNIT_TEST_END #31

Merged
merged 1 commit into from
Oct 3, 2024

Conversation

ping-ee
Copy link
Contributor

@ping-ee ping-ee commented Oct 2, 2024

Description

This PR aims to prevent the UNIT_TEST_END macro from calling ERROR, which caused an unintended increment of the error count when a unit test failed.

Additionally, this PR updates the message format displayed at the end of the unit test to match the format used at the start of the test for consistency.

Problem

The current UNIT_TEST_END macro calls ERROR macro to display an error message when a unit test fails. However,
the ERROR macro increments the svut_error counter. As a result, if a unit test has n assertion errors, it will display n+1 errors.

For example, if the ASSERT statement at example/ffd_testbench.sv:99 is made false, it will display

Error number:  2

instead of one due to the additional error increment caused by this issue.

image

Change

  1. Introduced the FAILURE macro, which prints a red message with a FAILURE: prefix and does not increment the error counter.
  2. Updated the test reporting logic to use the FAILURE macro instead of ERROR.
  3. Adjusted the message format displayed in UNIT_TEST_END to match the format used in UNIT_TEST().
  4. Updated test script for svut to match the updated error counter checks.

Result

The following picture shows the result after applying the changes. It displays the error count correctly, avoiding the extra increment.
image

Discussion

  1. I think svut_error count should only count the number of false assertions, but I'm not sure if this aligns with the original design intention.
  2. I'm uncertain if the introduction of the new message displaying macro FAILURE is the best approach. I decided to implement this to match the calling of the SUCCESS() macro when a unit test pass.

Please feel free to provide any feedback or alternative suggestions regarding this PR without any hesitation.

Best Regards

This commit change the usage of the `ERROR` macro in `UNIT_TEST_END`  to `FAILURE` macro macro to prevent incrementing of error count when test case fails.
@dpretet dpretet merged commit 76af301 into dpretet:master Oct 3, 2024
4 checks passed
@dpretet
Copy link
Owner

dpretet commented Oct 3, 2024

Thank you for this contribution, always a pleasure to see such pull request, clean and documented :)

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 this pull request may close these issues.

2 participants