diff options
Diffstat (limited to 'auto_tests/toxav_many_test.c')
-rw-r--r-- | auto_tests/toxav_many_test.c | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/auto_tests/toxav_many_test.c b/auto_tests/toxav_many_test.c index 84f94e96..f913c9d3 100644 --- a/auto_tests/toxav_many_test.c +++ b/auto_tests/toxav_many_test.c | |||
@@ -9,10 +9,11 @@ | |||
9 | #include <check.h> | 9 | #include <check.h> |
10 | #include <stdlib.h> | 10 | #include <stdlib.h> |
11 | #include <time.h> | 11 | #include <time.h> |
12 | #include <assert.h> | ||
13 | 12 | ||
14 | #include <vpx/vpx_image.h> | 13 | #include <vpx/vpx_image.h> |
15 | 14 | ||
15 | #include "helpers.h" | ||
16 | |||
16 | #include "../toxcore/tox.h" | 17 | #include "../toxcore/tox.h" |
17 | #include "../toxcore/util.h" | 18 | #include "../toxcore/util.h" |
18 | #include "../toxcore/logger.h" | 19 | #include "../toxcore/logger.h" |
@@ -97,7 +98,7 @@ void t_accept_friend_request_cb(Tox *m, const uint8_t *public_key, const uint8_t | |||
97 | { | 98 | { |
98 | (void) userdata; | 99 | (void) userdata; |
99 | if (length == 7 && memcmp("gentoo", data, 7) == 0) { | 100 | if (length == 7 && memcmp("gentoo", data, 7) == 0) { |
100 | assert(tox_friend_add_norequest(m, public_key, NULL) != (uint32_t) ~0); | 101 | ck_assert(tox_friend_add_norequest(m, public_key, NULL) != (uint32_t) ~0); |
101 | } | 102 | } |
102 | } | 103 | } |
103 | 104 | ||
@@ -110,7 +111,7 @@ ToxAV* setup_av_instance(Tox* tox, CallControl *CC) | |||
110 | TOXAV_ERR_NEW error; | 111 | TOXAV_ERR_NEW error; |
111 | 112 | ||
112 | ToxAV* av = toxav_new(tox, &error); | 113 | ToxAV* av = toxav_new(tox, &error); |
113 | assert(error == TOXAV_ERR_NEW_OK); | 114 | ck_assert(error == TOXAV_ERR_NEW_OK); |
114 | 115 | ||
115 | toxav_callback_call(av, t_toxav_call_cb, CC); | 116 | toxav_callback_call(av, t_toxav_call_cb, CC); |
116 | toxav_callback_call_state(av, t_toxav_call_state_cb, CC); | 117 | toxav_callback_call_state(av, t_toxav_call_state_cb, CC); |
@@ -137,7 +138,7 @@ void* call_thread(void* pd) | |||
137 | 138 | ||
138 | if (rc != TOXAV_ERR_CALL_OK) { | 139 | if (rc != TOXAV_ERR_CALL_OK) { |
139 | printf("toxav_call failed: %d\n", rc); | 140 | printf("toxav_call failed: %d\n", rc); |
140 | exit(1); | 141 | ck_assert(0); |
141 | } | 142 | } |
142 | } | 143 | } |
143 | 144 | ||
@@ -150,7 +151,7 @@ void* call_thread(void* pd) | |||
150 | 151 | ||
151 | if (rc != TOXAV_ERR_ANSWER_OK) { | 152 | if (rc != TOXAV_ERR_ANSWER_OK) { |
152 | printf("toxav_answer failed: %d\n", rc); | 153 | printf("toxav_answer failed: %d\n", rc); |
153 | exit(1); | 154 | ck_assert(0); |
154 | } | 155 | } |
155 | } | 156 | } |
156 | 157 | ||
@@ -167,7 +168,7 @@ void* call_thread(void* pd) | |||
167 | memset(video_v, 0, sizeof(video_v)); | 168 | memset(video_v, 0, sizeof(video_v)); |
168 | 169 | ||
169 | time_t start_time = time(NULL); | 170 | time_t start_time = time(NULL); |
170 | while(time(NULL) - start_time < 9) { | 171 | while(time(NULL) - start_time < 4) { |
171 | toxav_iterate(AliceAV); | 172 | toxav_iterate(AliceAV); |
172 | toxav_iterate(BobAV); | 173 | toxav_iterate(BobAV); |
173 | 174 | ||
@@ -186,11 +187,13 @@ void* call_thread(void* pd) | |||
186 | 187 | ||
187 | if (rc != TOXAV_ERR_CALL_CONTROL_OK) { | 188 | if (rc != TOXAV_ERR_CALL_CONTROL_OK) { |
188 | printf("toxav_call_control failed: %d\n", rc); | 189 | printf("toxav_call_control failed: %d\n", rc); |
189 | exit(1); | 190 | ck_assert(0); |
190 | } | 191 | } |
191 | } | 192 | } |
192 | 193 | ||
193 | c_sleep(30); | 194 | c_sleep(30); |
195 | |||
196 | printf ("Closing thread\n"); | ||
194 | pthread_exit(NULL); | 197 | pthread_exit(NULL); |
195 | } | 198 | } |
196 | 199 | ||
@@ -206,19 +209,19 @@ START_TEST(test_AV_three_calls) | |||
206 | TOX_ERR_NEW error; | 209 | TOX_ERR_NEW error; |
207 | 210 | ||
208 | bootstrap = tox_new(NULL, NULL, 0, &error); | 211 | bootstrap = tox_new(NULL, NULL, 0, &error); |
209 | assert(error == TOX_ERR_NEW_OK); | 212 | ck_assert(error == TOX_ERR_NEW_OK); |
210 | 213 | ||
211 | Alice = tox_new(NULL, NULL, 0, &error); | 214 | Alice = tox_new(NULL, NULL, 0, &error); |
212 | assert(error == TOX_ERR_NEW_OK); | 215 | ck_assert(error == TOX_ERR_NEW_OK); |
213 | 216 | ||
214 | Bobs[0] = tox_new(NULL, NULL, 0, &error); | 217 | Bobs[0] = tox_new(NULL, NULL, 0, &error); |
215 | assert(error == TOX_ERR_NEW_OK); | 218 | ck_assert(error == TOX_ERR_NEW_OK); |
216 | 219 | ||
217 | Bobs[1] = tox_new(NULL, NULL, 0, &error); | 220 | Bobs[1] = tox_new(NULL, NULL, 0, &error); |
218 | assert(error == TOX_ERR_NEW_OK); | 221 | ck_assert(error == TOX_ERR_NEW_OK); |
219 | 222 | ||
220 | Bobs[2] = tox_new(NULL, NULL, 0, &error); | 223 | Bobs[2] = tox_new(NULL, NULL, 0, &error); |
221 | assert(error == TOX_ERR_NEW_OK); | 224 | ck_assert(error == TOX_ERR_NEW_OK); |
222 | } | 225 | } |
223 | 226 | ||
224 | printf("Created 5 instances of Tox\n"); | 227 | printf("Created 5 instances of Tox\n"); |
@@ -232,9 +235,9 @@ START_TEST(test_AV_three_calls) | |||
232 | tox_self_get_address(Alice, address); | 235 | tox_self_get_address(Alice, address); |
233 | 236 | ||
234 | 237 | ||
235 | assert(tox_friend_add(Bobs[0], address, (uint8_t *)"gentoo", 7, NULL) != (uint32_t) ~0); | 238 | ck_assert(tox_friend_add(Bobs[0], address, (uint8_t *)"gentoo", 7, NULL) != (uint32_t) ~0); |
236 | assert(tox_friend_add(Bobs[1], address, (uint8_t *)"gentoo", 7, NULL) != (uint32_t) ~0); | 239 | ck_assert(tox_friend_add(Bobs[1], address, (uint8_t *)"gentoo", 7, NULL) != (uint32_t) ~0); |
237 | assert(tox_friend_add(Bobs[2], address, (uint8_t *)"gentoo", 7, NULL) != (uint32_t) ~0); | 240 | ck_assert(tox_friend_add(Bobs[2], address, (uint8_t *)"gentoo", 7, NULL) != (uint32_t) ~0); |
238 | 241 | ||
239 | uint8_t off = 1; | 242 | uint8_t off = 1; |
240 | 243 | ||
@@ -302,7 +305,7 @@ START_TEST(test_AV_three_calls) | |||
302 | (void) pthread_detach(tids[2]); | 305 | (void) pthread_detach(tids[2]); |
303 | 306 | ||
304 | time_t start_time = time(NULL); | 307 | time_t start_time = time(NULL); |
305 | while (time(NULL) - start_time < 10) { | 308 | while (time(NULL) - start_time < 5) { |
306 | tox_iterate(Alice); | 309 | tox_iterate(Alice); |
307 | tox_iterate(Bobs[0]); | 310 | tox_iterate(Bobs[0]); |
308 | tox_iterate(Bobs[1]); | 311 | tox_iterate(Bobs[1]); |
@@ -314,6 +317,7 @@ START_TEST(test_AV_three_calls) | |||
314 | (void) pthread_join(tids[1], NULL); | 317 | (void) pthread_join(tids[1], NULL); |
315 | (void) pthread_join(tids[2], NULL); | 318 | (void) pthread_join(tids[2], NULL); |
316 | 319 | ||
320 | printf ("Killing all instances\n"); | ||
317 | toxav_kill(BobsAV[0]); | 321 | toxav_kill(BobsAV[0]); |
318 | toxav_kill(BobsAV[1]); | 322 | toxav_kill(BobsAV[1]); |
319 | toxav_kill(BobsAV[2]); | 323 | toxav_kill(BobsAV[2]); |