From 85c7fa27734c4ede8b8ffbd14e52b11db3fe359d Mon Sep 17 00:00:00 2001 From: Guillaume BIENKOWSKI Date: Tue, 9 Dec 2014 10:18:17 +0100 Subject: [PATCH] Add an API to keep the accounts created on flexisip across calls to liblinphone_tester_run_tests(). This is used by iOS because of how the XCTest framework works. --- tester/liblinphone_tester.h | 18 ++++++++++++++++++ tester/tester.c | 15 ++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/tester/liblinphone_tester.h b/tester/liblinphone_tester.h index 12531a57f..2c926b27d 100644 --- a/tester/liblinphone_tester.h +++ b/tester/liblinphone_tester.h @@ -79,6 +79,24 @@ extern void liblinphone_tester_set_fileprefix(const char* file_prefix); extern void liblinphone_tester_set_writable_dir_prefix(const char* writable_dir_prefix); extern int liblinphone_tester_ipv6_available(void); +/** + * @brief Tells the tester whether or not to clean the accounts it has created between runs. + * @details Setting this to 1 will not clear the list of created accounts between successive + * calls to liblinphone_run_tests(). Some testing APIs call this function for *each* test, + * in which case we should keep the accounts that were created for further testing. + * + * You are supposed to manually call liblinphone_tester_clear_account when all the tests are + * finished. + * + * @param keep 1 to keep the accounts in-between runs, 0 to clear them after each run. + */ +extern void liblinphone_tester_keep_accounts( int keep ); + +/** + * @brief Clears the created accounts during the testing session. + */ +extern void liblinphone_tester_clear_accounts(void); + #ifdef __cplusplus }; #endif diff --git a/tester/tester.c b/tester/tester.c index b705a8912..7c6ac48da 100644 --- a/tester/tester.c +++ b/tester/tester.c @@ -39,6 +39,7 @@ const char* test_username="liblinphone_tester"; const char* test_password="secret"; const char* test_route="sip2.linphone.org"; int liblinphone_tester_use_log_file=0; +static int liblinphone_tester_keep_accounts_flag = 0; #if WINAPI_FAMILY_PHONE_APP const char *liblinphone_tester_file_prefix="Assets"; @@ -545,7 +546,10 @@ int liblinphone_tester_run_tests(const char *suite_name, const char *test_name) } CU_cleanup_registry(); - account_manager_destroy(); + + if( liblinphone_tester_keep_accounts_flag == 0){ + liblinphone_tester_clear_accounts(); + } return ret; } @@ -583,3 +587,12 @@ int liblinphone_tester_ipv6_available(void){ return FALSE; } +void liblinphone_tester_keep_accounts( int keep ){ + liblinphone_tester_keep_accounts_flag = keep; +} + +void liblinphone_tester_clear_accounts(void){ + account_manager_destroy(); +} + +