diff --git a/CMakeLists.txt b/CMakeLists.txt index a41bd5e81..83a0a0ce1 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 aa4d79353..f43bae64b 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 a39533c01..9b9d38760 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 817731904..7a9a907e8 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 08ad50fa0..a025acc4c 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 314c814b4..aa0d2f267 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