summaryrefslogtreecommitdiff
path: root/auto_tests
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2015-03-13 15:29:34 -0400
committerirungentoo <irungentoo@gmail.com>2015-03-13 15:29:34 -0400
commit8e2957ec50fda43b8e7a705081e63c19d70107e1 (patch)
tree4256c0696b89f6d6fc9ce7a175acc77cea2c8b1a /auto_tests
parent96d9cef66c551feae380596d77e6f120525ad0ca (diff)
parent64fefb6f43e9213db9f3313aa7e8af7c36bf8538 (diff)
Merge branch 'newer_api' of https://github.com/dubslow/toxcore into new_api
Diffstat (limited to 'auto_tests')
-rw-r--r--auto_tests/tox_test.c110
-rw-r--r--auto_tests/toxav_basic_test.c26
-rw-r--r--auto_tests/toxav_many_test.c16
3 files changed, 76 insertions, 76 deletions
diff --git a/auto_tests/tox_test.c b/auto_tests/tox_test.c
index 0b7f976b..0303c128 100644
--- a/auto_tests/tox_test.c
+++ b/auto_tests/tox_test.c
@@ -123,10 +123,10 @@ void tox_file_receive(Tox *tox, uint32_t friend_number, uint32_t file_number, TO
123 123
124 TOX_ERR_FILE_CONTROL error; 124 TOX_ERR_FILE_CONTROL error;
125 125
126 if (tox_file_control(tox, friend_number, file_number, TOX_FILE_CONTROL_RESUME, &error)) { 126 if (tox_file_send_control(tox, friend_number, file_number, TOX_FILE_CONTROL_RESUME, &error)) {
127 ++file_accepted; 127 ++file_accepted;
128 } else { 128 } else {
129 ck_abort_msg("tox_file_control failed. %i", error); 129 ck_abort_msg("tox_file_send_control failed. %i", error);
130 } 130 }
131} 131}
132 132
@@ -231,7 +231,7 @@ START_TEST(test_one)
231 231
232 { 232 {
233 TOX_ERR_GET_PORT error; 233 TOX_ERR_GET_PORT error;
234 ck_assert_msg(tox_get_udp_port(tox1, &error) == 33445, "First Tox instance did not bind to udp port 33445.\n"); 234 ck_assert_msg(tox_self_get_udp_port(tox1, &error) == 33445, "First Tox instance did not bind to udp port 33445.\n");
235 ck_assert_msg(error == TOX_ERR_GET_PORT_OK, "wrong error"); 235 ck_assert_msg(error == TOX_ERR_GET_PORT_OK, "wrong error");
236 } 236 }
237 237
@@ -308,19 +308,19 @@ START_TEST(test_few_clients)
308 308
309 { 309 {
310 TOX_ERR_GET_PORT error; 310 TOX_ERR_GET_PORT error;
311 ck_assert_msg(tox_get_udp_port(tox1, &error) == 33445, "First Tox instance did not bind to udp port 33445.\n"); 311 ck_assert_msg(tox_self_get_udp_port(tox1, &error) == 33445, "First Tox instance did not bind to udp port 33445.\n");
312 ck_assert_msg(error == TOX_ERR_GET_PORT_OK, "wrong error"); 312 ck_assert_msg(error == TOX_ERR_GET_PORT_OK, "wrong error");
313 } 313 }
314 314
315 { 315 {
316 TOX_ERR_GET_PORT error; 316 TOX_ERR_GET_PORT error;
317 ck_assert_msg(tox_get_udp_port(tox2, &error) == 33446, "Second Tox instance did not bind to udp port 33446.\n"); 317 ck_assert_msg(tox_self_get_udp_port(tox2, &error) == 33446, "Second Tox instance did not bind to udp port 33446.\n");
318 ck_assert_msg(error == TOX_ERR_GET_PORT_OK, "wrong error"); 318 ck_assert_msg(error == TOX_ERR_GET_PORT_OK, "wrong error");
319 } 319 }
320 320
321 { 321 {
322 TOX_ERR_GET_PORT error; 322 TOX_ERR_GET_PORT error;
323 ck_assert_msg(tox_get_udp_port(tox3, &error) == 33447, "Third Tox instance did not bind to udp port 33447.\n"); 323 ck_assert_msg(tox_self_get_udp_port(tox3, &error) == 33447, "Third Tox instance did not bind to udp port 33447.\n");
324 ck_assert_msg(error == TOX_ERR_GET_PORT_OK, "wrong error"); 324 ck_assert_msg(error == TOX_ERR_GET_PORT_OK, "wrong error");
325 } 325 }
326 326
@@ -336,9 +336,9 @@ START_TEST(test_few_clients)
336 uint8_t off = 1; 336 uint8_t off = 1;
337 337
338 while (1) { 338 while (1) {
339 tox_iteration(tox1); 339 tox_iterate(tox1);
340 tox_iteration(tox2); 340 tox_iterate(tox2);
341 tox_iteration(tox3); 341 tox_iterate(tox3);
342 342
343 if (tox_get_connection_status(tox1) && tox_get_connection_status(tox2) && tox_get_connection_status(tox3)) { 343 if (tox_get_connection_status(tox1) && tox_get_connection_status(tox2) && tox_get_connection_status(tox3)) {
344 if (off) { 344 if (off) {
@@ -361,17 +361,17 @@ START_TEST(test_few_clients)
361 tox_callback_friend_message(tox3, print_message, &to_compare); 361 tox_callback_friend_message(tox3, print_message, &to_compare);
362 uint8_t msgs[TOX_MAX_MESSAGE_LENGTH + 1]; 362 uint8_t msgs[TOX_MAX_MESSAGE_LENGTH + 1];
363 memset(msgs, 'G', sizeof(msgs)); 363 memset(msgs, 'G', sizeof(msgs));
364 TOX_ERR_SEND_MESSAGE errm; 364 TOX_ERR_FRIEND_SEND_MESSAGE errm;
365 tox_send_message(tox2, 0, msgs, TOX_MAX_MESSAGE_LENGTH + 1, &errm); 365 tox_friend_send_message(tox2, 0, msgs, TOX_MAX_MESSAGE_LENGTH + 1, &errm);
366 ck_assert_msg(errm == TOX_ERR_SEND_MESSAGE_TOO_LONG, "TOX_MAX_MESSAGE_LENGTH is too small\n"); 366 ck_assert_msg(errm == TOX_ERR_FRIEND_SEND_MESSAGE_TOO_LONG, "TOX_MAX_MESSAGE_LENGTH is too small\n");
367 tox_send_message(tox2, 0, msgs, TOX_MAX_MESSAGE_LENGTH, &errm); 367 tox_friend_send_message(tox2, 0, msgs, TOX_MAX_MESSAGE_LENGTH, &errm);
368 ck_assert_msg(errm == TOX_ERR_SEND_MESSAGE_OK, "TOX_MAX_MESSAGE_LENGTH is too big\n"); 368 ck_assert_msg(errm == TOX_ERR_FRIEND_SEND_MESSAGE_OK, "TOX_MAX_MESSAGE_LENGTH is too big\n");
369 369
370 while (1) { 370 while (1) {
371 messages_received = 0; 371 messages_received = 0;
372 tox_iteration(tox1); 372 tox_iterate(tox1);
373 tox_iteration(tox2); 373 tox_iterate(tox2);
374 tox_iteration(tox3); 374 tox_iterate(tox3);
375 375
376 if (messages_received) 376 if (messages_received)
377 break; 377 break;
@@ -388,9 +388,9 @@ START_TEST(test_few_clients)
388 388
389 while (1) { 389 while (1) {
390 name_changes = 0; 390 name_changes = 0;
391 tox_iteration(tox1); 391 tox_iterate(tox1);
392 tox_iteration(tox2); 392 tox_iterate(tox2);
393 tox_iteration(tox3); 393 tox_iterate(tox3);
394 394
395 if (name_changes) 395 if (name_changes)
396 break; 396 break;
@@ -409,9 +409,9 @@ START_TEST(test_few_clients)
409 409
410 while (1) { 410 while (1) {
411 status_m_changes = 0; 411 status_m_changes = 0;
412 tox_iteration(tox1); 412 tox_iterate(tox1);
413 tox_iteration(tox2); 413 tox_iterate(tox2);
414 tox_iteration(tox3); 414 tox_iterate(tox3);
415 415
416 if (status_m_changes) 416 if (status_m_changes)
417 break; 417 break;
@@ -431,9 +431,9 @@ START_TEST(test_few_clients)
431 431
432 while (1) { 432 while (1) {
433 typing_changes = 0; 433 typing_changes = 0;
434 tox_iteration(tox1); 434 tox_iterate(tox1);
435 tox_iteration(tox2); 435 tox_iterate(tox2);
436 tox_iteration(tox3); 436 tox_iterate(tox3);
437 437
438 438
439 if (typing_changes == 2) 439 if (typing_changes == 2)
@@ -449,9 +449,9 @@ START_TEST(test_few_clients)
449 449
450 while (1) { 450 while (1) {
451 typing_changes = 0; 451 typing_changes = 0;
452 tox_iteration(tox1); 452 tox_iterate(tox1);
453 tox_iteration(tox2); 453 tox_iterate(tox2);
454 tox_iteration(tox3); 454 tox_iterate(tox3);
455 455
456 if (typing_changes == 1) 456 if (typing_changes == 1)
457 break; 457 break;
@@ -469,16 +469,16 @@ START_TEST(test_few_clients)
469 tox_callback_friend_lossless_packet(tox3, &handle_custom_packet, &packet_number); 469 tox_callback_friend_lossless_packet(tox3, &handle_custom_packet, &packet_number);
470 uint8_t data_c[TOX_MAX_CUSTOM_PACKET_SIZE + 1]; 470 uint8_t data_c[TOX_MAX_CUSTOM_PACKET_SIZE + 1];
471 memset(data_c, ((uint8_t)packet_number), sizeof(data_c)); 471 memset(data_c, ((uint8_t)packet_number), sizeof(data_c));
472 int ret = tox_send_lossless_packet(tox2, 0, data_c, sizeof(data_c), 0); 472 int ret = tox_friend_send_lossless_packet(tox2, 0, data_c, sizeof(data_c), 0);
473 ck_assert_msg(ret == 0, "tox_send_lossless_packet bigger fail %i", ret); 473 ck_assert_msg(ret == 0, "tox_friend_send_lossless_packet bigger fail %i", ret);
474 ret = tox_send_lossless_packet(tox2, 0, data_c, TOX_MAX_CUSTOM_PACKET_SIZE, 0); 474 ret = tox_friend_send_lossless_packet(tox2, 0, data_c, TOX_MAX_CUSTOM_PACKET_SIZE, 0);
475 ck_assert_msg(ret == 1, "tox_send_lossless_packet fail %i", ret); 475 ck_assert_msg(ret == 1, "tox_friend_send_lossless_packet fail %i", ret);
476 476
477 while (1) { 477 while (1) {
478 custom_packet = 0; 478 custom_packet = 0;
479 tox_iteration(tox1); 479 tox_iterate(tox1);
480 tox_iteration(tox2); 480 tox_iterate(tox2);
481 tox_iteration(tox3); 481 tox_iterate(tox3);
482 482
483 if (custom_packet == 1) 483 if (custom_packet == 1)
484 break; 484 break;
@@ -491,16 +491,16 @@ START_TEST(test_few_clients)
491 packet_number = 200; 491 packet_number = 200;
492 tox_callback_friend_lossy_packet(tox3, &handle_custom_packet, &packet_number); 492 tox_callback_friend_lossy_packet(tox3, &handle_custom_packet, &packet_number);
493 memset(data_c, ((uint8_t)packet_number), sizeof(data_c)); 493 memset(data_c, ((uint8_t)packet_number), sizeof(data_c));
494 ret = tox_send_lossy_packet(tox2, 0, data_c, sizeof(data_c), 0); 494 ret = tox_friend_send_lossy_packet(tox2, 0, data_c, sizeof(data_c), 0);
495 ck_assert_msg(ret == 0, "tox_send_lossy_packet bigger fail %i", ret); 495 ck_assert_msg(ret == 0, "tox_friend_send_lossy_packet bigger fail %i", ret);
496 ret = tox_send_lossy_packet(tox2, 0, data_c, TOX_MAX_CUSTOM_PACKET_SIZE, 0); 496 ret = tox_friend_send_lossy_packet(tox2, 0, data_c, TOX_MAX_CUSTOM_PACKET_SIZE, 0);
497 ck_assert_msg(ret == 1, "tox_send_lossy_packet fail %i", ret); 497 ck_assert_msg(ret == 1, "tox_friend_send_lossy_packet fail %i", ret);
498 498
499 while (1) { 499 while (1) {
500 custom_packet = 0; 500 custom_packet = 0;
501 tox_iteration(tox1); 501 tox_iterate(tox1);
502 tox_iteration(tox2); 502 tox_iterate(tox2);
503 tox_iteration(tox3); 503 tox_iterate(tox3);
504 504
505 if (custom_packet == 1) 505 if (custom_packet == 1)
506 break; 506 break;
@@ -515,9 +515,9 @@ START_TEST(test_few_clients)
515 file_accepted = file_size = file_recv = sendf_ok = size_recv = 0; 515 file_accepted = file_size = file_recv = sendf_ok = size_recv = 0;
516 long long unsigned int f_time = time(NULL); 516 long long unsigned int f_time = time(NULL);
517 tox_callback_file_receive_chunk(tox3, write_file, &to_compare); 517 tox_callback_file_receive_chunk(tox3, write_file, &to_compare);
518 tox_callback_file_control(tox2, file_print_control, &to_compare); 518 tox_callback_file_recv_control(tox2, file_print_control, &to_compare);
519 tox_callback_file_request_chunk(tox2, tox_file_request_chunk, &to_compare); 519 tox_callback_file_request_chunk(tox2, tox_file_request_chunk, &to_compare);
520 tox_callback_file_control(tox3, file_print_control, &to_compare); 520 tox_callback_file_recv_control(tox3, file_print_control, &to_compare);
521 tox_callback_file_receive(tox3, tox_file_receive, &to_compare); 521 tox_callback_file_receive(tox3, tox_file_receive, &to_compare);
522 uint64_t totalf_size = 100 * 1024 * 1024; 522 uint64_t totalf_size = 100 * 1024 * 1024;
523 uint32_t fnum = tox_file_send(tox2, 0, TOX_FILE_KIND_DATA, totalf_size, (uint8_t *)"Gentoo.exe", sizeof("Gentoo.exe"), 523 uint32_t fnum = tox_file_send(tox2, 0, TOX_FILE_KIND_DATA, totalf_size, (uint8_t *)"Gentoo.exe", sizeof("Gentoo.exe"),
@@ -526,9 +526,9 @@ START_TEST(test_few_clients)
526 526
527 527
528 while (1) { 528 while (1) {
529 tox_iteration(tox1); 529 tox_iterate(tox1);
530 tox_iteration(tox2); 530 tox_iterate(tox2);
531 tox_iteration(tox3); 531 tox_iterate(tox3);
532 532
533 if (file_sending_done) { 533 if (file_sending_done) {
534 if (sendf_ok && file_recv && totalf_size == file_size && size_recv == file_size && sending_pos == size_recv) { 534 if (sendf_ok && file_recv && totalf_size == file_size && size_recv == file_size && sending_pos == size_recv) {
@@ -578,7 +578,7 @@ START_TEST(test_many_clients)
578 578
579 { 579 {
580 TOX_ERR_GET_PORT error; 580 TOX_ERR_GET_PORT error;
581 ck_assert_msg(tox_get_udp_port(toxes[0], &error) == 33445, "First Tox instance did not bind to udp port 33445.\n"); 581 ck_assert_msg(tox_self_get_udp_port(toxes[0], &error) == 33445, "First Tox instance did not bind to udp port 33445.\n");
582 ck_assert_msg(error == TOX_ERR_GET_PORT_OK, "wrong error"); 582 ck_assert_msg(error == TOX_ERR_GET_PORT_OK, "wrong error");
583 } 583 }
584 584
@@ -625,7 +625,7 @@ loop_top:
625 } 625 }
626 626
627 for (i = 0; i < NUM_TOXES; ++i) { 627 for (i = 0; i < NUM_TOXES; ++i) {
628 tox_iteration(toxes[i]); 628 tox_iterate(toxes[i]);
629 } 629 }
630 630
631 c_sleep(50); 631 c_sleep(50);
@@ -706,7 +706,7 @@ START_TEST(test_many_group)
706 706
707 { 707 {
708 TOX_ERR_GET_PORT error; 708 TOX_ERR_GET_PORT error;
709 ck_assert_msg(tox_get_udp_port(toxes[0], &error) == 33445, "First Tox instance did not bind to udp port 33445.\n"); 709 ck_assert_msg(tox_self_get_udp_port(toxes[0], &error) == 33445, "First Tox instance did not bind to udp port 33445.\n");
710 ck_assert_msg(error == TOX_ERR_GET_PORT_OK, "wrong error"); 710 ck_assert_msg(error == TOX_ERR_GET_PORT_OK, "wrong error");
711 } 711 }
712 712
@@ -730,7 +730,7 @@ START_TEST(test_many_group)
730 break; 730 break;
731 731
732 for (i = 0; i < NUM_GROUP_TOX; ++i) { 732 for (i = 0; i < NUM_GROUP_TOX; ++i) {
733 tox_iteration(toxes[i]); 733 tox_iterate(toxes[i]);
734 } 734 }
735 735
736 c_sleep(50); 736 c_sleep(50);
@@ -748,7 +748,7 @@ START_TEST(test_many_group)
748 748
749 while (1) { 749 while (1) {
750 for (i = 0; i < NUM_GROUP_TOX; ++i) { 750 for (i = 0; i < NUM_GROUP_TOX; ++i) {
751 tox_iteration(toxes[i]); 751 tox_iterate(toxes[i]);
752 } 752 }
753 753
754 if (!invite_counter) { 754 if (!invite_counter) {
@@ -786,7 +786,7 @@ START_TEST(test_many_group)
786 786
787 for (j = 0; j < 20; ++j) { 787 for (j = 0; j < 20; ++j) {
788 for (i = 0; i < NUM_GROUP_TOX; ++i) { 788 for (i = 0; i < NUM_GROUP_TOX; ++i) {
789 tox_iteration(toxes[i]); 789 tox_iterate(toxes[i]);
790 } 790 }
791 791
792 c_sleep(50); 792 c_sleep(50);
@@ -799,7 +799,7 @@ START_TEST(test_many_group)
799 799
800 for (j = 0; j < 10; ++j) { 800 for (j = 0; j < 10; ++j) {
801 for (i = 0; i < NUM_GROUP_TOX; ++i) { 801 for (i = 0; i < NUM_GROUP_TOX; ++i) {
802 tox_iteration(toxes[i]); 802 tox_iterate(toxes[i]);
803 } 803 }
804 804
805 c_sleep(50); 805 c_sleep(50);
diff --git a/auto_tests/toxav_basic_test.c b/auto_tests/toxav_basic_test.c
index 59730edf..3f4a3b8d 100644
--- a/auto_tests/toxav_basic_test.c
+++ b/auto_tests/toxav_basic_test.c
@@ -232,7 +232,7 @@ void register_callbacks(ToxAv *av, void *data)
232 */ 232 */
233#define CALL_AND_START_LOOP(AliceCallType, BobCallType) \ 233#define CALL_AND_START_LOOP(AliceCallType, BobCallType) \
234{ int step = 0, running = 1; while (running) {\ 234{ int step = 0, running = 1; while (running) {\
235 tox_iteration(bootstrap_node); tox_iteration(Alice); tox_iteration(Bob); \ 235 tox_iterate(bootstrap_node); tox_iterate(Alice); tox_iterate(Bob); \
236 toxav_do(status_control.Bob.av); toxav_do(status_control.Alice.av); \ 236 toxav_do(status_control.Bob.av); toxav_do(status_control.Alice.av); \
237 switch ( step ) {\ 237 switch ( step ) {\
238 case 0: /* Alice */ printf("Alice is calling...\n");\ 238 case 0: /* Alice */ printf("Alice is calling...\n");\
@@ -267,9 +267,9 @@ START_TEST(test_AV_flows)
267 uint8_t off = 1; 267 uint8_t off = 1;
268 268
269 while (1) { 269 while (1) {
270 tox_iteration(bootstrap_node); 270 tox_iterate(bootstrap_node);
271 tox_iteration(Alice); 271 tox_iterate(Alice);
272 tox_iteration(Bob); 272 tox_iterate(Bob);
273 273
274 if (tox_get_connection_status(bootstrap_node) && tox_get_connection_status(Alice) && tox_get_connection_status(Bob) 274 if (tox_get_connection_status(bootstrap_node) && tox_get_connection_status(Alice) && tox_get_connection_status(Bob)
275 && off) { 275 && off) {
@@ -484,9 +484,9 @@ START_TEST(test_AV_flows)
484 int running = 1; 484 int running = 1;
485 485
486 while (running) { 486 while (running) {
487 tox_iteration(bootstrap_node); 487 tox_iterate(bootstrap_node);
488 tox_iteration(Alice); 488 tox_iterate(Alice);
489 tox_iteration(Bob); 489 tox_iterate(Bob);
490 490
491 switch ( step ) { 491 switch ( step ) {
492 case 0: /* Alice */ 492 case 0: /* Alice */
@@ -525,9 +525,9 @@ START_TEST(test_AV_flows)
525 int running = 1; 525 int running = 1;
526 526
527 while (running) { 527 while (running) {
528 tox_iteration(bootstrap_node); 528 tox_iterate(bootstrap_node);
529 tox_iteration(Alice); 529 tox_iterate(Alice);
530 tox_iteration(Bob); 530 tox_iterate(Bob);
531 531
532 toxav_do(status_control.Alice.av); 532 toxav_do(status_control.Alice.av);
533 toxav_do(status_control.Bob.av); 533 toxav_do(status_control.Bob.av);
@@ -570,9 +570,9 @@ START_TEST(test_AV_flows)
570 int running = 1; 570 int running = 1;
571 571
572 while (running) { 572 while (running) {
573 tox_iteration(bootstrap_node); 573 tox_iterate(bootstrap_node);
574 tox_iteration(Alice); 574 tox_iterate(Alice);
575 tox_iteration(Bob); 575 tox_iterate(Bob);
576 576
577 toxav_do(status_control.Alice.av); 577 toxav_do(status_control.Alice.av);
578 toxav_do(status_control.Bob.av); 578 toxav_do(status_control.Bob.av);
diff --git a/auto_tests/toxav_many_test.c b/auto_tests/toxav_many_test.c
index 4002c4e7..f22043e1 100644
--- a/auto_tests/toxav_many_test.c
+++ b/auto_tests/toxav_many_test.c
@@ -294,11 +294,11 @@ START_TEST(test_AV_three_calls)
294 uint8_t off = 1; 294 uint8_t off = 1;
295 295
296 while (1) { 296 while (1) {
297 tox_iteration(bootstrap_node); 297 tox_iterate(bootstrap_node);
298 tox_iteration(caller); 298 tox_iterate(caller);
299 299
300 for (i = 0; i < 3; i ++) { 300 for (i = 0; i < 3; i ++) {
301 tox_iteration(callees[i]); 301 tox_iterate(callees[i]);
302 } 302 }
303 303
304 304
@@ -351,11 +351,11 @@ START_TEST(test_AV_three_calls)
351 while (call_running[0] || call_running[1] || call_running[2]) { 351 while (call_running[0] || call_running[1] || call_running[2]) {
352 pthread_mutex_lock(&muhmutex); 352 pthread_mutex_lock(&muhmutex);
353 353
354 tox_iteration(bootstrap_node); 354 tox_iterate(bootstrap_node);
355 tox_iteration(caller); 355 tox_iterate(caller);
356 tox_iteration(callees[0]); 356 tox_iterate(callees[0]);
357 tox_iteration(callees[1]); 357 tox_iterate(callees[1]);
358 tox_iteration(callees[2]); 358 tox_iterate(callees[2]);
359 359
360 for ( i = 0; i < 3; i++ ) 360 for ( i = 0; i < 3; i++ )
361 toxav_do(status_control.calls[0].Caller.av); 361 toxav_do(status_control.calls[0].Caller.av);