From 451900b3532d94aa62c5eed6e9acca99316a8244 Mon Sep 17 00:00:00 2001 From: Chris Rienzo Date: Sun, 17 Jan 2021 14:41:10 -0500 Subject: [PATCH] [Unit-tests] Report test failure details as they happen. Fix issue where fst_xcheck definition did not allow its use inside conditional statements. --- src/include/test/switch_fct.h | 4 ++++ src/include/test/switch_test.h | 8 ++++---- tests/unit/switch_rtp.c | 6 +++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/include/test/switch_fct.h b/src/include/test/switch_fct.h index f88821b49c..8cb07cc20f 100644 --- a/src/include/test/switch_fct.h +++ b/src/include/test/switch_fct.h @@ -2858,6 +2858,10 @@ fct_standard_logger__on_chk( /* Only record failures. */ if ( !fctchk__is_pass(e->chk) ) { + printf("\nTEST FAIL: %s(%d): %s\n", + fctchk__file(e->chk), + fctchk__lineno(e->chk), + fctchk__msg(e->chk)); fct_logger_record_failure(e->chk, &(logger->failed_cndtns_list)); } } diff --git a/src/include/test/switch_test.h b/src/include/test/switch_test.h index 7839a6c736..db5f4f7a7d 100644 --- a/src/include/test/switch_test.h +++ b/src/include/test/switch_test.h @@ -203,13 +203,13 @@ static switch_status_t fst_init_core_and_modload(const char *confdir, const char * Check a test /w error message */ #define fst_xcheck(expr, error_msg) \ - fct_xchk(expr, "%s", error_msg); + (fct_xchk(expr, "%s", error_msg)) /** * Fail a test */ #define fst_fail(error_msg) \ - fct_xchk(0, "%s", error_msg); + (fct_xchk(0, "%s", error_msg)) /** * Check duration relative to test start, last marked time, or last check. @@ -236,7 +236,7 @@ static switch_status_t fst_init_core_and_modload(const char *confdir, const char (actual), \ (expected), \ (precision) \ - ); + ) /** * Check if double-precision number is in range @@ -248,7 +248,7 @@ static switch_status_t fst_init_core_and_modload(const char *confdir, const char (actual), \ (expected), \ (precision) \ - ); + ) /** * Run test without loading FS core diff --git a/tests/unit/switch_rtp.c b/tests/unit/switch_rtp.c index 35de9d8630..ebe307ad29 100644 --- a/tests/unit/switch_rtp.c +++ b/tests/unit/switch_rtp.c @@ -63,7 +63,7 @@ FST_TEARDOWN_END() fst_requires(switch_rtp_ready(rtp_session)); switch_rtp_activate_rtcp(rtp_session, 5, rx_port + 1, 0); switch_rtp_set_default_payload(rtp_session, TEST_PT); - fst_xcheck(switch_rtp_get_default_payload(rtp_session) == TEST_PT, "get Payload Type") + fst_xcheck(switch_rtp_get_default_payload(rtp_session) == TEST_PT, "get Payload Type"); switch_rtp_set_ssrc(rtp_session, 0xabcd); switch_rtp_set_remote_ssrc(rtp_session, 0xcdef); fst_xcheck(switch_rtp_get_ssrc(rtp_session) == 0xabcd, "get SSRC"); @@ -105,9 +105,9 @@ FST_TEARDOWN_END() session = switch_rtp_get_core_session(rtp_session); fst_requires(session); status = switch_rtp_activate_jitter_buffer(rtp_session, 1, 10, 80, 8000); - fst_xcheck(status == SWITCH_STATUS_SUCCESS, "switch_rtp_activate_jitter_buffer()") + fst_xcheck(status == SWITCH_STATUS_SUCCESS, "switch_rtp_activate_jitter_buffer()"); status = switch_rtp_debug_jitter_buffer(rtp_session, "debug"); - fst_xcheck(status == SWITCH_STATUS_SUCCESS, "switch_rtp_debug_jitter_buffer()") + fst_xcheck(status == SWITCH_STATUS_SUCCESS, "switch_rtp_debug_jitter_buffer()"); fst_requires(switch_rtp_get_jitter_buffer(rtp_session)); status = switch_rtp_pause_jitter_buffer(rtp_session, SWITCH_TRUE); fst_xcheck(status == SWITCH_STATUS_SUCCESS, "switch_rtp_pause_jitter_buffer()");