summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--auto_tests/tox_test.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/auto_tests/tox_test.c b/auto_tests/tox_test.c
index 3e4cc127..c7d2f5f9 100644
--- a/auto_tests/tox_test.c
+++ b/auto_tests/tox_test.c
@@ -35,7 +35,10 @@ void print_message(Tox *m, int friendnumber, uint8_t *string, uint16_t length, v
35 if (*((uint32_t *)userdata) != 974536) 35 if (*((uint32_t *)userdata) != 974536)
36 return; 36 return;
37 37
38 if (length == sizeof("Install Gentoo") && memcmp(string, "Install Gentoo", sizeof("Install Gentoo")) == 0) 38 uint8_t cmp_msg[TOX_MAX_MESSAGE_LENGTH];
39 memset(cmp_msg, 'G', sizeof(cmp_msg));
40
41 if (length == TOX_MAX_MESSAGE_LENGTH && memcmp(string, cmp_msg, sizeof(cmp_msg)) == 0)
39 ++messages_received; 42 ++messages_received;
40} 43}
41 44
@@ -150,7 +153,11 @@ START_TEST(test_few_clients)
150 printf("tox clients connected took %llu seconds\n", time(NULL) - con_time); 153 printf("tox clients connected took %llu seconds\n", time(NULL) - con_time);
151 to_compare = 974536; 154 to_compare = 974536;
152 tox_callback_friend_message(tox3, print_message, &to_compare); 155 tox_callback_friend_message(tox3, print_message, &to_compare);
153 tox_send_message(tox2, 0, (uint8_t *)"Install Gentoo", sizeof("Install Gentoo")); 156 uint8_t msgs[TOX_MAX_MESSAGE_LENGTH + 1];
157 memset(msgs, 'G', sizeof(msgs));
158 ck_assert_msg(tox_send_message(tox2, 0, msgs, TOX_MAX_MESSAGE_LENGTH + 1) == 0,
159 "TOX_MAX_MESSAGE_LENGTH is too small\n");
160 ck_assert_msg(tox_send_message(tox2, 0, msgs, TOX_MAX_MESSAGE_LENGTH) != 0, "TOX_MAX_MESSAGE_LENGTH is too big\n");
154 161
155 while (1) { 162 while (1) {
156 messages_received = 0; 163 messages_received = 0;
@@ -261,6 +268,7 @@ START_TEST(test_few_clients)
261 uint32_t tox1_interval = tox_do_interval(tox1); 268 uint32_t tox1_interval = tox_do_interval(tox1);
262 uint32_t tox2_interval = tox_do_interval(tox2); 269 uint32_t tox2_interval = tox_do_interval(tox2);
263 uint32_t tox3_interval = tox_do_interval(tox3); 270 uint32_t tox3_interval = tox_do_interval(tox3);
271
264 if (tox2_interval > tox3_interval) { 272 if (tox2_interval > tox3_interval) {
265 c_sleep(tox3_interval); 273 c_sleep(tox3_interval);
266 } else { 274 } else {