From cb69b8a986b050020e175654a68ca62b6bfb8bc7 Mon Sep 17 00:00:00 2001 From: iphydf Date: Sun, 4 Jun 2017 20:58:28 +0000 Subject: 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`. --- auto_tests/Makefile.inc | 1 + auto_tests/TCP_test.c | 3 ++- auto_tests/check_compat.h | 8 ++++++++ auto_tests/conference_test.c | 3 ++- auto_tests/crypto_test.c | 5 +++-- auto_tests/dht_test.c | 8 +++++--- auto_tests/encryptsave_test.c | 3 ++- auto_tests/file_saving_test.c | 1 + auto_tests/helpers.h | 14 +++++++------- auto_tests/messenger_test.c | 3 ++- auto_tests/monolith_test.c | 5 +++-- auto_tests/network_test.c | 3 ++- auto_tests/onion_test.c | 3 ++- auto_tests/resource_leak_test.c | 6 +++--- auto_tests/self_conference_title_change_test.c | 12 +++++------- auto_tests/selfname_change_conference_test.c | 12 +++++------- auto_tests/skeleton_test.c | 6 ++---- auto_tests/tox_many_tcp_test.c | 3 ++- auto_tests/tox_many_test.c | 3 ++- auto_tests/tox_one_test.c | 3 ++- auto_tests/tox_strncasecmp_test.c | 3 ++- auto_tests/tox_test.c | 3 ++- auto_tests/toxav_basic_test.c | 3 ++- auto_tests/toxav_many_test.c | 4 +++- 24 files changed, 70 insertions(+), 48 deletions(-) create mode 100644 auto_tests/check_compat.h (limited to 'auto_tests') 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) tox_strncasecmp_test_LDADD = $(AUTOTEST_LDADD) +EXTRA_DIST += $(top_srcdir)/auto_tests/check_compat.h EXTRA_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 @@ #include "config.h" #endif -#include +#include "check_compat.h" + #include #include #include 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 @@ +#ifdef _MSC_VER +#define pid_t int +// #include +#endif +#include +#ifdef _MSC_VER +#undef pid_t +#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 @@ #include "config.h" #endif -#include +#include "check_compat.h" + #include #include #include 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 @@ #include "config.h" #endif -#include "../toxcore/net_crypto.h" +#include "check_compat.h" -#include #include #include #include @@ -13,6 +12,8 @@ #include "helpers.h" +#include "../toxcore/net_crypto.h" + static void rand_bytes(uint8_t *b, size_t blen) { 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 @@ #include "config.h" #endif +#include "check_compat.h" + +#include +#include + #include "helpers.h" #include "../toxcore/DHT.c" #include "../toxcore/tox.h" -#include -#include - // These tests currently fail. static 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 @@ #include "config.h" #endif -#include +#include "check_compat.h" + #include #include #include 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 @@ * You should have received a copy of the GNU General Public License * along with Tox. If not, see . */ + #include #include #include 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 @@ #include "../toxcore/tox.h" #include -#include #include +#include -#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32) +#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) #include #define c_sleep(x) Sleep(x) #else #include -#define c_sleep(x) usleep(1000*(x)) +#define c_sleep(x) usleep(1000 * (x)) #endif #define DEFTESTCASE(NAME) \ TCase *tc_##NAME = tcase_create(#NAME); \ tcase_add_test(tc_##NAME, test_##NAME); \ - suite_add_tcase(s, tc_##NAME); + suite_add_tcase(s, tc_##NAME) -#define DEFTESTCASE_SLOW(NAME, TIMEOUT) \ - DEFTESTCASE(NAME) \ - tcase_set_timeout(tc_##NAME, TIMEOUT); +#define DEFTESTCASE_SLOW(NAME, TIMEOUT) \ + DEFTESTCASE(NAME); \ + tcase_set_timeout(tc_##NAME, TIMEOUT) static const char *tox_log_level_name(TOX_LOG_LEVEL level) { 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 @@ #include "config.h" #endif +#include "check_compat.h" + #include "helpers.h" #include "../testing/misc_tools.c" // hex_string_to_bin #include "../toxcore/Messenger.h" -#include #include #include #include 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 @@ /* Auto Tests: One instance. */ +#define _DARWIN_C_SOURCE +#define _XOPEN_SOURCE 600 + #ifdef HAVE_CONFIG_H #include "config.h" #endif -#define _DARWIN_C_SOURCE -#define _XOPEN_SOURCE 600 #include "../other/monolith.h" int 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 @@ #include "config.h" #endif -#include +#include "check_compat.h" + #include #include #include 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 @@ #include "config.h" #endif -#include +#include "check_compat.h" + #include #include #include 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 @@ -#include "helpers.h" - #if defined(__AIX__) -# define _XOPEN_SOURCE 1 +#define _XOPEN_SOURCE 1 #endif +#include "helpers.h" + // See man 2 sbrk. #if _BSD_SOURCE || _SVID_SOURCE || \ (_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 @@ * along with Tox. If not, see . * */ +#define _XOPEN_SOURCE 500 #include #include @@ -30,6 +31,8 @@ #include "../toxcore/tox.h" #include "../toxencryptsave/toxencryptsave.h" +#include "helpers.h" + static const char *newtitle = "kitten over darknet"; static 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 int main(void) { uint32_t conference_number; - struct timespec sleeptime; struct Tox_Options to; Tox *t; TOX_ERR_CONFERENCE_NEW conference_err; @@ -62,11 +64,7 @@ int main(void) } tox_iterate(t, NULL); - - sleeptime.tv_sec = 0; - sleeptime.tv_nsec = tox_iteration_interval(t) * 1E6; - - nanosleep(&sleeptime, NULL); + c_sleep(tox_iteration_interval(t)); if (!tox_conference_set_title(t, conference_number, (const uint8_t *)newtitle, strlen(newtitle), &title_err)) { tox_kill(t); @@ -75,7 +73,7 @@ int main(void) } tox_iterate(t, NULL); - nanosleep(&sleeptime, NULL); + c_sleep(tox_iteration_interval(t)); tox_iterate(t, NULL); 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 @@ * along with Tox. If not, see . * */ +#define _XOPEN_SOURCE 500 #include #include #include #include +#include "helpers.h" + #include "../toxcore/tox.h" #include "../toxencryptsave/toxencryptsave.h" @@ -55,7 +58,6 @@ static void cbconfmembers(Tox *tox, uint32_t conference_number, uint32_t peer_nu int main(void) { uint32_t conference_number; - struct timespec sleeptime; struct Tox_Options to; Tox *t; TOX_ERR_CONFERENCE_NEW conference_err; @@ -73,11 +75,7 @@ int main(void) } tox_iterate(t, NULL); - - sleeptime.tv_sec = 0; - sleeptime.tv_nsec = tox_iteration_interval(t) * 1E6; - - nanosleep(&sleeptime, NULL); + c_sleep(tox_iteration_interval(t)); if (!tox_self_set_name(t, (const uint8_t *)newname, strlen(newname), &name_err)) { tox_kill(t); @@ -86,7 +84,7 @@ int main(void) } tox_iterate(t, NULL); - nanosleep(&sleeptime, NULL); + c_sleep(tox_iteration_interval(t)); tox_iterate(t, NULL); 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 @@ #include "config.h" #endif -#include -#include +#include "check_compat.h" + #include -#include -#include #include #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 @@ #include "config.h" #endif -#include +#include "check_compat.h" + #include #include #include 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 @@ #include "config.h" #endif -#include +#include "check_compat.h" + #include #include #include 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 @@ #include "config.h" #endif -#include +#include "check_compat.h" + #include #include 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 @@ #include "config.h" #endif -#include +#include "check_compat.h" + #include #include #include 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 @@ #include "config.h" #endif -#include +#include "check_compat.h" + #include #include #include 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 @@ #include "config.h" #endif -#include "helpers.h" +#include "check_compat.h" #include #include @@ -21,6 +21,7 @@ #include "../toxcore/tox.h" #include "../toxcore/util.h" +#include "helpers.h" #define TEST_REGULAR_AV 1 #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 @@ #include "config.h" #endif -#include "helpers.h" +#include "check_compat.h" #include #include @@ -21,6 +21,8 @@ #include "../toxcore/tox.h" #include "../toxcore/util.h" +#include "helpers.h" + #if !defined(_WIN32) && !defined(__WIN32__) && !defined(WIN32) #include #endif -- cgit v1.2.3