summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--auto_tests/TCP_test.c7
-rw-r--r--auto_tests/conference_test.c9
-rw-r--r--auto_tests/dht_test.c8
-rw-r--r--auto_tests/helpers.h8
-rw-r--r--auto_tests/onion_test.c7
-rw-r--r--auto_tests/save_friend_test.c8
-rw-r--r--auto_tests/tox_many_tcp_test.c8
-rw-r--r--auto_tests/tox_many_test.c8
-rw-r--r--auto_tests/tox_test.c8
-rw-r--r--auto_tests/toxav_basic_test.c9
-rw-r--r--auto_tests/toxav_many_test.c8
-rw-r--r--other/DHT_bootstrap.c9
-rw-r--r--testing/DHT_test.c10
-rw-r--r--testing/Messenger_test.c9
-rw-r--r--testing/av_test.c2
-rw-r--r--testing/dns3_test.c9
-rw-r--r--testing/misc_tools.c9
-rw-r--r--testing/nTox.c4
-rw-r--r--testing/tox_shell.c3
-rw-r--r--testing/tox_sync.c3
20 files changed, 23 insertions, 123 deletions
diff --git a/auto_tests/TCP_test.c b/auto_tests/TCP_test.c
index bc684af9..769ba5de 100644
--- a/auto_tests/TCP_test.c
+++ b/auto_tests/TCP_test.c
@@ -18,13 +18,6 @@
18 18
19#include "helpers.h" 19#include "helpers.h"
20 20
21#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
22#define c_sleep(x) Sleep(1*x)
23#else
24#include <unistd.h>
25#define c_sleep(x) usleep(1000*x)
26#endif
27
28#define NUM_PORTS 3 21#define NUM_PORTS 3
29 22
30static uint16_t ports[NUM_PORTS] = {1234, 33445, 25643}; 23static uint16_t ports[NUM_PORTS] = {1234, 33445, 25643};
diff --git a/auto_tests/conference_test.c b/auto_tests/conference_test.c
index 36707e0f..33110441 100644
--- a/auto_tests/conference_test.c
+++ b/auto_tests/conference_test.c
@@ -17,15 +17,6 @@
17 17
18#include "helpers.h" 18#include "helpers.h"
19 19
20#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
21#include <windows.h>
22#define c_sleep(x) Sleep(1*x)
23#else
24#include <unistd.h>
25#define c_sleep(x) usleep(1000*x)
26#endif
27
28
29#define NUM_GROUP_TOX 32 20#define NUM_GROUP_TOX 32
30 21
31static void g_accept_friend_request(Tox *m, const uint8_t *public_key, const uint8_t *data, size_t length, 22static void g_accept_friend_request(Tox *m, const uint8_t *public_key, const uint8_t *data, size_t length,
diff --git a/auto_tests/dht_test.c b/auto_tests/dht_test.c
index 479b0eb8..6ed84098 100644
--- a/auto_tests/dht_test.c
+++ b/auto_tests/dht_test.c
@@ -571,14 +571,6 @@ static void ip_callback(void *data, int32_t number, IP_Port ip_port)
571{ 571{
572} 572}
573 573
574
575#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
576#define c_sleep(x) Sleep(1*x)
577#else
578#include <unistd.h>
579#define c_sleep(x) usleep(1000*x)
580#endif
581
582#define NUM_DHT_FRIENDS 20 574#define NUM_DHT_FRIENDS 20
583 575
584START_TEST(test_DHT_test) 576START_TEST(test_DHT_test)
diff --git a/auto_tests/helpers.h b/auto_tests/helpers.h
index 5cec575c..e5860449 100644
--- a/auto_tests/helpers.h
+++ b/auto_tests/helpers.h
@@ -7,6 +7,14 @@
7#include <check.h> 7#include <check.h>
8#include <stdio.h> 8#include <stdio.h>
9 9
10#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
11#include <windows.h>
12#define c_sleep(x) Sleep(x)
13#else
14#include <unistd.h>
15#define c_sleep(x) usleep(1000*(x))
16#endif
17
10#define DEFTESTCASE(NAME) \ 18#define DEFTESTCASE(NAME) \
11 TCase *tc_##NAME = tcase_create(#NAME); \ 19 TCase *tc_##NAME = tcase_create(#NAME); \
12 tcase_add_test(tc_##NAME, test_##NAME); \ 20 tcase_add_test(tc_##NAME, test_##NAME); \
diff --git a/auto_tests/onion_test.c b/auto_tests/onion_test.c
index 05264927..c52bbb58 100644
--- a/auto_tests/onion_test.c
+++ b/auto_tests/onion_test.c
@@ -18,13 +18,6 @@
18 18
19#include "helpers.h" 19#include "helpers.h"
20 20
21#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
22#define c_sleep(x) Sleep(1*x)
23#else
24#include <unistd.h>
25#define c_sleep(x) usleep(1000*x)
26#endif
27
28static void do_onion(Onion *onion) 21static void do_onion(Onion *onion)
29{ 22{
30 networking_poll(onion->net, NULL); 23 networking_poll(onion->net, NULL);
diff --git a/auto_tests/save_friend_test.c b/auto_tests/save_friend_test.c
index 6d0640c3..061425bd 100644
--- a/auto_tests/save_friend_test.c
+++ b/auto_tests/save_friend_test.c
@@ -12,14 +12,6 @@
12#include <stdlib.h> 12#include <stdlib.h>
13#include <string.h> 13#include <string.h>
14 14
15#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
16#include <windows.h>
17#define c_sleep(x) Sleep(1*x)
18#else
19#include <unistd.h>
20#define c_sleep(x) usleep(1000*x)
21#endif
22
23struct test_data { 15struct test_data {
24 uint8_t name[TOX_MAX_NAME_LENGTH]; 16 uint8_t name[TOX_MAX_NAME_LENGTH];
25 uint8_t status_message[TOX_MAX_STATUS_MESSAGE_LENGTH]; 17 uint8_t status_message[TOX_MAX_STATUS_MESSAGE_LENGTH];
diff --git a/auto_tests/tox_many_tcp_test.c b/auto_tests/tox_many_tcp_test.c
index 48f5671c..77c611d9 100644
--- a/auto_tests/tox_many_tcp_test.c
+++ b/auto_tests/tox_many_tcp_test.c
@@ -17,14 +17,6 @@
17 17
18#include "helpers.h" 18#include "helpers.h"
19 19
20#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
21#include <windows.h>
22#define c_sleep(x) Sleep(1*x)
23#else
24#include <unistd.h>
25#define c_sleep(x) usleep(1000*x)
26#endif
27
28/* The Travis-CI container responds poorly to ::1 as a localhost address 20/* The Travis-CI container responds poorly to ::1 as a localhost address
29 * You're encouraged to -D FORCE_TESTS_IPV6 on a local test */ 21 * You're encouraged to -D FORCE_TESTS_IPV6 on a local test */
30#ifdef FORCE_TESTS_IPV6 22#ifdef FORCE_TESTS_IPV6
diff --git a/auto_tests/tox_many_test.c b/auto_tests/tox_many_test.c
index b44bbb0c..1a1a715d 100644
--- a/auto_tests/tox_many_test.c
+++ b/auto_tests/tox_many_test.c
@@ -17,14 +17,6 @@
17 17
18#include "helpers.h" 18#include "helpers.h"
19 19
20#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
21#include <windows.h>
22#define c_sleep(x) Sleep(1*x)
23#else
24#include <unistd.h>
25#define c_sleep(x) usleep(1000*x)
26#endif
27
28static void accept_friend_request(Tox *m, const uint8_t *public_key, const uint8_t *data, size_t length, void *userdata) 20static void accept_friend_request(Tox *m, const uint8_t *public_key, const uint8_t *data, size_t length, void *userdata)
29{ 21{
30 if (*((uint32_t *)userdata) != 974536) { 22 if (*((uint32_t *)userdata) != 974536) {
diff --git a/auto_tests/tox_test.c b/auto_tests/tox_test.c
index d9074ac0..f3557226 100644
--- a/auto_tests/tox_test.c
+++ b/auto_tests/tox_test.c
@@ -27,14 +27,6 @@
27 27
28#include "helpers.h" 28#include "helpers.h"
29 29
30#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
31#include <windows.h>
32#define c_sleep(x) Sleep(1*x)
33#else
34#include <unistd.h>
35#define c_sleep(x) usleep(1000*x)
36#endif
37
38/* The Travis-CI container responds poorly to ::1 as a localhost address 30/* The Travis-CI container responds poorly to ::1 as a localhost address
39 * You're encouraged to -D FORCE_TESTS_IPV6 on a local test */ 31 * You're encouraged to -D FORCE_TESTS_IPV6 on a local test */
40#ifdef FORCE_TESTS_IPV6 32#ifdef FORCE_TESTS_IPV6
diff --git a/auto_tests/toxav_basic_test.c b/auto_tests/toxav_basic_test.c
index 79f552de..2885d8be 100644
--- a/auto_tests/toxav_basic_test.c
+++ b/auto_tests/toxav_basic_test.c
@@ -22,15 +22,6 @@
22#include "../toxcore/util.h" 22#include "../toxcore/util.h"
23 23
24 24
25#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
26#include <windows.h>
27#define c_sleep(x) Sleep(1*x)
28#else
29#include <unistd.h>
30#define c_sleep(x) usleep(1000*x)
31#endif
32
33
34#define TEST_REGULAR_AV 1 25#define TEST_REGULAR_AV 1
35#define TEST_REGULAR_A 1 26#define TEST_REGULAR_A 1
36#define TEST_REGULAR_V 1 27#define TEST_REGULAR_V 1
diff --git a/auto_tests/toxav_many_test.c b/auto_tests/toxav_many_test.c
index 1a10db44..83a7b313 100644
--- a/auto_tests/toxav_many_test.c
+++ b/auto_tests/toxav_many_test.c
@@ -21,16 +21,10 @@
21#include "../toxcore/tox.h" 21#include "../toxcore/tox.h"
22#include "../toxcore/util.h" 22#include "../toxcore/util.h"
23 23
24#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) 24#if !defined(_WIN32) && !defined(__WIN32__) && !defined(WIN32)
25#include <windows.h>
26#define c_sleep(x) Sleep(1*x)
27#else
28#include <pthread.h> 25#include <pthread.h>
29#include <unistd.h>
30#define c_sleep(x) usleep(1000*x)
31#endif 26#endif
32 27
33
34typedef struct { 28typedef struct {
35 bool incoming; 29 bool incoming;
36 uint32_t state; 30 uint32_t state;
diff --git a/other/DHT_bootstrap.c b/other/DHT_bootstrap.c
index f4dd5a65..78139de0 100644
--- a/other/DHT_bootstrap.c
+++ b/other/DHT_bootstrap.c
@@ -50,15 +50,6 @@
50#define DHT_MOTD "This is a test motd" 50#define DHT_MOTD "This is a test motd"
51#endif 51#endif
52 52
53/* Sleep function (x = milliseconds) */
54#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
55#define c_sleep(x) Sleep(1*x)
56#else
57#include <arpa/inet.h>
58#include <unistd.h>
59#define c_sleep(x) usleep(1000*x)
60#endif
61
62#define PORT 33445 53#define PORT 33445
63 54
64 55
diff --git a/testing/DHT_test.c b/testing/DHT_test.c
index 536217fe..6e65bf3a 100644
--- a/testing/DHT_test.c
+++ b/testing/DHT_test.c
@@ -41,16 +41,8 @@
41 41
42#include <string.h> 42#include <string.h>
43 43
44//Sleep function (x = milliseconds) 44#if !defined(_WIN32) && !defined(__WIN32__) && !defined (WIN32)
45#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
46
47#define c_sleep(x) Sleep(1*x)
48
49#else
50#include <arpa/inet.h> 45#include <arpa/inet.h>
51#include <unistd.h>
52#define c_sleep(x) usleep(1000*x)
53
54#endif 46#endif
55 47
56#define PORT 33445 48#define PORT 33445
diff --git a/testing/Messenger_test.c b/testing/Messenger_test.c
index c1a63da8..7dc773b2 100644
--- a/testing/Messenger_test.c
+++ b/testing/Messenger_test.c
@@ -47,15 +47,8 @@
47#include "../toxcore/Messenger.h" 47#include "../toxcore/Messenger.h"
48#include "misc_tools.c" 48#include "misc_tools.c"
49 49
50#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32) 50#if !defined(_WIN32) && !defined(__WIN32__) && !defined (WIN32)
51
52#define c_sleep(x) Sleep(1*x)
53
54#else
55#include <arpa/inet.h> 51#include <arpa/inet.h>
56#include <unistd.h>
57#define c_sleep(x) usleep(1000*x)
58#define PORT 33445
59 52
60#endif 53#endif
61 54
diff --git a/testing/av_test.c b/testing/av_test.c
index 8aaebfe7..4d09d023 100644
--- a/testing/av_test.c
+++ b/testing/av_test.c
@@ -73,7 +73,7 @@ extern "C" {
73#include <time.h> 73#include <time.h>
74#include <unistd.h> 74#include <unistd.h>
75 75
76#define c_sleep(x) usleep(1000*x) 76#define c_sleep(x) usleep(1000*(x))
77 77
78 78
79#define CLIP(X) ((X) > 255 ? 255 : (X) < 0 ? 0 : X) 79#define CLIP(X) ((X) > 255 ? 255 : (X) < 0 ? 0 : X)
diff --git a/testing/dns3_test.c b/testing/dns3_test.c
index 821f3b4b..4c03fc52 100644
--- a/testing/dns3_test.c
+++ b/testing/dns3_test.c
@@ -3,15 +3,6 @@
3#include "../toxdns/toxdns.h" 3#include "../toxdns/toxdns.h"
4#include "misc_tools.c" 4#include "misc_tools.c"
5 5
6#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
7
8#define c_sleep(x) Sleep(1*x)
9
10#else
11#define c_sleep(x) usleep(1000*x)
12
13#endif
14
15static uint32_t create_packet(uint8_t *packet, uint8_t *string, uint8_t str_len, uint8_t id) 6static uint32_t create_packet(uint8_t *packet, uint8_t *string, uint8_t str_len, uint8_t id)
16{ 7{
17 memset(packet, 0, str_len + 13 + 16); 8 memset(packet, 0, str_len + 13 + 16);
diff --git a/testing/misc_tools.c b/testing/misc_tools.c
index f0e12526..f6e76e46 100644
--- a/testing/misc_tools.c
+++ b/testing/misc_tools.c
@@ -31,6 +31,15 @@
31#include <stdlib.h> 31#include <stdlib.h>
32#include <string.h> 32#include <string.h>
33 33
34//Sleep function (x = milliseconds)
35#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
36#include <windows.h>
37#define c_sleep(x) Sleep(x)
38#else
39#include <unistd.h>
40#define c_sleep(x) usleep(1000*(x))
41#endif
42
34// You are responsible for freeing the return value! 43// You are responsible for freeing the return value!
35uint8_t *hex_string_to_bin(const char *hex_string) 44uint8_t *hex_string_to_bin(const char *hex_string)
36{ 45{
diff --git a/testing/nTox.c b/testing/nTox.c
index d02a1652..73038622 100644
--- a/testing/nTox.c
+++ b/testing/nTox.c
@@ -48,10 +48,10 @@
48#include <time.h> 48#include <time.h>
49 49
50#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32) 50#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
51#define c_sleep(x) Sleep(1*x) 51#define c_sleep(x) Sleep(x)
52#else 52#else
53#include <unistd.h> 53#include <unistd.h>
54#define c_sleep(x) usleep(1000*x) 54#define c_sleep(x) usleep(1000*(x))
55#endif 55#endif
56 56
57static void new_lines(char const *line); 57static void new_lines(char const *line);
diff --git a/testing/tox_shell.c b/testing/tox_shell.c
index f983f4e9..43e0b544 100644
--- a/testing/tox_shell.c
+++ b/testing/tox_shell.c
@@ -43,9 +43,6 @@
43#include <pty.h> 43#include <pty.h>
44#endif 44#endif
45#include <fcntl.h> 45#include <fcntl.h>
46#include <unistd.h>
47
48#define c_sleep(x) usleep(1000*x)
49 46
50static void print_online(Tox *tox, uint32_t friendnumber, TOX_CONNECTION status, void *userdata) 47static void print_online(Tox *tox, uint32_t friendnumber, TOX_CONNECTION status, void *userdata)
51{ 48{
diff --git a/testing/tox_sync.c b/testing/tox_sync.c
index d2fc41ca..10fc047e 100644
--- a/testing/tox_sync.c
+++ b/testing/tox_sync.c
@@ -38,9 +38,6 @@
38#include "../toxcore/tox.h" 38#include "../toxcore/tox.h"
39#include "misc_tools.c" 39#include "misc_tools.c"
40 40
41#include <unistd.h>
42#define c_sleep(x) usleep(1000*x)
43
44#include <arpa/inet.h> 41#include <arpa/inet.h>
45#include <dirent.h> 42#include <dirent.h>
46#include <netinet/in.h> 43#include <netinet/in.h>