Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
liblinphone
Commits
2fced27f
Commit
2fced27f
authored
May 13, 2015
by
Gautier Pelloux-Prayer
Browse files
tester: use new macros instead of CUnit ones to get better error logs
parent
5b3c46b0
Changes
25
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
1448 additions
and
1449 deletions
+1448
-1449
.gitignore
.gitignore
+3
-0
tester/Makefile.am
tester/Makefile.am
+1
-0
tester/call_tester.c
tester/call_tester.c
+581
-580
tester/common/bc_tester_utils.c
tester/common/bc_tester_utils.c
+1
-0
tester/common/bc_tester_utils.h
tester/common/bc_tester_utils.h
+62
-60
tester/dtmf_tester.c
tester/dtmf_tester.c
+17
-17
tester/eventapi_tester.c
tester/eventapi_tester.c
+51
-52
tester/flexisip_tester.c
tester/flexisip_tester.c
+154
-155
tester/liblinphone_tester.c
tester/liblinphone_tester.c
+1
-3
tester/log_collection_tester.c
tester/log_collection_tester.c
+11
-11
tester/message_tester.c
tester/message_tester.c
+116
-117
tester/multi_call.c
tester/multi_call.c
+98
-98
tester/multicast_call_tester.c
tester/multicast_call_tester.c
+32
-32
tester/offeranswer_tester.c
tester/offeranswer_tester.c
+35
-35
tester/player_tester.c
tester/player_tester.c
+6
-6
tester/presence_tester.c
tester/presence_tester.c
+50
-51
tester/quality_reporting_tester.c
tester/quality_reporting_tester.c
+76
-76
tester/register_tester.c
tester/register_tester.c
+84
-85
tester/remote_provisioning_tester.c
tester/remote_provisioning_tester.c
+22
-23
tester/setup_tester.c
tester/setup_tester.c
+47
-48
No files found.
.gitignore
View file @
2fced27f
...
...
@@ -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
tester/Makefile.am
View file @
2fced27f
...
...
@@ -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
...
...
tester/call_tester.c
View file @
2fced27f
This diff is collapsed.
Click to expand it.
tester/common/bc_tester_utils.c
View file @
2fced27f
...
...
@@ -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
...
...
tester/common/bc_tester_utils.h
View file @
2fced27f
...
...
@@ -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_C
leanup
F
unc
cleanup_func
;
init_function_t
init_func
;
c
leanup
_f
unc
tion_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
}
...
...
tester/dtmf_tester.c
View file @
2fced27f
...
...
@@ -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
);
C
U
_ASSERT_TRUE
(
call
(
pauline
,
marie
));
B
C_ASSERT_TRUE
(
call
(
pauline
,
marie
));
marie_call
=
linphone_core_get_current_call
(
marie
->
lc
);
C
U
_ASSERT_PTR_NOT_NULL
(
marie_call
);
B
C_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*/
C
U
_ASSERT_TRUE
(
wait_for_until
(
marie
->
lc
,
pauline
->
lc
,
&
pauline
->
stat
.
dtmf_count
,
dtmf_count_prev
+
1
,
10000
));
B
C_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*/
C
U
_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
)));
B
C_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
)
{
C
U
_ASSERT_PTR_NOT_NULL
(
pauline
->
stat
.
dtmf_list_received
);
B
C_ASSERT_PTR_NOT_NULL
(
pauline
->
stat
.
dtmf_list_received
);
if
(
pauline
->
stat
.
dtmf_list_received
)
{
C
U
_ASSERT_STRING_EQUAL
(
pauline
->
stat
.
dtmf_list_received
,
expected
);
B
C_ASSERT_STRING_EQUAL
(
pauline
->
stat
.
dtmf_list_received
,
expected
);
}
ms_free
(
expected
);
}
else
{
C
U
_ASSERT_PTR_NULL
(
pauline
->
stat
.
dtmf_list_received
);
B
C_ASSERT_PTR_NULL
(
pauline
->
stat
.
dtmf_list_received
);
}
}
void
send_dtmf_cleanup
()
{
C
U
_ASSERT_PTR_NULL
(
marie_call
->
dtmfs_timer
);
C
U
_ASSERT_PTR_NULL
(
marie_call
->
dtmf_sequence
);
B
C_ASSERT_PTR_NULL
(
marie_call
->
dtmfs_timer
);
B
C_ASSERT_PTR_NULL
(
marie_call
->
dtmf_sequence
);
/*just to sleep*/
linphone_core_terminate_all_calls
(
pauline
->
lc
);
C
U
_ASSERT_TRUE
(
wait_for
(
pauline
->
lc
,
marie
->
lc
,
&
pauline
->
stat
.
number_of_LinphoneCallEnd
,
1
));
C
U
_ASSERT_TRUE
(
wait_for
(
pauline
->
lc
,
marie
->
lc
,
&
marie
->
stat
.
number_of_LinphoneCallEnd
,
1
));
B
C_ASSERT_TRUE
(
wait_for
(
pauline
->
lc
,
marie
->
lc
,
&
pauline
->
stat
.
number_of_LinphoneCallEnd
,
1
));
B
C_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"
);
C
U
_ASSERT_EQUAL
(
linphone_call_send_dtmfs
(
linphone_core_get_current_call
(
marie
->
lc
),
"123"
),
-
1
);
B
C_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
);
C
U
_ASSERT_TRUE
(
wait_for
(
marie
->
lc
,
pauline
->
lc
,
&
marie
->
stat
.
number_of_LinphoneCallPausing
,
1
));
C
U
_ASSERT_TRUE
(
wait_for
(
marie
->
lc
,
pauline
->
lc
,
&
marie
->
stat
.
number_of_LinphoneCallPaused
,
1
));
B
C_ASSERT_TRUE
(
wait_for
(
marie
->
lc
,
pauline
->
lc
,
&
marie
->
stat
.
number_of_LinphoneCallPausing
,
1
));
B
C_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
);
C
U
_ASSERT_PTR_NULL
(
pauline
->
stat
.
dtmf_list_received
);
B
C_ASSERT_PTR_NULL
(
pauline
->
stat
.
dtmf_list_received
);
send_dtmf_cleanup
();
}
...
...
tester/eventapi_tester.c
View file @
2fced27f
...
...
@@ -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
;
C
U
_ASSERT_PTR_NOT_NULL_FATAL
(
content
);
C
U
_ASSERT_TRUE
(
strcmp
(
notify_content
,(
const
char
*
)
linphone_content_get_buffer
(
content
))
==
0
);
B
C_ASSERT_PTR_NOT_NULL_FATAL
(
content
);
B
C_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*/
C
U
_ASSERT_PTR_NOT_NULL
(
linphone_event_get_custom_header
(
ev
,
"From"
));
counters
->
number_of_LinphonePublishOk
++
;
B
C_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
);
C
U
_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
marie
->
stat
.
number_of_LinphoneSubscriptionOutgoingInit
,
1
,
1000
));
C
U
_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
pauline
->
stat
.
number_of_LinphoneSubscriptionIncomingReceived
,
1
,
3000
));
C
U
_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
marie
->
stat
.
number_of_LinphoneSubscriptionError
,
1
,
21000
));
/*yes flexisip may wait 20 secs in case of forking*/
B
C_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
marie
->
stat
.
number_of_LinphoneSubscriptionOutgoingInit
,
1
,
1000
));
B
C_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
pauline
->
stat
.
number_of_LinphoneSubscriptionIncomingReceived
,
1
,
3000
));
B
C_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
);
C
U
_ASSERT_PTR_NOT_NULL
(
ei
);
B
C_ASSERT_PTR_NOT_NULL
(
ei
);
if
(
ei
){
C
U
_ASSERT_EQUAL
(
linphone_error_info_get_protocol_code
(
ei
),
603
);
C
U
_ASSERT_PTR_NOT_NULL
(
linphone_error_info_get_phrase
(
ei
));
B
C_ASSERT_EQUAL
(
linphone_error_info_get_protocol_code
(
ei
),
603
,
int
,
"%d"
);
B
C_ASSERT_PTR_NOT_NULL
(
linphone_error_info_get_phrase
(
ei
));
}
C
U
_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
pauline
->
stat
.
number_of_LinphoneSubscriptionTerminated
,
1
,
1000
));
B
C_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
);
C
U
_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
marie
->
stat
.
number_of_LinphoneSubscriptionOutgoingInit
,
1
,
1000
));
C
U
_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
pauline
->
stat
.
number_of_LinphoneSubscriptionIncomingReceived
,
1
,
3000
));
C
U
_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
marie
->
stat
.
number_of_LinphoneSubscriptionActive
,
1
,
3000
));
C
U
_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
pauline
->
stat
.
number_of_LinphoneSubscriptionActive
,
1
,
1000
));
B
C_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
marie
->
stat
.
number_of_LinphoneSubscriptionOutgoingInit
,
1
,
1000
));
B
C_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
pauline
->
stat
.
number_of_LinphoneSubscriptionIncomingReceived
,
1
,
3000
));
B
C_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
marie
->
stat
.
number_of_LinphoneSubscriptionActive
,
1
,
3000
));
B
C_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
pauline
->
stat
.
number_of_LinphoneSubscriptionActive
,
1
,
1000
));
/*make sure marie receives first notification before terminating*/
C
U
_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
marie
->
stat
.
number_of_NotifyReceived
,
1
,
1000
));
B
C_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
marie
->
stat
.
number_of_NotifyReceived
,
1
,
1000
));
if
(
refresh_type
==
AutoRefresh
){
wait_for_list
(
lcs
,
NULL
,
0
,
6000
);
C
U
_ASSERT_TRUE
(
linphone_event_get_subscription_state
(
pauline
->
lev
)
==
LinphoneSubscriptionActive
);
B
C_ASSERT_TRUE
(
linphone_event_get_subscription_state
(
pauline
->
lev
)
==
LinphoneSubscriptionActive
);
}
else
if
(
refresh_type
==
ManualRefresh
){
C
U
_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
marie
->
stat
.
number_of_LinphoneSubscriptionExpiring
,
1
,
4000
));
B
C_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
marie
->
stat
.
number_of_LinphoneSubscriptionExpiring
,
1
,
4000
));
linphone_event_update_subscribe
(
lev
,
NULL
);
C
U
_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
marie
->
stat
.
number_of_LinphoneSubscriptionActive
,
2
,
2000
));
B
C_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
marie
->
stat
.
number_of_LinphoneSubscriptionActive
,
2
,
2000
));
}
if
(
terminated_by_subscriber
){
linphone_event_terminate
(
lev
);
}
else
{
C
U
_ASSERT_PTR_NOT_NULL_FATAL
(
pauline
->
lev
);
B
C_ASSERT_PTR_NOT_NULL_FATAL
(
pauline
->
lev
);
linphone_event_terminate
(
pauline
->
lev
);
}
C
U
_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
marie
->
stat
.
number_of_LinphoneSubscriptionTerminated
,
1
,
1000
));
C
U
_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
pauline
->
stat
.
number_of_LinphoneSubscriptionTerminated
,
1
,
1000
));
B
C_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
marie
->
stat
.
number_of_LinphoneSubscriptionTerminated
,
1
,
1000
));
B
C_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
);
C
U
_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
marie
->
stat
.
number_of_LinphoneSubscriptionOutgoingInit
,
1
,
1000
));
C
U
_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
pauline
->
stat
.
number_of_LinphoneSubscriptionIncomingReceived
,
1
,
3000
));
B
C_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
marie
->
stat
.
number_of_LinphoneSubscriptionOutgoingInit
,
1
,
1000
));
B
C_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
pauline
->
stat
.
number_of_LinphoneSubscriptionIncomingReceived
,
1
,
3000
));
/*check good receipt of custom headers*/
C
U
_ASSERT_STRING_EQUAL
(
linphone_event_get_custom_header
(
pauline
->
lev
,
"My-Header"
),
"pouet"
);
C
U
_ASSERT_STRING_EQUAL
(
linphone_event_get_custom_header
(
pauline
->
lev
,
"My-Header2"
),
"pimpon"
);
C
U
_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
marie
->
stat
.
number_of_LinphoneSubscriptionActive
,
1
,
5000
));
C
U
_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
pauline
->
stat
.
number_of_LinphoneSubscriptionActive
,
1
,
5000
));
B
C_ASSERT_STRING_EQUAL
(
linphone_event_get_custom_header
(
pauline
->
lev
,
"My-Header"
),
"pouet"
);
B
C_ASSERT_STRING_EQUAL
(
linphone_event_get_custom_header
(
pauline
->
lev
,
"My-Header2"
),
"pimpon"
);
B
C_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
marie
->
stat
.
number_of_LinphoneSubscriptionActive
,
1
,
5000
));
B
C_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
pauline
->
stat
.
number_of_LinphoneSubscriptionActive
,
1
,
5000
));
/*make sure marie receives first notification before terminating*/
C
U
_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
marie
->
stat
.
number_of_NotifyReceived
,
1
,
5000
));
B
C_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
marie
->
stat
.
number_of_NotifyReceived
,
1
,
5000
));
if
(
refresh_type
==
AutoRefresh
){
wait_for_list
(
lcs
,
NULL
,
0
,
6000
);
C
U
_ASSERT_TRUE
(
linphone_event_get_subscription_state
(
pauline
->
lev
)
==
LinphoneSubscriptionActive
);
B
C_ASSERT_TRUE
(
linphone_event_get_subscription_state
(
pauline
->
lev
)
==
LinphoneSubscriptionActive
);
}
else
if
(
refresh_type
==
ManualRefresh
){
C
U
_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
marie
->
stat
.
number_of_LinphoneSubscriptionExpiring
,
1
,
4000
));
B
C_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
marie
->
stat
.
number_of_LinphoneSubscriptionExpiring
,
1
,
4000
));
linphone_event_update_subscribe
(
lev
,
NULL
);
C
U
_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
marie
->
stat
.
number_of_LinphoneSubscriptionActive
,
2
,
5000
));
B
C_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
marie
->
stat
.
number_of_LinphoneSubscriptionActive
,
2
,
5000
));
}
if
(
terminated_by_subscriber
){
linphone_event_terminate
(
lev
);
}
else
{
C
U
_ASSERT_PTR_NOT_NULL_FATAL
(
pauline
->
lev
);
B
C_ASSERT_PTR_NOT_NULL_FATAL
(
pauline
->
lev
);
linphone_event_terminate
(
pauline
->
lev
);
}
C
U
_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
marie
->
stat
.
number_of_LinphoneSubscriptionTerminated
,
1
,
5000
));
C
U
_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
pauline
->
stat
.
number_of_LinphoneSubscriptionTerminated
,
1
,
5000
));
B
C_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
marie
->
stat
.
number_of_LinphoneSubscriptionTerminated
,
1
,
5000
));
B
C_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
);
C
U
_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
marie
->
stat
.
number_of_LinphonePublishProgress
,
1
,
1000
));
C
U
_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
marie
->
stat
.
number_of_LinphonePublishOk
,
1
,
3000
));
B
C_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
marie
->
stat
.
number_of_LinphonePublishProgress
,
1
,
1000
));
B
C_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
marie
->
stat
.
number_of_LinphonePublishOk
,
1
,
3000
));
if
(
!
refresh
){
C
U
_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
marie
->
stat
.
number_of_LinphonePublishExpiring
,
1
,
5000
));
B
C_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
marie
->
stat
.
number_of_LinphonePublishExpiring
,
1
,
5000
));
linphone_event_update_publish
(
lev
,
content
);
C
U
_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
marie
->
stat
.
number_of_LinphonePublishProgress
,
1
,
1000
));
C
U
_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
marie
->
stat
.
number_of_LinphonePublishOk
,
1
,
3000
));
B
C_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
marie
->
stat
.
number_of_LinphonePublishProgress
,
1
,
1000
));
B
C_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
marie
->
stat
.
number_of_LinphonePublishOk
,
1
,
3000
));
}
else
{
}
linphone_event_terminate
(
lev
);
C
U
_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
marie
->
stat
.
number_of_LinphonePublishCleared
,
1
,
3000
));
B
C_ASSERT_TRUE
(
wait_for_list
(
lcs
,
&
marie
->
stat
.
number_of_LinphonePublishCleared
,
1
,
3000
));
linphone_event_unref
(
lev
);
...
...
tester/flexisip_tester.c
View file @
2fced27f
This diff is collapsed.
Click to expand it.
tester/liblinphone_tester.c
View file @
2fced27f
...
...
@@ -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
...
...
tester/log_collection_tester.c
View file @
2fced27f
...
...
@@ -136,7 +136,7 @@ static FILE* gzuncompress(const char* filepath) {
memset
(
buffer
,
0
,
strlen
(
buffer
));
}
fclose
(
output
);
C
U
_ASSERT_EQUAL
(
gzclose
(
file
),
Z_OK
);
B
C_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
;
C
U
_ASSERT_PTR_NOT_NULL
(
filepath
);
B
C_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
C
U
_ASSERT_PTR_NOT_NULL
(
file
);
B
C_ASSERT_PTR_NOT_NULL
(
file
);
if
(
!
file
)
return
0
;
// 1) expect to find folder name in filename path
C
U
_ASSERT_PTR_NOT_NULL
(
strstr
(
filepath
,
bc_tester_writable_dir_prefix
));
B
C_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
);
C
U
_ASSERT_TRUE
(
log_time
>=
time_prev
);
B
C_ASSERT_TRUE
(
log_time
>=
time_prev
);
time_prev
=
log_time
;
}
}
#endif
}
C
U
_ASSERT_TRUE
(
line_count
>
25
);
B
C_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
C
U
_ASSERT_TRUE
(
timediff
<=
1
);
B
C_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
);
C
U
_ASSERT_PTR_NULL
(
linphone_core_compress_log_collection
(
marie
->
lc
));
B
C_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
++
;
C
U
_ASSERT_
TRUE
(
strlen
(
info
)
>
0
)
B
C_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
);
C
U
_ASSERT_TRUE
(
wait_for
(
marie
->
lc
,
marie
->
lc
,
&
marie
->
stat
.
number_of_LinphoneCoreLogCollectionUploadStateDelivered
,
1
));
B
C_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
);