Skip to content

Commit

Permalink
Remove libcheck from the dependencies.
Browse files Browse the repository at this point in the history
We're not gaining much from this library, and it's a burden, especially
for windows development.
  • Loading branch information
iphydf committed Feb 5, 2018
1 parent 9f2582d commit 16f0c8e
Show file tree
Hide file tree
Showing 19 changed files with 76 additions and 117 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Expand Up @@ -17,7 +17,6 @@ matrix:
- avsm
packages:
- aspcud # For Opam
- check # For tests.
- libconfig-dev # For tox-bootstrapd.
- libcv-dev # For av_test.
- libhighgui-dev # For av_test.
Expand Down
8 changes: 3 additions & 5 deletions CMakeLists.txt
Expand Up @@ -450,28 +450,26 @@ elseif(FORMAT_TEST)
endif()

function(auto_test target)
if(CHECK_FOUND AND NOT ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" AND ARGV1 STREQUAL "MSVC_DONT_BUILD"))
if(NOT ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC" AND ARGV1 STREQUAL "MSVC_DONT_BUILD"))
add_executable(auto_${target}_test auto_tests/${target}_test.c)
target_link_modules(auto_${target}_test
toxcore
toxcrypto
toxmessenger
toxnetcrypto
${CHECK_LIBRARIES})
toxnetcrypto)
if(NOT ARGV1 STREQUAL "DONT_RUN")
add_test(NAME ${target} COMMAND ${CROSSCOMPILING_EMULATOR} auto_${target}_test)
set_tests_properties(${target} PROPERTIES TIMEOUT "${TEST_TIMEOUT_SECONDS}")
endif()
endif()
endfunction()

if(BUILD_TOXAV AND CHECK_FOUND)
if(BUILD_TOXAV)
add_definitions(-D__STDC_LIMIT_MACROS=1)
add_executable(auto_monolith_test
auto_tests/monolith_test.cpp
${ANDROID_CPU_FEATURES})
target_link_modules(auto_monolith_test
${CHECK_LIBRARIES}
${LIBSODIUM_LIBRARIES}
${OPUS_LIBRARIES}
${VPX_LIBRARIES}
Expand Down
2 changes: 0 additions & 2 deletions INSTALL.md
Expand Up @@ -176,7 +176,6 @@ Build the container image based on the Dockerfile. The following options are ava
| SUPPORT_ARCH_i686 | Support building 32-bit toxcore. | "true" or "false" (case sensitive). | true |
| SUPPORT_ARCH_x86_64 | Support building 64-bit toxcore. | "true" or "false" (case sensitive). | true |
| SUPPORT_TEST | Support running toxcore automated tests. | "true" or "false" (case sensitive). | false |
| VERSION_CHECK | Version of libcheck. Needed only when SUPPORT_TEST is enabled. | Git branch name. | 0.12.0 |
| VERSION_OPUS | Version of libopus to build toxcore with. | Git branch name. | v1.2.1 |
| VERSION_SODIUM | Version of libsodium to build toxcore with. | Git branch name. | 1.0.16 |
| VERSION_VPX | Version of libvpx to build toxcore with. | Git branch name. | v1.6.1 |
Expand All @@ -187,7 +186,6 @@ Example of building a container image with options
cd other/docker/windows
docker build \
--build-arg SUPPORT_TEST=true \
--build-arg VERSION_CHECK=0.11.0 \
-t toxcore \
.
```
Expand Down
5 changes: 0 additions & 5 deletions appveyor.yml
Expand Up @@ -7,11 +7,6 @@ install:
- choco install curl
- refreshenv
- 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
Expand Down
2 changes: 0 additions & 2 deletions auto_tests/BUILD.bazel
Expand Up @@ -22,7 +22,6 @@ cc_library(
"//c-toxcore/toxav",
"//c-toxcore/toxcore",
"//c-toxcore/toxencryptsave",
"@check",
],
) for src in glob(["*_test.c"])]

Expand All @@ -47,6 +46,5 @@ cc_test(
":monolith",
"//c-toxcore/other:monolith",
"//c-toxcore/testing:misc_tools",
"@check",
],
)
6 changes: 2 additions & 4 deletions auto_tests/Makefile.inc
Expand Up @@ -5,8 +5,7 @@ check_PROGRAMS = encryptsave_test messenger_autotest crypto_test network_test on

AUTOTEST_CFLAGS = \
$(LIBSODIUM_CFLAGS) \
$(NACL_CFLAGS) \
$(CHECK_CFLAGS)
$(NACL_CFLAGS)

AUTOTEST_LDADD = \
$(LIBSODIUM_LDFLAGS) \
Expand All @@ -15,8 +14,7 @@ AUTOTEST_LDADD = \
libtoxencryptsave.la \
$(LIBSODIUM_LIBS) \
$(NACL_OBJECTS) \
$(NACL_LIBS) \
$(CHECK_LIBS)
$(NACL_LIBS)



Expand Down
74 changes: 66 additions & 8 deletions auto_tests/check_compat.h
@@ -1,8 +1,66 @@
#ifdef _MSC_VER
#define pid_t int
// #include <libcompat.h>
#endif
#include <check.h>
#ifdef _MSC_VER
#undef pid_t
#endif
#ifndef CHECK_COMPAT_H
#define CHECK_COMPAT_H

#include "../toxcore/ccompat.h"

#include <stdbool.h>
#include <stdio.h>

#define START_TEST(name) static void name(void)
#define END_TEST

#define DEFTESTCASE(NAME) test_##NAME()
#define DEFTESTCASE_SLOW(NAME, TIMEOUT) test_##NAME()

typedef struct Suite Suite;
typedef struct SRunner SRunner;
enum SRunMode { CK_NORMAL };

Suite *suite_create(const char *title)
{
printf("Running test suite: %s\n", title);
return nullptr;
}

SRunner *srunner_create(Suite *s)
{
return nullptr;
}

void srunner_free(SRunner *s)
{
}

void srunner_run_all(SRunner *r, int mode)
{
}

int srunner_ntests_failed(SRunner *r)
{
return 0;
}

#define ck_assert(ok) do { \
if (!(ok)) { \
fprintf(stderr, "%s:%d: failed `%s'\n", __FILE__, __LINE__, #ok); \
exit(EXIT_FAILURE); \
} \
} while (0)

#define ck_assert_msg(ok, ...) do { \
if (!(ok)) { \
fprintf(stderr, "%s:%d: failed `%s': ", __FILE__, __LINE__, #ok); \
fprintf(stderr, __VA_ARGS__); \
fprintf(stderr, "\n"); \
exit(EXIT_FAILURE); \
} \
} while (0)

#define ck_abort_msg(...) do { \
fprintf(stderr, "%s:%d: ", __FILE__, __LINE__); \
fprintf(stderr, __VA_ARGS__); \
fprintf(stderr, "\n"); \
exit(EXIT_FAILURE); \
} while (0)

#endif // CHECK_COMPAT_H
9 changes: 0 additions & 9 deletions auto_tests/helpers.h
Expand Up @@ -17,15 +17,6 @@
#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)

#define DEFTESTCASE_SLOW(NAME, TIMEOUT) \
DEFTESTCASE(NAME); \
tcase_set_timeout(tc_##NAME, TIMEOUT)

static const char *tox_log_level_name(TOX_LOG_LEVEL level)
{
switch (level) {
Expand Down
5 changes: 1 addition & 4 deletions auto_tests/toxav_many_test.c
Expand Up @@ -341,10 +341,7 @@ static Suite *tox_suite(void)
{
Suite *s = suite_create("ToxAV");

TCase *tc_av_three_calls = tcase_create("AV_three_calls");
tcase_add_test(tc_av_three_calls, test_AV_three_calls);
tcase_set_timeout(tc_av_three_calls, 150);
suite_add_tcase(s, tc_av_three_calls);
DEFTESTCASE(AV_three_calls);

return s;
}
Expand Down
2 changes: 1 addition & 1 deletion circle.yml
Expand Up @@ -16,7 +16,7 @@ dependencies:
- sudo apt-get update
- sudo apt-get install astyle/trusty-backports
- sudo apt-get install clang
- sudo apt-get install build-essential libtool autotools-dev automake checkinstall check git yasm
- sudo apt-get install build-essential libtool autotools-dev automake checkinstall git yasm
- sudo apt-get install libopus-dev libvpx-dev pkg-config

# ------------ network_test requires that "localhost" resolves to ::1 ------------
Expand Down
25 changes: 0 additions & 25 deletions cmake/Dependencies.cmake
Expand Up @@ -21,9 +21,6 @@ pkg_use_module(VPX vpx )
# For tox-bootstrapd.
pkg_use_module(LIBCONFIG libconfig )

# For auto tests.
pkg_use_module(CHECK check )

# For tox-spectest.
pkg_use_module(MSGPACK msgpack )

Expand All @@ -39,7 +36,6 @@ pkg_use_module(SNDFILE sndfile )
# 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
#
###############################################################################

Expand All @@ -61,27 +57,6 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
message(FATAL_ERROR "libsodium libraries not found")
endif()

# 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"
)
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}")
endif()

# pthreads
# --------
if(CMAKE_USE_WIN32_THREADS_INIT)
Expand Down
32 changes: 0 additions & 32 deletions configure.ac
Expand Up @@ -26,7 +26,6 @@ TOX_LOGGER="no"

NCURSES_FOUND="no"
LIBCONFIG_FOUND="no"
LIBCHECK_FOUND="no"
WANT_NACL="no"
ADD_NACL_OBJECTS_TO_PKGCONFIG="yes"
SET_SO_VERSION="yes"
Expand Down Expand Up @@ -525,17 +524,6 @@ if test "x$BUILD_AV" = "xyes"; then
fi

if test -n "$PKG_CONFIG"; then
if test "x$BUILD_TESTS" = "xyes"; then
PKG_CHECK_MODULES([CHECK], [check],
[
LIBCHECK_FOUND="yes"
],
[
AC_MSG_WARN([libcheck not found, not building unit tests: $CHECK_PKG_ERRORS])
BUILD_TESTS="no"
])
fi

if test "x$BUILD_DHT_BOOTSTRAP_DAEMON" = "xyes"; then
PKG_CHECK_MODULES([LIBCONFIG], [libconfig >= 1.4.6],
[
Expand Down Expand Up @@ -572,26 +560,6 @@ if (test "x$BUILD_DHT_BOOTSTRAP_DAEMON" = "xyes") && \
fi
fi

if (test "x$BUILD_TESTS" = "xyes") && (test "x$LIBCHECK_FOUND" = "xno"); then
AC_CHECK_HEADER([check.h],
[],
[
AC_MSG_WARN([header file for check library was not found on your system, unit tests will be disabled])
BUILD_TESTS="no"
]
)

if test "x$BUILD_TESTS" = "xyes"; then
AC_CHECK_LIB([check], [suite_create],
[],
[
AC_MSG_WARN([library check was not found on the system, unit tests will be disabled])
BUILD_TESTS="no"
]
)
fi
fi

if test "x$WIN32" = "xyes"; then
AC_CHECK_LIB(ws2_32, main,
[
Expand Down
1 change: 0 additions & 1 deletion other/bootstrap_daemon/docker/Dockerfile
Expand Up @@ -8,7 +8,6 @@ RUN export BUILD_PACKAGES="\
autotools-dev \
automake \
checkinstall \
check \
git \
yasm \
libsodium-dev \
Expand Down
1 change: 0 additions & 1 deletion other/bootstrap_daemon/docker/Dockerfile.alpine
Expand Up @@ -20,7 +20,6 @@ RUN set -x && \
apk --no-cache add --virtual build-dependencies \
autoconf \
automake \
check-dev \
curl \
build-base \
libtool \
Expand Down
1 change: 0 additions & 1 deletion other/docker/windows/Dockerfile
Expand Up @@ -4,7 +4,6 @@ FROM debian:stretch-slim
ARG VERSION_SODIUM=1.0.16
ARG VERSION_OPUS=v1.2.1
ARG VERSION_VPX=v1.6.1
ARG VERSION_CHECK=0.12.0

ARG SUPPORT_TEST=false
ARG SUPPORT_ARCH_i686=true
Expand Down
12 changes: 0 additions & 12 deletions other/docker/windows/build_dependencies.sh
Expand Up @@ -59,18 +59,6 @@ build()
make install
cd ..

if [ "${SUPPORT_TEST}" = "true" ]; then
echo
echo "=== Building Check ${VERSION_CHECK} ${ARCH} ==="
git clone --depth=1 --branch="${VERSION_CHECK}" https://github.com/libcheck/check
cd check
autoreconf --install
./configure --host="${WINDOWS_TOOLCHAIN}" --prefix="${EXTRA_PREFIX_DIR}"
make
make install
cd ..
fi

rm -rf /tmp/*
}

Expand Down
4 changes: 2 additions & 2 deletions other/docker/windows/build_toxcore.sh
Expand Up @@ -17,7 +17,7 @@ build()
# toxcore dependencies that we will copy to the user for static build of toxcore (e.g. vpx, opus, sodium)
DEP_PREFIX_DIR="/root/prefix/${ARCH}"

# toxcore dependencies that user doesn't need in build result (e.g. libcheck used for testing toxcore)
# toxcore dependencies that user doesn't need in build result
EXTRA_DEP_PREFIX_DIR="/root/extra-prefix/${ARCH}"
mkdir -p "${EXTRA_DEP_PREFIX_DIR}"

Expand Down Expand Up @@ -73,7 +73,7 @@ build()

winecfg
export CTEST_OUTPUT_ON_FAILURE=1
# add libgcc_s_sjlj-1.dll libwinpthread-1.dll libcheck-0.dll into PATH env var of wine
# add libgcc_s_sjlj-1.dll libwinpthread-1.dll into PATH env var of wine
export WINEPATH=`cd /usr/lib/gcc/${WINDOWS_TOOLCHAIN}/*posix/ ; winepath -w $(pwd)`\;`winepath -w /usr/${WINDOWS_TOOLCHAIN}/lib/`\;`winepath -w ${EXTRA_DEP_PREFIX_DIR}/bin`

if [ "${ALLOW_TEST_FAILURE}" = "true" ]; then
Expand Down
1 change: 0 additions & 1 deletion other/travis/freebsd-install-stage1
Expand Up @@ -110,7 +110,6 @@ if [ ! -f ./$IMAGE_NAME.tgz ] || [ ! -f ./freebsd-install-stage1.sha256 ] || [ "
gmake \
cmake \
pkgconf \
check \
opencv \
portaudio \
libsndfile \
Expand Down
2 changes: 1 addition & 1 deletion other/travis/toxcore-osx-install
Expand Up @@ -3,4 +3,4 @@
# Workaround for bug in Homebrew where it only finds an old Ruby version.
brew update

brew install libsodium libvpx opus libconfig check astyle
brew install libsodium libvpx opus libconfig astyle

0 comments on commit 16f0c8e

Please sign in to comment.