From c527979daa5b65ec9a838c1b3fe998af6375953a Mon Sep 17 00:00:00 2001 From: notsecure Date: Mon, 7 Jul 2014 17:37:05 -0400 Subject: make autotests compile --- auto_tests/toxav_many_test.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'auto_tests/toxav_many_test.c') diff --git a/auto_tests/toxav_many_test.c b/auto_tests/toxav_many_test.c index 2a931cb0..106d2f32 100644 --- a/auto_tests/toxav_many_test.c +++ b/auto_tests/toxav_many_test.c @@ -124,6 +124,14 @@ void callback_requ_timeout ( int32_t call_index, void *_arg ) { ck_assert_msg(0, "No answer!"); } + +static void callback_audio(ToxAv *av, int32_t call_index, int16_t *data, int length) +{ +} + +static void callback_video(ToxAv *av, int32_t call_index, vpx_image_t *img) +{ +} /*************************************************************************************************/ @@ -142,6 +150,11 @@ void *in_thread_call (void *arg) uint8_t prepared_payload[RTP_PAYLOAD_SIZE]; + toxav_register_audio_recv_callback(this_call->Caller.av, callback_audio); + toxav_register_video_recv_callback(this_call->Caller.av, callback_video); + toxav_register_audio_recv_callback(this_call->Callee.av, callback_audio); + toxav_register_video_recv_callback(this_call->Callee.av, callback_video); + /* NOTE: CALLEE WILL ALWAHYS NEED CALL_IDX == 0 */ while (running) { @@ -192,18 +205,18 @@ void *in_thread_call (void *arg) int recved; /* Payload from CALLER */ - recved = toxav_recv_audio(this_call->Callee.av, 0, frame_size, storage); + /*recved = toxav_recv_audio(this_call->Callee.av, 0, frame_size, storage); if ( recved ) { - /*ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from CALLER is invalid");*/ - } + //ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from CALLER is invalid"); + }*/ /* Payload from CALLEE */ - recved = toxav_recv_audio(this_call->Caller.av, call_idx, frame_size, storage); + /*recved = toxav_recv_audio(this_call->Caller.av, call_idx, frame_size, storage); if ( recved ) { - /*ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from CALLEE is invalid");*/ - } + //ck_assert_msg(recved == 10 && memcmp(storage, sample_payload, 10) == 0, "Payload from CALLEE is invalid"); + }*/ c_sleep(20); } @@ -335,7 +348,6 @@ START_TEST(test_AV_three_calls) toxav_register_callstate_callback(callback_requ_timeout, av_OnRequestTimeout, &status_control); - for ( i = 0; i < 3; i++ ) pthread_create(&status_control.calls[i].tid, NULL, in_thread_call, &status_control.calls[i]); @@ -403,4 +415,4 @@ int main(int argc, char *argv[]) // test_AV_three_calls(); // // return 0; -} \ No newline at end of file +} -- cgit v1.2.3 From b90ecb377d59384770a594abc5c5e3022e99adc8 Mon Sep 17 00:00:00 2001 From: notsecure Date: Mon, 7 Jul 2014 18:47:49 -0400 Subject: locks in test --- auto_tests/toxav_many_test.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'auto_tests/toxav_many_test.c') diff --git a/auto_tests/toxav_many_test.c b/auto_tests/toxav_many_test.c index 106d2f32..3195d1ed 100644 --- a/auto_tests/toxav_many_test.c +++ b/auto_tests/toxav_many_test.c @@ -24,6 +24,7 @@ #define c_sleep(x) usleep(1000*x) #endif +pthread_mutex_t muhmutex; typedef enum _CallStatus { none, @@ -223,8 +224,10 @@ void *in_thread_call (void *arg) step++; /* This terminates the loop */ + pthread_mutex_lock(&muhmutex); toxav_kill_transmission(this_call->Callee.av, 0); toxav_kill_transmission(this_call->Caller.av, call_idx); + pthread_mutex_unlock(&muhmutex); /* Call over CALLER hangs up */ toxav_hangup(this_call->Caller.av, call_idx); @@ -348,6 +351,9 @@ START_TEST(test_AV_three_calls) toxav_register_callstate_callback(callback_requ_timeout, av_OnRequestTimeout, &status_control); + pthread_mutex_init(&muhmutex, NULL); + + for ( i = 0; i < 3; i++ ) pthread_create(&status_control.calls[i].tid, NULL, in_thread_call, &status_control.calls[i]); @@ -362,11 +368,15 @@ START_TEST(test_AV_three_calls) status_control.calls[1].Callee.status != Ended && status_control.calls[1].Caller.status != Ended && status_control.calls[2].Callee.status != Ended && status_control.calls[2].Caller.status != Ended ) { + pthread_mutex_lock(&muhmutex); + tox_do(bootstrap_node); tox_do(caller); tox_do(callees[0]); tox_do(callees[1]); tox_do(callees[2]); + + pthread_mutex_unlock(&muhmutex); c_sleep(20); } -- cgit v1.2.3