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`.
This commit is contained in:
iphydf 2017-06-04 20:58:28 +00:00
parent 7f5b057b05
commit cb69b8a986
No known key found for this signature in database
GPG Key ID: 3855DBA2D74403C9
28 changed files with 158 additions and 82 deletions

View File

@ -381,7 +381,7 @@ elseif(FORMAT_TEST)
endif()
function(auto_test target)
if(CHECK_FOUND)
if(CHECK_FOUND AND NOT ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" AND ARGV1 STREQUAL "MSVC_DONT_BUILD"))
add_c_executable(auto_${target}_test auto_tests/${target}_test.c)
target_link_modules(auto_${target}_test
toxcore
@ -390,8 +390,10 @@ function(auto_test target)
if(BUILD_TOXAV)
target_link_modules(auto_${target}_test toxav)
endif()
add_test(NAME ${target} COMMAND auto_${target}_test)
set_tests_properties(${target} PROPERTIES TIMEOUT "${TEST_TIMEOUT_SECONDS}")
if(NOT ARGV1 STREQUAL "DONT_RUN")
add_test(NAME ${target} COMMAND auto_${target}_test)
set_tests_properties(${target} PROPERTIES TIMEOUT "${TEST_TIMEOUT_SECONDS}")
endif()
endif()
endfunction()
@ -407,10 +409,10 @@ endif()
auto_test(TCP)
auto_test(conference)
auto_test(crypto)
auto_test(dht)
auto_test(crypto MSVC_DONT_BUILD)
auto_test(dht MSVC_DONT_BUILD)
auto_test(encryptsave)
auto_test(messenger)
auto_test(messenger MSVC_DONT_BUILD)
auto_test(network)
auto_test(onion)
auto_test(resource_leak)
@ -424,8 +426,8 @@ auto_test(tox_strncasecmp)
auto_test(version)
# TODO(iphydf): These tests are broken. The code needs to be fixed, as the
# tests themselves are correct.
#auto_test(selfname_change_conference)
#auto_test(self_conference_title_change)
auto_test(selfname_change_conference DONT_RUN)
auto_test(self_conference_title_change DONT_RUN)
if(BUILD_TOXAV)
auto_test(toxav_basic)

View File

@ -1,15 +1,26 @@
cache:
- '%APPDATA%\downloads'
install:
# TODO(iphydf): Remove this when appveyor gets curl back, which it should have
# according to https://www.appveyor.com/docs/how-to/download-file/.
- choco install curl
- refreshenv
- mkdir libsodium && cd libsodium
- curl https://download.libsodium.org/libsodium/releases/libsodium-1.0.11-msvc.zip -o libsodium.zip
- unzip libsodium.zip
- if not exist %APPDATA%\downloads mkdir %APPDATA%\downloads
# libcheck
- if not exist %APPDATA%\downloads\check.zip curl -L https://github.com/libcheck/check/archive/0.11.0.zip -o %APPDATA%\downloads\check.zip
- unzip %APPDATA%\downloads\check.zip && cd check-0.11.0
- if not exist "%PROGRAMFILES%\check\include\check.h" cmake . && msbuild INSTALL.vcxproj
- cd ..
# libsodium
- mkdir libsodium && cd libsodium
- 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
- unzip %APPDATA%\downloads\libsodium.zip
- cd ..
# pthreads-win32
- mkdir pthreads-win32 && cd pthreads-win32
- curl ftp://sourceware.org/pub/pthreads-win32/pthreads-w32-2-9-1-release.zip -o pthreads.zip
- unzip pthreads.zip
- 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
- unzip %APPDATA%\downloads\pthreads.zip
- cd ..
before_build:
@ -18,6 +29,10 @@ before_build:
build:
project: INSTALL.vcxproj
# TODO(iphydf): Tests all segfault on Windows at the moment.
#test_script:
#- ctest -C Debug
branches:
only:
- master

View File

@ -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

View File

@ -4,7 +4,8 @@
#include "config.h"
#endif
#include <check.h>
#include "check_compat.h"
#include <stdint.h>
#include <stdlib.h>
#include <string.h>

View File

@ -0,0 +1,8 @@
#ifdef _MSC_VER
#define pid_t int
// #include <libcompat.h>
#endif
#include <check.h>
#ifdef _MSC_VER
#undef pid_t
#endif

View File

@ -7,7 +7,8 @@
#include "config.h"
#endif
#include <check.h>
#include "check_compat.h"
#include <inttypes.h>
#include <stdlib.h>
#include <time.h>

View File

@ -2,9 +2,8 @@
#include "config.h"
#endif
#include "../toxcore/net_crypto.h"
#include "check_compat.h"
#include <check.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
@ -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;

View File

@ -4,14 +4,16 @@
#include "config.h"
#endif
#include "check_compat.h"
#include <sys/param.h>
#include <time.h>
#include "helpers.h"
#include "../toxcore/DHT.c"
#include "../toxcore/tox.h"
#include <sys/param.h>
#include <time.h>
// These tests currently fail.
static bool enable_broken_tests = false;

View File

@ -2,7 +2,8 @@
#include "config.h"
#endif
#include <check.h>
#include "check_compat.h"
#include <stdint.h>
#include <stdlib.h>
#include <string.h>

View File

@ -22,6 +22,7 @@
* You should have received a copy of the GNU General Public License
* along with Tox. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

View File

@ -4,25 +4,25 @@
#include "../toxcore/tox.h"
#include <assert.h>
#include <check.h>
#include <stdio.h>
#include <string.h>
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
#include <windows.h>
#define c_sleep(x) Sleep(x)
#else
#include <unistd.h>
#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)
{

View File

@ -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 <check.h>
#include <stdint.h>
#include <string.h>
#include <sys/types.h>

View File

@ -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[])

View File

@ -2,7 +2,8 @@
#include "config.h"
#endif
#include <check.h>
#include "check_compat.h"
#include <errno.h>
#include <stdint.h>
#include <stdlib.h>

View File

@ -4,7 +4,8 @@
#include "config.h"
#endif
#include <check.h>
#include "check_compat.h"
#include <stdint.h>
#include <stdlib.h>
#include <string.h>

View File

@ -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 || \

View File

@ -21,6 +21,7 @@
* along with Tox. If not, see <http://www.gnu.org/licenses/>.
*
*/
#define _XOPEN_SOURCE 500
#include <stdio.h>
#include <stdlib.h>
@ -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");

View File

@ -21,12 +21,15 @@
* along with Tox. If not, see <http://www.gnu.org/licenses/>.
*
*/
#define _XOPEN_SOURCE 500
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#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");

View File

@ -2,11 +2,9 @@
#include "config.h"
#endif
#include <check.h>
#include <stdint.h>
#include "check_compat.h"
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <time.h>
#include "helpers.h"

View File

@ -7,7 +7,8 @@
#include "config.h"
#endif
#include <check.h>
#include "check_compat.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

View File

@ -7,7 +7,8 @@
#include "config.h"
#endif
#include <check.h>
#include "check_compat.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

View File

@ -5,7 +5,8 @@
#include "config.h"
#endif
#include <check.h>
#include "check_compat.h"
#include <stdlib.h>
#include <time.h>

View File

@ -2,7 +2,8 @@
#include "config.h"
#endif
#include <check.h>
#include "check_compat.h"
#include <stdint.h>
#include <stdlib.h>
#include <string.h>

View File

@ -16,7 +16,8 @@
#include "config.h"
#endif
#include <check.h>
#include "check_compat.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

View File

@ -4,7 +4,7 @@
#include "config.h"
#endif
#include "helpers.h"
#include "check_compat.h"
#include <stdint.h>
#include <stdio.h>
@ -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

View File

@ -4,7 +4,7 @@
#include "config.h"
#endif
#include "helpers.h"
#include "check_compat.h"
#include <stdint.h>
#include <stdio.h>
@ -21,6 +21,8 @@
#include "../toxcore/tox.h"
#include "../toxcore/util.h"
#include "helpers.h"
#if !defined(_WIN32) && !defined(__WIN32__) && !defined(WIN32)
#include <pthread.h>
#endif

View File

@ -35,36 +35,71 @@ pkg_use_module(SNDFILE sndfile )
###############################################################################
#
# :: For Windows and other systems lacking pkg-config.
# :: For MSVC Windows builds.
#
# These require specific installation paths of dependencies:
# - libsodium in libsodium/Win32/Release/v140/static
# - pthreads in pthreads-win32/Pre-built.2
# - check in %PROGRAMFILES%/check
#
###############################################################################
if(NOT LIBSODIUM_FOUND)
include_directories(libsodium/include)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
# libsodium
# ---------
find_library(LIBSODIUM_LIBRARIES
NAMES
sodium
libsodium
NAMES sodium libsodium
PATHS
libsodium/Win32/Release/v140/static
libsodium/x64/Release/v140/static
"libsodium/Win32/Release/v140/static"
"libsodium/x64/Release/v140/static"
)
if(LIBSODIUM_LIBRARIES)
include_directories("libsodium/include")
set(LIBSODIUM_FOUND TRUE)
add_definitions(-DSODIUM_STATIC)
message("libsodium: ${LIBSODIUM_LIBRARIES}")
else()
message(FATAL_ERROR "libsodium libraries not found")
endif()
add_definitions(-DSODIUM_STATIC)
message("libsodium: ${LIBSODIUM_LIBRARIES}")
endif()
if(("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") AND CMAKE_USE_WIN32_THREADS_INIT)
include_directories(pthreads-win32/Pre-built.2/include)
find_library(CMAKE_THREAD_LIBS_INIT
NAMES
pthreadVC2
PATHS
pthreads-win32/Pre-built.2/lib/x86
pthreads-win32/Pre-built.2/lib/x64
# check
# -----
#
# We look for the check and compat (containing clock_gettime and other POSIX
# functions not present on Windows) libraries in Program Files, since that is
# the default location where cmake installs its packages.
find_library(LIBCHECK_LIBRARIES
NAMES check libcheck
PATHS "$ENV{PROGRAMFILES}/check/lib"
)
add_definitions(-DHAVE_STRUCT_TIMESPEC)
message("libpthreads: ${CMAKE_THREAD_LIBS_INIT}")
find_library(LIBCOMPAT_LIBRARIES
NAMES compat libcompat
PATHS "$ENV{PROGRAMFILES}/check/lib"
)
if(LIBCHECK_LIBRARIES AND LIBCOMPAT_LIBRARIES)
include_directories("$ENV{PROGRAMFILES}/check/include")
set(CHECK_FOUND TRUE)
set(CHECK_LIBRARIES ${LIBCHECK_LIBRARIES} ${LIBCOMPAT_LIBRARIES})
message("check: ${CHECK_LIBRARIES}")
else()
message(FATAL_ERROR "check libraries not found")
endif()
# pthreads
# --------
if(CMAKE_USE_WIN32_THREADS_INIT)
find_library(CMAKE_THREAD_LIBS_INIT
NAMES pthreadVC2
PATHS
"pthreads-win32/Pre-built.2/lib/x86"
"pthreads-win32/Pre-built.2/lib/x64"
)
if(CMAKE_THREAD_LIBS_INIT)
include_directories("pthreads-win32/Pre-built.2/include")
add_definitions(-DHAVE_STRUCT_TIMESPEC)
message("libpthreads: ${CMAKE_THREAD_LIBS_INIT}")
else()
message(FATAL_ERROR "libpthreads libraries not found")
endif()
endif()
endif()

View File

@ -32,6 +32,7 @@
#include <string.h>
//Sleep function (x = milliseconds)
#ifndef c_sleep
#if defined(_WIN32) || defined(__WIN32__) || defined (WIN32)
#include <windows.h>
#define c_sleep(x) Sleep(x)
@ -39,6 +40,7 @@
#include <unistd.h>
#define c_sleep(x) usleep(1000*(x))
#endif
#endif
// You are responsible for freeing the return value!
uint8_t *hex_string_to_bin(const char *hex_string)