summaryrefslogtreecommitdiff
path: root/auto_tests
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2017-06-04 20:58:28 +0000
committeriphydf <iphydf@users.noreply.github.com>2017-06-05 13:45:20 +0000
commitcb69b8a986b050020e175654a68ca62b6bfb8bc7 (patch)
treecb9015459cc86a127663259702fe12d0ca20c3f3 /auto_tests
parent7f5b057b05ab9262c878aef03dc92d3fbdad31ad (diff)
Build tests on appveyor, the MSVC build.
Tests are not actually ran on appveyor for now, since they all fault for some reason. For now, we just build them. Also, some tests are disabled on msvc entirely, because they don't even compile. We'll need to look into those, later. They are disabled using `MSVC_DONT_BUILD`.
Diffstat (limited to 'auto_tests')
-rw-r--r--auto_tests/Makefile.inc1
-rw-r--r--auto_tests/TCP_test.c3
-rw-r--r--auto_tests/check_compat.h8
-rw-r--r--auto_tests/conference_test.c3
-rw-r--r--auto_tests/crypto_test.c5
-rw-r--r--auto_tests/dht_test.c8
-rw-r--r--auto_tests/encryptsave_test.c3
-rw-r--r--auto_tests/file_saving_test.c1
-rw-r--r--auto_tests/helpers.h14
-rw-r--r--auto_tests/messenger_test.c3
-rw-r--r--auto_tests/monolith_test.c5
-rw-r--r--auto_tests/network_test.c3
-rw-r--r--auto_tests/onion_test.c3
-rw-r--r--auto_tests/resource_leak_test.c6
-rw-r--r--auto_tests/self_conference_title_change_test.c12
-rw-r--r--auto_tests/selfname_change_conference_test.c12
-rw-r--r--auto_tests/skeleton_test.c6
-rw-r--r--auto_tests/tox_many_tcp_test.c3
-rw-r--r--auto_tests/tox_many_test.c3
-rw-r--r--auto_tests/tox_one_test.c3
-rw-r--r--auto_tests/tox_strncasecmp_test.c3
-rw-r--r--auto_tests/tox_test.c3
-rw-r--r--auto_tests/toxav_basic_test.c3
-rw-r--r--auto_tests/toxav_many_test.c4
24 files changed, 70 insertions, 48 deletions
diff --git a/auto_tests/Makefile.inc b/auto_tests/Makefile.inc
index 244737d9..536b08c5 100644
--- a/auto_tests/Makefile.inc
+++ b/auto_tests/Makefile.inc
@@ -123,4 +123,5 @@ tox_strncasecmp_test_CFLAGS = $(AUTOTEST_CFLAGS)
123tox_strncasecmp_test_LDADD = $(AUTOTEST_LDADD) 123tox_strncasecmp_test_LDADD = $(AUTOTEST_LDADD)
124 124
125 125
126EXTRA_DIST += $(top_srcdir)/auto_tests/check_compat.h
126EXTRA_DIST += $(top_srcdir)/auto_tests/helpers.h 127EXTRA_DIST += $(top_srcdir)/auto_tests/helpers.h
diff --git a/auto_tests/TCP_test.c b/auto_tests/TCP_test.c
index 769ba5de..f8412832 100644
--- a/auto_tests/TCP_test.c
+++ b/auto_tests/TCP_test.c
@@ -4,7 +4,8 @@
4#include "config.h" 4#include "config.h"
5#endif 5#endif
6 6
7#include <check.h> 7#include "check_compat.h"
8
8#include <stdint.h> 9#include <stdint.h>
9#include <stdlib.h> 10#include <stdlib.h>
10#include <string.h> 11#include <string.h>
diff --git a/auto_tests/check_compat.h b/auto_tests/check_compat.h
new file mode 100644
index 00000000..e4fde89f
--- /dev/null
+++ b/auto_tests/check_compat.h
@@ -0,0 +1,8 @@
1#ifdef _MSC_VER
2#define pid_t int
3// #include <libcompat.h>
4#endif
5#include <check.h>
6#ifdef _MSC_VER
7#undef pid_t
8#endif
diff --git a/auto_tests/conference_test.c b/auto_tests/conference_test.c
index 33110441..e8d7e238 100644
--- a/auto_tests/conference_test.c
+++ b/auto_tests/conference_test.c
@@ -7,7 +7,8 @@
7#include "config.h" 7#include "config.h"
8#endif 8#endif
9 9
10#include <check.h> 10#include "check_compat.h"
11
11#include <inttypes.h> 12#include <inttypes.h>
12#include <stdlib.h> 13#include <stdlib.h>
13#include <time.h> 14#include <time.h>
diff --git a/auto_tests/crypto_test.c b/auto_tests/crypto_test.c
index 952b0312..2fdfb0cd 100644
--- a/auto_tests/crypto_test.c
+++ b/auto_tests/crypto_test.c
@@ -2,9 +2,8 @@
2#include "config.h" 2#include "config.h"
3#endif 3#endif
4 4
5#include "../toxcore/net_crypto.h" 5#include "check_compat.h"
6 6
7#include <check.h>
8#include <stdint.h> 7#include <stdint.h>
9#include <stdlib.h> 8#include <stdlib.h>
10#include <string.h> 9#include <string.h>
@@ -13,6 +12,8 @@
13 12
14#include "helpers.h" 13#include "helpers.h"
15 14
15#include "../toxcore/net_crypto.h"
16
16static void rand_bytes(uint8_t *b, size_t blen) 17static void rand_bytes(uint8_t *b, size_t blen)
17{ 18{
18 size_t i; 19 size_t i;
diff --git a/auto_tests/dht_test.c b/auto_tests/dht_test.c
index 5533593f..c04b67e4 100644
--- a/auto_tests/dht_test.c
+++ b/auto_tests/dht_test.c
@@ -4,14 +4,16 @@
4#include "config.h" 4#include "config.h"
5#endif 5#endif
6 6
7#include "check_compat.h"
8
9#include <sys/param.h>
10#include <time.h>
11
7#include "helpers.h" 12#include "helpers.h"
8 13
9#include "../toxcore/DHT.c" 14#include "../toxcore/DHT.c"
10#include "../toxcore/tox.h" 15#include "../toxcore/tox.h"
11 16
12#include <sys/param.h>
13#include <time.h>
14
15 17
16// These tests currently fail. 18// These tests currently fail.
17static bool enable_broken_tests = false; 19static bool enable_broken_tests = false;
diff --git a/auto_tests/encryptsave_test.c b/auto_tests/encryptsave_test.c
index 749767a0..dfe85710 100644
--- a/auto_tests/encryptsave_test.c
+++ b/auto_tests/encryptsave_test.c
@@ -2,7 +2,8 @@
2#include "config.h" 2#include "config.h"
3#endif 3#endif
4 4
5#include <check.h> 5#include "check_compat.h"
6
6#include <stdint.h> 7#include <stdint.h>
7#include <stdlib.h> 8#include <stdlib.h>
8#include <string.h> 9#include <string.h>
diff --git a/auto_tests/file_saving_test.c b/auto_tests/file_saving_test.c
index 8cff56e8..0d167b5a 100644
--- a/auto_tests/file_saving_test.c
+++ b/auto_tests/file_saving_test.c
@@ -22,6 +22,7 @@
22 * You should have received a copy of the GNU General Public License 22 * You should have received a copy of the GNU General Public License
23 * along with Tox. If not, see <http://www.gnu.org/licenses/>. 23 * along with Tox. If not, see <http://www.gnu.org/licenses/>.
24 */ 24 */
25
25#include <stdio.h> 26#include <stdio.h>
26#include <stdlib.h> 27#include <stdlib.h>
27#include <string.h> 28#include <string.h>
diff --git a/auto_tests/helpers.h b/auto_tests/helpers.h
index e5860449..55cc1ca0 100644
--- a/auto_tests/helpers.h
+++ b/auto_tests/helpers.h
@@ -4,25 +4,25 @@
4#include "../toxcore/tox.h" 4#include "../toxcore/tox.h"
5 5
6#include <assert.h> 6#include <assert.h>
7#include <check.h>
8#include <stdio.h> 7#include <stdio.h>
8#include <string.h>
9 9
10#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32) 10#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
11#include <windows.h> 11#include <windows.h>
12#define c_sleep(x) Sleep(x) 12#define c_sleep(x) Sleep(x)
13#else 13#else
14#include <unistd.h> 14#include <unistd.h>
15#define c_sleep(x) usleep(1000*(x)) 15#define c_sleep(x) usleep(1000 * (x))
16#endif 16#endif
17 17
18#define DEFTESTCASE(NAME) \ 18#define DEFTESTCASE(NAME) \
19 TCase *tc_##NAME = tcase_create(#NAME); \ 19 TCase *tc_##NAME = tcase_create(#NAME); \
20 tcase_add_test(tc_##NAME, test_##NAME); \ 20 tcase_add_test(tc_##NAME, test_##NAME); \
21 suite_add_tcase(s, tc_##NAME); 21 suite_add_tcase(s, tc_##NAME)
22 22
23#define DEFTESTCASE_SLOW(NAME, TIMEOUT) \ 23#define DEFTESTCASE_SLOW(NAME, TIMEOUT) \
24 DEFTESTCASE(NAME) \ 24 DEFTESTCASE(NAME); \
25 tcase_set_timeout(tc_##NAME, TIMEOUT); 25 tcase_set_timeout(tc_##NAME, TIMEOUT)
26 26
27static const char *tox_log_level_name(TOX_LOG_LEVEL level) 27static const char *tox_log_level_name(TOX_LOG_LEVEL level)
28{ 28{
diff --git a/auto_tests/messenger_test.c b/auto_tests/messenger_test.c
index bd524014..614b1057 100644
--- a/auto_tests/messenger_test.c
+++ b/auto_tests/messenger_test.c
@@ -14,12 +14,13 @@
14#include "config.h" 14#include "config.h"
15#endif 15#endif
16 16
17#include "check_compat.h"
18
17#include "helpers.h" 19#include "helpers.h"
18 20
19#include "../testing/misc_tools.c" // hex_string_to_bin 21#include "../testing/misc_tools.c" // hex_string_to_bin
20#include "../toxcore/Messenger.h" 22#include "../toxcore/Messenger.h"
21 23
22#include <check.h>
23#include <stdint.h> 24#include <stdint.h>
24#include <string.h> 25#include <string.h>
25#include <sys/types.h> 26#include <sys/types.h>
diff --git a/auto_tests/monolith_test.c b/auto_tests/monolith_test.c
index d6f675a2..253d2bd3 100644
--- a/auto_tests/monolith_test.c
+++ b/auto_tests/monolith_test.c
@@ -1,12 +1,13 @@
1/* Auto Tests: One instance. 1/* Auto Tests: One instance.
2 */ 2 */
3 3
4#define _DARWIN_C_SOURCE
5#define _XOPEN_SOURCE 600
6
4#ifdef HAVE_CONFIG_H 7#ifdef HAVE_CONFIG_H
5#include "config.h" 8#include "config.h"
6#endif 9#endif
7 10
8#define _DARWIN_C_SOURCE
9#define _XOPEN_SOURCE 600
10#include "../other/monolith.h" 11#include "../other/monolith.h"
11 12
12int main(int argc, char *argv[]) 13int main(int argc, char *argv[])
diff --git a/auto_tests/network_test.c b/auto_tests/network_test.c
index 9ae1ddcb..67090f74 100644
--- a/auto_tests/network_test.c
+++ b/auto_tests/network_test.c
@@ -2,7 +2,8 @@
2#include "config.h" 2#include "config.h"
3#endif 3#endif
4 4
5#include <check.h> 5#include "check_compat.h"
6
6#include <errno.h> 7#include <errno.h>
7#include <stdint.h> 8#include <stdint.h>
8#include <stdlib.h> 9#include <stdlib.h>
diff --git a/auto_tests/onion_test.c b/auto_tests/onion_test.c
index c52bbb58..a0d4f4bc 100644
--- a/auto_tests/onion_test.c
+++ b/auto_tests/onion_test.c
@@ -4,7 +4,8 @@
4#include "config.h" 4#include "config.h"
5#endif 5#endif
6 6
7#include <check.h> 7#include "check_compat.h"
8
8#include <stdint.h> 9#include <stdint.h>
9#include <stdlib.h> 10#include <stdlib.h>
10#include <string.h> 11#include <string.h>
diff --git a/auto_tests/resource_leak_test.c b/auto_tests/resource_leak_test.c
index 3a87e245..5b25bc77 100644
--- a/auto_tests/resource_leak_test.c
+++ b/auto_tests/resource_leak_test.c
@@ -1,9 +1,9 @@
1#include "helpers.h"
2
3#if defined(__AIX__) 1#if defined(__AIX__)
4# define _XOPEN_SOURCE 1 2#define _XOPEN_SOURCE 1
5#endif 3#endif
6 4
5#include "helpers.h"
6
7// See man 2 sbrk. 7// See man 2 sbrk.
8#if _BSD_SOURCE || _SVID_SOURCE || \ 8#if _BSD_SOURCE || _SVID_SOURCE || \
9 (_XOPEN_SOURCE >= 500 || \ 9 (_XOPEN_SOURCE >= 500 || \
diff --git a/auto_tests/self_conference_title_change_test.c b/auto_tests/self_conference_title_change_test.c
index f0896101..a91aa0b4 100644
--- a/auto_tests/self_conference_title_change_test.c
+++ b/auto_tests/self_conference_title_change_test.c
@@ -21,6 +21,7 @@
21 * along with Tox. If not, see <http://www.gnu.org/licenses/>. 21 * along with Tox. If not, see <http://www.gnu.org/licenses/>.
22 * 22 *
23 */ 23 */
24#define _XOPEN_SOURCE 500
24 25
25#include <stdio.h> 26#include <stdio.h>
26#include <stdlib.h> 27#include <stdlib.h>
@@ -30,6 +31,8 @@
30#include "../toxcore/tox.h" 31#include "../toxcore/tox.h"
31#include "../toxencryptsave/toxencryptsave.h" 32#include "../toxencryptsave/toxencryptsave.h"
32 33
34#include "helpers.h"
35
33static const char *newtitle = "kitten over darknet"; 36static const char *newtitle = "kitten over darknet";
34 37
35static void cbtitlechange(Tox *tox, uint32_t conference_number, uint32_t peer_number, const uint8_t *title, 38static void cbtitlechange(Tox *tox, uint32_t conference_number, uint32_t peer_number, const uint8_t *title,
@@ -44,7 +47,6 @@ static void cbtitlechange(Tox *tox, uint32_t conference_number, uint32_t peer_nu
44int main(void) 47int main(void)
45{ 48{
46 uint32_t conference_number; 49 uint32_t conference_number;
47 struct timespec sleeptime;
48 struct Tox_Options to; 50 struct Tox_Options to;
49 Tox *t; 51 Tox *t;
50 TOX_ERR_CONFERENCE_NEW conference_err; 52 TOX_ERR_CONFERENCE_NEW conference_err;
@@ -62,11 +64,7 @@ int main(void)
62 } 64 }
63 65
64 tox_iterate(t, NULL); 66 tox_iterate(t, NULL);
65 67 c_sleep(tox_iteration_interval(t));
66 sleeptime.tv_sec = 0;
67 sleeptime.tv_nsec = tox_iteration_interval(t) * 1E6;
68
69 nanosleep(&sleeptime, NULL);
70 68
71 if (!tox_conference_set_title(t, conference_number, (const uint8_t *)newtitle, strlen(newtitle), &title_err)) { 69 if (!tox_conference_set_title(t, conference_number, (const uint8_t *)newtitle, strlen(newtitle), &title_err)) {
72 tox_kill(t); 70 tox_kill(t);
@@ -75,7 +73,7 @@ int main(void)
75 } 73 }
76 74
77 tox_iterate(t, NULL); 75 tox_iterate(t, NULL);
78 nanosleep(&sleeptime, NULL); 76 c_sleep(tox_iteration_interval(t));
79 tox_iterate(t, NULL); 77 tox_iterate(t, NULL);
80 78
81 fprintf(stderr, "error: title was not changed in callback. exiting.\n"); 79 fprintf(stderr, "error: title was not changed in callback. exiting.\n");
diff --git a/auto_tests/selfname_change_conference_test.c b/auto_tests/selfname_change_conference_test.c
index 340f7aa6..2536b10e 100644
--- a/auto_tests/selfname_change_conference_test.c
+++ b/auto_tests/selfname_change_conference_test.c
@@ -21,12 +21,15 @@
21 * along with Tox. If not, see <http://www.gnu.org/licenses/>. 21 * along with Tox. If not, see <http://www.gnu.org/licenses/>.
22 * 22 *
23 */ 23 */
24#define _XOPEN_SOURCE 500
24 25
25#include <stdio.h> 26#include <stdio.h>
26#include <stdlib.h> 27#include <stdlib.h>
27#include <string.h> 28#include <string.h>
28#include <time.h> 29#include <time.h>
29 30
31#include "helpers.h"
32
30#include "../toxcore/tox.h" 33#include "../toxcore/tox.h"
31#include "../toxencryptsave/toxencryptsave.h" 34#include "../toxencryptsave/toxencryptsave.h"
32 35
@@ -55,7 +58,6 @@ static void cbconfmembers(Tox *tox, uint32_t conference_number, uint32_t peer_nu
55int main(void) 58int main(void)
56{ 59{
57 uint32_t conference_number; 60 uint32_t conference_number;
58 struct timespec sleeptime;
59 struct Tox_Options to; 61 struct Tox_Options to;
60 Tox *t; 62 Tox *t;
61 TOX_ERR_CONFERENCE_NEW conference_err; 63 TOX_ERR_CONFERENCE_NEW conference_err;
@@ -73,11 +75,7 @@ int main(void)
73 } 75 }
74 76
75 tox_iterate(t, NULL); 77 tox_iterate(t, NULL);
76 78 c_sleep(tox_iteration_interval(t));
77 sleeptime.tv_sec = 0;
78 sleeptime.tv_nsec = tox_iteration_interval(t) * 1E6;
79
80 nanosleep(&sleeptime, NULL);
81 79
82 if (!tox_self_set_name(t, (const uint8_t *)newname, strlen(newname), &name_err)) { 80 if (!tox_self_set_name(t, (const uint8_t *)newname, strlen(newname), &name_err)) {
83 tox_kill(t); 81 tox_kill(t);
@@ -86,7 +84,7 @@ int main(void)
86 } 84 }
87 85
88 tox_iterate(t, NULL); 86 tox_iterate(t, NULL);
89 nanosleep(&sleeptime, NULL); 87 c_sleep(tox_iteration_interval(t));
90 tox_iterate(t, NULL); 88 tox_iterate(t, NULL);
91 89
92 fprintf(stderr, "error: name was not changed in callback. exiting.\n"); 90 fprintf(stderr, "error: name was not changed in callback. exiting.\n");
diff --git a/auto_tests/skeleton_test.c b/auto_tests/skeleton_test.c
index b8950921..48f95093 100644
--- a/auto_tests/skeleton_test.c
+++ b/auto_tests/skeleton_test.c
@@ -2,11 +2,9 @@
2#include "config.h" 2#include "config.h"
3#endif 3#endif
4 4
5#include <check.h> 5#include "check_compat.h"
6#include <stdint.h> 6
7#include <stdlib.h> 7#include <stdlib.h>
8#include <string.h>
9#include <sys/types.h>
10#include <time.h> 8#include <time.h>
11 9
12#include "helpers.h" 10#include "helpers.h"
diff --git a/auto_tests/tox_many_tcp_test.c b/auto_tests/tox_many_tcp_test.c
index 77c611d9..510109ee 100644
--- a/auto_tests/tox_many_tcp_test.c
+++ b/auto_tests/tox_many_tcp_test.c
@@ -7,7 +7,8 @@
7#include "config.h" 7#include "config.h"
8#endif 8#endif
9 9
10#include <check.h> 10#include "check_compat.h"
11
11#include <stdio.h> 12#include <stdio.h>
12#include <stdlib.h> 13#include <stdlib.h>
13#include <time.h> 14#include <time.h>
diff --git a/auto_tests/tox_many_test.c b/auto_tests/tox_many_test.c
index 1a1a715d..a34cfa8d 100644
--- a/auto_tests/tox_many_test.c
+++ b/auto_tests/tox_many_test.c
@@ -7,7 +7,8 @@
7#include "config.h" 7#include "config.h"
8#endif 8#endif
9 9
10#include <check.h> 10#include "check_compat.h"
11
11#include <stdio.h> 12#include <stdio.h>
12#include <stdlib.h> 13#include <stdlib.h>
13#include <time.h> 14#include <time.h>
diff --git a/auto_tests/tox_one_test.c b/auto_tests/tox_one_test.c
index ce698486..1b277d96 100644
--- a/auto_tests/tox_one_test.c
+++ b/auto_tests/tox_one_test.c
@@ -5,7 +5,8 @@
5#include "config.h" 5#include "config.h"
6#endif 6#endif
7 7
8#include <check.h> 8#include "check_compat.h"
9
9#include <stdlib.h> 10#include <stdlib.h>
10#include <time.h> 11#include <time.h>
11 12
diff --git a/auto_tests/tox_strncasecmp_test.c b/auto_tests/tox_strncasecmp_test.c
index 0acc85fe..5e0edcbd 100644
--- a/auto_tests/tox_strncasecmp_test.c
+++ b/auto_tests/tox_strncasecmp_test.c
@@ -2,7 +2,8 @@
2#include "config.h" 2#include "config.h"
3#endif 3#endif
4 4
5#include <check.h> 5#include "check_compat.h"
6
6#include <stdint.h> 7#include <stdint.h>
7#include <stdlib.h> 8#include <stdlib.h>
8#include <string.h> 9#include <string.h>
diff --git a/auto_tests/tox_test.c b/auto_tests/tox_test.c
index f3557226..3613b9c4 100644
--- a/auto_tests/tox_test.c
+++ b/auto_tests/tox_test.c
@@ -16,7 +16,8 @@
16#include "config.h" 16#include "config.h"
17#endif 17#endif
18 18
19#include <check.h> 19#include "check_compat.h"
20
20#include <stdio.h> 21#include <stdio.h>
21#include <stdlib.h> 22#include <stdlib.h>
22#include <time.h> 23#include <time.h>
diff --git a/auto_tests/toxav_basic_test.c b/auto_tests/toxav_basic_test.c
index 2885d8be..2b77da37 100644
--- a/auto_tests/toxav_basic_test.c
+++ b/auto_tests/toxav_basic_test.c
@@ -4,7 +4,7 @@
4#include "config.h" 4#include "config.h"
5#endif 5#endif
6 6
7#include "helpers.h" 7#include "check_compat.h"
8 8
9#include <stdint.h> 9#include <stdint.h>
10#include <stdio.h> 10#include <stdio.h>
@@ -21,6 +21,7 @@
21#include "../toxcore/tox.h" 21#include "../toxcore/tox.h"
22#include "../toxcore/util.h" 22#include "../toxcore/util.h"
23 23
24#include "helpers.h"
24 25
25#define TEST_REGULAR_AV 1 26#define TEST_REGULAR_AV 1
26#define TEST_REGULAR_A 1 27#define TEST_REGULAR_A 1
diff --git a/auto_tests/toxav_many_test.c b/auto_tests/toxav_many_test.c
index 83a7b313..5796905c 100644
--- a/auto_tests/toxav_many_test.c
+++ b/auto_tests/toxav_many_test.c
@@ -4,7 +4,7 @@
4#include "config.h" 4#include "config.h"
5#endif 5#endif
6 6
7#include "helpers.h" 7#include "check_compat.h"
8 8
9#include <stdint.h> 9#include <stdint.h>
10#include <stdio.h> 10#include <stdio.h>
@@ -21,6 +21,8 @@
21#include "../toxcore/tox.h" 21#include "../toxcore/tox.h"
22#include "../toxcore/util.h" 22#include "../toxcore/util.h"
23 23
24#include "helpers.h"
25
24#if !defined(_WIN32) && !defined(__WIN32__) && !defined(WIN32) 26#if !defined(_WIN32) && !defined(__WIN32__) && !defined(WIN32)
25#include <pthread.h> 27#include <pthread.h>
26#endif 28#endif