summaryrefslogtreecommitdiff
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
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`.
-rw-r--r--CMakeLists.txt18
-rw-r--r--appveyor.yml23
-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
-rw-r--r--cmake/Dependencies.cmake77
-rw-r--r--testing/misc_tools.c2
28 files changed, 157 insertions, 81 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2f76edec..cce5885f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -381,7 +381,7 @@ elseif(FORMAT_TEST)
381endif() 381endif()
382 382
383function(auto_test target) 383function(auto_test target)
384 if(CHECK_FOUND) 384 if(CHECK_FOUND AND NOT ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" AND ARGV1 STREQUAL "MSVC_DONT_BUILD"))
385 add_c_executable(auto_${target}_test auto_tests/${target}_test.c) 385 add_c_executable(auto_${target}_test auto_tests/${target}_test.c)
386 target_link_modules(auto_${target}_test 386 target_link_modules(auto_${target}_test
387 toxcore 387 toxcore
@@ -390,8 +390,10 @@ function(auto_test target)
390 if(BUILD_TOXAV) 390 if(BUILD_TOXAV)
391 target_link_modules(auto_${target}_test toxav) 391 target_link_modules(auto_${target}_test toxav)
392 endif() 392 endif()
393 add_test(NAME ${target} COMMAND auto_${target}_test) 393 if(NOT ARGV1 STREQUAL "DONT_RUN")
394 set_tests_properties(${target} PROPERTIES TIMEOUT "${TEST_TIMEOUT_SECONDS}") 394 add_test(NAME ${target} COMMAND auto_${target}_test)
395 set_tests_properties(${target} PROPERTIES TIMEOUT "${TEST_TIMEOUT_SECONDS}")
396 endif()
395 endif() 397 endif()
396endfunction() 398endfunction()
397 399
@@ -407,10 +409,10 @@ endif()
407 409
408auto_test(TCP) 410auto_test(TCP)
409auto_test(conference) 411auto_test(conference)
410auto_test(crypto) 412auto_test(crypto MSVC_DONT_BUILD)
411auto_test(dht) 413auto_test(dht MSVC_DONT_BUILD)
412auto_test(encryptsave) 414auto_test(encryptsave)
413auto_test(messenger) 415auto_test(messenger MSVC_DONT_BUILD)
414auto_test(network) 416auto_test(network)
415auto_test(onion) 417auto_test(onion)
416auto_test(resource_leak) 418auto_test(resource_leak)
@@ -424,8 +426,8 @@ auto_test(tox_strncasecmp)
424auto_test(version) 426auto_test(version)
425# TODO(iphydf): These tests are broken. The code needs to be fixed, as the 427# TODO(iphydf): These tests are broken. The code needs to be fixed, as the
426# tests themselves are correct. 428# tests themselves are correct.
427#auto_test(selfname_change_conference) 429auto_test(selfname_change_conference DONT_RUN)
428#auto_test(self_conference_title_change) 430auto_test(self_conference_title_change DONT_RUN)
429 431
430if(BUILD_TOXAV) 432if(BUILD_TOXAV)
431 auto_test(toxav_basic) 433 auto_test(toxav_basic)
diff --git a/appveyor.yml b/appveyor.yml
index 4b4bfb20..66453ccf 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -1,15 +1,26 @@
1cache:
2- '%APPDATA%\downloads'
3
1install: 4install:
2# TODO(iphydf): Remove this when appveyor gets curl back, which it should have 5# TODO(iphydf): Remove this when appveyor gets curl back, which it should have
3# according to https://www.appveyor.com/docs/how-to/download-file/. 6# according to https://www.appveyor.com/docs/how-to/download-file/.
4- choco install curl 7- choco install curl
5- refreshenv 8- refreshenv
9- if not exist %APPDATA%\downloads mkdir %APPDATA%\downloads
10# libcheck
11- if not exist %APPDATA%\downloads\check.zip curl -L https://github.com/libcheck/check/archive/0.11.0.zip -o %APPDATA%\downloads\check.zip
12- unzip %APPDATA%\downloads\check.zip && cd check-0.11.0
13- if not exist "%PROGRAMFILES%\check\include\check.h" cmake . && msbuild INSTALL.vcxproj
14- cd ..
15# libsodium
6- mkdir libsodium && cd libsodium 16- mkdir libsodium && cd libsodium
7- curl https://download.libsodium.org/libsodium/releases/libsodium-1.0.11-msvc.zip -o libsodium.zip 17- if not exist %APPDATA%\downloads\libsodium.zip curl -L https://download.libsodium.org/libsodium/releases/libsodium-1.0.12-msvc.zip -o %APPDATA%\downloads\libsodium.zip
8- unzip libsodium.zip 18- unzip %APPDATA%\downloads\libsodium.zip
9- cd .. 19- cd ..
20# pthreads-win32
10- mkdir pthreads-win32 && cd pthreads-win32 21- mkdir pthreads-win32 && cd pthreads-win32
11- curl ftp://sourceware.org/pub/pthreads-win32/pthreads-w32-2-9-1-release.zip -o pthreads.zip 22- if not exist %APPDATA%\downloads\pthreads.zip curl -L ftp://sourceware.org/pub/pthreads-win32/pthreads-w32-2-9-1-release.zip -o %APPDATA%\downloads\pthreads.zip
12- unzip pthreads.zip 23- unzip %APPDATA%\downloads\pthreads.zip
13- cd .. 24- cd ..
14 25
15before_build: 26before_build:
@@ -18,6 +29,10 @@ before_build:
18build: 29build:
19 project: INSTALL.vcxproj 30 project: INSTALL.vcxproj
20 31
32# TODO(iphydf): Tests all segfault on Windows at the moment.
33#test_script:
34#- ctest -C Debug
35
21branches: 36branches:
22 only: 37 only:
23 - master 38 - master
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
diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake
index 5ad332bd..b87922a9 100644
--- a/cmake/Dependencies.cmake
+++ b/cmake/Dependencies.cmake
@@ -35,36 +35,71 @@ pkg_use_module(SNDFILE sndfile )
35 35
36############################################################################### 36###############################################################################
37# 37#
38# :: For Windows and other systems lacking pkg-config. 38# :: For MSVC Windows builds.
39#
40# These require specific installation paths of dependencies:
41# - libsodium in libsodium/Win32/Release/v140/static
42# - pthreads in pthreads-win32/Pre-built.2
43# - check in %PROGRAMFILES%/check
39# 44#
40############################################################################### 45###############################################################################
41 46
42if(NOT LIBSODIUM_FOUND) 47if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
43 include_directories(libsodium/include) 48 # libsodium
49 # ---------
44 find_library(LIBSODIUM_LIBRARIES 50 find_library(LIBSODIUM_LIBRARIES
45 NAMES 51 NAMES sodium libsodium
46 sodium
47 libsodium
48 PATHS 52 PATHS
49 libsodium/Win32/Release/v140/static 53 "libsodium/Win32/Release/v140/static"
50 libsodium/x64/Release/v140/static 54 "libsodium/x64/Release/v140/static"
51 ) 55 )
52 if(LIBSODIUM_LIBRARIES) 56 if(LIBSODIUM_LIBRARIES)
57 include_directories("libsodium/include")
53 set(LIBSODIUM_FOUND TRUE) 58 set(LIBSODIUM_FOUND TRUE)
59 add_definitions(-DSODIUM_STATIC)
60 message("libsodium: ${LIBSODIUM_LIBRARIES}")
61 else()
62 message(FATAL_ERROR "libsodium libraries not found")
54 endif() 63 endif()
55 add_definitions(-DSODIUM_STATIC)
56 message("libsodium: ${LIBSODIUM_LIBRARIES}")
57endif()
58 64
59if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") AND CMAKE_USE_WIN32_THREADS_INIT) 65 # check
60 include_directories(pthreads-win32/Pre-built.2/include) 66 # -----
61 find_library(CMAKE_THREAD_LIBS_INIT 67 #
62 NAMES 68 # We look for the check and compat (containing clock_gettime and other POSIX
63 pthreadVC2 69 # functions not present on Windows) libraries in Program Files, since that is
64 PATHS 70 # the default location where cmake installs its packages.
65 pthreads-win32/Pre-built.2/lib/x86 71 find_library(LIBCHECK_LIBRARIES
66 pthreads-win32/Pre-built.2/lib/x64 72 NAMES check libcheck
73 PATHS "$ENV{PROGRAMFILES}/check/lib"
74 )
75 find_library(LIBCOMPAT_LIBRARIES
76 NAMES compat libcompat
77 PATHS "$ENV{PROGRAMFILES}/check/lib"
67 ) 78 )
68 add_definitions(-DHAVE_STRUCT_TIMESPEC) 79 if(LIBCHECK_LIBRARIES AND LIBCOMPAT_LIBRARIES)
69 message("libpthreads: ${CMAKE_THREAD_LIBS_INIT}") 80 include_directories("$ENV{PROGRAMFILES}/check/include")
81 set(CHECK_FOUND TRUE)
82 set(CHECK_LIBRARIES ${LIBCHECK_LIBRARIES} ${LIBCOMPAT_LIBRARIES})
83 message("check: ${CHECK_LIBRARIES}")
84 else()
85 message(FATAL_ERROR "check libraries not found")
86 endif()
87
88 # pthreads
89 # --------
90 if(CMAKE_USE_WIN32_THREADS_INIT)
91 find_library(CMAKE_THREAD_LIBS_INIT
92 NAMES pthreadVC2
93 PATHS
94 "pthreads-win32/Pre-built.2/lib/x86"
95 "pthreads-win32/Pre-built.2/lib/x64"
96 )
97 if(CMAKE_THREAD_LIBS_INIT)
98 include_directories("pthreads-win32/Pre-built.2/include")
99 add_definitions(-DHAVE_STRUCT_TIMESPEC)
100 message("libpthreads: ${CMAKE_THREAD_LIBS_INIT}")
101 else()
102 message(FATAL_ERROR "libpthreads libraries not found")
103 endif()
104 endif()
70endif() 105endif()
diff --git a/testing/misc_tools.c b/testing/misc_tools.c
index f6e76e46..a3a89c2f 100644
--- a/testing/misc_tools.c
+++ b/testing/misc_tools.c
@@ -32,6 +32,7 @@
32#include <string.h> 32#include <string.h>
33 33
34//Sleep function (x = milliseconds) 34//Sleep function (x = milliseconds)
35#ifndef c_sleep
35#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32) 36#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
36#include <windows.h> 37#include <windows.h>
37#define c_sleep(x) Sleep(x) 38#define c_sleep(x) Sleep(x)
@@ -39,6 +40,7 @@
39#include <unistd.h> 40#include <unistd.h>
40#define c_sleep(x) usleep(1000*(x)) 41#define c_sleep(x) usleep(1000*(x))
41#endif 42#endif
43#endif
42 44
43// You are responsible for freeing the return value! 45// You are responsible for freeing the return value!
44uint8_t *hex_string_to_bin(const char *hex_string) 46uint8_t *hex_string_to_bin(const char *hex_string)