aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/platform/posix/posix_rand.c3
-rw-r--r--tests/bus.c4
-rw-r--r--tests/event.c4
-rw-r--r--tests/idhash.c4
-rw-r--r--tests/inproc.c2
-rw-r--r--tests/ipc.c2
-rw-r--r--tests/pipeline.c4
-rw-r--r--tests/platform.c11
-rw-r--r--tests/pubsub.c3
-rw-r--r--tests/reqrep.c3
-rw-r--r--tests/sock.c10
-rw-r--r--tests/survey.c4
-rw-r--r--tests/tcp.c2
13 files changed, 50 insertions, 6 deletions
diff --git a/src/platform/posix/posix_rand.c b/src/platform/posix/posix_rand.c
index 76b2ee46..f8986e07 100644
--- a/src/platform/posix/posix_rand.c
+++ b/src/platform/posix/posix_rand.c
@@ -45,6 +45,8 @@ nni_plat_seed_prng(void *buf, size_t bufsz)
struct nni_plat_prng_x x;
int i;
+ memset(buf, 0, bufsz);
+
#if defined(NNG_USE_GETRANDOM)
// Latest Linux has a nice API here.
(void) getrandom(buf, bufsz, 0);
@@ -72,6 +74,7 @@ nni_plat_seed_prng(void *buf, size_t bufsz)
// limited of systems, we have at least *some* level of randomness.
// The mixing is done in a way to avoid diminishing entropy we may
// have already collected.
+ memset(&x, 0, sizeof (x)); // satisfy valgrind
x.now = nni_clock();
x.pid = getpid();
x.uid = getuid();
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 <string.h>
@@ -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 <string.h>
-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();
})