From 7e844cf618d67675928fb4c6fadc6cc16db19d19 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Wed, 18 Jan 2017 01:16:40 -0800 Subject: Fixes for valgrind issues. --- tests/bus.c | 4 ++++ tests/event.c | 4 ++++ tests/idhash.c | 4 ++++ tests/inproc.c | 2 ++ tests/ipc.c | 2 ++ tests/pipeline.c | 4 ++++ tests/platform.c | 11 ++++++----- tests/pubsub.c | 3 +++ tests/reqrep.c | 3 +++ tests/sock.c | 10 +++++++++- tests/survey.c | 4 ++++ tests/tcp.c | 2 ++ 12 files changed, 47 insertions(+), 6 deletions(-) (limited to 'tests') diff --git a/tests/bus.c b/tests/bus.c index ec059bb0..bb8531bd 100644 --- a/tests/bus.c +++ b/tests/bus.c @@ -9,6 +9,7 @@ #include "convey.h" #include "nng.h" +#include "core/nng_impl.h" #include @@ -19,6 +20,7 @@ Main({ int rv; const char *addr = "inproc://test"; + nni_init(); Test("BUS pattern", { Convey("We can create a BUS socket", { @@ -101,4 +103,6 @@ Main({ }) }) }) + + nni_fini(); }) diff --git a/tests/event.c b/tests/event.c index 766ef3ad..ab42203b 100644 --- a/tests/event.c +++ b/tests/event.c @@ -69,6 +69,8 @@ bump(nng_event *ev, void *arg) Main({ const char *addr = "inproc://test"; + nni_init(); + Test("Event Handling", { Convey("Given a connected pair of pair sockets", { nng_socket *sock1; @@ -129,4 +131,6 @@ Main({ }) }) }) + + nni_fini(); }) diff --git a/tests/idhash.c b/tests/idhash.c index b05b4b2f..0609248b 100644 --- a/tests/idhash.c +++ b/tests/idhash.c @@ -12,6 +12,8 @@ #include "core/idhash.c" Main({ + nni_init(); + Test("General ID Hash", { int rv; @@ -166,4 +168,6 @@ Main({ }) }) }) + + nni_fini(); }) diff --git a/tests/inproc.c b/tests/inproc.c index 065b604b..89b43ced 100644 --- a/tests/inproc.c +++ b/tests/inproc.c @@ -14,5 +14,7 @@ // Inproc tests. TestMain("Inproc Transport", { + nni_init(); trantest_test_all("inproc://TEST"); + nni_fini(); }) diff --git a/tests/ipc.c b/tests/ipc.c index 69fe36d0..7e9221f3 100644 --- a/tests/ipc.c +++ b/tests/ipc.c @@ -14,5 +14,7 @@ // Inproc tests. TestMain("IPC Transport", { + nni_init(); trantest_test_all("ipc:///tmp/nng_ipc_test"); + nni_fini(); }) diff --git a/tests/pipeline.c b/tests/pipeline.c index 22f636d2..a01409c4 100644 --- a/tests/pipeline.c +++ b/tests/pipeline.c @@ -19,6 +19,8 @@ Main({ const char *addr = "inproc://test"; + nni_init(); + Test("PIPELINE (PUSH/PULL) pattern", { Convey("We can create a PUSH socket", { nng_socket *push; @@ -177,4 +179,6 @@ Main({ So(nng_recvmsg(pull2, &abc, 0) == NNG_ETIMEDOUT); }) }) + + nni_fini(); }) diff --git a/tests/platform.c b/tests/platform.c index fb8ee2a7..5bfdc367 100644 --- a/tests/platform.c +++ b/tests/platform.c @@ -72,13 +72,12 @@ nop(void) return (0); } -TestMain("Platform Operations", { +Main({ + nni_init(); + + Test("Platform Operations", { // This is required for anything else to work - int rv = nni_plat_init(nop); - Convey("Platform init worked", { - So(rv == 0); - }) Convey("The clock works", { uint64_t now = getms(); @@ -205,4 +204,6 @@ TestMain("Platform Operations", { nni_mtx_unlock(&arg.mx); }) }) + }) + nni_fini(); }) diff --git a/tests/pubsub.c b/tests/pubsub.c index ac106afb..ba2d43ae 100644 --- a/tests/pubsub.c +++ b/tests/pubsub.c @@ -19,6 +19,7 @@ Main({ int rv; const char *addr = "inproc://test"; + nni_init(); Test("PUB/SUB pattern", { Convey("We can create a PUB socket", { @@ -168,4 +169,6 @@ Main({ }) }) + + nni_fini(); }) diff --git a/tests/reqrep.c b/tests/reqrep.c index c3ff9315..1a9f3735 100644 --- a/tests/reqrep.c +++ b/tests/reqrep.c @@ -15,6 +15,7 @@ Main({ int rv; const char *addr = "inproc://test"; + nni_init(); Test("REQ/REP pattern", { Convey("We can create a REQ socket", { @@ -164,4 +165,6 @@ Main({ nng_msg_free(cmd); }) }) + + nni_fini(); }) diff --git a/tests/sock.c b/tests/sock.c index 7d1d226b..6a122cdf 100644 --- a/tests/sock.c +++ b/tests/sock.c @@ -10,10 +10,15 @@ #include "convey.h" #include "stubs.h" #include "nng.h" +#include "core/nng_impl.h" #include -TestMain("Socket Operations", { +Main({ + nni_init(); + + Test("Socket Operations", { + Convey("We are able to open a PAIR socket", { int rv; nng_socket *sock = NULL; @@ -194,4 +199,7 @@ TestMain("Socket Operations", { nng_close(sock2); }) }) + }) + + nni_fini(); }) diff --git a/tests/survey.c b/tests/survey.c index a3b6f0ae..3ead961d 100644 --- a/tests/survey.c +++ b/tests/survey.c @@ -20,6 +20,8 @@ Main({ int rv; const char *addr = "inproc://test"; + nni_init(); + Test("SURVEY pattern", { Convey("We can create a SURVEYOR socket", { nng_socket *surv; @@ -135,4 +137,6 @@ Main({ }) }) }) + + nni_fini(); }) diff --git a/tests/tcp.c b/tests/tcp.c index 3d46e92b..02b75795 100644 --- a/tests/tcp.c +++ b/tests/tcp.c @@ -14,5 +14,7 @@ // Inproc tests. TestMain("TCP Transport", { + nni_init(); trantest_test_all("tcp://127.0.0.1:4450"); + nni_fini(); }) -- cgit v1.2.3-70-g09d2