diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-01-16 00:43:03 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-01-16 00:43:03 -0800 |
| commit | 39dbff5615631522d3ef98b83141957038502c0d (patch) | |
| tree | 89becbf88ebb79df9c9202450acd476bd790bde0 /tests | |
| parent | f71209a0b429cddcd44f1f2473c49e986c9b4be7 (diff) | |
| download | nng-39dbff5615631522d3ef98b83141957038502c0d.tar.gz nng-39dbff5615631522d3ef98b83141957038502c0d.tar.bz2 nng-39dbff5615631522d3ef98b83141957038502c0d.zip | |
Various complaints found in AppVeyor build.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/CMakeLists.txt | 12 | ||||
| -rw-r--r-- | tests/convey.c | 2 | ||||
| -rw-r--r-- | tests/idhash.c | 2 | ||||
| -rw-r--r-- | tests/list.c | 1 | ||||
| -rw-r--r-- | tests/pipeline.c | 1 | ||||
| -rw-r--r-- | tests/platform.c | 9 | ||||
| -rw-r--r-- | tests/reqrep.c | 1 | ||||
| -rw-r--r-- | tests/sock.c | 29 | ||||
| -rw-r--r-- | tests/stubs.h | 47 |
9 files changed, 60 insertions, 44 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 066865e3..9c711408 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -40,6 +40,7 @@ if (NNG_TESTS) add_executable (${NAME} ${NAME}.c convey.c) target_link_libraries (${NAME} ${PROJECT_NAME}_static) target_link_libraries (${NAME} ${NNG_REQUIRED_LIBRARIES}) + target_compile_definitions(${NAME} PUBLIC -DNNG_STATIC_LIB) if (CMAKE_THREAD_LIBS_INIT) target_link_libraries (${NAME} "${CMAKE_THREAD_LIBS_INIT}") endif() @@ -49,20 +50,9 @@ if (NNG_TESTS) math (EXPR TEST_PORT "${TEST_PORT}+10") endmacro (add_nng_test) - macro (add_nng_perf NAME) - add_executable (${NAME} perf/${NAME}.c) - target_link_libraries (${NAME} ${PROJECT_NAME}_static) - target_link_libraries (${NAME} ${NNG_REQUIRED_LIBRARIES}) - if (CMAKE_THREAD_LIBS_INIT) - target_link_libraries (${NAME} "${CMAKE_THREAD_LIBS_INIT}") - endif() - endmacro (add_nng_perf) - else () macro (add_nng_test NAME TIMEOUT) endmacro (add_nng_test) - macro (add_nng_perf NAME) - endmacro (add_nng_perf) endif () add_nng_test(bus 5) diff --git a/tests/convey.c b/tests/convey.c index e74e150a..9a56cf82 100644 --- a/tests/convey.c +++ b/tests/convey.c @@ -619,7 +619,7 @@ convey_vlogf(struct convey_log *log, const char *fmt, va_list va, int addnl) { /* Grow the log buffer if we need to */ while ((log->log_size - log->log_length) < 256) { - int newsz = log->log_size + 2000; + size_t newsz = log->log_size + 2000; char *ptr = malloc(newsz); if (ptr == NULL) { return; diff --git a/tests/idhash.c b/tests/idhash.c index 6ecff47b..fb240078 100644 --- a/tests/idhash.c +++ b/tests/idhash.c @@ -9,6 +9,7 @@ #include "core/idhash.c" #include "convey.h" +#include "stubs.h" Main({ Test("General ID Hash", { @@ -93,7 +94,6 @@ Main({ Test("Resize ID Hash", { int expect[1024]; - int actual[1024]; int rv; int i; diff --git a/tests/list.c b/tests/list.c index 10668b50..b0da1196 100644 --- a/tests/list.c +++ b/tests/list.c @@ -9,6 +9,7 @@ #include "core/list.c" #include "convey.h" +#include "stubs.h" typedef struct { int pad[2]; diff --git a/tests/pipeline.c b/tests/pipeline.c index d6af728f..a8200900 100644 --- a/tests/pipeline.c +++ b/tests/pipeline.c @@ -17,7 +17,6 @@ So(memcmp(nng_msg_body(m), s, strlen(s)) == 0) Main({ - int rv; const char *addr = "inproc://test"; Test("PIPELINE (PUSH/PULL) pattern", { diff --git a/tests/platform.c b/tests/platform.c index 0ac881d6..fb8ee2a7 100644 --- a/tests/platform.c +++ b/tests/platform.c @@ -66,9 +66,16 @@ notifyafter(void *arg) nni_mtx_unlock(&na->mx); } +int +nop(void) +{ + return (0); +} + TestMain("Platform Operations", { - int rv = nni_init(); // This is required for anything else to work + // This is required for anything else to work + int rv = nni_plat_init(nop); Convey("Platform init worked", { So(rv == 0); }) diff --git a/tests/reqrep.c b/tests/reqrep.c index 53091928..c3ff9315 100644 --- a/tests/reqrep.c +++ b/tests/reqrep.c @@ -118,7 +118,6 @@ Main({ nng_msg *abc; nng_msg *def; nng_msg *cmd; - nng_msg *nvm; uint64_t retry = 100000; // 100 ms size_t len; diff --git a/tests/sock.c b/tests/sock.c index 8863023c..7d1d226b 100644 --- a/tests/sock.c +++ b/tests/sock.c @@ -8,38 +8,11 @@ // #include "convey.h" +#include "stubs.h" #include "nng.h" #include <string.h> -#ifndef _WIN32 -#include <sys/time.h> -#endif - -uint64_t -getms(void) -{ -#ifdef _WIN32 - return (GetTickCount64()) ; -#else - static time_t epoch; - struct timeval tv; - - if (epoch == 0) { - epoch = time(NULL); - } - gettimeofday(&tv, NULL); - - if (tv.tv_sec < epoch) { - // Broken clock. - // This will force all other timing tests to fail - return (0); - } - tv.tv_sec -= epoch; - return (((uint64_t)(tv.tv_sec ) * 1000) + (tv.tv_usec / 1000)); -#endif -} - TestMain("Socket Operations", { Convey("We are able to open a PAIR socket", { int rv; diff --git a/tests/stubs.h b/tests/stubs.h new file mode 100644 index 00000000..9bd9c279 --- /dev/null +++ b/tests/stubs.h @@ -0,0 +1,47 @@ +// +// Copyright 2017 Garrett D'Amore <garrett@damore.org> +// +// This software is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +#include "convey.h" +#include "nng.h" +#include <string.h> +#include <stdio.h> +#include <stdlib.h> +#include <stdarg.h> + +#ifdef _WIN32 +#include <windows.h> +#else +#include <sys/time.h> +#endif + +// Stub handlers for some common things. + +uint64_t +getms(void) +{ +#ifdef _WIN32 + return (GetTickCount64()) ; +#else + static time_t epoch; + struct timeval tv; + + if (epoch == 0) { + epoch = time(NULL); + } + gettimeofday(&tv, NULL); + + if (tv.tv_sec < epoch) { + // Broken clock. + // This will force all other timing tests to fail + return (0); + } + tv.tv_sec -= epoch; + return (((uint64_t)(tv.tv_sec ) * 1000) + (tv.tv_usec / 1000)); +#endif +} |
