tester: use new macros instead of CUnit ones to get better error logs

parent 5b3c46b0
......@@ -85,3 +85,6 @@ tester/linphone_log.gz.txt
tools/auto_answer
tools/lp-autoanswer
build/macos/pkg-distribution.xml
tester/record_for_lc_*.wav
tester/record-call_with_file_player.wav
......@@ -33,6 +33,7 @@ liblinphonetester_la_SOURCES = \
upnp_tester.c \
video_tester.c \
common/bc_tester_utils.c
liblinphonetester_ladir = $(includedir)/linphone
liblinphonetester_la_HEADERS = common/bc_tester_utils.h
......
This diff is collapsed.
......@@ -24,6 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <stdlib.h>
#include "CUnit/Basic.h"
#include "CUnit/Automated.h"
#if WINAPI_FAMILY_PHONE_APP
......
......@@ -20,9 +20,10 @@
#ifndef TESTER_UTILS_H
#define TESTER_UTILS_H
#include "CUnit/Basic.h"
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <math.h>
extern const char *bc_tester_read_dir_prefix;
extern const char *bc_tester_writable_dir_prefix;
......@@ -31,6 +32,8 @@ extern int bc_printf_verbosity_info;
extern int bc_printf_verbosity_error;
typedef void (*test_function_t)(void);
typedef int (*init_function_t)(void);
typedef int (*cleanup_function_t)(void);
typedef int (*test_suite_function_t)(const char *name);
typedef struct {
......@@ -40,8 +43,8 @@ typedef struct {
typedef struct {
const char *name;
CU_InitializeFunc init_func;
CU_CleanupFunc cleanup_func;
init_function_t init_func;
cleanup_function_t cleanup_func;
int nb_tests;
test_t *tests;
} test_suite_t;
......@@ -85,63 +88,62 @@ int bc_tester_suite_index(const char *suite_name);
*/
char * bc_tester_res(const char *name);
/*Redefine the CU_... macros WITHOUT final ';' semicolon, to allow IF conditions */
#define BC_ASSERT_EQUAL(actual, expected) CU_assertImplementation(((actual) == (expected)), __LINE__, ("CU_ASSERT_EQUAL(" #actual "," #expected ")"), __FILE__, "", CU_FALSE)
#define BC_PASS(msg) CU_assertImplementation(CU_TRUE, __LINE__, ("CU_PASS(" #msg ")"), __FILE__, "", CU_FALSE)
#define BC_ASSERT(value) CU_assertImplementation((value), __LINE__, #value, __FILE__, "", CU_FALSE)
#define BC_ASSERT_FATAL(value) CU_assertImplementation((value), __LINE__, #value, __FILE__, "", CU_TRUE)
#define BC_TEST(value) CU_assertImplementation((value), __LINE__, #value, __FILE__, "", CU_FALSE)
#define BC_TEST_FATAL(value) CU_assertImplementation((value), __LINE__, #value, __FILE__, "", CU_TRUE)
#define BC_ASSERT_TRUE(value) CU_assertImplementation((value), __LINE__, ("CU_ASSERT_TRUE(" #value ")"), __FILE__, "", CU_FALSE)
#define BC_ASSERT_TRUE_FATAL(value) CU_assertImplementation((value), __LINE__, ("CU_ASSERT_TRUE_FATAL(" #value ")"), __FILE__, "", CU_TRUE)
#define BC_ASSERT_FALSE(value) CU_assertImplementation(!(value), __LINE__, ("CU_ASSERT_FALSE(" #value ")"), __FILE__, "", CU_FALSE)
#define BC_ASSERT_FALSE_FATAL(value) CU_assertImplementation(!(value), __LINE__, ("CU_ASSERT_FALSE_FATAL(" #value ")"), __FILE__, "", CU_TRUE)
#define BC_ASSERT_EQUAL(actual, expected) CU_assertImplementation(((actual) == (expected)), __LINE__, ("CU_ASSERT_EQUAL(" #actual "," #expected ")"), __FILE__, "", CU_FALSE)
#define BC_ASSERT_EQUAL_FATAL(actual, expected) CU_assertImplementation(((actual) == (expected)), __LINE__, ("CU_ASSERT_EQUAL_FATAL(" #actual "," #expected ")"), __FILE__, "", CU_TRUE)
#define BC_ASSERT_NOT_EQUAL(actual, expected) CU_assertImplementation(((actual) != (expected)), __LINE__, ("CU_ASSERT_NOT_EQUAL(" #actual "," #expected ")"), __FILE__, "", CU_FALSE)
#define BC_ASSERT_NOT_EQUAL_FATAL(actual, expected) CU_assertImplementation(((actual) != (expected)), __LINE__, ("CU_ASSERT_NOT_EQUAL_FATAL(" #actual "," #expected ")"), __FILE__, "", CU_TRUE)
#define BC_ASSERT_PTR_EQUAL(actual, expected) CU_assertImplementation(((const void*)(actual) == (const void*)(expected)), __LINE__, ("CU_ASSERT_PTR_EQUAL(" #actual "," #expected ")"), __FILE__, "", CU_FALSE)
#define BC_ASSERT_PTR_EQUAL_FATAL(actual, expected) CU_assertImplementation(((const void*)(actual) == (const void*)(expected)), __LINE__, ("CU_ASSERT_PTR_EQUAL_FATAL(" #actual "," #expected ")"), __FILE__, "", CU_TRUE)
#define BC_ASSERT_PTR_NOT_EQUAL(actual, expected) CU_assertImplementation(((const void*)(actual) != (const void*)(expected)), __LINE__, ("CU_ASSERT_PTR_NOT_EQUAL(" #actual "," #expected ")"), __FILE__, "", CU_FALSE)
#define BC_ASSERT_PTR_NOT_EQUAL_FATAL(actual, expected) CU_assertImplementation(((const void*)(actual) != (const void*)(expected)), __LINE__, ("CU_ASSERT_PTR_NOT_EQUAL_FATAL(" #actual "," #expected ")"), __FILE__, "", CU_TRUE)
#define BC_ASSERT_PTR_NULL(value) CU_assertImplementation((NULL == (const void*)(value)), __LINE__, ("CU_ASSERT_PTR_NULL(" #value")"), __FILE__, "", CU_FALSE)
#define BC_ASSERT_PTR_NULL_FATAL(value) CU_assertImplementation((NULL == (const void*)(value)), __LINE__, ("CU_ASSERT_PTR_NULL_FATAL(" #value")"), __FILE__, "", CU_TRUE)
#define BC_ASSERT_PTR_NOT_NULL(value) CU_assertImplementation((NULL != (const void*)(value)), __LINE__, ("CU_ASSERT_PTR_NOT_NULL(" #value")"), __FILE__, "", CU_FALSE)
#define BC_ASSERT_PTR_NOT_NULL_FATAL(value) CU_assertImplementation((NULL != (const void*)(value)), __LINE__, ("CU_ASSERT_PTR_NOT_NULL_FATAL(" #value")"), __FILE__, "", CU_TRUE)
#define BC_ASSERT_STRING_EQUAL(actual, expected) CU_assertImplementation(!(strcmp((const char*)(actual), (const char*)(expected))), __LINE__, ("CU_ASSERT_STRING_EQUAL(" #actual "," #expected ")"), __FILE__, "", CU_FALSE)
#define BC_ASSERT_STRING_EQUAL_FATAL(actual, expected) CU_assertImplementation(!(strcmp((const char*)(actual), (const char*)(expected))), __LINE__, ("CU_ASSERT_STRING_EQUAL_FATAL(" #actual "," #expected ")"), __FILE__, "", CU_TRUE)
#define BC_ASSERT_STRING_NOT_EQUAL(actual, expected) CU_assertImplementation((strcmp((const char*)(actual), (const char*)(expected))), __LINE__, ("CU_ASSERT_STRING_NOT_EQUAL(" #actual "," #expected ")"), __FILE__, "", CU_FALSE)
#define BC_ASSERT_STRING_NOT_EQUAL_FATAL(actual, expected) CU_assertImplementation((strcmp((const char*)(actual), (const char*)(expected))), __LINE__, ("CU_ASSERT_STRING_NOT_EQUAL_FATAL(" #actual "," #expected ")"), __FILE__, "", CU_TRUE)
#define BC_ASSERT_NSTRING_EQUAL(actual, expected, count) CU_assertImplementation(!(strncmp((const char*)(actual), (const char*)(expected), (size_t)(count))), __LINE__, ("CU_ASSERT_NSTRING_EQUAL(" #actual "," #expected "," #count ")"), __FILE__, "", CU_FALSE)
#define BC_ASSERT_NSTRING_EQUAL_FATAL(actual, expected, count) CU_assertImplementation(!(strncmp((const char*)(actual), (const char*)(expected), (size_t)(count))), __LINE__, ("CU_ASSERT_NSTRING_EQUAL_FATAL(" #actual "," #expected "," #count ")"), __FILE__, "", CU_TRUE)
#define BC_ASSERT_NSTRING_NOT_EQUAL(actual, expected, count) CU_assertImplementation((strncmp((const char*)(actual), (const char*)(expected), (size_t)(count))), __LINE__, ("CU_ASSERT_NSTRING_NOT_EQUAL(" #actual "," #expected "," #count ")"), __FILE__, "", CU_FALSE)
#define BC_ASSERT_NSTRING_NOT_EQUAL_FATAL(actual, expected, count) CU_assertImplementation((strncmp((const char*)(actual), (const char*)(expected), (size_t)(count))), __LINE__, ("CU_ASSERT_NSTRING_NOT_EQUAL_FATAL(" #actual "," #expected "," #count ")"), __FILE__, "", CU_TRUE)
#define BC_ASSERT_DOUBLE_EQUAL(actual, expected, granularity) CU_assertImplementation(((fabs((double)(actual) - (expected)) <= fabs((double)(granularity)))), __LINE__, ("CU_ASSERT_DOUBLE_EQUAL(" #actual "," #expected "," #granularity ")"), __FILE__, "", CU_FALSE)
#define BC_ASSERT_DOUBLE_EQUAL_FATAL(actual, expected, granularity) CU_assertImplementation(((fabs((double)(actual) - (expected)) <= fabs((double)(granularity)))), __LINE__, ("CU_ASSERT_DOUBLE_EQUAL_FATAL(" #actual "," #expected "," #granularity ")"), __FILE__, "", CU_TRUE)
#define BC_ASSERT_DOUBLE_NOT_EQUAL(actual, expected, granularity) CU_assertImplementation(((fabs((double)(actual) - (expected)) > fabs((double)(granularity)))), __LINE__, ("CU_ASSERT_DOUBLE_NOT_EQUAL(" #actual "," #expected "," #granularity ")"), __FILE__, "", CU_FALSE)
#define BC_ASSERT_DOUBLE_NOT_EQUAL_FATAL(actual, expected, granularity) CU_assertImplementation(((fabs((double)(actual) - (expected)) > fabs((double)(granularity)))), __LINE__, ("CU_ASSERT_DOUBLE_NOT_EQUAL_FATAL(" #actual "," #expected "," #granularity ")"), __FILE__, "", CU_TRUE)
#define BC_ASSERT_GREATER(actual, expected) CU_assertImplementation(((actual) >= (expected)), __LINE__, ("CU_ASSERT_GREATER(" #actual "," #expected ")"), __FILE__, "", CU_FALSE)
#define BC_ASSERT_LOWER(actual, expected) CU_assertImplementation(((actual) <= (expected)), __LINE__, ("CU_ASSERT_LOWER(" #actual "," #expected ")"), __FILE__, "", CU_FALSE)
/*Add some custom defines with logs in case of fail*/
#define BC_ASSERT_EQUAL_WITH_TYPE(actual, expected, type, type_format) { \
type cactual = (actual), cexpected = (expected); \
if (! BC_ASSERT_EQUAL(cactual, cexpected)) { \
bc_tester_printf(bc_printf_verbosity_error, "%s:%d - Expected " #actual " = " #expected " but was " type_format " != " type_format "\n", __FILE__, __LINE__, cactual, cexpected); \
} \
}
#define BC_ASSERT_GREATER_WITH_TYPE(actual, expected, type, type_format) { \
type cactual = (actual), cexpected = (expected); \
if (! BC_ASSERT_GREATER(cactual, cexpected)) { \
bc_tester_printf(bc_printf_verbosity_error, "%s:%d - Expected " #actual " >= " #expected " but was " type_format " < " type_format "\n", __FILE__, __LINE__, cactual, cexpected); \
} \
}
#define BC_ASSERT_LOWER_WITH_TYPE(actual, expected, type, type_format) { \
type cactual = (actual), cexpected = (expected); \
if (! BC_ASSERT_LOWER(cactual, cexpected)) { \
bc_tester_printf(bc_printf_verbosity_error, "%s:%d - Expected " #actual " <= " #expected " but was " type_format " > " type_format "\n", __FILE__, __LINE__, cactual, cexpected); \
} \
}
/*Redefine the CU_... macros WITHOUT final ';' semicolon, to allow IF conditions and with smarter error message */
extern int CU_assertImplementation(int bValue,
unsigned int uiLine,
const char *strCondition,
const char *strFile,
const char *strFunction,
int bFatal);
#define _BC_ASSERT(pred, format, fatal) CU_assertImplementation(pred, __LINE__, format, __FILE__, "", fatal)
#define _BC_ASSERT_PRED(name, pred, actual, expected, type, fatal, ...) \
do { \
char format[4096] = {0}; \
type cactual = (actual); \
type cexpected = (expected); \
snprintf(format, 4096, name "(" #actual ", " #expected ") - " __VA_ARGS__); \
_BC_ASSERT(pred, format, fatal); \
} while (0)
#define BC_PASS(msg) _BC_ASSERT(TRUE, "BC_PASS(" #msg ").", FALSE)
#define BC_FAIL(msg) _BC_ASSERT(FALSE, "BC_FAIL(" #msg ").", FALSE)
#define BC_ASSERT(value) _BC_ASSERT((value), #value, FALSE)
#define BC_ASSERT_FATAL(value) _BC_ASSERT((value), #value, TRUE)
#define BC_TEST(value) _BC_ASSERT((value), #value, FALSE)
#define BC_TEST_FATAL(value) _BC_ASSERT((value), #value, TRUE)
#define BC_ASSERT_TRUE(value) _BC_ASSERT((value), ("BC_ASSERT_TRUE(" #value ")"), FALSE)
#define BC_ASSERT_TRUE_FATAL(value) _BC_ASSERT((value), ("BC_ASSERT_TRUE_FATAL(" #value ")"), TRUE)
#define BC_ASSERT_FALSE(value) _BC_ASSERT(!(value), ("BC_ASSERT_FALSE(" #value ")"), FALSE)
#define BC_ASSERT_FALSE_FATAL(value) _BC_ASSERT(!(value), ("BC_ASSERT_FALSE_FATAL(" #value ")"), TRUE)
#define BC_ASSERT_EQUAL(actual, expected, type, type_format) _BC_ASSERT_PRED("BC_ASSERT_EQUAL", ((cactual) == (cexpected)), actual, expected, type, FALSE, "Expected " type_format " but was " type_format ".", cexpected, cactual)
#define BC_ASSERT_EQUAL_FATAL(actual, expected, type, type_format) _BC_ASSERT_PRED("BC_ASSERT_EQUAL_FATAL", ((cactual) == (cexpected)), actual, expected, type, TRUE, "Expected " type_format " but was " type_format ".", cexpected, cactual)
#define BC_ASSERT_NOT_EQUAL(actual, expected, type, type_format) _BC_ASSERT_PRED("BC_ASSERT_NOT_EQUAL", ((cactual) != (cexpected)), actual, expected, type, FALSE, "Expected NOT " type_format " but it was.", cexpected)
#define BC_ASSERT_NOT_EQUAL_FATAL(actual, expected, type, type_format) _BC_ASSERT_PRED("BC_ASSERT_NOT_EQUAL_FATAL", ((cactual) != (cexpected)), actual, expected, type, TRUE, "Expected NOT " type_format " but it was.", cexpected)
#define BC_ASSERT_PTR_EQUAL(actual, expected) _BC_ASSERT_PRED("BC_ASSERT_PTR_EQUAL", ((cactual) == (cexpected)), (const void*)(actual), (const void*)(expected), const void*, FALSE, "Expected %p but was %p.", cexpected, cactual)
#define BC_ASSERT_PTR_EQUAL_FATAL(actual, expected) _BC_ASSERT_PRED("BC_ASSERT_PTR_EQUAL_FATAL", ((cactual) == (cexpected)), (const void*)(actual), (const void*)(expected), const void*, TRUE, "Expected %p but was %p.", cexpected, cactual)
#define BC_ASSERT_PTR_NOT_EQUAL(actual, expected) _BC_ASSERT_PRED("BC_ASSERT_PTR_NOT_EQUAL", ((cactual) != (cexpected)), (const void*)(actual), (const void*)(expected), const void*, FALSE, "Expected NOT %p but it was.", cexpected)
#define BC_ASSERT_PTR_NOT_EQUAL_FATAL(actual, expected) _BC_ASSERT_PRED("BC_ASSERT_PTR_NOT_EQUAL_FATAL", ((cactual) != (cexpected)), (const void*)(actual), (const void*)(expected), const void*, TRUE, "Expected NOT %p but it was.", cexpected)
#define BC_ASSERT_PTR_NULL(value) _BC_ASSERT_PRED("BC_ASSERT_PTR_NULL", ((cactual) == (cexpected)), (const void*)(value), (const void*)NULL, const void*, FALSE, "Expected NULL but was %p.", cactual)
#define BC_ASSERT_PTR_NULL_FATAL(value) _BC_ASSERT_PRED("BC_ASSERT_PTR_NULL_FATAL", ((cactual) == (cexpected)), (const void*)(value), (const void*)NULL, const void*, TRUE, "Expected NULL but was %p.", cactual)
#define BC_ASSERT_PTR_NOT_NULL(value) _BC_ASSERT_PRED("BC_ASSERT_PTR_NOT_NULL", ((cactual) != (cexpected)), (const void*)(value), (const void*)NULL, const void*, FALSE, "Expected NOT NULL but it was.")
#define BC_ASSERT_PTR_NOT_NULL_FATAL(value) _BC_ASSERT_PRED("BC_ASSERT_PTR_NOT_NULL_FATAL", ((cactual) != (cexpected)), (const void*)(value), (const void*)NULL, const void*, TRUE, "Expected NOT NULL but it was.")
#define BC_ASSERT_STRING_EQUAL(actual, expected) _BC_ASSERT_PRED("BC_ASSERT_STRING_EQUAL", !(strcmp((const char*)(cactual), (const char*)(cexpected))), actual, expected, const char*, FALSE, "Expected %s but was %s.", cexpected, cactual)
#define BC_ASSERT_STRING_EQUAL_FATAL(actual, expected) _BC_ASSERT_PRED("BC_ASSERT_STRING_EQUAL_FATAL", !(strcmp((const char*)(cactual), (const char*)(cexpected))), actual, expected, const char*, TRUE, "Expected %s but was %s.", cexpected, cactual)
#define BC_ASSERT_STRING_NOT_EQUAL(actual, expected) _BC_ASSERT_PRED("BC_ASSERT_STRING_NOT_EQUAL", (strcmp((const char*)(cactual), (const char*)(cexpected))), actual, expected, const char*, FALSE, "Expected NOT %s but it was.", cexpected)
#define BC_ASSERT_STRING_NOT_EQUAL_FATAL(actual, expected) _BC_ASSERT_PRED("BC_ASSERT_STRING_NOT_EQUAL_FATAL", (strcmp((const char*)(cactual), (const char*)(cexpected))), actual, expected, const char*, TRUE, "Expected NOT %s but it was.", cexpected)
#define BC_ASSERT_NSTRING_EQUAL(actual, expected, count) _BC_ASSERT_PRED("BC_ASSERT_NSTRING_EQUAL", !(strncmp((const char*)(cactual), (const char*)(cexpected), (size_t)(count))), actual, expected, const char*, FALSE, "Expected %*s but was %*s.", (int)(count), cexpected, (int)(count), cactual)
#define BC_ASSERT_NSTRING_EQUAL_FATAL(actual, expected, count) _BC_ASSERT_PRED("BC_ASSERT_NSTRING_EQUAL_FATAL", !(strncmp((const char*)(cactual), (const char*)(cexpected), (size_t)(count))), actual, expected, const char*, TRUE, "Expected %*s but was %*s.", (int)count, cexpected, (int)count, cactual)
#define BC_ASSERT_NSTRING_NOT_EQUAL(actual, expected, count) _BC_ASSERT_PRED("BC_ASSERT_NSTRING_NOT_EQUAL", (strncmp((const char*)(cactual), (const char*)(cexpected), (size_t)(count))), actual, expected, const char*, FALSE, "Expected %*s but it was.", (int)count, cexpected)
#define BC_ASSERT_NSTRING_NOT_EQUAL_FATAL(actual, expected, count) _BC_ASSERT_PRED("BC_ASSERT_NSTRING_NOT_EQUAL_FATAL", (strncmp((const char*)(cactual), (const char*)(cexpected), (size_t)(count))), actual, expected, const char*, TRUE, "Expected %*s but it was.", (int)count, cexpected)
#define BC_ASSERT_DOUBLE_EQUAL(actual, expected, granularity) _BC_ASSERT_PRED("BC_ASSERT_DOUBLE_EQUAL", ((fabs((double)(cactual) - (cexpected)) <= fabs((double)(granularity)))), actual, expected, double, FALSE, "Expected %f but was %f.", cexpected, cactual)
#define BC_ASSERT_DOUBLE_EQUAL_FATAL(actual, expected, granularity) _BC_ASSERT_PRED("BC_ASSERT_DOUBLE_EQUAL_FATAL", ((fabs((double)(cactual) - (cexpected)) <= fabs((double)(granularity)))), actual, expected, double, TRUE, "Expected %f but was %f.", cexpected, cactual)
#define BC_ASSERT_DOUBLE_NOT_EQUAL(actual, expected, granularity) _BC_ASSERT_PRED("BC_ASSERT_DOUBLE_NOT_EQUAL", ((fabs((double)(cactual) - (cexpected)) > fabs((double)(granularity)))), actual, expected, double, FALSE, "Expected %f but was %f.", cexpected, cactual)
#define BC_ASSERT_DOUBLE_NOT_EQUAL_FATAL(actual, expected, granularity) _BC_ASSERT_PRED("BC_ASSERT_DOUBLE_NOT_EQUAL_FATAL", ((fabs((double)(cactual) - (cexpected)) > fabs((double)(granularity)))), actual, expected, double, TRUE, "Expected %f but was %f.", cexpected, cactual)
/*Custom defines*/
#define BC_ASSERT_GREATER(actual, lower, type, type_format) _BC_ASSERT_PRED("BC_ASSERT_GREATER", ((cactual) >= (cexpected)), actual, lower, type, FALSE, "Expected " type_format " but was " type_format ".", cexpected, cactual)
#define BC_ASSERT_LOWER(actual, lower, type, type_format) _BC_ASSERT_PRED("BC_ASSERT_LOWER", ((cactual) <= (cexpected)), actual, lower, type, FALSE, "Expected " type_format " but was " type_format ".", cexpected, cactual)
#ifdef __cplusplus
}
......
......@@ -43,12 +43,12 @@ void send_dtmf_base(bool_t use_rfc2833, bool_t use_sipinfo, char dtmf, char* dtm
linphone_core_set_use_rfc2833_for_dtmf(pauline->lc, use_rfc2833);
linphone_core_set_use_info_for_dtmf(pauline->lc, use_sipinfo);
CU_ASSERT_TRUE(call(pauline,marie));
BC_ASSERT_TRUE(call(pauline,marie));
marie_call = linphone_core_get_current_call(marie->lc);
CU_ASSERT_PTR_NOT_NULL(marie_call);
BC_ASSERT_PTR_NOT_NULL(marie_call);
if (!marie_call) return;
if (dtmf != '\0') {
......@@ -56,7 +56,7 @@ void send_dtmf_base(bool_t use_rfc2833, bool_t use_sipinfo, char dtmf, char* dtm
linphone_call_send_dtmf(marie_call, dtmf);
/*wait for the DTMF to be received from pauline*/
CU_ASSERT_TRUE(wait_for_until(marie->lc, pauline->lc, &pauline->stat.dtmf_count, dtmf_count_prev+1, 10000));
BC_ASSERT_TRUE(wait_for_until(marie->lc, pauline->lc, &pauline->stat.dtmf_count, dtmf_count_prev+1, 10000));
expected = ms_strdup_printf("%c", dtmf);
}
......@@ -66,29 +66,29 @@ void send_dtmf_base(bool_t use_rfc2833, bool_t use_sipinfo, char dtmf, char* dtm
linphone_call_send_dtmfs(marie_call, dtmf_seq);
/*wait for the DTMF sequence to be received from pauline*/
CU_ASSERT_TRUE(wait_for_until(marie->lc, pauline->lc, &pauline->stat.dtmf_count, dtmf_count_prev + strlen(dtmf_seq), 10000 + dtmf_delay_ms * strlen(dtmf_seq)));
BC_ASSERT_TRUE(wait_for_until(marie->lc, pauline->lc, &pauline->stat.dtmf_count, dtmf_count_prev + strlen(dtmf_seq), 10000 + dtmf_delay_ms * strlen(dtmf_seq)));
expected = (dtmf!='\0')?ms_strdup_printf("%c%s",dtmf,dtmf_seq):ms_strdup(dtmf_seq);
}
if (expected != NULL) {
CU_ASSERT_PTR_NOT_NULL(pauline->stat.dtmf_list_received);
BC_ASSERT_PTR_NOT_NULL(pauline->stat.dtmf_list_received);
if (pauline->stat.dtmf_list_received) {
CU_ASSERT_STRING_EQUAL(pauline->stat.dtmf_list_received, expected);
BC_ASSERT_STRING_EQUAL(pauline->stat.dtmf_list_received, expected);
}
ms_free(expected);
} else {
CU_ASSERT_PTR_NULL(pauline->stat.dtmf_list_received);
BC_ASSERT_PTR_NULL(pauline->stat.dtmf_list_received);
}
}
void send_dtmf_cleanup() {
CU_ASSERT_PTR_NULL(marie_call->dtmfs_timer);
CU_ASSERT_PTR_NULL(marie_call->dtmf_sequence);
BC_ASSERT_PTR_NULL(marie_call->dtmfs_timer);
BC_ASSERT_PTR_NULL(marie_call->dtmf_sequence);
/*just to sleep*/
linphone_core_terminate_all_calls(pauline->lc);
CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallEnd,1));
CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallEnd,1));
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallEnd,1));
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallEnd,1));
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
......@@ -116,7 +116,7 @@ static void send_dtmfs_sequence_sip_info() {
static void send_dtmfs_sequence_not_ready() {
marie = linphone_core_manager_new( "marie_rc");
CU_ASSERT_EQUAL(linphone_call_send_dtmfs(linphone_core_get_current_call(marie->lc), "123"), -1);
BC_ASSERT_EQUAL(linphone_call_send_dtmfs(linphone_core_get_current_call(marie->lc), "123"), -1, int, "%d");
linphone_core_manager_destroy(marie);
}
......@@ -127,13 +127,13 @@ static void send_dtmfs_sequence_call_state_changed() {
linphone_call_send_dtmfs(marie_call, "123456789123456789");
/*just after, change call state, and expect DTMF to be canceled*/
linphone_core_pause_call(marie_call->core,marie_call);
CU_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallPausing,1));
CU_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallPaused,1));
BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallPausing,1));
BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallPaused,1));
/*wait a few time to ensure that no DTMF are received*/
wait_for_until(marie->lc, pauline->lc, NULL, 0, 1000);
CU_ASSERT_PTR_NULL(pauline->stat.dtmf_list_received);
BC_ASSERT_PTR_NULL(pauline->stat.dtmf_list_received);
send_dtmf_cleanup();
}
......
......@@ -17,8 +17,7 @@
*/
#include <stdio.h>
#include "CUnit/Basic.h"
#include "linphonecore.h"
#include "private.h"
#include "lpconfig.h"
......@@ -39,8 +38,8 @@ const char *liblinphone_tester_get_notify_content(void){
void linphone_notify_received(LinphoneCore *lc, LinphoneEvent *lev, const char *eventname, const LinphoneContent *content){
LinphoneCoreManager *mgr;
CU_ASSERT_PTR_NOT_NULL_FATAL(content);
CU_ASSERT_TRUE(strcmp(notify_content,(const char*)linphone_content_get_buffer(content))==0);
BC_ASSERT_PTR_NOT_NULL_FATAL(content);
BC_ASSERT_TRUE(strcmp(notify_content,(const char*)linphone_content_get_buffer(content))==0);
mgr=get_manager(lc);
mgr->stat.number_of_NotifyReceived++;
}
......@@ -55,7 +54,7 @@ void linphone_subscription_state_change(LinphoneCore *lc, LinphoneEvent *lev, Li
linphone_content_set_type(content,"application");
linphone_content_set_subtype(content,"somexml2");
linphone_content_set_buffer(content,notify_content,strlen(notify_content));
ms_message("Subscription state [%s] from [%s]",linphone_subscription_state_to_string(state),from);
ms_free(from);
......@@ -107,10 +106,10 @@ void linphone_publish_state_changed(LinphoneCore *lc, LinphoneEvent *ev, Linphon
ms_free(from);
switch(state){
case LinphonePublishProgress: counters->number_of_LinphonePublishProgress++; break;
case LinphonePublishOk:
case LinphonePublishOk:
/*make sure custom header access API is working*/
CU_ASSERT_PTR_NOT_NULL(linphone_event_get_custom_header(ev,"From"));
counters->number_of_LinphonePublishOk++;
BC_ASSERT_PTR_NOT_NULL(linphone_event_get_custom_header(ev,"From"));
counters->number_of_LinphonePublishOk++;
break;
case LinphonePublishError: counters->number_of_LinphonePublishError++; break;
case LinphonePublishExpiring: counters->number_of_LinphonePublishExpiring++; break;
......@@ -118,7 +117,7 @@ void linphone_publish_state_changed(LinphoneCore *lc, LinphoneEvent *ev, Linphon
default:
break;
}
}
static void subscribe_test_declined(void) {
......@@ -140,16 +139,16 @@ static void subscribe_test_declined(void) {
lev=linphone_core_subscribe(marie->lc,pauline->identity,"dodo",600,content);
linphone_event_ref(lev);
CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionOutgoingInit,1,1000));
CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneSubscriptionIncomingReceived,1,3000));
CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionError,1,21000));/*yes flexisip may wait 20 secs in case of forking*/
BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionOutgoingInit,1,1000));
BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneSubscriptionIncomingReceived,1,3000));
BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionError,1,21000));/*yes flexisip may wait 20 secs in case of forking*/
ei=linphone_event_get_error_info(lev);
CU_ASSERT_PTR_NOT_NULL(ei);
BC_ASSERT_PTR_NOT_NULL(ei);
if (ei){
CU_ASSERT_EQUAL(linphone_error_info_get_protocol_code(ei),603);
CU_ASSERT_PTR_NOT_NULL(linphone_error_info_get_phrase(ei));
BC_ASSERT_EQUAL(linphone_error_info_get_protocol_code(ei),603, int, "%d");
BC_ASSERT_PTR_NOT_NULL(linphone_error_info_get_phrase(ei));
}
CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneSubscriptionTerminated,1,1000));
BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneSubscriptionTerminated,1,1000));
linphone_content_unref(content);
linphone_event_unref(lev);
......@@ -183,33 +182,33 @@ static void subscribe_test_with_args(bool_t terminated_by_subscriber, RefreshTes
linphone_content_set_buffer(content,subscribe_content,strlen(subscribe_content));
lev=linphone_core_subscribe(marie->lc,pauline->identity,"dodo",expires,content);
CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionOutgoingInit,1,1000));
CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneSubscriptionIncomingReceived,1,3000));
CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionActive,1,3000));
CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneSubscriptionActive,1,1000));
BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionOutgoingInit,1,1000));
BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneSubscriptionIncomingReceived,1,3000));
BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionActive,1,3000));
BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneSubscriptionActive,1,1000));
/*make sure marie receives first notification before terminating*/
CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_NotifyReceived,1,1000));
BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_NotifyReceived,1,1000));
if (refresh_type==AutoRefresh){
wait_for_list(lcs,NULL,0,6000);
CU_ASSERT_TRUE(linphone_event_get_subscription_state(pauline->lev)==LinphoneSubscriptionActive);
BC_ASSERT_TRUE(linphone_event_get_subscription_state(pauline->lev)==LinphoneSubscriptionActive);
}else if (refresh_type==ManualRefresh){
CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionExpiring,1,4000));
BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionExpiring,1,4000));
linphone_event_update_subscribe(lev,NULL);
CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionActive,2,2000));
BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionActive,2,2000));
}
if (terminated_by_subscriber){
linphone_event_terminate(lev);
}else{
CU_ASSERT_PTR_NOT_NULL_FATAL(pauline->lev);
BC_ASSERT_PTR_NOT_NULL_FATAL(pauline->lev);
linphone_event_terminate(pauline->lev);
}
CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionTerminated,1,1000));
CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneSubscriptionTerminated,1,1000));
BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionTerminated,1,1000));
BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneSubscriptionTerminated,1,1000));
linphone_content_unref(content);
linphone_core_manager_destroy(marie);
......@@ -223,7 +222,7 @@ static void subscribe_test_with_args2(bool_t terminated_by_subscriber, RefreshTe
LinphoneEvent *lev;
int expires= refresh_type!=NoRefresh ? 4 : 600;
MSList* lcs=ms_list_append(NULL,marie->lc);
lcs=ms_list_append(lcs,pauline->lc);
if (refresh_type==ManualRefresh){
......@@ -240,37 +239,37 @@ static void subscribe_test_with_args2(bool_t terminated_by_subscriber, RefreshTe
linphone_event_add_custom_header(lev,"My-Header2","pimpon");
linphone_event_send_subscribe(lev,content);
CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionOutgoingInit,1,1000));
CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneSubscriptionIncomingReceived,1,3000));
BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionOutgoingInit,1,1000));
BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneSubscriptionIncomingReceived,1,3000));
/*check good receipt of custom headers*/
CU_ASSERT_STRING_EQUAL(linphone_event_get_custom_header(pauline->lev,"My-Header"),"pouet");
CU_ASSERT_STRING_EQUAL(linphone_event_get_custom_header(pauline->lev,"My-Header2"),"pimpon");
CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionActive,1,5000));
CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneSubscriptionActive,1,5000));
BC_ASSERT_STRING_EQUAL(linphone_event_get_custom_header(pauline->lev,"My-Header"),"pouet");
BC_ASSERT_STRING_EQUAL(linphone_event_get_custom_header(pauline->lev,"My-Header2"),"pimpon");
BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionActive,1,5000));
BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneSubscriptionActive,1,5000));
/*make sure marie receives first notification before terminating*/
CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_NotifyReceived,1,5000));
BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_NotifyReceived,1,5000));
if (refresh_type==AutoRefresh){
wait_for_list(lcs,NULL,0,6000);
CU_ASSERT_TRUE(linphone_event_get_subscription_state(pauline->lev)==LinphoneSubscriptionActive);
BC_ASSERT_TRUE(linphone_event_get_subscription_state(pauline->lev)==LinphoneSubscriptionActive);
}else if (refresh_type==ManualRefresh){
CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionExpiring,1,4000));
BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionExpiring,1,4000));
linphone_event_update_subscribe(lev,NULL);
CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionActive,2,5000));
BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionActive,2,5000));
}
if (terminated_by_subscriber){
linphone_event_terminate(lev);
}else{
CU_ASSERT_PTR_NOT_NULL_FATAL(pauline->lev);
BC_ASSERT_PTR_NOT_NULL_FATAL(pauline->lev);
linphone_event_terminate(pauline->lev);
}
CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionTerminated,1,5000));
CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneSubscriptionTerminated,1,5000));
BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionTerminated,1,5000));
BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneSubscriptionTerminated,1,5000));
linphone_content_unref(content);
linphone_core_manager_destroy(marie);
......@@ -285,7 +284,7 @@ static void subscribe_test_terminated_by_notifier(void){
subscribe_test_with_args(FALSE,NoRefresh);
}
/* Caution: this test does not really check that the subscribe are refreshed, because the core is not managing the expiration of
/* Caution: this test does not really check that the subscribe are refreshed, because the core is not managing the expiration of
* unrefreshed subscribe dialogs. So it is just checking that it is not crashing.
*/
static void subscribe_test_refreshed(void){
......@@ -320,21 +319,21 @@ static void publish_test_with_args(bool_t refresh, int expires){
linphone_event_send_publish(lev,content);
linphone_event_ref(lev);
CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphonePublishProgress,1,1000));
CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphonePublishOk,1,3000));
BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphonePublishProgress,1,1000));
BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphonePublishOk,1,3000));
if (!refresh){
CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphonePublishExpiring,1,5000));
BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphonePublishExpiring,1,5000));
linphone_event_update_publish(lev,content);
CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphonePublishProgress,1,1000));
CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphonePublishOk,1,3000));
BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphonePublishProgress,1,1000));
BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphonePublishOk,1,3000));
}else{
}
linphone_event_terminate(lev);
CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphonePublishCleared,1,3000));
BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphonePublishCleared,1,3000));
linphone_event_unref(lev);
......
This diff is collapsed.
......@@ -16,8 +16,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include "CUnit/Basic.h"
#include "linphonecore.h"
#include "private.h"
#include "liblinphone_tester.h"
......@@ -28,7 +27,6 @@
#include <gtk/gtk.h>
#endif
static FILE * log_file = NULL;
#ifdef ANDROID
......
......@@ -136,7 +136,7 @@ static FILE* gzuncompress(const char* filepath) {
memset(buffer, 0, strlen(buffer));
}
fclose(output);
CU_ASSERT_EQUAL(gzclose(file), Z_OK);
BC_ASSERT_EQUAL(gzclose(file), Z_OK, int, "%d");
ret=fopen(newname, "rb");
ms_free(newname);
return ret;
......@@ -169,7 +169,7 @@ static time_t check_file(LinphoneCoreManager* mgr) {
uint32_t timediff = 0;
FILE *file = NULL;
CU_ASSERT_PTR_NOT_NULL(filepath);
BC_ASSERT_PTR_NOT_NULL(filepath);
if (filepath != NULL) {
int line_count = 0;
......@@ -186,10 +186,10 @@ static time_t check_file(LinphoneCoreManager* mgr) {
#else
file = fopen(filepath, "rb");
#endif
CU_ASSERT_PTR_NOT_NULL(file);
BC_ASSERT_PTR_NOT_NULL(file);
if (!file) return 0;
// 1) expect to find folder name in filename path
CU_ASSERT_PTR_NOT_NULL(strstr(filepath, bc_tester_writable_dir_prefix));
BC_ASSERT_PTR_NOT_NULL(strstr(filepath, bc_tester_writable_dir_prefix));
// 2) check file contents
while (getline(&line, &line_size, file) != -1) {
......@@ -205,13 +205,13 @@ static time_t check_file(LinphoneCoreManager* mgr) {
if (strptime(date, "%Y-%m-%d %H:%M:%S", &tm_curr) != NULL) {
tm_curr.tm_isdst = -1; // LOL
log_time = mktime(&tm_curr);
CU_ASSERT_TRUE(log_time >= time_prev);
BC_ASSERT_TRUE(log_time >= time_prev);
time_prev = log_time;
}
}
#endif
}
CU_ASSERT_TRUE(line_count > 25);
BC_ASSERT_TRUE(line_count > 25);
free(line);
fclose(file);
ms_free(filepath);
......@@ -220,7 +220,7 @@ static time_t check_file(LinphoneCoreManager* mgr) {
timediff = labs((long int)log_time - (long int)cur_time);
(void)timediff;
#ifndef WIN32
CU_ASSERT_TRUE( timediff <= 1 );
BC_ASSERT_TRUE( timediff <= 1 );
if( !(timediff <= 1) ){
char buffers[2][128] = {{0}};
strftime(buffers[0], sizeof(buffers[0]), "%Y-%m-%d %H:%M:%S", localtime(&log_time));
......@@ -242,7 +242,7 @@ static time_t check_file(LinphoneCoreManager* mgr) {
static void collect_files_disabled() {
LinphoneCoreManager* marie = setup(FALSE);
CU_ASSERT_PTR_NULL(linphone_core_compress_log_collection(marie->lc));
BC_ASSERT_PTR_NULL(linphone_core_compress_log_collection(marie->lc));
collect_cleanup(marie);
}
......@@ -282,7 +282,7 @@ static void logCollectionUploadStateChangedCb(LinphoneCore *lc, LinphoneCoreLogC
break;
case LinphoneCoreLogCollectionUploadStateDelivered:
counters->number_of_LinphoneCoreLogCollectionUploadStateDelivered++;
CU_ASSERT_TRUE(strlen(info)>0)
BC_ASSERT_GREATER(strlen(info), 0, int, "%d");
break;
case LinphoneCoreLogCollectionUploadStateNotDelivered:
counters->number_of_LinphoneCoreLogCollectionUploadStateNotDelivered++;
......@@ -302,7 +302,7 @@ static void upload_collected_traces() {
while (--waiting) ms_error("(test error)Waiting %d...", waiting);
linphone_core_compress_log_collection(marie->lc);
linphone_core_upload_log_collection(marie->lc);
CU_ASSERT_TRUE(wait_for(marie->lc,marie->lc,&marie->stat.number_of_LinphoneCoreLogCollectionUploadStateDelivered,1));
BC_ASSERT_TRUE(wait_for(marie->lc,marie->lc,&marie->stat.number_of_LinphoneCoreLogCollectionUploadStateDelivered,1));
/*try 2 times*/
waiting=100;
......@@ -310,7 +310,7 @@ static void upload_collected_traces() {
while (--waiting) ms_error("(test error)Waiting %d...", waiting);
linphone_core_compress_log_collection(marie->lc);
linphone_core_upload_log_collection(marie->lc);
CU_ASSERT_TRUE(wait_for(marie->lc,marie->lc,&marie->stat.number_of_LinphoneCoreLogCollectionUploadStateDelivered,2));
BC_ASSERT_TRUE(wait_for(marie->lc,marie->lc,&marie->stat.number_of_LinphoneCoreLogCollectionUploadStateDelivered,2));
collect_cleanup(marie);
}
......