Commit c08c8b9d authored by Simon Morlat's avatar Simon Morlat Committed by Sylvain Berfini

Fix/crash in multipart tester

parent f33bc192
......@@ -38,7 +38,7 @@ shared_ptr<RealTimeTextChatRoom> CallPrivate::getChatRoom () {
L_Q();
if (!chatRoom && (q->getState() != CallSession::State::End) && (q->getState() != CallSession::State::Released)) {
chatRoom = static_pointer_cast<RealTimeTextChatRoom>(q->getCore()->getOrCreateBasicChatRoom(q->getRemoteAddress(), true));
chatRoom->getPrivate()->setCall(q->getSharedFromThis());
if (chatRoom) chatRoom->getPrivate()->setCall(q->getSharedFromThis());
}
return chatRoom;
}
......@@ -498,7 +498,9 @@ bool CallPrivate::isPlayingRingbackTone (const shared_ptr<CallSession> &session)
void CallPrivate::onRealTimeTextCharacterReceived (const shared_ptr<CallSession> &session, RealtimeTextReceivedCharacter *data) {
L_Q();
getChatRoom()->getPrivate()->realtimeTextReceived(data->character, q->getSharedFromThis());
shared_ptr<RealTimeTextChatRoom> cr = getChatRoom();
if (cr) cr->getPrivate()->realtimeTextReceived(data->character, q->getSharedFromThis());
else lError()<<"CallPrivate::onRealTimeTextCharacterReceived: no chatroom.";
}
void CallPrivate::onTmmbrReceived (const shared_ptr<CallSession> &session, int streamIndex, int tmmbr) {
......
......@@ -277,8 +277,13 @@ shared_ptr<AbstractChatRoom> Core::getOrCreateBasicChatRoom (const ChatRoomId &c
L_D();
shared_ptr<AbstractChatRoom> chatRoom = findChatRoom(chatRoomId);
if (chatRoom)
if (chatRoom){
if (isRtt && !(chatRoom->getCapabilities() & ChatRoom::Capabilities::RealTimeText)){
lError() << "Found chatroom but without RealTimeText capability. This is a bug, fixme";
return nullptr;
}
return chatRoom;
}
chatRoom = d->createBasicChatRoom(chatRoomId,
isRtt ? ChatRoom::CapabilitiesMask(ChatRoom::Capabilities::RealTimeText) : ChatRoom::CapabilitiesMask()
......@@ -293,8 +298,14 @@ shared_ptr<AbstractChatRoom> Core::getOrCreateBasicChatRoom (const IdentityAddre
L_D();
list<shared_ptr<AbstractChatRoom>> chatRooms = findChatRooms(peerAddress);
if (!chatRooms.empty())
return chatRooms.front();
if (!chatRooms.empty()){
shared_ptr<AbstractChatRoom> ret = chatRooms.front();
if (isRtt && !(ret->getCapabilities() & ChatRoom::Capabilities::RealTimeText)){
lError() << "Found chatroom but without RealTimeText capability. This is a bug, fixme";
ret = nullptr;
}
return ret;
}
shared_ptr<AbstractChatRoom> chatRoom = d->createBasicChatRoom(
ChatRoomId(peerAddress, getDefaultLocalAddress(getSharedFromThis(), peerAddress)),
......
......@@ -4981,6 +4981,8 @@ static void call_record_with_custom_rtp_modifier(void) {
custom_rtp_modifier(FALSE, TRUE);
}
/*Case where the caller disconnects just after initiating the call*/
static void recovered_call_on_network_switch_in_early_state(LinphoneCoreManager* callerMgr) {
const LinphoneCallParams *remote_params;
LinphoneCall *incoming_call;
......@@ -5026,6 +5028,8 @@ static void recovered_call_on_network_switch_in_early_state_1_udp(void) {
recovered_call_on_network_switch_in_early_state(laure);
linphone_core_manager_destroy(laure);
}
/*case where the caller disconnects just after the call is accepted*/
static void recovered_call_on_network_switch_in_early_state_2(void) {
LinphoneCall *incoming_call;
LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
......@@ -5054,6 +5058,8 @@ end:
linphone_core_manager_destroy(pauline);
}
/*case where the callee disconnects between the moment it receives the call and the moment it accepts the call*/
static void recovered_call_on_network_switch_in_early_state_3(void) {
LinphoneCall *incoming_call;
LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
......@@ -5083,6 +5089,7 @@ end:
linphone_core_manager_destroy(pauline);
}
/*case where the callee disconnects just after accepting the call*/
static void recovered_call_on_network_switch_in_early_state_4(void) {
LinphoneCall *incoming_call;
LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
......
......@@ -84,17 +84,22 @@ void file_transfer_received(LinphoneChatMessage *msg, const LinphoneContent* con
file = fopen(receive_file,"wb");
linphone_chat_message_set_user_data(msg,(void*)file); /*store fd for next chunks*/
}
bc_free(receive_file);
file = (FILE*)linphone_chat_message_get_user_data(msg);
BC_ASSERT_PTR_NOT_NULL(file);
if (linphone_buffer_is_empty(buffer)) { /* tranfer complete */
struct stat st;
linphone_chat_message_set_user_data(msg, NULL);
fclose(file);
BC_ASSERT_TRUE(stat(receive_file, &st)==0);
BC_ASSERT_EQUAL((int)linphone_content_get_file_size(content), (int)st.st_size, int, "%i");
} else { /* store content on a file*/
if (fwrite(linphone_buffer_get_content(buffer),linphone_buffer_get_size(buffer),1,file)==0){
ms_error("file_transfer_received(): write() failed: %s",strerror(errno));
}
}
bc_free(receive_file);
}
/*
......@@ -1747,6 +1752,7 @@ static void real_time_text(
bool_t do_not_store_rtt_messages_in_sql_storage
) {
LinphoneChatRoom *pauline_chat_room;
LinphoneChatRoom *marie_chat_room;
LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc");
LinphoneCallParams *marie_params = NULL;
......@@ -1819,12 +1825,14 @@ static void real_time_text(
}
pauline_chat_room = linphone_call_get_chat_room(pauline_call);
marie_chat_room = linphone_call_get_chat_room(marie_call);
BC_ASSERT_PTR_NOT_NULL(pauline_chat_room);
if (pauline_chat_room) {
BC_ASSERT_PTR_NOT_NULL(marie_chat_room);
if (pauline_chat_room && marie_chat_room) {
const char* message = "Be l3l";
size_t i;
LinphoneChatMessage* rtt_message = linphone_chat_room_create_message(pauline_chat_room,NULL);
LinphoneChatRoom *marie_chat_room = linphone_call_get_chat_room(marie_call);
for (i = 0; i < strlen(message); i++) {
BC_ASSERT_FALSE(linphone_chat_message_put_char(rtt_message, message[i]));
......@@ -1911,7 +1919,7 @@ static void real_time_text_conversation(void) {
pauline_chat_room = linphone_call_get_chat_room(pauline_call);
BC_ASSERT_PTR_NOT_NULL(pauline_chat_room);
marie_chat_room = linphone_call_get_chat_room(marie_call);
BC_ASSERT_PTR_NOT_NULL(pauline_chat_room);
BC_ASSERT_PTR_NOT_NULL(marie_chat_room);
if (pauline_chat_room && marie_chat_room) {
const char* message1_1 = "Lorem";
const char* message1_2 = "Ipsum";
......@@ -2017,6 +2025,7 @@ static void real_time_text_message_compat(bool_t end_with_crlf, bool_t end_with_
LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc");
LinphoneCallParams *marie_params = NULL;
LinphoneCall *pauline_call, *marie_call;
LinphoneChatRoom *marie_chat_room;
marie_params = linphone_core_create_call_params(marie->lc, NULL);
linphone_call_params_enable_realtime_text(marie_params,TRUE);
......@@ -2028,12 +2037,13 @@ static void real_time_text_message_compat(bool_t end_with_crlf, bool_t end_with_
BC_ASSERT_TRUE(linphone_call_params_realtime_text_enabled(linphone_call_get_current_params(pauline_call)));
pauline_chat_room = linphone_call_get_chat_room(pauline_call);
marie_chat_room = linphone_call_get_chat_room(marie_call);
BC_ASSERT_PTR_NOT_NULL(pauline_chat_room);
if (pauline_chat_room) {
BC_ASSERT_PTR_NOT_NULL(marie_chat_room);
if (pauline_chat_room && marie_chat_room) {
const char* message = "Be l3l";
size_t i;
LinphoneChatMessage* rtt_message = linphone_chat_room_create_message(pauline_chat_room,NULL);
LinphoneChatRoom *marie_chat_room = linphone_call_get_chat_room(marie_call);
uint32_t crlf = 0x0D0A;
uint32_t lf = 0x0A;
......@@ -2069,6 +2079,7 @@ static void real_time_text_message_compat_lf(void) {
static void real_time_text_message_accented_chars(void) {
LinphoneChatRoom *pauline_chat_room;
LinphoneChatRoom *marie_chat_room;
LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc");
LinphoneCallParams *marie_params = NULL;
......@@ -2084,10 +2095,11 @@ static void real_time_text_message_accented_chars(void) {
BC_ASSERT_TRUE(linphone_call_params_realtime_text_enabled(linphone_call_get_current_params(pauline_call)));
pauline_chat_room = linphone_call_get_chat_room(pauline_call);
marie_chat_room = linphone_call_get_chat_room(marie_call);
BC_ASSERT_PTR_NOT_NULL(pauline_chat_room);
if (pauline_chat_room) {
BC_ASSERT_PTR_NOT_NULL(marie_chat_room);
if (pauline_chat_room && marie_chat_room) {
LinphoneChatMessage* rtt_message = linphone_chat_room_create_message(pauline_chat_room,NULL);
LinphoneChatRoom *marie_chat_room = linphone_call_get_chat_room(marie_call);
int i;
uint32_t message[8];
int message_len = 8;
......@@ -2134,6 +2146,7 @@ static void real_time_text_message_different_text_codecs_payload_numbers_receive
static void real_time_text_copy_paste(void) {
LinphoneChatRoom *pauline_chat_room;
LinphoneChatRoom *marie_chat_room;
LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc");
LinphoneCallParams *marie_params = NULL;
......@@ -2149,12 +2162,14 @@ static void real_time_text_copy_paste(void) {
BC_ASSERT_TRUE(linphone_call_params_realtime_text_enabled(linphone_call_get_current_params(pauline_call)));
pauline_chat_room = linphone_call_get_chat_room(pauline_call);
marie_chat_room = linphone_call_get_chat_room(marie_call);
BC_ASSERT_PTR_NOT_NULL(pauline_chat_room);
if (pauline_chat_room) {
BC_ASSERT_PTR_NOT_NULL(marie_chat_room);
if (pauline_chat_room && marie_chat_room) {
const char* message = "Be l3l";
size_t i;
LinphoneChatMessage* rtt_message = linphone_chat_room_create_message(pauline_chat_room,NULL);
LinphoneChatRoom *marie_chat_room = linphone_call_get_chat_room(marie_call);
for (i = 1; i <= strlen(message); i++) {
linphone_chat_message_put_char(rtt_message, message[i-1]);
......
......@@ -185,9 +185,11 @@ static void chat_message_multipart_modifier_base(bool first_file_transfer, bool
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneMessageReceived,1));
BC_ASSERT_PTR_NOT_NULL(pauline->stat.last_received_chat_message);
const bctbx_list_t *contents = linphone_chat_message_get_contents(pauline->stat.last_received_chat_message);
check_contents(contents, first_file_transfer, second_file_transfer, third_content);
if (pauline->stat.last_received_chat_message){
const bctbx_list_t *contents = linphone_chat_message_get_contents(pauline->stat.last_received_chat_message);
check_contents(contents, first_file_transfer, second_file_transfer, third_content);
}
marieRoom.reset(); // Avoid bad weak ptr when the core is destroyed below this line.
......
......@@ -275,6 +275,40 @@ bool_t transport_supported(LinphoneTransportType transport) {
}
}
#ifdef __linux
static void avoid_pulseaudio_hack(LinphoneCoreManager *mgr){
bctbx_list_t *cards = linphone_core_get_sound_devices_list(mgr->lc);
bctbx_list_t *it;
bool_t capture_set = FALSE, playback_set = FALSE;
bool_t pulseaudio_found = FALSE;
for (it = cards; it != NULL ; it = it->next){
const char * card_id = (const char *)it->data;
if (strstr(card_id, "PulseAudio") != NULL) {
pulseaudio_found = TRUE;
continue;
}
if (!capture_set && linphone_core_sound_device_can_capture(mgr->lc, card_id)){
capture_set = TRUE;
linphone_core_set_capture_device(mgr->lc, card_id);
}
if (!playback_set && linphone_core_sound_device_can_playback(mgr->lc, card_id)){
playback_set = TRUE;
linphone_core_set_playback_device(mgr->lc, card_id);
linphone_core_set_ringer_device(mgr->lc, card_id);
}
if (playback_set && capture_set){
if (pulseaudio_found) ms_warning("PulseAudio is not used in liblinphone_tester because of internal random crashes or hangs.");
break;
}
}
if (!playback_set || !capture_set){
ms_error("Could not find soundcard other than pulseaudio to use during tests. Some tests may crash or hang.");
}
bctbx_list_free(cards);
}
#endif
void linphone_core_manager_configure (LinphoneCoreManager *mgr) {
LinphoneImNotifPolicy *im_notif_policy;
char *hellopath = bc_tester_res("sounds/hello8000.wav");
......@@ -294,6 +328,13 @@ void linphone_core_manager_configure (LinphoneCoreManager *mgr) {
linphone_core_set_ringback(mgr->lc, NULL);
#elif __QNX__
linphone_core_set_playback_device(mgr->lc, "QSA: voice");
#elif defined(__linux)
{
/* Special trick for linux. Pulseaudio has random hangs, deadlocks or abort while executing test suites.
* It never happens in the linphone app.
* So far we could not identify something bad in our pulseaudio usage. As a workaround, we disable pulseaudio for the tests.*/
avoid_pulseaudio_hack(mgr);
}
#endif
#ifdef VIDEO_ENABLED
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment