summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2024-04-23 07:39:59 -0700
committerGarrett D'Amore <garrett@damore.org>2024-04-23 07:39:59 -0700
commit01817988f4631bdd8ee5cec9c6b69039712a93fe (patch)
treec8c4259671fbb586a466a8c5d623fc8c183f8927 /tests
parentff00eac2401732e9efb6170ffb90100dcf6332a7 (diff)
downloadnng-01817988f4631bdd8ee5cec9c6b69039712a93fe.tar.gz
nng-01817988f4631bdd8ee5cec9c6b69039712a93fe.tar.bz2
nng-01817988f4631bdd8ee5cec9c6b69039712a93fe.zip
Move the rest of the functionality from platform.h into core.
This also deprecates supplemental/util/platform.h.
Diffstat (limited to 'tests')
-rw-r--r--tests/device.c15
-rw-r--r--tests/multistress.c21
-rw-r--r--tests/nonblock.c5
-rw-r--r--tests/pipe.c16
-rw-r--r--tests/pollfd.c7
-rw-r--r--tests/reqctx.c12
-rw-r--r--tests/reqstress.c13
-rw-r--r--tests/scalability.c7
-rw-r--r--tests/synch.c9
-rw-r--r--tests/trantest.h37
10 files changed, 66 insertions, 76 deletions
diff --git a/tests/device.c b/tests/device.c
index 77da41b6..53f51ba3 100644
--- a/tests/device.c
+++ b/tests/device.c
@@ -1,5 +1,5 @@
//
-// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
//
// This software is supplied under the terms of the MIT License, a
@@ -12,7 +12,6 @@
#include <nng/nng.h>
#include <nng/protocol/pair1/pair.h>
-#include <nng/supplemental/util/platform.h>
#include "convey.h"
#include "stubs.h"
@@ -38,7 +37,6 @@ dodev(void *arg)
#define SECOND(x) ((x) *1000)
Main({
-
Test("PAIRv1 device", {
const char *addr1 = "inproc://dev1";
const char *addr2 = "inproc://dev2";
@@ -55,8 +53,8 @@ Main({
nng_socket end1;
nng_socket end2;
nng_duration tmo;
- nng_msg * msg;
- nng_thread * thr;
+ nng_msg *msg;
+ nng_thread *thr;
So(nng_pair1_open_raw(&dev1) == 0);
So(nng_pair1_open_raw(&dev2) == 0);
@@ -82,12 +80,13 @@ Main({
So(nng_dial(end2, addr2, NULL, 0) == 0);
tmo = SECOND(1);
- So(nng_socket_set_ms(end1, NNG_OPT_RECVTIMEO, tmo) == 0);
- So(nng_socket_set_ms(end2, NNG_OPT_RECVTIMEO, tmo) == 0);
+ So(nng_socket_set_ms(end1, NNG_OPT_RECVTIMEO, tmo) ==
+ 0);
+ So(nng_socket_set_ms(end2, NNG_OPT_RECVTIMEO, tmo) ==
+ 0);
nng_msleep(100);
Convey("Device can send and receive", {
-
So(nng_msg_alloc(&msg, 0) == 0);
APPENDSTR(msg, "ALPHA");
So(nng_sendmsg(end1, msg, 0) == 0);
diff --git a/tests/multistress.c b/tests/multistress.c
index e4fa1f2f..5511fcc4 100644
--- a/tests/multistress.c
+++ b/tests/multistress.c
@@ -1,5 +1,5 @@
//
-// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
//
// This software is supplied under the terms of the MIT License, a
@@ -24,7 +24,6 @@
#include <nng/protocol/reqrep0/req.h>
#include <nng/protocol/survey0/respond.h>
#include <nng/protocol/survey0/survey.h>
-#include <nng/supplemental/util/platform.h>
#include <nng/transport/inproc/inproc.h>
#include <nng/transport/ipc/ipc.h>
#include <nng/transport/tcp/tcp.h>
@@ -69,9 +68,9 @@ typedef struct test_case {
int nrecv;
int nsend;
int nfail;
- nng_aio * recd;
- nng_aio * sent;
- nng_aio * woke;
+ nng_aio *recd;
+ nng_aio *sent;
+ nng_aio *woke;
char addr[NNG_MAXADDRLEN];
char buf[32];
@@ -151,7 +150,7 @@ static void
req0_woke(void *arg)
{
test_case *c = arg;
- nng_msg * msg = NULL;
+ nng_msg *msg = NULL;
int rv;
if ((rv = nng_aio_result(c->woke)) != 0) {
@@ -173,7 +172,7 @@ static void
req0_recd(void *arg)
{
test_case *c = arg;
- nng_msg * msg = NULL;
+ nng_msg *msg = NULL;
int rv;
if ((rv = nng_aio_result(c->recd)) != 0) {
@@ -290,7 +289,7 @@ static void
pair0_woke(void *arg)
{
test_case *c = arg;
- nng_msg * msg = NULL;
+ nng_msg *msg = NULL;
int rv;
if ((rv = nng_aio_result(c->woke)) != 0) {
@@ -390,7 +389,7 @@ static void
bus0_woke(void *arg)
{
test_case *c = arg;
- nng_msg * msg = NULL;
+ nng_msg *msg = NULL;
int rv;
if ((rv = nng_aio_result(c->woke)) != 0) {
@@ -470,7 +469,7 @@ void
pub0_woke(void *arg)
{
test_case *c = arg;
- nng_msg * msg = NULL;
+ nng_msg *msg = NULL;
int rv;
if ((rv = nng_aio_result(c->woke)) != 0) {
@@ -627,7 +626,7 @@ void
push0_woke(void *arg)
{
test_case *c = arg;
- nng_msg * msg = NULL;
+ nng_msg *msg = NULL;
int rv;
if ((rv = nng_aio_result(c->woke)) != 0) {
diff --git a/tests/nonblock.c b/tests/nonblock.c
index 4fde2c80..19174882 100644
--- a/tests/nonblock.c
+++ b/tests/nonblock.c
@@ -1,5 +1,5 @@
//
-// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
//
// This software is supplied under the terms of the MIT License, a
@@ -19,7 +19,6 @@
#include <nng/nng.h>
#include <nng/protocol/reqrep0/rep.h>
#include <nng/protocol/reqrep0/req.h>
-#include <nng/supplemental/util/platform.h>
#include "convey.h"
#include "stubs.h"
@@ -42,7 +41,7 @@ repthr(void *arg)
for (;;) {
fd_set fset;
struct timeval tmo;
- char * msgbuf;
+ char *msgbuf;
size_t msglen;
FD_ZERO(&fset);
diff --git a/tests/pipe.c b/tests/pipe.c
index c2d1f06c..665018b0 100644
--- a/tests/pipe.c
+++ b/tests/pipe.c
@@ -1,5 +1,5 @@
//
-// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
//
// This software is supplied under the terms of the MIT License, a
@@ -14,7 +14,6 @@
#include <nng/nng.h>
#include <nng/protocol/pipeline0/pull.h>
#include <nng/protocol/pipeline0/push.h>
-#include <nng/supplemental/util/platform.h>
#include "convey.h"
#include "stubs.h"
@@ -34,8 +33,8 @@ struct testcase {
int rem;
int err;
int rej;
- nng_mtx * lk;
- nng_cv * cv;
+ nng_mtx *lk;
+ nng_cv *cv;
};
static bool
@@ -114,7 +113,6 @@ char addr[64];
static int cnt;
TestMain("Pipe notify works", {
-
Convey("We can create a pipeline", {
struct testcase push;
struct testcase pull;
@@ -161,10 +159,10 @@ TestMain("Pipe notify works", {
So(nng_dialer_create(&push.d, push.s, addr) == 0);
So(nng_listener_id(pull.l) > 0);
So(nng_dialer_id(push.d) > 0);
- So(nng_dialer_set_ms(
- push.d, NNG_OPT_RECONNMINT, 10) == 0);
- So(nng_dialer_set_ms(
- push.d, NNG_OPT_RECONNMAXT, 10) == 0);
+ So(nng_dialer_set_ms(push.d, NNG_OPT_RECONNMINT, 10) ==
+ 0);
+ So(nng_dialer_set_ms(push.d, NNG_OPT_RECONNMAXT, 10) ==
+ 0);
So(nng_listener_start(pull.l, 0) == 0);
So(nng_dialer_start(push.d, 0) == 0);
So(expect(&pull, &pull.add_pre, 1));
diff --git a/tests/pollfd.c b/tests/pollfd.c
index 0c93c365..adb9d806 100644
--- a/tests/pollfd.c
+++ b/tests/pollfd.c
@@ -1,5 +1,5 @@
//
-// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
//
// This software is supplied under the terms of the MIT License, a
@@ -33,7 +33,6 @@
#include <nng/protocol/pair1/pair.h>
#include <nng/protocol/pipeline0/pull.h>
#include <nng/protocol/pipeline0/push.h>
-#include <nng/supplemental/util/platform.h>
#include "convey.h"
#include "stubs.h"
@@ -64,8 +63,8 @@ TestMain("Poll FDs", {
Convey("And it is always the same fd", {
int fd2;
sz = sizeof(fd2);
- So(nng_socket_get(s1, NNG_OPT_RECVFD, &fd2, &sz) ==
- 0);
+ So(nng_socket_get(
+ s1, NNG_OPT_RECVFD, &fd2, &sz) == 0);
So(fd2 == fd);
});
diff --git a/tests/reqctx.c b/tests/reqctx.c
index e878037f..47222c00 100644
--- a/tests/reqctx.c
+++ b/tests/reqctx.c
@@ -1,5 +1,5 @@
//
-// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
//
// This software is supplied under the terms of the MIT License, a
@@ -13,7 +13,6 @@
#include <nng/nng.h>
#include <nng/protocol/reqrep0/rep.h>
#include <nng/protocol/reqrep0/req.h>
-#include <nng/supplemental/util/platform.h>
#include "convey.h"
#include "stubs.h"
@@ -22,9 +21,9 @@ static struct {
nng_aio *aio;
enum { START, SEND, RECV } state;
nng_socket s;
- nng_msg * msg;
+ nng_msg *msg;
int cnt;
- nng_mtx * mtx;
+ nng_mtx *mtx;
} rep_state;
void
@@ -117,7 +116,8 @@ TestMain("REQ concurrent contexts", {
nng_aio_set_timeout(saios[i], 5000);
}
- So(nng_socket_set_int(rep_state.s, NNG_OPT_SENDBUF, NCTX) == 0);
+ So(nng_socket_set_int(rep_state.s, NNG_OPT_SENDBUF, NCTX) ==
+ 0);
So(i == NCTX);
for (i = 0; i < NCTX; i++) {
uint32_t tmp;
@@ -230,7 +230,7 @@ TestMain("REQ concurrent contexts", {
Convey("Given a socket and a context", {
nng_socket req;
nng_ctx ctx;
- nng_aio * aio;
+ nng_aio *aio;
So(nng_req0_open(&req) == 0);
So(nng_ctx_open(&ctx, req) == 0);
diff --git a/tests/reqstress.c b/tests/reqstress.c
index 89190c64..6696eace 100644
--- a/tests/reqstress.c
+++ b/tests/reqstress.c
@@ -1,5 +1,5 @@
//
-// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
//
// This software is supplied under the terms of the MIT License, a
@@ -16,7 +16,6 @@
#include <nng/protocol/bus0/bus.h>
#include <nng/protocol/reqrep0/rep.h>
#include <nng/protocol/reqrep0/req.h>
-#include <nng/supplemental/util/platform.h>
#include <nng/transport/inproc/inproc.h>
#include <nng/transport/ipc/ipc.h>
#include <nng/transport/tcp/tcp.h>
@@ -64,9 +63,9 @@ typedef struct test_case {
int nrecv;
int nsend;
int nfail;
- nng_aio * recv_aio;
- nng_aio * send_aio;
- nng_aio * time_aio;
+ nng_aio *recv_aio;
+ nng_aio *send_aio;
+ nng_aio *time_aio;
char buf[32];
} test_case;
@@ -144,7 +143,7 @@ static void
req_time_cb(void *arg)
{
test_case *c = arg;
- nng_msg * msg = NULL;
+ nng_msg *msg = NULL;
int rv;
if ((rv = nng_aio_result(c->time_aio)) != 0) {
@@ -167,7 +166,7 @@ static void
req_recv_cb(void *arg)
{
test_case *c = arg;
- nng_msg * msg = NULL;
+ nng_msg *msg = NULL;
int rv;
if ((rv = nng_aio_result(c->recv_aio)) != 0) {
diff --git a/tests/scalability.c b/tests/scalability.c
index c794a4ee..0b4b1799 100644
--- a/tests/scalability.c
+++ b/tests/scalability.c
@@ -1,5 +1,5 @@
//
-// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
//
// This software is supplied under the terms of the MIT License, a
@@ -13,7 +13,6 @@
#include <nng/nng.h>
#include <nng/protocol/reqrep0/rep.h>
#include <nng/protocol/reqrep0/req.h>
-#include <nng/supplemental/util/platform.h>
#include "convey.h"
#include "stubs.h"
@@ -22,7 +21,7 @@ static int nclients = 200;
static char *addr = "inproc:///atscale";
nng_socket rep;
-nng_thread * server;
+nng_thread *server;
void
serve(void *arg)
@@ -87,7 +86,7 @@ transact(nng_socket *clients, int num)
Main({
nng_socket *clients;
- int * results;
+ int *results;
clients = calloc(nclients, sizeof(nng_socket));
results = calloc(nclients, sizeof(int));
diff --git a/tests/synch.c b/tests/synch.c
index 9174385d..c0bf18c9 100644
--- a/tests/synch.c
+++ b/tests/synch.c
@@ -1,6 +1,6 @@
//
// Copyright 2022 Staysail Systems, Inc. <info@staysail.tech>
-// Copyright 2018 Capitar IT Group BV <info@capitar.com>
+// Copyright 2024 Capitar IT Group BV <info@capitar.com>
//
// This software is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
@@ -9,7 +9,6 @@
//
#include <nng/nng.h>
-#include <nng/supplemental/util/platform.h>
#include "convey.h"
@@ -17,8 +16,8 @@
struct notifyarg {
int did;
nng_duration when;
- nng_mtx * mx;
- nng_cv * cv;
+ nng_mtx *mx;
+ nng_cv *cv;
};
void
@@ -34,7 +33,7 @@ notifyafter(void *a)
}
struct notifyarg arg;
-nng_thread * thr;
+nng_thread *thr;
static void
test_sync(void)
diff --git a/tests/trantest.h b/tests/trantest.h
index 91b75494..9176c543 100644
--- a/tests/trantest.h
+++ b/tests/trantest.h
@@ -1,5 +1,5 @@
//
-// Copyright 2022 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
//
// This software is supplied under the terms of the MIT License, a
@@ -14,7 +14,6 @@
#include <nng/nng.h>
#include <nng/protocol/reqrep0/rep.h>
#include <nng/protocol/reqrep0/req.h>
-#include <nng/supplemental/util/platform.h>
#include "convey.h"
#include "core/nng_impl.h"
@@ -28,11 +27,11 @@ typedef int (*trantest_proptest_t)(nng_msg *);
typedef struct trantest trantest;
struct trantest {
- const char *tmpl;
- char addr[NNG_MAXADDRLEN + 1];
- nng_socket reqsock;
- nng_socket repsock;
- nni_sp_tran * tran;
+ const char *tmpl;
+ char addr[NNG_MAXADDRLEN + 1];
+ nng_socket reqsock;
+ nng_socket repsock;
+ nni_sp_tran *tran;
int (*init)(struct trantest *);
void (*fini)(struct trantest *);
int (*dialer_init)(nng_dialer);
@@ -105,7 +104,7 @@ trantest_next_address(char *out, const char *prefix)
// we append the port, and for web sockets also a /test path
(void) snprintf(out, NNG_MAXADDRLEN, "%s%u%s", prefix, trantest_port,
- prefix[0] == 'w' ? "/test" : "");
+ prefix[0] == 'w' ? "/test" : "");
trantest_port++;
}
@@ -249,10 +248,10 @@ trantest_send_recv(trantest *tt)
nng_listener l = NNG_LISTENER_INITIALIZER;
nng_dialer d = NNG_DIALER_INITIALIZER;
nng_pipe p = NNG_PIPE_INITIALIZER;
- nng_msg * send;
- nng_msg * recv;
+ nng_msg *send;
+ nng_msg *recv;
size_t len;
- char * url;
+ char *url;
So(trantest_listen(tt, &l) == 0);
So(nng_listener_id(l) > 0);
@@ -299,9 +298,9 @@ trantest_send_recv_multi(trantest *tt)
nng_listener l = NNG_LISTENER_INITIALIZER;
nng_dialer d = NNG_DIALER_INITIALIZER;
nng_pipe p = NNG_PIPE_INITIALIZER;
- nng_msg * send;
- nng_msg * recv;
- char * url;
+ nng_msg *send;
+ nng_msg *recv;
+ char *url;
int i;
char msgbuf[16];
@@ -353,8 +352,8 @@ trantest_check_properties(trantest *tt, trantest_proptest_t f)
Convey("Properties test", {
nng_listener l = NNG_LISTENER_INITIALIZER;
nng_dialer d = NNG_DIALER_INITIALIZER;
- nng_msg * send;
- nng_msg * recv;
+ nng_msg *send;
+ nng_msg *recv;
int rv;
So(trantest_listen(tt, &l) == 0);
@@ -388,9 +387,9 @@ trantest_send_recv_large(trantest *tt)
Convey("Send and recv large data", {
nng_listener l = NNG_LISTENER_INITIALIZER;
nng_dialer d = NNG_DIALER_INITIALIZER;
- nng_msg * send;
- nng_msg * recv;
- char * data;
+ nng_msg *send;
+ nng_msg *recv;
+ char *data;
size_t size;
size = 1024 * 128; // bigger than any transport segment