Skip to content

Commit

Permalink
Add FAILURE Macro to Prevent Error Count Increment in UNIT_TEST_END
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ping-ee committed Oct 2, 2024
1 parent 37bd8c7 commit df8b76f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
13 changes: 10 additions & 3 deletions svut/svut_h.sv
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@
svut_critical += 1;\
end

/// This macro will not increment the error counter while displaying a failure
/// message.
`define FAILURE(msg) \
begin\
$display("\033[1;31mFAILURE: %s (@ %0t) (%s:%0d)\033[0m", msg, $realtime, `__FILE__, `__LINE__);\
end

`define ERROR(msg)\
begin\
$display("\033[1;31mERROR: %s (@ %0t) (%s:%0d)\033[0m", msg, $realtime, `__FILE__, `__LINE__);\
Expand Down Expand Up @@ -187,11 +194,11 @@ endfunction
teardown(); \
if (svut_error == 0) begin \
svut_nb_test_success = svut_nb_test_success + 1; \
svut_msg = {"Test ", testnum, " pass"}; \
svut_msg = {"<< ", "Test ", testnum, ": ", svut_test_name, " >>", " pass"}; \
`SUCCESS(svut_msg); \
end else begin \
svut_msg = {"Test ", testnum, " fail"}; \
`ERROR(svut_msg); \
svut_msg = {"<< ", "Test ", testnum, ": ", svut_test_name, " >>", " fail"}; \
`FAILURE(svut_msg); \
svut_fail_list = {svut_fail_list, " '", svut_test_name, "'"}; \
svut_error_total += svut_error; \
end \
Expand Down
1 change: 1 addition & 0 deletions svut/template.sv
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ ${module_inst}
// - `SUCCESS("message"): Print a green message if SUCCESS: prefix
// - `WARNING("message"): Print an orange message with WARNING: prefix and increment warning counter
// - `CRITICAL("message"): Print a purple message with CRITICAL: prefix and increment critical counter
// - `FAILURE("message"): Print a red message with FAILURE: prefix and do **not** increment error counter
// - `ERROR("message"): Print a red message with ERROR: prefix and increment error counter
//
// - `FAIL_IF(aSignal): Increment error counter if evaluaton is true
Expand Down
2 changes: 1 addition & 1 deletion test/testsuite_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ test_run_ko_testsuite() { #@test
test_run_ko_testsuite_error_count() { #@test

run exe_ko_to_log
error_num=10
error_num=8
[ $(grep -c "ERROR:" log) -eq "$error_num" ]
}

Expand Down

0 comments on commit df8b76f

Please sign in to comment.