diff options
author | iphydf <iphydf@users.noreply.github.com> | 2016-11-05 16:52:41 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2016-11-06 20:35:09 +0000 |
commit | 82515f92eecde2dffc0659519317d00459a09239 (patch) | |
tree | f17b9afe68fdd475be368623d58c7f51e8cc0ba2 /auto_tests | |
parent | fcc8ad943e93308b7048c4e0071ae00b54804934 (diff) |
Move log callback to options.
Previously, all log messages generated by tox_new (which is quite a lot)
were dropped, because client code had no chance to register a logging
callback, yet. This change allows setting the log callback from the
beginning and removes the ability to unset it.
Since the log callback is forever special, since it can't be stateless,
we don't necessarily need to treat it uniformly (with `event`).
Diffstat (limited to 'auto_tests')
-rw-r--r-- | auto_tests/conference_test.c | 6 | ||||
-rw-r--r-- | auto_tests/encryptsave_test.c | 10 | ||||
-rw-r--r-- | auto_tests/helpers.h | 51 | ||||
-rw-r--r-- | auto_tests/messenger_test.c | 2 | ||||
-rw-r--r-- | auto_tests/tox_many_tcp_test.c | 8 | ||||
-rw-r--r-- | auto_tests/tox_many_test.c | 4 | ||||
-rw-r--r-- | auto_tests/tox_one_test.c | 9 | ||||
-rw-r--r-- | auto_tests/tox_test.c | 9 | ||||
-rw-r--r-- | auto_tests/toxav_basic_test.c | 28 | ||||
-rw-r--r-- | auto_tests/toxav_many_test.c | 32 |
10 files changed, 92 insertions, 67 deletions
diff --git a/auto_tests/conference_test.c b/auto_tests/conference_test.c index fba64bcc..aa2f8e13 100644 --- a/auto_tests/conference_test.c +++ b/auto_tests/conference_test.c | |||
@@ -7,7 +7,6 @@ | |||
7 | 7 | ||
8 | #include <check.h> | 8 | #include <check.h> |
9 | #include <inttypes.h> | 9 | #include <inttypes.h> |
10 | #include <stdio.h> | ||
11 | #include <stdlib.h> | 10 | #include <stdlib.h> |
12 | #include <time.h> | 11 | #include <time.h> |
13 | 12 | ||
@@ -91,13 +90,16 @@ group_test_restart: | |||
91 | ; | 90 | ; |
92 | 91 | ||
93 | Tox *toxes[NUM_GROUP_TOX]; | 92 | Tox *toxes[NUM_GROUP_TOX]; |
93 | uint32_t tox_index[NUM_GROUP_TOX]; | ||
94 | unsigned int i, j, k; | 94 | unsigned int i, j, k; |
95 | uint32_t to_comp = 234212; | 95 | uint32_t to_comp = 234212; |
96 | int test_run = 0; | 96 | int test_run = 0; |
97 | long long unsigned int cur_time = time(NULL); | 97 | long long unsigned int cur_time = time(NULL); |
98 | 98 | ||
99 | for (i = 0; i < NUM_GROUP_TOX; ++i) { | 99 | for (i = 0; i < NUM_GROUP_TOX; ++i) { |
100 | toxes[i] = tox_new(0, 0); | 100 | tox_index[i] = i + 1; |
101 | toxes[i] = tox_new_log(0, 0, &tox_index[i]); | ||
102 | |||
101 | ck_assert_msg(toxes[i] != 0, "Failed to create tox instances %u", i); | 103 | ck_assert_msg(toxes[i] != 0, "Failed to create tox instances %u", i); |
102 | tox_callback_friend_request(toxes[i], &g_accept_friend_request); | 104 | tox_callback_friend_request(toxes[i], &g_accept_friend_request); |
103 | tox_callback_conference_invite(toxes[i], &print_group_invite_callback); | 105 | tox_callback_conference_invite(toxes[i], &print_group_invite_callback); |
diff --git a/auto_tests/encryptsave_test.c b/auto_tests/encryptsave_test.c index 2a2827da..fcdef3e6 100644 --- a/auto_tests/encryptsave_test.c +++ b/auto_tests/encryptsave_test.c | |||
@@ -56,8 +56,8 @@ END_TEST | |||
56 | 56 | ||
57 | START_TEST(test_save_friend) | 57 | START_TEST(test_save_friend) |
58 | { | 58 | { |
59 | Tox *tox1 = tox_new(0, 0); | 59 | Tox *tox1 = tox_new_log(0, 0, 0); |
60 | Tox *tox2 = tox_new(0, 0); | 60 | Tox *tox2 = tox_new_log(0, 0, 0); |
61 | ck_assert_msg(tox1 || tox2, "Failed to create 2 tox instances"); | 61 | ck_assert_msg(tox1 || tox2, "Failed to create 2 tox instances"); |
62 | tox_callback_friend_request(tox2, accept_friend_request); | 62 | tox_callback_friend_request(tox2, accept_friend_request); |
63 | uint8_t address[TOX_ADDRESS_SIZE]; | 63 | uint8_t address[TOX_ADDRESS_SIZE]; |
@@ -82,7 +82,7 @@ START_TEST(test_save_friend) | |||
82 | options.savedata_length = size2; | 82 | options.savedata_length = size2; |
83 | 83 | ||
84 | TOX_ERR_NEW err2; | 84 | TOX_ERR_NEW err2; |
85 | Tox *tox3 = tox_new(&options, &err2); | 85 | Tox *tox3 = tox_new_log(&options, &err2, 0); |
86 | ck_assert_msg(err2 == TOX_ERR_NEW_LOAD_ENCRYPTED, "wrong error! %u. should fail with %u", err2, | 86 | ck_assert_msg(err2 == TOX_ERR_NEW_LOAD_ENCRYPTED, "wrong error! %u. should fail with %u", err2, |
87 | TOX_ERR_NEW_LOAD_ENCRYPTED); | 87 | TOX_ERR_NEW_LOAD_ENCRYPTED); |
88 | ck_assert_msg(tox3 == NULL, "tox_new with error should return NULL"); | 88 | ck_assert_msg(tox3 == NULL, "tox_new with error should return NULL"); |
@@ -92,7 +92,7 @@ START_TEST(test_save_friend) | |||
92 | ck_assert_msg(ret, "failed to decrypt save: %u", err3); | 92 | ck_assert_msg(ret, "failed to decrypt save: %u", err3); |
93 | options.savedata_data = dec_data; | 93 | options.savedata_data = dec_data; |
94 | options.savedata_length = size; | 94 | options.savedata_length = size; |
95 | tox3 = tox_new(&options, &err2); | 95 | tox3 = tox_new_log(&options, &err2, 0); |
96 | ck_assert_msg(err2 == TOX_ERR_NEW_OK, "failed to load from decrypted data: %u", err2); | 96 | ck_assert_msg(err2 == TOX_ERR_NEW_OK, "failed to load from decrypted data: %u", err2); |
97 | uint8_t address2[TOX_PUBLIC_KEY_SIZE]; | 97 | uint8_t address2[TOX_PUBLIC_KEY_SIZE]; |
98 | ret = tox_friend_get_public_key(tox3, 0, address2, 0); | 98 | ret = tox_friend_get_public_key(tox3, 0, address2, 0); |
@@ -122,7 +122,7 @@ START_TEST(test_save_friend) | |||
122 | // to remove the manual check now that it's there) | 122 | // to remove the manual check now that it's there) |
123 | options.savedata_data = out1; | 123 | options.savedata_data = out1; |
124 | options.savedata_length = size; | 124 | options.savedata_length = size; |
125 | Tox *tox4 = tox_new(&options, &err2); | 125 | Tox *tox4 = tox_new_log(&options, &err2, 0); |
126 | ck_assert_msg(err2 == TOX_ERR_NEW_OK, "failed to new the third"); | 126 | ck_assert_msg(err2 == TOX_ERR_NEW_OK, "failed to new the third"); |
127 | uint8_t address5[TOX_PUBLIC_KEY_SIZE]; | 127 | uint8_t address5[TOX_PUBLIC_KEY_SIZE]; |
128 | ret = tox_friend_get_public_key(tox4, 0, address5, 0); | 128 | ret = tox_friend_get_public_key(tox4, 0, address5, 0); |
diff --git a/auto_tests/helpers.h b/auto_tests/helpers.h index 9e8043db..99930e90 100644 --- a/auto_tests/helpers.h +++ b/auto_tests/helpers.h | |||
@@ -1,7 +1,10 @@ | |||
1 | #ifndef TOXCORE_TEST_HELPERS_H | 1 | #ifndef TOXCORE_TEST_HELPERS_H |
2 | #define TOXCORE_TEST_HELPERS_H | 2 | #define TOXCORE_TEST_HELPERS_H |
3 | 3 | ||
4 | #include "../toxcore/tox.h" | ||
5 | |||
4 | #include <check.h> | 6 | #include <check.h> |
7 | #include <stdio.h> | ||
5 | 8 | ||
6 | #define DEFTESTCASE(NAME) \ | 9 | #define DEFTESTCASE(NAME) \ |
7 | TCase *tc_##NAME = tcase_create(#NAME); \ | 10 | TCase *tc_##NAME = tcase_create(#NAME); \ |
@@ -12,4 +15,52 @@ | |||
12 | DEFTESTCASE(NAME) \ | 15 | DEFTESTCASE(NAME) \ |
13 | tcase_set_timeout(tc_##NAME, TIMEOUT); | 16 | tcase_set_timeout(tc_##NAME, TIMEOUT); |
14 | 17 | ||
18 | static const char *tox_log_level_name(TOX_LOG_LEVEL level) | ||
19 | { | ||
20 | switch (level) { | ||
21 | case TOX_LOG_LEVEL_TRACE: | ||
22 | return "TRACE"; | ||
23 | |||
24 | case TOX_LOG_LEVEL_DEBUG: | ||
25 | return "DEBUG"; | ||
26 | |||
27 | case TOX_LOG_LEVEL_INFO: | ||
28 | return "INFO"; | ||
29 | |||
30 | case TOX_LOG_LEVEL_WARNING: | ||
31 | return "WARNING"; | ||
32 | |||
33 | case TOX_LOG_LEVEL_ERROR: | ||
34 | return "ERROR"; | ||
35 | } | ||
36 | } | ||
37 | |||
38 | static void print_debug_log(Tox *m, TOX_LOG_LEVEL level, const char *path, uint32_t line, const char *func, | ||
39 | const char *message, void *user_data) | ||
40 | { | ||
41 | if (level == TOX_LOG_LEVEL_TRACE) { | ||
42 | return; | ||
43 | } | ||
44 | |||
45 | uint32_t index = user_data ? *(uint32_t *)user_data : 0; | ||
46 | const char *file = strrchr(path, '/'); | ||
47 | file = file ? file + 1 : path; | ||
48 | printf("[#%d] %s %s:%d\t%s:\t%s\n", index, tox_log_level_name(level), file, line, func, message); | ||
49 | } | ||
50 | |||
51 | Tox *tox_new_log(struct Tox_Options *options, TOX_ERR_NEW *err, void *log_user_data) | ||
52 | { | ||
53 | struct Tox_Options *my_options = tox_options_new(NULL); | ||
54 | |||
55 | if (options != NULL) { | ||
56 | *my_options = *options; | ||
57 | } | ||
58 | |||
59 | tox_options_set_log_callback(my_options, &print_debug_log); | ||
60 | tox_options_set_log_user_data(my_options, log_user_data); | ||
61 | Tox *tox = tox_new(my_options, err); | ||
62 | tox_options_free(my_options); | ||
63 | return tox; | ||
64 | } | ||
65 | |||
15 | #endif // TOXCORE_TEST_HELPERS_H | 66 | #endif // TOXCORE_TEST_HELPERS_H |
diff --git a/auto_tests/messenger_test.c b/auto_tests/messenger_test.c index 5d0be284..eed52a31 100644 --- a/auto_tests/messenger_test.c +++ b/auto_tests/messenger_test.c | |||
@@ -342,7 +342,7 @@ int main(int argc, char *argv[]) | |||
342 | /* IPv6 status from global define */ | 342 | /* IPv6 status from global define */ |
343 | Messenger_Options options = {0}; | 343 | Messenger_Options options = {0}; |
344 | options.ipv6enabled = TOX_ENABLE_IPV6_DEFAULT; | 344 | options.ipv6enabled = TOX_ENABLE_IPV6_DEFAULT; |
345 | m = new_messenger(NULL, &options, 0); | 345 | m = new_messenger(&options, 0); |
346 | 346 | ||
347 | /* setup a default friend and friendnum */ | 347 | /* setup a default friend and friendnum */ |
348 | if (m_addfriend_norequest(m, (uint8_t *)friend_id) < 0) { | 348 | if (m_addfriend_norequest(m, (uint8_t *)friend_id) < 0) { |
diff --git a/auto_tests/tox_many_tcp_test.c b/auto_tests/tox_many_tcp_test.c index 59d69c49..f802bf57 100644 --- a/auto_tests/tox_many_tcp_test.c +++ b/auto_tests/tox_many_tcp_test.c | |||
@@ -50,6 +50,7 @@ START_TEST(test_many_clients_tcp) | |||
50 | { | 50 | { |
51 | long long unsigned int cur_time = time(NULL); | 51 | long long unsigned int cur_time = time(NULL); |
52 | Tox *toxes[NUM_TOXES_TCP]; | 52 | Tox *toxes[NUM_TOXES_TCP]; |
53 | uint32_t index[NUM_TOXES_TCP]; | ||
53 | uint32_t i, j; | 54 | uint32_t i, j; |
54 | uint32_t to_comp = 974536; | 55 | uint32_t to_comp = 974536; |
55 | 56 | ||
@@ -63,7 +64,8 @@ START_TEST(test_many_clients_tcp) | |||
63 | opts.udp_enabled = 0; | 64 | opts.udp_enabled = 0; |
64 | } | 65 | } |
65 | 66 | ||
66 | toxes[i] = tox_new(&opts, 0); | 67 | index[i] = i + 1; |
68 | toxes[i] = tox_new_log(&opts, 0, &index[i]); | ||
67 | ck_assert_msg(toxes[i] != 0, "Failed to create tox instances %u", i); | 69 | ck_assert_msg(toxes[i] != 0, "Failed to create tox instances %u", i); |
68 | tox_callback_friend_request(toxes[i], accept_friend_request); | 70 | tox_callback_friend_request(toxes[i], accept_friend_request); |
69 | uint8_t dpk[TOX_PUBLIC_KEY_SIZE]; | 71 | uint8_t dpk[TOX_PUBLIC_KEY_SIZE]; |
@@ -149,6 +151,7 @@ START_TEST(test_many_clients_tcp_b) | |||
149 | { | 151 | { |
150 | long long unsigned int cur_time = time(NULL); | 152 | long long unsigned int cur_time = time(NULL); |
151 | Tox *toxes[NUM_TOXES_TCP]; | 153 | Tox *toxes[NUM_TOXES_TCP]; |
154 | uint32_t index[NUM_TOXES_TCP]; | ||
152 | uint32_t i, j; | 155 | uint32_t i, j; |
153 | uint32_t to_comp = 974536; | 156 | uint32_t to_comp = 974536; |
154 | 157 | ||
@@ -162,7 +165,8 @@ START_TEST(test_many_clients_tcp_b) | |||
162 | opts.udp_enabled = 0; | 165 | opts.udp_enabled = 0; |
163 | } | 166 | } |
164 | 167 | ||
165 | toxes[i] = tox_new(&opts, 0); | 168 | index[i] = i + 1; |
169 | toxes[i] = tox_new_log(&opts, 0, &index[i]); | ||
166 | ck_assert_msg(toxes[i] != 0, "Failed to create tox instances %u", i); | 170 | ck_assert_msg(toxes[i] != 0, "Failed to create tox instances %u", i); |
167 | tox_callback_friend_request(toxes[i], accept_friend_request); | 171 | tox_callback_friend_request(toxes[i], accept_friend_request); |
168 | uint8_t dpk[TOX_PUBLIC_KEY_SIZE]; | 172 | uint8_t dpk[TOX_PUBLIC_KEY_SIZE]; |
diff --git a/auto_tests/tox_many_test.c b/auto_tests/tox_many_test.c index fa657580..0c4c8c7d 100644 --- a/auto_tests/tox_many_test.c +++ b/auto_tests/tox_many_test.c | |||
@@ -42,11 +42,13 @@ START_TEST(test_many_clients) | |||
42 | { | 42 | { |
43 | long long unsigned int cur_time = time(NULL); | 43 | long long unsigned int cur_time = time(NULL); |
44 | Tox *toxes[NUM_TOXES]; | 44 | Tox *toxes[NUM_TOXES]; |
45 | uint32_t index[NUM_TOXES]; | ||
45 | uint32_t i, j; | 46 | uint32_t i, j; |
46 | uint32_t to_comp = 974536; | 47 | uint32_t to_comp = 974536; |
47 | 48 | ||
48 | for (i = 0; i < NUM_TOXES; ++i) { | 49 | for (i = 0; i < NUM_TOXES; ++i) { |
49 | toxes[i] = tox_new(0, 0); | 50 | index[i] = i + 1; |
51 | toxes[i] = tox_new_log(0, 0, &index[i]); | ||
50 | ck_assert_msg(toxes[i] != 0, "Failed to create tox instances %u", i); | 52 | ck_assert_msg(toxes[i] != 0, "Failed to create tox instances %u", i); |
51 | tox_callback_friend_request(toxes[i], accept_friend_request); | 53 | tox_callback_friend_request(toxes[i], accept_friend_request); |
52 | } | 54 | } |
diff --git a/auto_tests/tox_one_test.c b/auto_tests/tox_one_test.c index 1248de19..871aa443 100644 --- a/auto_tests/tox_one_test.c +++ b/auto_tests/tox_one_test.c | |||
@@ -26,8 +26,9 @@ START_TEST(test_one) | |||
26 | tox_options_free(o1); | 26 | tox_options_free(o1); |
27 | } | 27 | } |
28 | 28 | ||
29 | Tox *tox1 = tox_new(0, 0); | 29 | uint32_t index[] = { 1, 2 }; |
30 | Tox *tox2 = tox_new(0, 0); | 30 | Tox *tox1 = tox_new_log(0, 0, &index[0]); |
31 | Tox *tox2 = tox_new_log(0, 0, &index[1]); | ||
31 | 32 | ||
32 | { | 33 | { |
33 | TOX_ERR_GET_PORT error; | 34 | TOX_ERR_GET_PORT error; |
@@ -85,7 +86,7 @@ START_TEST(test_one) | |||
85 | options.savedata_type = TOX_SAVEDATA_TYPE_TOX_SAVE; | 86 | options.savedata_type = TOX_SAVEDATA_TYPE_TOX_SAVE; |
86 | options.savedata_data = data; | 87 | options.savedata_data = data; |
87 | options.savedata_length = save_size; | 88 | options.savedata_length = save_size; |
88 | tox2 = tox_new(&options, &err_n); | 89 | tox2 = tox_new_log(&options, &err_n, &index[1]); |
89 | ck_assert_msg(err_n == TOX_ERR_NEW_OK, "Load failed"); | 90 | ck_assert_msg(err_n == TOX_ERR_NEW_OK, "Load failed"); |
90 | 91 | ||
91 | ck_assert_msg(tox_self_get_name_size(tox2) == sizeof name, "Wrong name size."); | 92 | ck_assert_msg(tox_self_get_name_size(tox2) == sizeof name, "Wrong name size."); |
@@ -105,7 +106,7 @@ START_TEST(test_one) | |||
105 | options.savedata_type = TOX_SAVEDATA_TYPE_SECRET_KEY; | 106 | options.savedata_type = TOX_SAVEDATA_TYPE_SECRET_KEY; |
106 | options.savedata_data = sk; | 107 | options.savedata_data = sk; |
107 | options.savedata_length = sizeof(sk); | 108 | options.savedata_length = sizeof(sk); |
108 | tox2 = tox_new(&options, &err_n); | 109 | tox2 = tox_new_log(&options, &err_n, &index[1]); |
109 | ck_assert_msg(err_n == TOX_ERR_NEW_OK, "Load failed"); | 110 | ck_assert_msg(err_n == TOX_ERR_NEW_OK, "Load failed"); |
110 | uint8_t address3[TOX_ADDRESS_SIZE]; | 111 | uint8_t address3[TOX_ADDRESS_SIZE]; |
111 | tox_self_get_address(tox2, address3); | 112 | tox_self_get_address(tox2, address3); |
diff --git a/auto_tests/tox_test.c b/auto_tests/tox_test.c index 1bcb8d5e..2faa8cad 100644 --- a/auto_tests/tox_test.c +++ b/auto_tests/tox_test.c | |||
@@ -321,13 +321,14 @@ static void tox_connection_status(Tox *tox, TOX_CONNECTION connection_status, vo | |||
321 | 321 | ||
322 | START_TEST(test_few_clients) | 322 | START_TEST(test_few_clients) |
323 | { | 323 | { |
324 | uint32_t index[] = { 1, 2, 3 }; | ||
324 | long long unsigned int con_time = 0, cur_time = time(NULL); | 325 | long long unsigned int con_time = 0, cur_time = time(NULL); |
325 | TOX_ERR_NEW t_n_error; | 326 | TOX_ERR_NEW t_n_error; |
326 | Tox *tox1 = tox_new(0, &t_n_error); | 327 | Tox *tox1 = tox_new_log(0, &t_n_error, &index[0]); |
327 | ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "wrong error"); | 328 | ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "wrong error"); |
328 | Tox *tox2 = tox_new(0, &t_n_error); | 329 | Tox *tox2 = tox_new_log(0, &t_n_error, &index[1]); |
329 | ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "wrong error"); | 330 | ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "wrong error"); |
330 | Tox *tox3 = tox_new(0, &t_n_error); | 331 | Tox *tox3 = tox_new_log(0, &t_n_error, &index[2]); |
331 | ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "wrong error"); | 332 | ck_assert_msg(t_n_error == TOX_ERR_NEW_OK, "wrong error"); |
332 | 333 | ||
333 | ck_assert_msg(tox1 && tox2 && tox3, "Failed to create 3 tox instances"); | 334 | ck_assert_msg(tox1 && tox2 && tox3, "Failed to create 3 tox instances"); |
@@ -422,7 +423,7 @@ START_TEST(test_few_clients) | |||
422 | options.savedata_type = TOX_SAVEDATA_TYPE_TOX_SAVE; | 423 | options.savedata_type = TOX_SAVEDATA_TYPE_TOX_SAVE; |
423 | options.savedata_data = save1; | 424 | options.savedata_data = save1; |
424 | options.savedata_length = save_size1; | 425 | options.savedata_length = save_size1; |
425 | tox2 = tox_new(&options, NULL); | 426 | tox2 = tox_new_log(&options, NULL, &index[1]); |
426 | cur_time = time(NULL); | 427 | cur_time = time(NULL); |
427 | off = 1; | 428 | off = 1; |
428 | 429 | ||
diff --git a/auto_tests/toxav_basic_test.c b/auto_tests/toxav_basic_test.c index 860ad402..b5028da4 100644 --- a/auto_tests/toxav_basic_test.c +++ b/auto_tests/toxav_basic_test.c | |||
@@ -2,15 +2,7 @@ | |||
2 | #include "config.h" | 2 | #include "config.h" |
3 | #endif | 3 | #endif |
4 | 4 | ||
5 | #ifndef HAVE_LIBCHECK | 5 | #include "helpers.h" |
6 | # include <assert.h> | ||
7 | |||
8 | # define ck_assert(X) assert(X); | ||
9 | # define START_TEST(NAME) static void NAME (void) | ||
10 | # define END_TEST | ||
11 | #else | ||
12 | # include "helpers.h" | ||
13 | #endif | ||
14 | 6 | ||
15 | #include <stdint.h> | 7 | #include <stdint.h> |
16 | #include <stdio.h> | 8 | #include <stdio.h> |
@@ -149,19 +141,20 @@ START_TEST(test_AV_flows) | |||
149 | { | 141 | { |
150 | Tox *Alice, *Bob, *bootstrap; | 142 | Tox *Alice, *Bob, *bootstrap; |
151 | ToxAV *AliceAV, *BobAV; | 143 | ToxAV *AliceAV, *BobAV; |
144 | uint32_t index[] = { 1, 2, 3 }; | ||
152 | 145 | ||
153 | CallControl AliceCC, BobCC; | 146 | CallControl AliceCC, BobCC; |
154 | 147 | ||
155 | { | 148 | { |
156 | TOX_ERR_NEW error; | 149 | TOX_ERR_NEW error; |
157 | 150 | ||
158 | bootstrap = tox_new(NULL, &error); | 151 | bootstrap = tox_new_log(NULL, &error, &index[0]); |
159 | ck_assert(error == TOX_ERR_NEW_OK); | 152 | ck_assert(error == TOX_ERR_NEW_OK); |
160 | 153 | ||
161 | Alice = tox_new(NULL, &error); | 154 | Alice = tox_new_log(NULL, &error, &index[1]); |
162 | ck_assert(error == TOX_ERR_NEW_OK); | 155 | ck_assert(error == TOX_ERR_NEW_OK); |
163 | 156 | ||
164 | Bob = tox_new(NULL, &error); | 157 | Bob = tox_new_log(NULL, &error, &index[2]); |
165 | ck_assert(error == TOX_ERR_NEW_OK); | 158 | ck_assert(error == TOX_ERR_NEW_OK); |
166 | } | 159 | } |
167 | 160 | ||
@@ -591,16 +584,6 @@ START_TEST(test_AV_flows) | |||
591 | } | 584 | } |
592 | END_TEST | 585 | END_TEST |
593 | 586 | ||
594 | #ifndef HAVE_LIBCHECK | ||
595 | int main(int argc, char *argv[]) | ||
596 | { | ||
597 | (void) argc; | ||
598 | (void) argv; | ||
599 | |||
600 | test_AV_flows(); | ||
601 | return 0; | ||
602 | } | ||
603 | #else | ||
604 | static Suite *tox_suite(void) | 587 | static Suite *tox_suite(void) |
605 | { | 588 | { |
606 | Suite *s = suite_create("ToxAV"); | 589 | Suite *s = suite_create("ToxAV"); |
@@ -625,4 +608,3 @@ int main(int argc, char *argv[]) | |||
625 | 608 | ||
626 | return number_failed; | 609 | return number_failed; |
627 | } | 610 | } |
628 | #endif | ||
diff --git a/auto_tests/toxav_many_test.c b/auto_tests/toxav_many_test.c index 6f864f07..a351129a 100644 --- a/auto_tests/toxav_many_test.c +++ b/auto_tests/toxav_many_test.c | |||
@@ -2,15 +2,7 @@ | |||
2 | #include "config.h" | 2 | #include "config.h" |
3 | #endif | 3 | #endif |
4 | 4 | ||
5 | #ifndef HAVE_LIBCHECK | 5 | #include "helpers.h" |
6 | # include <assert.h> | ||
7 | |||
8 | # define ck_assert(X) assert(X); | ||
9 | # define START_TEST(NAME) static void NAME (void) | ||
10 | # define END_TEST | ||
11 | #else | ||
12 | # include "helpers.h" | ||
13 | #endif | ||
14 | 6 | ||
15 | #include <stdint.h> | 7 | #include <stdint.h> |
16 | #include <stdio.h> | 8 | #include <stdio.h> |
@@ -207,6 +199,7 @@ static void *call_thread(void *pd) | |||
207 | 199 | ||
208 | START_TEST(test_AV_three_calls) | 200 | START_TEST(test_AV_three_calls) |
209 | { | 201 | { |
202 | uint32_t index[] = { 1, 2, 3, 4, 5 }; | ||
210 | Tox *Alice, *bootstrap, *Bobs[3]; | 203 | Tox *Alice, *bootstrap, *Bobs[3]; |
211 | ToxAV *AliceAV, *BobsAV[3]; | 204 | ToxAV *AliceAV, *BobsAV[3]; |
212 | 205 | ||
@@ -215,19 +208,19 @@ START_TEST(test_AV_three_calls) | |||
215 | { | 208 | { |
216 | TOX_ERR_NEW error; | 209 | TOX_ERR_NEW error; |
217 | 210 | ||
218 | bootstrap = tox_new(NULL, &error); | 211 | bootstrap = tox_new_log(NULL, &error, &index[0]); |
219 | ck_assert(error == TOX_ERR_NEW_OK); | 212 | ck_assert(error == TOX_ERR_NEW_OK); |
220 | 213 | ||
221 | Alice = tox_new(NULL, &error); | 214 | Alice = tox_new_log(NULL, &error, &index[1]); |
222 | ck_assert(error == TOX_ERR_NEW_OK); | 215 | ck_assert(error == TOX_ERR_NEW_OK); |
223 | 216 | ||
224 | Bobs[0] = tox_new(NULL, &error); | 217 | Bobs[0] = tox_new_log(NULL, &error, &index[2]); |
225 | ck_assert(error == TOX_ERR_NEW_OK); | 218 | ck_assert(error == TOX_ERR_NEW_OK); |
226 | 219 | ||
227 | Bobs[1] = tox_new(NULL, &error); | 220 | Bobs[1] = tox_new_log(NULL, &error, &index[3]); |
228 | ck_assert(error == TOX_ERR_NEW_OK); | 221 | ck_assert(error == TOX_ERR_NEW_OK); |
229 | 222 | ||
230 | Bobs[2] = tox_new(NULL, &error); | 223 | Bobs[2] = tox_new_log(NULL, &error, &index[4]); |
231 | ck_assert(error == TOX_ERR_NEW_OK); | 224 | ck_assert(error == TOX_ERR_NEW_OK); |
232 | } | 225 | } |
233 | 226 | ||
@@ -341,16 +334,6 @@ START_TEST(test_AV_three_calls) | |||
341 | END_TEST | 334 | END_TEST |
342 | 335 | ||
343 | 336 | ||
344 | #ifndef HAVE_LIBCHECK | ||
345 | int main(int argc, char *argv[]) | ||
346 | { | ||
347 | (void) argc; | ||
348 | (void) argv; | ||
349 | |||
350 | test_AV_three_calls(); | ||
351 | return 0; | ||
352 | } | ||
353 | #else | ||
354 | static Suite *tox_suite(void) | 337 | static Suite *tox_suite(void) |
355 | { | 338 | { |
356 | Suite *s = suite_create("ToxAV"); | 339 | Suite *s = suite_create("ToxAV"); |
@@ -380,4 +363,3 @@ int main(int argc, char *argv[]) | |||
380 | 363 | ||
381 | return number_failed; | 364 | return number_failed; |
382 | } | 365 | } |
383 | #endif | ||