From 42dfdf73c1dfd899a4f5a44ea1584aaf3a4ed3d2 Mon Sep 17 00:00:00 2001 From: iphydf Date: Tue, 8 Nov 2016 21:56:54 +0000 Subject: [PATCH] Add spectest to the cmake test suite. This allows for easier development. It is not used on travis (yet). --- CMakeLists.txt | 28 ++++++++++++++++++++++++++++ testing/hstox/binary_decode.c | 2 +- testing/hstox/binary_encode.c | 2 +- testing/hstox/driver.c | 2 +- testing/hstox/methods.c | 4 ++-- testing/hstox/packet_kinds.c | 2 +- 6 files changed, 34 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a41bd5e8..83a0a0ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -163,6 +163,9 @@ pkg_use_module(LIBCONFIG libconfig ) # For auto tests. pkg_use_module(CHECK check ) +# For tox-spectest. +pkg_use_module(MSGPACK msgpack ) + # For av_test. pkg_use_module(OPENCV opencv ) pkg_use_module(PORTAUDIO portaudio-2.0 ) @@ -337,6 +340,31 @@ add_module(toxencryptsave toxencryptsave/toxencryptsave.c) target_link_modules(toxencryptsave toxcore) +################################################################################ +# +# :: Tox specification tests +# +################################################################################ + +find_program(SPECTEST NAMES + tox-spectest + ${CMAKE_SOURCE_DIR}/../.cabal-sandbox/bin/tox-spectest) + +if(SPECTEST AND MSGPACK_FOUND) + add_c_executable(toxcore-sut + testing/hstox/binary_decode.c + testing/hstox/binary_encode.c + testing/hstox/driver.c + testing/hstox/methods.c + testing/hstox/packet_kinds.c + testing/hstox/test_main.c + testing/hstox/util.c) + target_link_modules(toxcore-sut + toxcore + ${MSGPACK_LIBRARIES}) + add_test(NAME spectest COMMAND ${SPECTEST} $) +endif() + ################################################################################ # # :: Automated regression tests diff --git a/testing/hstox/binary_decode.c b/testing/hstox/binary_decode.c index aa4d7935..f43bae64 100644 --- a/testing/hstox/binary_decode.c +++ b/testing/hstox/binary_decode.c @@ -3,7 +3,7 @@ #include "byteswap.h" #include "packet_kinds.h" -#include +#include "../../toxcore/DHT.h" METHOD(bin, Binary_decode, CipherText) { diff --git a/testing/hstox/binary_encode.c b/testing/hstox/binary_encode.c index a39533c0..9b9d3876 100644 --- a/testing/hstox/binary_encode.c +++ b/testing/hstox/binary_encode.c @@ -3,7 +3,7 @@ #include "byteswap.h" #include "packet_kinds.h" -#include +#include "../../toxcore/DHT.h" METHOD(bin, Binary_encode, CipherText) { diff --git a/testing/hstox/driver.c b/testing/hstox/driver.c index 81773190..7a9a907e 100644 --- a/testing/hstox/driver.c +++ b/testing/hstox/driver.c @@ -17,7 +17,7 @@ #include -static void handle_interrupt(int signum) +static void __attribute__((__noreturn__)) handle_interrupt(int signum) { printf("Caught signal %d; exiting cleanly.\n", signum); exit(0); diff --git a/testing/hstox/methods.c b/testing/hstox/methods.c index 08ad50fa..a025acc4 100644 --- a/testing/hstox/methods.c +++ b/testing/hstox/methods.c @@ -2,8 +2,8 @@ #include "util.h" -#include -#include +#include "../../toxcore/crypto_core.h" +#include "../../toxcore/net_crypto.h" char const *const failure = "Failure"; char const *const pending = "Pending"; diff --git a/testing/hstox/packet_kinds.c b/testing/hstox/packet_kinds.c index 314c814b..aa0d2f26 100644 --- a/testing/hstox/packet_kinds.c +++ b/testing/hstox/packet_kinds.c @@ -1,6 +1,6 @@ #include "packet_kinds.h" -#include +#include "../../toxcore/network.h" uint8_t const packet_kinds[21] = { // = PingRequest -- 0x00: Ping request