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
5264b67f
Commit
5264b67f
authored
Jan 10, 2018
by
Ronan
Browse files
Revert "feat(tester): add random database file for each core"
This reverts commit
1d0495f8
.
parent
95d75214
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
95 deletions
+41
-95
tester/db/linphone.db
tester/db/linphone.db
+0
-0
tester/liblinphone_tester.h
tester/liblinphone_tester.h
+0
-1
tester/main-db-tester.cpp
tester/main-db-tester.cpp
+20
-12
tester/tester.c
tester/tester.c
+21
-82
No files found.
tester/db/linphone.db
View file @
5264b67f
No preview for this file type
tester/liblinphone_tester.h
View file @
5264b67f
...
...
@@ -300,7 +300,6 @@ typedef struct _LinphoneCoreManager {
int
number_of_bcunit_error_at_creation
;
char
*
phone_alias
;
char
*
rc_path
;
char
*
database_path
;
}
LinphoneCoreManager
;
typedef
struct
_LinphoneConferenceServer
{
...
...
tester/main-db-tester.cpp
View file @
5264b67f
...
...
@@ -17,16 +17,14 @@
*/
#include "address/address.h"
#include "core/core
-p
.h"
#include "core/core.h"
#include "db/main-db.h"
#include "event-log/events.h"
// TODO: Remove me later.
#include "private.h"
#include "liblinphone_tester.h"
#include "tester_utils.h"
#include "tools/tester.h"
// =============================================================================
...
...
@@ -36,23 +34,33 @@ using namespace LinphonePrivate;
// -----------------------------------------------------------------------------
static
const
string
getDatabasePath
()
{
static
const
string
path
=
string
(
bc_tester_get_resource_dir_prefix
())
+
"db/linphone.db"
;
return
path
;
}
// -----------------------------------------------------------------------------
class
MainDbProvider
{
public:
MainDbProvider
()
{
mCoreManager
=
linphone_core_manager_create
(
"marie_rc"
);
linphone_core_manager_start
(
mCoreManager
,
false
);
mCoreManager
=
linphone_core_manager_new
(
"marie_rc"
);
mMainDb
=
new
MainDb
(
mCoreManager
->
lc
->
cppPtr
->
getSharedFromThis
());
mMainDb
->
connect
(
MainDb
::
Sqlite3
,
getDatabasePath
());
}
~
MainDbProvider
()
{
delete
mMainDb
;
linphone_core_manager_destroy
(
mCoreManager
);
}
const
MainDb
&
getMainDb
()
{
return
*
L_GET_PRIVATE
(
mCoreManager
->
lc
->
cppPtr
)
->
mainDb
;
return
*
m
M
ainDb
;
}
private:
LinphoneCoreManager
*
mCoreManager
;
MainDb
*
mMainDb
;
};
// -----------------------------------------------------------------------------
...
...
@@ -122,7 +130,7 @@ static void get_history () {
ChatRoomId
(
IdentityAddress
(
"sip:test-1@sip.linphone.org"
),
IdentityAddress
(
"sip:test-1@sip.linphone.org"
)),
0
,
-
1
,
MainDb
::
Filter
::
ConferenceChatMessageFilter
).
size
(),
8
04
,
8
62
,
int
,
"%d"
);
...
...
@@ -141,11 +149,11 @@ static void get_conference_notified_events () {
MainDbProvider
provider
;
const
MainDb
&
mainDb
=
provider
.
getMainDb
();
list
<
shared_ptr
<
EventLog
>>
events
=
mainDb
.
getConferenceNotifiedEvents
(
ChatRoomId
(
IdentityAddress
(
"sip:
test-44
@sip.linphone.org"
),
IdentityAddress
(
"sip:
test-1
@sip.linphone.org"
)),
-
1
ChatRoomId
(
IdentityAddress
(
"sip:
fake-group-2
@sip.linphone.org"
),
IdentityAddress
(
"sip:
fake-group-2
@sip.linphone.org"
)),
1
);
BC_ASSERT_EQUAL
(
events
.
size
(),
5
,
int
,
"%d"
);
if
(
events
.
size
()
!=
5
)
BC_ASSERT_EQUAL
(
events
.
size
(),
3
,
int
,
"%d"
);
if
(
events
.
size
()
!=
3
)
return
;
shared_ptr
<
EventLog
>
event
;
...
...
@@ -191,7 +199,7 @@ test_t main_db_tests[] = {
TEST_NO_TAG
(
"Get messages count"
,
get_messages_count
),
TEST_NO_TAG
(
"Get unread messages count"
,
get_unread_messages_count
),
TEST_NO_TAG
(
"Get history"
,
get_history
),
TEST_NO_TAG
(
"Get conference
notified
events"
,
get_conference_notified_events
)
TEST_NO_TAG
(
"Get conference events"
,
get_conference_notified_events
)
};
test_suite_t
main_db_test_suite
=
{
...
...
tester/tester.c
View file @
5264b67f
...
...
@@ -94,25 +94,27 @@ LinphoneAddress * create_linphone_address(const char * domain) {
}
LinphoneAddress
*
create_linphone_address_for_algo
(
const
char
*
domain
,
const
char
*
username
)
{
LinphoneAddress
*
addr
=
linphone_address_new
(
NULL
);
if
(
!
BC_ASSERT_PTR_NOT_NULL
(
addr
))
return
NULL
;
/* For clients who support different algorithms, their usernames must be differnet for having diffrent forms of password */
if
(
username
)
linphone_address_set_username
(
addr
,
username
);
else
linphone_address_set_username
(
addr
,
test_username
);
if
(
username
)
BC_ASSERT_STRING_EQUAL
(
username
,
linphone_address_get_username
(
addr
));
else
BC_ASSERT_STRING_EQUAL
(
test_username
,
linphone_address_get_username
(
addr
));
if
(
!
domain
)
domain
=
test_route
;
linphone_address_set_domain
(
addr
,
domain
);
BC_ASSERT_STRING_EQUAL
(
domain
,
linphone_address_get_domain
(
addr
));
linphone_address_set_display_name
(
addr
,
NULL
);
linphone_address_set_display_name
(
addr
,
"Mr Tester"
);
BC_ASSERT_STRING_EQUAL
(
"Mr Tester"
,
linphone_address_get_display_name
(
addr
));
return
addr
;
LinphoneAddress
*
addr
=
linphone_address_new
(
NULL
);
if
(
!
BC_ASSERT_PTR_NOT_NULL
(
addr
))
return
NULL
;
/* For clients who support different algorithms, their usernames must be differnet for having diffrent forms of password */
if
(
username
)
linphone_address_set_username
(
addr
,
username
);
else
linphone_address_set_username
(
addr
,
test_username
);
if
(
username
)
BC_ASSERT_STRING_EQUAL
(
username
,
linphone_address_get_username
(
addr
));
else
BC_ASSERT_STRING_EQUAL
(
test_username
,
linphone_address_get_username
(
addr
));
if
(
!
domain
)
domain
=
test_route
;
linphone_address_set_domain
(
addr
,
domain
);
BC_ASSERT_STRING_EQUAL
(
domain
,
linphone_address_get_domain
(
addr
));
linphone_address_set_display_name
(
addr
,
NULL
);
linphone_address_set_display_name
(
addr
,
"Mr Tester"
);
BC_ASSERT_STRING_EQUAL
(
"Mr Tester"
,
linphone_address_get_display_name
(
addr
));
return
addr
;
}
static
void
auth_info_requested
(
LinphoneCore
*
lc
,
const
char
*
realm
,
const
char
*
username
,
const
char
*
domain
)
{
stats
*
counters
;
ms_message
(
"Auth info requested for user id [%s] at realm [%s]
\n
"
,
username
,
realm
);
ms_message
(
"Auth info requested for user id [%s] at realm [%s]
\n
"
,
username
,
realm
);
counters
=
get_stats
(
lc
);
counters
->
number_of_auth_info_requested
++
;
}
...
...
@@ -288,11 +290,11 @@ bool_t transport_supported(LinphoneTransportType transport) {
}
}
static
void
linphone_core_manager_configure
(
LinphoneCoreManager
*
mgr
)
{
void
linphone_core_manager_configure
(
LinphoneCoreManager
*
mgr
)
{
LinphoneImNotifPolicy
*
im_notif_policy
;
char
*
hellopath
=
bc_tester_res
(
"sounds/hello8000.wav"
);
mgr
->
lc
=
configure_lc_from
(
&
mgr
->
v_table
,
NULL
,
mgr
->
rc_path
,
mgr
);
mgr
->
lc
=
configure_lc_from
(
&
mgr
->
v_table
,
bc_tester_get_resource_dir_prefix
()
,
mgr
->
rc_path
,
mgr
);
linphone_core_manager_check_accounts
(
mgr
);
im_notif_policy
=
linphone_core_get_im_notif_policy
(
mgr
->
lc
);
if
(
im_notif_policy
!=
NULL
)
{
...
...
@@ -342,57 +344,6 @@ static void linphone_core_manager_configure (LinphoneCoreManager *mgr) {
linphone_core_enable_send_call_stats_periodical_updates
(
mgr
->
lc
,
TRUE
);
}
// TODO: Remove me later. When C++ will be available in this (bullshit) file... :'(
static
int
copy_file
(
const
char
*
from
,
const
char
*
to
)
{
FILE
*
in
,
*
out
;
char
buf
[
255
];
size_t
n
;
in
=
fopen
(
from
,
"rb"
);
if
(
!
in
)
{
bctbx_error
(
"Can't open %s for reading: %s
\n
"
,
from
,
strerror
(
errno
));
return
1
;
}
out
=
fopen
(
to
,
"wb"
);
if
(
!
out
)
{
bctbx_error
(
"Can't open %s for writing: %s
\n
"
,
to
,
strerror
(
errno
));
fclose
(
in
);
return
1
;
}
while
((
n
=
fread
(
buf
,
sizeof
buf
[
0
],
sizeof
buf
,
in
))
>
0
)
if
(
!
fwrite
(
buf
,
1
,
n
,
out
))
{
bctbx_error
(
"Could not write in %s: %s
\n
"
,
to
,
strerror
(
errno
));
fclose
(
in
);
fclose
(
out
);
return
1
;
}
fclose
(
in
);
fclose
(
out
);
return
0
;
}
static
void
configure_random_database_path
(
LinphoneCoreManager
*
mgr
)
{
LinphoneConfig
*
config
=
linphone_config_new
(
mgr
->
rc_path
);
if
(
!
config
)
bctbx_fatal
(
"Unable to open linphone config from: %s"
,
mgr
->
rc_path
);
char
random_id
[
32
];
belle_sip_random_token
(
random_id
,
sizeof
random_id
);
char
*
database_path_format
=
bctbx_strdup_printf
(
"linphone_%s.db"
,
random_id
);
mgr
->
database_path
=
bc_tester_file
(
database_path_format
);
linphone_config_set_string
(
config
,
"storage"
,
"backend"
,
"sqlite3"
);
linphone_config_set_string
(
config
,
"storage"
,
"uri"
,
mgr
->
database_path
);
linphone_config_sync
(
config
);
linphone_config_unref
(
config
);
bctbx_free
(
database_path_format
);
}
#if __clang__ || ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4)
#pragma GCC diagnostic push
#endif
...
...
@@ -426,13 +377,7 @@ void linphone_core_manager_init(LinphoneCoreManager *mgr, const char* rc_file, c
mgr
->
phone_alias
=
phone_alias
?
ms_strdup
(
phone_alias
)
:
NULL
;
reset_counters
(
&
mgr
->
stat
);
if
(
rc_file
)
{
char
*
src
=
bctbx_strdup_printf
(
"%s/rcfiles/%s"
,
bc_tester_get_resource_dir_prefix
(),
rc_file
);
mgr
->
rc_path
=
bc_tester_file
(
"rc_file"
);
copy_file
(
src
,
mgr
->
rc_path
);
bctbx_free
(
src
);
configure_random_database_path
(
mgr
);
}
if
(
rc_file
)
mgr
->
rc_path
=
ms_strdup_printf
(
"rcfiles/%s"
,
rc_file
);
manager_count
++
;
...
...
@@ -544,14 +489,8 @@ void linphone_core_manager_uninit(LinphoneCoreManager *mgr) {
if
(
mgr
->
identity
)
{
linphone_address_unref
(
mgr
->
identity
);
}
if
(
mgr
->
rc_path
)
{
unlink
(
mgr
->
rc_path
);
if
(
mgr
->
rc_path
)
bctbx_free
(
mgr
->
rc_path
);
}
if
(
mgr
->
database_path
)
{
unlink
(
mgr
->
database_path
);
bctbx_free
(
mgr
->
database_path
);
}
manager_count
--
;
linphone_core_set_log_level
(
old_log_level
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment