aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt2
-rw-r--r--tests/base64.c8
-rw-r--r--tests/compat_bug777.c2
-rw-r--r--tests/compat_testutil.c229
-rw-r--r--tests/compat_testutil.h213
-rw-r--r--tests/convey.c24
-rw-r--r--tests/convey.h3
-rw-r--r--tests/convey_test.c4
-rw-r--r--tests/cplusplus_pair.cc4
-rw-r--r--tests/files.c3
-rw-r--r--tests/httpserver.c4
-rw-r--r--tests/idhash.c7
-rw-r--r--tests/scalability.c5
-rw-r--r--tests/sock.c20
-rw-r--r--tests/stubs.h7
-rw-r--r--tests/synch.c5
-rw-r--r--tests/tcp.c2
-rw-r--r--tests/tcp6.c4
-rw-r--r--tests/tls.c18
-rw-r--r--tests/trantest.h26
-rw-r--r--tests/ws.c2
-rw-r--r--tests/wss.c6
-rw-r--r--tests/wssfile.c19
-rw-r--r--tests/zt.c64
24 files changed, 349 insertions, 332 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 358e9d00..6ae41ffe 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -77,7 +77,7 @@ if (NNG_TESTS)
macro (add_nng_compat_test NAME TIMEOUT)
list (APPEND all_tests ${NAME})
- add_executable (${NAME} ${NAME}.c)
+ add_executable (${NAME} ${NAME}.c compat_testutil.c)
target_link_libraries (${NAME} ${PROJECT_NAME}_static)
target_link_libraries (${NAME} ${NNG_REQUIRED_LIBRARIES})
target_compile_definitions(${NAME} PUBLIC -DNNG_STATIC_LIB)
diff --git a/tests/base64.c b/tests/base64.c
index 714bd4b2..eac84df2 100644
--- a/tests/base64.c
+++ b/tests/base64.c
@@ -1,6 +1,6 @@
//
-// Copyright 2017 Staysail Systems, Inc. <info@staysail.tech>
-// Copyright 2017 Capitar IT Group BV <info@capitar.com>
+// Copyright 2018 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
// copy of which should be located in the distribution where this
@@ -45,7 +45,7 @@ TestMain("Base64 Verification", {
for (i = 0; (dec = cases[i].decoded) != NULL; i++) {
rv = nni_base64_encode(dec, strlen(dec), buf, 1024);
So(rv >= 0);
- So(rv == strlen(cases[i].encoded));
+ So(rv == (int) strlen(cases[i].encoded));
buf[rv] = 0;
So(strcmp(buf, cases[i].encoded) == 0);
}
@@ -61,7 +61,7 @@ TestMain("Base64 Verification", {
rv = nni_base64_decode(
enc, strlen(enc), (void *) buf, 1024);
So(rv >= 0);
- So(rv == strlen(cases[i].decoded));
+ So(rv == (int) strlen(cases[i].decoded));
buf[rv] = 0;
So(strcmp(buf, cases[i].decoded) == 0);
}
diff --git a/tests/compat_bug777.c b/tests/compat_bug777.c
index 686b8181..ba4a8b02 100644
--- a/tests/compat_bug777.c
+++ b/tests/compat_bug777.c
@@ -25,7 +25,7 @@
#include "nng.h"
#include "compat_testutil.h"
-int main (int argc, const char *argv[])
+int main (NN_UNUSED int argc, NN_UNUSED const char *argv[])
{
int sb;
int sc1;
diff --git a/tests/compat_testutil.c b/tests/compat_testutil.c
new file mode 100644
index 00000000..e24f31fc
--- /dev/null
+++ b/tests/compat_testutil.c
@@ -0,0 +1,229 @@
+/*
+ Copyright (c) 2013 Insollo Entertainment, LLC. All rights reserved.
+ Copyright 2016 Franklin "Snaipe" Mathieu <franklinmathieu@gmail.com>
+ Copyright 2018 Staysail Systems, Inc. <info@staysail.tech>
+ Copyright 2018 Capitar IT Group BV <info@capitar.com>
+
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom
+ the Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+*/
+
+// Note: This file started life in nanomsg. We have copied it, and adjusted
+// it for validating the compatibility features of nanomsg. As much as
+// possible we want to run tests from the nanomsg test suite unmodified.
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "compat_testutil.h"
+#include "nng_compat.h"
+
+int test_socket_impl(char *file, int line, int family, int protocol);
+int test_connect_impl(char *file, int line, int sock, char *address);
+int test_bind_impl(char *file, int line, int sock, char *address);
+void test_close_impl(char *file, int line, int sock);
+void test_send_impl(char *file, int line, int sock, char *data);
+void test_recv_impl(char *file, int line, int sock, char *data);
+void test_drop_impl(char *file, int line, int sock, int err);
+int test_setsockopt_impl(char *file, int line, int sock, int level, int option,
+ const void *optval, size_t optlen);
+
+int
+test_socket_impl(char *file, int line, int family, int protocol)
+{
+ int sock;
+
+ sock = nn_socket(family, protocol);
+ if (sock == -1) {
+ fprintf(stderr, "Failed create socket: %s [%d] (%s:%d)\n",
+ nn_err_strerror(errno), (int) errno, file, line);
+ nn_err_abort();
+ }
+
+ return (sock);
+}
+
+int
+test_connect_impl(char *file, int line, int sock, char *address)
+{
+ int rc;
+
+ rc = nn_connect(sock, address);
+ if (rc < 0) {
+ fprintf(stderr, "Failed connect to \"%s\": %s [%d] (%s:%d)\n",
+ address, nn_err_strerror(errno), (int) errno, file, line);
+ nn_err_abort();
+ }
+ return (rc);
+}
+
+int
+test_bind_impl(char *file, int line, int sock, char *address)
+{
+ int rc;
+
+ rc = nn_bind(sock, address);
+ if (rc < 0) {
+ fprintf(stderr, "Failed bind to \"%s\": %s [%d] (%s:%d)\n",
+ address, nn_err_strerror(errno), (int) errno, file, line);
+ nn_err_abort();
+ }
+ return (rc);
+}
+
+int
+test_setsockopt_impl(char *file, int line, int sock, int level, int option,
+ const void *optval, size_t optlen)
+{
+ int rc;
+
+ rc = nn_setsockopt(sock, level, option, optval, optlen);
+ if (rc < 0) {
+ fprintf(stderr, "Failed set option \"%d\": %s [%d] (%s:%d)\n",
+ option, nn_err_strerror(errno), (int) errno, file, line);
+ nn_err_abort();
+ }
+ return rc;
+}
+
+void
+test_close_impl(char *file, int line, int sock)
+{
+ int rc;
+
+ rc = nn_close(sock);
+ if ((rc != 0) && (errno != EBADF && errno != ETERM)) {
+ fprintf(stderr, "Failed to close socket: %s [%d] (%s:%d)\n",
+ nn_err_strerror(errno), (int) errno, file, line);
+ nn_err_abort();
+ }
+}
+
+void
+test_send_impl(char *file, int line, int sock, char *data)
+{
+ size_t data_len;
+ int rc;
+
+ data_len = strlen(data);
+
+ rc = nn_send(sock, data, data_len, 0);
+ if (rc < 0) {
+ fprintf(stderr, "Failed to send: %s [%d] (%s:%d)\n",
+ nn_err_strerror(errno), (int) errno, file, line);
+ nn_err_abort();
+ }
+ if (rc != (int) data_len) {
+ fprintf(stderr,
+ "Data to send is truncated: %d != %d (%s:%d)\n", rc,
+ (int) data_len, file, line);
+ nn_err_abort();
+ }
+}
+
+void
+test_recv_impl(char *file, int line, int sock, char *data)
+{
+ size_t data_len;
+ int rc;
+ char * buf;
+
+ data_len = strlen(data);
+ /* We allocate plus one byte so that we are sure that message received
+ has correct length and not truncated */
+ buf = malloc(data_len + 1);
+ alloc_assert(buf);
+
+ rc = nn_recv(sock, buf, data_len + 1, 0);
+ if (rc < 0) {
+ fprintf(stderr, "Failed to recv: %s [%d] (%s:%d)\n",
+ nn_err_strerror(errno), (int) errno, file, line);
+ nn_err_abort();
+ }
+ if (rc != (int) data_len) {
+ fprintf(stderr,
+ "Received data has wrong length: %d != %d (%s:%d)\n", rc,
+ (int) data_len, file, line);
+ nn_err_abort();
+ }
+ if (memcmp(data, buf, data_len) != 0) {
+ /* We don't print the data as it may have binary garbage */
+ fprintf(
+ stderr, "Received data is wrong (%s:%d)\n", file, line);
+ nn_err_abort();
+ }
+
+ free(buf);
+}
+
+void
+test_drop_impl(char *file, int line, int sock, int err)
+{
+ int rc;
+ char buf[1024];
+
+ rc = nn_recv(sock, buf, sizeof(buf), 0);
+ if (rc < 0 && err != errno) {
+ fprintf(stderr,
+ "Got wrong err to recv: %s [%d != %d] (%s:%d)\n",
+ nn_err_strerror(errno), (int) errno, err, file, line);
+ nn_err_abort();
+ } else if (rc >= 0) {
+ fprintf(stderr, "Did not drop message: [%d bytes] (%s:%d)\n",
+ rc, file, line);
+ nn_err_abort();
+ }
+}
+
+int
+get_test_port(int argc, const char *argv[])
+{
+ return (atoi(argc < 2 ? "5555" : argv[1]));
+}
+
+void
+test_addr_from(char *out, const char *proto, const char *ip, int port)
+{
+ sprintf(out, "%s://%s:%d", proto, ip, port);
+}
+
+extern int nng_thread_create(void **, void (*)(void *), void *);
+
+int
+nn_thread_init(struct nn_thread *thr, void (*func)(void *), void *arg)
+{
+ return (nng_thread_create(&thr->thr, func, arg));
+}
+
+extern void nng_thread_destroy(void *);
+
+void
+nn_thread_term(struct nn_thread *thr)
+{
+ nng_thread_destroy(thr->thr);
+}
+
+extern void nng_msleep(int32_t);
+
+void
+nn_sleep(int ms)
+{
+ nng_msleep(ms);
+} \ No newline at end of file
diff --git a/tests/compat_testutil.h b/tests/compat_testutil.h
index 00e7cb0b..745f5621 100644
--- a/tests/compat_testutil.h
+++ b/tests/compat_testutil.h
@@ -2,6 +2,8 @@
Copyright (c) 2013 Insollo Entertainment, LLC. All rights reserved.
Copyright 2017 Garrett D'Amore <garrett@damore.org>
Copyright 2016 Franklin "Snaipe" Mathieu <franklinmathieu@gmail.com>
+ Copyright 2018 Staysail Systems, Inc. <info@staysail.tech>
+ Copyright 2018 Capitar IT Group BV <info@capitar.com>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
@@ -40,15 +42,25 @@
#define errno_assert assert
#define alloc_assert(x) assert(x != NULL)
-static int test_socket_impl(char *file, int line, int family, int protocol);
-static int test_connect_impl(char *file, int line, int sock, char *address);
-static int test_bind_impl(char *file, int line, int sock, char *address);
-static void test_close_impl(char *file, int line, int sock);
-static void test_send_impl(char *file, int line, int sock, char *data);
-static void test_recv_impl(char *file, int line, int sock, char *data);
-static void test_drop_impl(char *file, int line, int sock, int err);
-static int test_setsockopt_impl(char *file, int line, int sock, int level,
- int option, const void *optval, size_t optlen);
+#if defined __GNUC__ || defined __llvm__ || defined __clang__
+#define NN_UNUSED __attribute__((unused))
+#else
+#define NN_UNUSED
+#endif
+
+extern int test_socket_impl(char *file, int line, int family, int protocol);
+extern int test_connect_impl(char *file, int line, int sock, char *address);
+extern int test_bind_impl(char *file, int line, int sock, char *address);
+extern void test_close_impl(char *file, int line, int sock);
+extern void test_send_impl(char *file, int line, int sock, char *data);
+extern void test_recv_impl(char *file, int line, int sock, char *data);
+extern void test_drop_impl(char *file, int line, int sock, int err);
+extern int test_setsockopt_impl(char *file, int line, int sock, int level,
+ int option, const void *optval, size_t optlen);
+extern int get_test_port(int argc, const char *argv[]);
+extern void test_addr_from(char *out, const char *proto, const char *ip,
+ int port);
+extern void nn_sleep(int);
#define test_socket(f, p) test_socket_impl(__FILE__, __LINE__, (f), (p))
#define test_connect(s, a) test_connect_impl(__FILE__, __LINE__, (s), (a))
@@ -60,190 +72,11 @@ static int test_setsockopt_impl(char *file, int line, int sock, int level,
#define test_setsockopt(s, l, o, v, z) \
test_setsockopt_impl(__FILE__, __LINE__, (s), (l), (o), (v), (z))
-#define NN_UNUSED
-
-static int
-test_socket_impl(char *file, int line, int family, int protocol)
-{
- int sock;
-
- sock = nn_socket(family, protocol);
- if (sock == -1) {
- fprintf(stderr, "Failed create socket: %s [%d] (%s:%d)\n",
- nn_err_strerror(errno), (int) errno, file, line);
- nn_err_abort();
- }
-
- return sock;
-}
-
-static int
-test_connect_impl(char *file, int line, int sock, char *address)
-{
- int rc;
-
- rc = nn_connect(sock, address);
- if (rc < 0) {
- fprintf(stderr, "Failed connect to \"%s\": %s [%d] (%s:%d)\n",
- address, nn_err_strerror(errno), (int) errno, file, line);
- nn_err_abort();
- }
- return rc;
-}
-
-static int
-test_bind_impl(char *file, int line, int sock, char *address)
-{
- int rc;
-
- rc = nn_bind(sock, address);
- if (rc < 0) {
- fprintf(stderr, "Failed bind to \"%s\": %s [%d] (%s:%d)\n",
- address, nn_err_strerror(errno), (int) errno, file, line);
- nn_err_abort();
- }
- return rc;
-}
-
-static int
-test_setsockopt_impl(char *file, int line, int sock, int level, int option,
- const void *optval, size_t optlen)
-{
- int rc;
-
- rc = nn_setsockopt(sock, level, option, optval, optlen);
- if (rc < 0) {
- fprintf(stderr, "Failed set option \"%d\": %s [%d] (%s:%d)\n",
- option, nn_err_strerror(errno), (int) errno, file, line);
- nn_err_abort();
- }
- return rc;
-}
-
-static void
-test_close_impl(char *file, int line, int sock)
-{
- int rc;
-
- rc = nn_close(sock);
- if ((rc != 0) && (errno != EBADF && errno != ETERM)) {
- fprintf(stderr, "Failed to close socket: %s [%d] (%s:%d)\n",
- nn_err_strerror(errno), (int) errno, file, line);
- nn_err_abort();
- }
-}
-
-static void
-test_send_impl(char *file, int line, int sock, char *data)
-{
- size_t data_len;
- int rc;
-
- data_len = strlen(data);
-
- rc = nn_send(sock, data, data_len, 0);
- if (rc < 0) {
- fprintf(stderr, "Failed to send: %s [%d] (%s:%d)\n",
- nn_err_strerror(errno), (int) errno, file, line);
- nn_err_abort();
- }
- if (rc != (int) data_len) {
- fprintf(stderr,
- "Data to send is truncated: %d != %d (%s:%d)\n", rc,
- (int) data_len, file, line);
- nn_err_abort();
- }
-}
-
-static void
-test_recv_impl(char *file, int line, int sock, char *data)
-{
- size_t data_len;
- int rc;
- char * buf;
-
- data_len = strlen(data);
- /* We allocate plus one byte so that we are sure that message received
- has correct length and not truncated */
- buf = malloc(data_len + 1);
- alloc_assert(buf);
-
- rc = nn_recv(sock, buf, data_len + 1, 0);
- if (rc < 0) {
- fprintf(stderr, "Failed to recv: %s [%d] (%s:%d)\n",
- nn_err_strerror(errno), (int) errno, file, line);
- nn_err_abort();
- }
- if (rc != (int) data_len) {
- fprintf(stderr,
- "Received data has wrong length: %d != %d (%s:%d)\n", rc,
- (int) data_len, file, line);
- nn_err_abort();
- }
- if (memcmp(data, buf, data_len) != 0) {
- /* We don't print the data as it may have binary garbage */
- fprintf(
- stderr, "Received data is wrong (%s:%d)\n", file, line);
- nn_err_abort();
- }
-
- free(buf);
-}
-
-static void
-test_drop_impl(char *file, int line, int sock, int err)
-{
- int rc;
- char buf[1024];
-
- rc = nn_recv(sock, buf, sizeof(buf), 0);
- if (rc < 0 && err != errno) {
- fprintf(stderr,
- "Got wrong err to recv: %s [%d != %d] (%s:%d)\n",
- nn_err_strerror(errno), (int) errno, err, file, line);
- nn_err_abort();
- } else if (rc >= 0) {
- fprintf(stderr, "Did not drop message: [%d bytes] (%s:%d)\n",
- rc, file, line);
- nn_err_abort();
- }
-}
-
-static int
-get_test_port(int argc, const char *argv[])
-{
- return atoi(argc < 2 ? "5555" : argv[1]);
-}
-
-static void
-test_addr_from(char *out, const char *proto, const char *ip, int port)
-{
- sprintf(out, "%s://%s:%d", proto, ip, port);
-}
-
-void
-nn_sleep(int32_t msec)
-{
- void nng_msleep(int32_t);
- nng_msleep(msec);
-}
-
struct nn_thread {
void *thr;
};
-int
-nn_thread_init(struct nn_thread *thr, void (*func)(void *), void *arg)
-{
- int nng_thread_create(void **, void (*)(void *), void *);
- return (nng_thread_create(&thr->thr, func, arg));
-}
-
-void
-nn_thread_term(struct nn_thread *thr)
-{
- void nng_thread_destroy(void *);
- nng_thread_destroy(thr->thr);
-}
+extern int nn_thread_init(struct nn_thread *, void (*)(void *), void *);
+extern void nn_thread_term(struct nn_thread *);
#endif // TESTUTIL_H_INCLUDED
diff --git a/tests/convey.c b/tests/convey.c
index 5e87779f..2dd4c323 100644
--- a/tests/convey.c
+++ b/tests/convey.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Garrett D'Amore <garrett@damore.org>
+ * Copyright 2018 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
@@ -96,7 +96,6 @@ static HANDLE convey_console;
#endif
#define CONVEY_EXIT_OK 0
-#define CONVEY_EXIT_USAGE 1
#define CONVEY_EXIT_FAIL 2
#define CONVEY_EXIT_FATAL 3
#define CONVEY_EXIT_NOMEM 4
@@ -507,19 +506,18 @@ convey_start_timer(struct convey_timer *pc)
pc->timer_base = pcnt.QuadPart;
pc->timer_rate = pfreq.QuadPart;
#elif defined(CLOCK_MONOTONIC) && !defined(CONVEY_USE_GETTIMEOFDAY)
- uint64_t usecs;
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
- pc->timer_base = ts.tv_sec * 1000000000;
- pc->timer_base += ts.tv_nsec;
+ pc->timer_base = (uint64_t) ts.tv_sec * 1000000000;
+ pc->timer_base += (uint64_t) ts.tv_nsec;
pc->timer_rate = 1000000000;
#else
struct timeval tv;
gettimeofday(&tv, NULL);
- pc->timer_base = tv.tv_sec * 1000000;
- pc->timer_base += tv.tv_usec;
+ pc->timer_base = (uint64_t) tv.tv_sec * 1000000;
+ pc->timer_base += (uint64_t) tv.tv_usec;
pc->timer_rate = 1000000;
#endif
pc->timer_running = 1;
@@ -542,7 +540,7 @@ convey_stop_timer(struct convey_timer *pc)
clock_gettime(CLOCK_MONOTONIC, &ts);
ns = (ts.tv_sec * 1000000000);
- ns += ts.tv_nsec;
+ ns += (uint64_t) ts.tv_nsec;
pc->timer_count += (ns - pc->timer_base);
#else
uint64_t us;
@@ -639,7 +637,7 @@ convey_tls_get(void)
#else
-pthread_key_t convey_tls_key;
+static pthread_key_t convey_tls_key;
static int
convey_tls_init(void)
@@ -851,8 +849,6 @@ conveyPrintf(const char *file, int line, const char *fmt, ...)
va_end(ap);
}
-extern int conveyMainImpl(void);
-
static void
convey_init_term(void)
{
@@ -885,9 +881,9 @@ convey_init_term(void)
// Values probably don't matter, just need to be
// different!
convey_nocolor = "\033[0m";
- convey_green = "\033[32m";
- convey_yellow = "\033[33m";
- convey_red = "\033[31m";
+ convey_green = "\033[32m";
+ convey_yellow = "\033[33m";
+ convey_red = "\033[31m";
}
term = getenv("TERM");
#endif
diff --git a/tests/convey.h b/tests/convey.h
index 9d9be0fa..299e0611 100644
--- a/tests/convey.h
+++ b/tests/convey.h
@@ -71,8 +71,8 @@
* framework creates a context automatically for each convey scope.
*/
typedef struct {
- jmp_buf cs_jmp;
void * cs_data;
+ jmp_buf cs_jmp;
} conveyScope;
/* These functions are not for use by tests -- they are used internally. */
@@ -90,6 +90,7 @@ extern void conveySkip(const char *, int, const char *, ...);
extern void conveyFail(const char *, int, const char *, ...);
extern void conveyError(const char *, int, const char *, ...);
extern void conveyPrintf(const char *, int, const char *, ...);
+extern int conveyMainImpl(void);
/*
* conveyRun is a helper macro not to be called directly by user
diff --git a/tests/convey_test.c b/tests/convey_test.c
index 0970e664..53ea2954 100644
--- a/tests/convey_test.c
+++ b/tests/convey_test.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2017 Garrett D'Amore <garrett@damore.org>
+ * Copyright 2018 Garrett D'Amore <garrett@damore.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"),
@@ -84,7 +84,9 @@ Main({
Test("Skipping works", {
int skipped = 0;
SkipConvey("ConveySkip works.", { So(skipped = 0); });
+ So(skipped == 0);
Convey("Assertion skipping works.", { SkipSo(skipped == 1); });
+ So(skipped == 0);
});
Test("Reset", {
diff --git a/tests/cplusplus_pair.cc b/tests/cplusplus_pair.cc
index 11ce1912..02f57eaa 100644
--- a/tests/cplusplus_pair.cc
+++ b/tests/cplusplus_pair.cc
@@ -26,6 +26,8 @@ main(int argc, char **argv)
int rv;
size_t sz;
char buf[8];
+ (void) argc;
+ (void) argv;
if ((rv = nng_pair1_open(&s1)) != 0) {
throw nng_strerror(rv);
@@ -68,6 +70,8 @@ main(int argc, char **argv)
std::cout << "Pass." << std::endl;
#else
+ (void) argc;
+ (void) argv;
std::cout << "Skipped (protocol unconfigured)." << std::endl;
#endif
diff --git a/tests/files.c b/tests/files.c
index 3b21ac65..9983d7d3 100644
--- a/tests/files.c
+++ b/tests/files.c
@@ -181,9 +181,10 @@ TestMain("Platform File Support", {
});
Convey("Directory walk works", {
- struct walkarg wa = { 0 };
+ struct walkarg wa;
int rv;
+ memset(&wa, 0, sizeof(wa));
rv = nni_file_walk(mydir, walker, &wa, 0);
So(rv == 0);
So(wa.a == 1);
diff --git a/tests/httpserver.c b/tests/httpserver.c
index bbdd8423..e3d7ab25 100644
--- a/tests/httpserver.c
+++ b/tests/httpserver.c
@@ -1,5 +1,5 @@
//
-// Copyright 2018 Garrett D'Amore <garrett@damore.org>
+// Copyright 2018 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
@@ -247,7 +247,7 @@ TestMain("HTTP Server", {
ptr = nng_http_res_get_header(
res, "Content-Length");
So(ptr != NULL);
- So(atoi(ptr) == strlen(doc1));
+ So(atoi(ptr) == (int) strlen(doc1));
iov.iov_len = strlen(doc1);
iov.iov_buf = chunk;
diff --git a/tests/idhash.c b/tests/idhash.c
index e4183e98..32751334 100644
--- a/tests/idhash.c
+++ b/tests/idhash.c
@@ -1,6 +1,6 @@
//
-// Copyright 2017 Garrett D'Amore <garrett@damore.org>
-// Copyright 2017 Capitar IT Group BV <info@capitar.com>
+// Copyright 2018 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
// copy of which should be located in the distribution where this
@@ -145,13 +145,12 @@ Main({
nni_idhash *h;
int expect[5];
uint64_t id;
- int i;
So(nni_idhash_init(&h) == 0);
Reset({ nni_idhash_fini(h); });
nni_idhash_set_limits(h, 10, 13, 10);
So(1);
Convey("We can fill the table", {
- for (i = 0; i < 4; i++) {
+ for (uint64_t i = 0; i < 4; i++) {
So(nni_idhash_alloc(
h, &id, &expect[i]) == 0);
So(id == (i + 10));
diff --git a/tests/scalability.c b/tests/scalability.c
index d869d5fc..9695c53c 100644
--- a/tests/scalability.c
+++ b/tests/scalability.c
@@ -1,6 +1,6 @@
//
-// Copyright 2017 Garrett D'Amore <garrett@damore.org>
-// Copyright 2017 Capitar IT Group BV <info@capitar.com>
+// Copyright 2018 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
// copy of which should be located in the distribution where this
@@ -27,6 +27,7 @@ void
serve(void *arg)
{
nng_msg *msg;
+ (void) arg; // unused
for (;;) {
msg = NULL;
diff --git a/tests/sock.c b/tests/sock.c
index d3af414a..404e160b 100644
--- a/tests/sock.c
+++ b/tests/sock.c
@@ -75,8 +75,6 @@ TestMain("Socket Operations", {
Convey("We can set and get options", {
nng_duration to = 1234;
- int64_t v = 0;
- size_t sz;
So(nng_setopt_ms(s1, NNG_OPT_SENDTIMEO, to) == 0);
@@ -99,7 +97,7 @@ TestMain("Socket Operations", {
s1, NNG_OPT_SOCKNAME, name, &sz) == 0);
So(sz > 0 && sz < 64);
So(sz == nni_strnlen(name, 64) + 1);
- So(atoi(name) == (unsigned) s1);
+ So(atoi(name) == (int) s1);
So(nng_setopt(
s1, NNG_OPT_SOCKNAME, "hello", 6) == 0);
@@ -164,6 +162,8 @@ TestMain("Socket Operations", {
Convey("We can apply options before endpoint", {
nng_listener l;
char addr[NNG_MAXADDRLEN];
+ size_t sz;
+
trantest_next_address(
addr, "ipc:///tmp/lopt_%u");
@@ -194,8 +194,8 @@ TestMain("Socket Operations", {
});
});
Convey("Short size is not copied", {
- sz = 0;
- to = 0;
+ size_t sz = 0;
+ to = 0;
So(nng_getopt(
s1, NNG_OPT_SENDTIMEO, &to, &sz) == 0);
So(sz == sizeof(to));
@@ -212,7 +212,7 @@ TestMain("Socket Operations", {
});
Convey("Correct size is copied", {
- sz = sizeof(to);
+ size_t sz = sizeof(to);
So(nng_getopt(
s1, NNG_OPT_SENDTIMEO, &to, &sz) == 0);
So(sz == sizeof(to));
@@ -220,8 +220,8 @@ TestMain("Socket Operations", {
});
Convey("Short size buf is not copied", {
- int l = 5;
- sz = 0;
+ int l = 5;
+ size_t sz = 0;
So(nng_getopt(s1, NNG_OPT_RECVBUF, &l, &sz) ==
0);
So(sz == sizeof(l));
@@ -241,8 +241,8 @@ TestMain("Socket Operations", {
});
Convey("Short timeout fails", {
- to = 0;
- sz = sizeof(to) - 1;
+ size_t sz = sizeof(to) - 1;
+ to = 0;
So(nng_setopt(s1, NNG_OPT_RECVTIMEO, &to,
sz) == NNG_EINVAL);
So(nng_setopt(s1, NNG_OPT_RECONNMINT, &to,
diff --git a/tests/stubs.h b/tests/stubs.h
index 0641c970..99f92f7d 100644
--- a/tests/stubs.h
+++ b/tests/stubs.h
@@ -1,5 +1,6 @@
//
-// Copyright 2017 Garrett D'Amore <garrett@damore.org>
+// Copyright 2018 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
// copy of which should be located in the distribution where this
@@ -40,13 +41,15 @@ getms(void)
return (0);
}
tv.tv_sec -= epoch;
- return (((uint64_t)(tv.tv_sec) * 1000) + (tv.tv_usec / 1000));
+ return (
+ ((uint64_t)(tv.tv_sec) * 1000) + (uint64_t)(tv.tv_usec / 1000));
#endif
}
int
nosocket(nng_socket *s)
{
+ (void) s; // not used
ConveySkip("Protocol unconfigured");
return (NNG_ENOTSUP);
}
diff --git a/tests/synch.c b/tests/synch.c
index b1d0d66a..c9de3deb 100644
--- a/tests/synch.c
+++ b/tests/synch.c
@@ -1,6 +1,6 @@
//
-// Copyright 2017 Garrett D'Amore <garrett@damore.org>
-// Copyright 2017 Capitar IT Group BV <info@capitar.com>
+// Copyright 2018 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
// copy of which should be located in the distribution where this
@@ -158,7 +158,6 @@ test_sync_fallback(void)
nni_plat_sync_fallback = 1;
Convey("Mutexes work", {
nni_mtx mx;
- int rv;
nni_mtx_init(&mx);
diff --git a/tests/tcp.c b/tests/tcp.c
index 5860eb03..ef572c9d 100644
--- a/tests/tcp.c
+++ b/tests/tcp.c
@@ -21,7 +21,7 @@
#endif
static int
-check_props_v4(nng_msg *msg, nng_listener l, nng_dialer d)
+check_props_v4(nng_msg *msg)
{
nng_pipe p;
size_t z;
diff --git a/tests/tcp6.c b/tests/tcp6.c
index a3e55d18..c00f00f2 100644
--- a/tests/tcp6.c
+++ b/tests/tcp6.c
@@ -37,7 +37,7 @@ has_v6(void)
}
static int
-check_props_v6(nng_msg *msg, nng_listener l, nng_dialer d)
+check_props_v6(nng_msg *msg)
{
nng_pipe p;
size_t z;
@@ -68,8 +68,6 @@ check_props_v6(nng_msg *msg, nng_listener l, nng_dialer d)
So(ra.s_un.s_family == NNG_AF_INET6);
So(ra.s_un.s_in6.sa_port != 0);
So(memcmp(ra.s_un.s_in6.sa_addr, loopback, 16) == 0);
-
- So(nng_dialer_getopt(d, NNG_OPT_REMADDR, &ra, &z) != 0);
});
Convey("Malformed TCPv6 addresses do not panic", {
diff --git a/tests/tls.c b/tests/tls.c
index c977d57f..02a89f97 100644
--- a/tests/tls.c
+++ b/tests/tls.c
@@ -103,7 +103,7 @@ static const char key[] =
"-----END RSA PRIVATE KEY-----\n";
static int
-check_props_v4(nng_msg *msg, nng_listener l, nng_dialer d)
+check_props_v4(nng_msg *msg)
{
nng_pipe p;
size_t z;
@@ -132,7 +132,7 @@ check_props_v4(nng_msg *msg, nng_listener l, nng_dialer d)
}
static int
-init_dialer_tls(trantest *tt, nng_dialer d)
+init_dialer_tls(nng_dialer d)
{
nng_tls_config *cfg;
int rv;
@@ -157,7 +157,7 @@ out:
}
static int
-init_listener_tls(trantest *tt, nng_listener l)
+init_listener_tls(nng_listener l)
{
nng_tls_config *cfg;
int rv;
@@ -177,7 +177,7 @@ out:
}
static int
-init_dialer_tls_file(trantest *tt, nng_dialer d)
+init_dialer_tls_file(nng_dialer d)
{
int rv;
char *tmpdir;
@@ -205,7 +205,7 @@ init_dialer_tls_file(trantest *tt, nng_dialer d)
}
static int
-init_listener_tls_file(trantest *tt, nng_listener l)
+init_listener_tls_file(nng_listener l)
{
int rv;
char *tmpdir;
@@ -368,7 +368,7 @@ TestMain("TLS Transport", {
});
trantest_next_address(addr, "tls+tcp://*:%u");
So(nng_listener_create(&l, s1, addr) == 0);
- So(init_listener_tls_file(NULL, l) == 0);
+ So(init_listener_tls_file(l) == 0);
So(nng_listener_start(l, 0) == 0);
nng_msleep(100);
@@ -376,7 +376,7 @@ TestMain("TLS Transport", {
trantest_prev_address(addr, "tls+tcp://127.0.0.1:%u");
So(nng_setopt_ms(s2, NNG_OPT_RECVTIMEO, 200) == 0);
So(nng_dialer_create(&d, s2, addr) == 0);
- So(init_dialer_tls_file(NULL, d) == 0);
+ So(init_dialer_tls_file(d) == 0);
So(nng_dialer_setopt_int(d, NNG_OPT_TLS_AUTH_MODE,
NNG_TLS_AUTH_MODE_OPTIONAL) == 0);
So(nng_dialer_setopt_string(
@@ -413,14 +413,14 @@ TestMain("TLS Transport", {
});
trantest_next_address(addr, "tls+tcp://*:%u");
So(nng_listener_create(&l, s1, addr) == 0);
- So(init_listener_tls_file(NULL, l) == 0);
+ So(init_listener_tls_file(l) == 0);
So(nng_listener_start(l, 0) == 0);
nng_msleep(100);
// reset port back one
trantest_prev_address(addr, "tls+tcp://localhost:%u");
So(nng_dialer_create(&d, s2, addr) == 0);
- So(init_dialer_tls_file(NULL, d) == 0);
+ So(init_dialer_tls_file(d) == 0);
So(nng_setopt_ms(s2, NNG_OPT_RECVTIMEO, 200) == 0);
So(nng_dialer_start(d, 0) == 0);
nng_msleep(100);
diff --git a/tests/trantest.h b/tests/trantest.h
index 771b761e..13445eaf 100644
--- a/tests/trantest.h
+++ b/tests/trantest.h
@@ -20,7 +20,7 @@
// we can avoid rewriting the same tests for each new transport. Include this
// file once in your test code. The test framework uses the REQ/REP protocol
// for messaging.
-typedef int (*trantest_proptest_t)(nng_msg *, nng_listener, nng_dialer);
+typedef int (*trantest_proptest_t)(nng_msg *);
typedef struct trantest trantest;
@@ -32,14 +32,26 @@ struct trantest {
nni_tran * tran;
int (*init)(struct trantest *);
void (*fini)(struct trantest *);
- int (*dialer_init)(struct trantest *, nng_dialer);
- int (*listener_init)(struct trantest *, nng_listener);
- int (*proptest)(nng_msg *, nng_listener, nng_dialer);
+ int (*dialer_init)(nng_dialer);
+ int (*listener_init)(nng_listener);
+ int (*proptest)(nng_msg *);
void *private; // transport specific private data
};
unsigned trantest_port = 0;
+extern int notransport(void);
+extern void trantest_checktran(const char *url);
+extern void trantest_next_address(char *out, const char *template);
+extern void trantest_prev_address(char *out, const char *template);
+extern void trantest_init(trantest *tt, const char *addr);
+extern int trantest_dial(trantest *tt, nng_dialer *dp);
+extern int trantest_listen(trantest *tt, nng_listener *lp);
+extern void trantest_scheme(trantest *tt);
+extern void trantest_test(trantest *tt);
+extern void trantest_test_extended(const char *addr, trantest_proptest_t f);
+extern void trantest_test_all(const char *addr);
+
#ifndef NNG_TRANSPORT_ZEROTIER
#define nng_zt_register notransport
#endif
@@ -166,7 +178,7 @@ trantest_dial(trantest *tt, nng_dialer *dp)
return (rv);
}
if (tt->dialer_init != NULL) {
- if ((rv = tt->dialer_init(tt, d)) != 0) {
+ if ((rv = tt->dialer_init(d)) != 0) {
nng_dialer_close(d);
return (rv);
}
@@ -191,7 +203,7 @@ trantest_listen(trantest *tt, nng_listener *lp)
return (rv);
}
if (tt->listener_init != NULL) {
- if ((rv = tt->listener_init(tt, l)) != 0) {
+ if ((rv = tt->listener_init(l)) != 0) {
nng_listener_close(l);
return (rv);
}
@@ -393,7 +405,7 @@ trantest_check_properties(trantest *tt, trantest_proptest_t f)
So(recv != NULL);
So(nng_msg_len(recv) == 5);
So(strcmp(nng_msg_body(recv), "props") == 0);
- rv = f(recv, l, d);
+ rv = f(recv);
nng_msg_free(recv);
So(rv == 0);
});
diff --git a/tests/ws.c b/tests/ws.c
index 0527337e..4a8bd7a7 100644
--- a/tests/ws.c
+++ b/tests/ws.c
@@ -22,7 +22,7 @@
#endif
static int
-check_props_v4(nng_msg *msg, nng_listener l, nng_dialer d)
+check_props_v4(nng_msg *msg)
{
nng_pipe p;
size_t z;
diff --git a/tests/wss.c b/tests/wss.c
index aee982c8..ebb2e310 100644
--- a/tests/wss.c
+++ b/tests/wss.c
@@ -130,7 +130,7 @@ validloopback(nng_sockaddr *sa)
}
static int
-check_props(nng_msg *msg, nng_listener l, nng_dialer d)
+check_props(nng_msg *msg)
{
nng_pipe p;
size_t z;
@@ -180,7 +180,7 @@ check_props(nng_msg *msg, nng_listener l, nng_dialer d)
}
static int
-init_dialer_wss(trantest *tt, nng_dialer d)
+init_dialer_wss(nng_dialer d)
{
nng_tls_config *cfg;
int rv;
@@ -206,7 +206,7 @@ out:
}
static int
-init_listener_wss(trantest *tt, nng_listener l)
+init_listener_wss(nng_listener l)
{
nng_tls_config *cfg;
int rv;
diff --git a/tests/wssfile.c b/tests/wssfile.c
index 73bc1cdb..82c519e1 100644
--- a/tests/wssfile.c
+++ b/tests/wssfile.c
@@ -130,7 +130,7 @@ validloopback(nng_sockaddr *sa)
}
static int
-check_props(nng_msg *msg, nng_listener l, nng_dialer d)
+check_props(nng_msg *msg)
{
nng_pipe p;
size_t z;
@@ -138,7 +138,6 @@ check_props(nng_msg *msg, nng_listener l, nng_dialer d)
nng_sockaddr ra;
char * buf;
size_t len;
- int v;
p = nng_msg_get_pipe(msg);
So(p > 0);
@@ -181,7 +180,7 @@ check_props(nng_msg *msg, nng_listener l, nng_dialer d)
}
static int
-init_dialer_wss_file(trantest *tt, nng_dialer d)
+init_dialer_wss_file(nng_dialer d)
{
int rv;
char *tmpdir;
@@ -209,7 +208,7 @@ init_dialer_wss_file(trantest *tt, nng_dialer d)
}
static int
-init_listener_wss_file(trantest *tt, nng_listener l)
+init_listener_wss_file(nng_listener l)
{
int rv;
char *tmpdir;
@@ -267,8 +266,6 @@ TestMain("WebSocket Secure (TLS) Transport (file based)", {
nng_socket s1;
nng_socket s2;
nng_listener l;
- char * buf;
- size_t sz;
char addr[NNG_MAXADDRLEN];
So(nng_pair_open(&s1) == 0);
@@ -279,7 +276,7 @@ TestMain("WebSocket Secure (TLS) Transport (file based)", {
});
trantest_next_address(addr, "wss://:%u/test");
So(nng_listener_create(&l, s1, addr) == 0);
- So(init_listener_wss_file(NULL, l) == 0);
+ So(init_listener_wss_file(l) == 0);
So(nng_listener_start(l, 0) == 0);
nng_msleep(100);
@@ -309,7 +306,7 @@ TestMain("WebSocket Secure (TLS) Transport (file based)", {
});
trantest_next_address(addr, "wss://:%u/test");
So(nng_listener_create(&l, s1, addr) == 0);
- So(init_listener_wss_file(NULL, l) == 0);
+ So(init_listener_wss_file(l) == 0);
So(nng_listener_start(l, 0) == 0);
nng_msleep(100);
@@ -317,7 +314,7 @@ TestMain("WebSocket Secure (TLS) Transport (file based)", {
trantest_prev_address(addr, "wss://127.0.0.1:%u/test");
So(nng_setopt_ms(s2, NNG_OPT_RECVTIMEO, 200) == 0);
So(nng_dialer_create(&d, s2, addr) == 0);
- So(init_dialer_wss_file(NULL, d) == 0);
+ So(init_dialer_wss_file(d) == 0);
So(nng_dialer_setopt_int(d, NNG_OPT_TLS_AUTH_MODE,
NNG_TLS_AUTH_MODE_OPTIONAL) == 0);
So(nng_dialer_setopt_string(
@@ -361,14 +358,14 @@ TestMain("WebSocket Secure (TLS) Transport (file based)", {
});
trantest_next_address(addr, "wss://:%u/test");
So(nng_listener_create(&l, s1, addr) == 0);
- So(init_listener_wss_file(NULL, l) == 0);
+ So(init_listener_wss_file(l) == 0);
So(nng_listener_start(l, 0) == 0);
nng_msleep(100);
// reset port back one
trantest_prev_address(addr, "wss://localhost:%u/test");
So(nng_dialer_create(&d, s2, addr) == 0);
- So(init_dialer_wss_file(NULL, d) == 0);
+ So(init_dialer_wss_file(d) == 0);
So(nng_setopt_ms(s2, NNG_OPT_RECVTIMEO, 200) == 0);
So(nng_dialer_start(d, 0) == 0);
nng_msleep(100);
diff --git a/tests/zt.c b/tests/zt.c
index 02e098fa..c8b7563c 100644
--- a/tests/zt.c
+++ b/tests/zt.c
@@ -44,7 +44,7 @@ mkdir(const char *path, int mode)
#endif
static int
-check_props(nng_msg *msg, nng_listener l, nng_dialer d)
+check_props(nng_msg *msg)
{
nng_sockaddr la, ra;
nng_pipe p;
@@ -78,8 +78,6 @@ check_props(nng_msg *msg, nng_listener l, nng_dialer d)
So(nng_pipe_getopt(p, NNG_OPT_ZT_NODE, &mynode, &z) == 0);
So(mynode != 0);
So(ra.s_un.s_zt.sa_nodeid == mynode);
-
- So(nng_dialer_getopt(d, NNG_OPT_REMADDR, &ra, &z) != 0);
});
Convey("NWID property works", {
@@ -89,16 +87,6 @@ check_props(nng_msg *msg, nng_listener l, nng_dialer d)
nwid = 0;
So(nng_pipe_getopt(p, NNG_OPT_ZT_NWID, &nwid, &z) == 0);
So(nwid = 0xa09acf02337b057bull);
-
- z = sizeof(nwid);
- nwid = 0;
- So(nng_dialer_getopt(d, NNG_OPT_ZT_NWID, &nwid, &z) == 0);
- So(nwid = 0xa09acf02337b057bull);
-
- z = sizeof(nwid);
- nwid = 0;
- So(nng_listener_getopt(l, NNG_OPT_ZT_NWID, &nwid, &z) == 0);
- So(nwid = 0xa09acf02337b057bull);
});
Convey("Network status property works", {
@@ -107,23 +95,6 @@ check_props(nng_msg *msg, nng_listener l, nng_dialer d)
s = 0;
So(nng_pipe_getopt(p, NNG_OPT_ZT_NETWORK_STATUS, &s, &z) == 0);
So(s == nng_zt_network_status_ok);
-
- z = sizeof(s);
- s = 0;
- So(nng_dialer_getopt(d, NNG_OPT_ZT_NETWORK_STATUS, &s, &z) ==
- 0);
- So(s == nng_zt_network_status_ok);
-
- z = sizeof(s);
- s = 0;
- So(nng_listener_getopt(l, NNG_OPT_ZT_NETWORK_STATUS, &s, &z) ==
- 0);
- So(s == nng_zt_network_status_ok);
-
- So(nng_dialer_setopt(d, NNG_OPT_ZT_NETWORK_STATUS, &s, z) ==
- NNG_EREADONLY);
- So(nng_listener_setopt(l, NNG_OPT_ZT_NETWORK_STATUS, &s, z) ==
- NNG_EREADONLY);
});
Convey("Ping properties work", {
@@ -138,20 +109,6 @@ check_props(nng_msg *msg, nng_listener l, nng_dialer d)
t = 0;
So(nng_pipe_getopt_ms(p, NNG_OPT_ZT_PING_TIME, &t) == 0);
So(t > 1000 && t < 3600000); // 1 sec - 1 hour
-
- c = 0;
- So(nng_dialer_getopt_int(d, NNG_OPT_ZT_PING_COUNT, &c) == 0);
- So(c > 0 && c < 10); // actually 5...
-
- t = 0;
- So(nng_dialer_getopt_ms(d, NNG_OPT_ZT_PING_TIME, &t) == 0);
- So(t > 1000 && t < 3600000); // 1 sec - 1 hour
-
- So(nng_dialer_setopt_int(d, NNG_OPT_ZT_PING_COUNT, 20) == 0);
- So(nng_dialer_setopt_int(d, NNG_OPT_ZT_PING_COUNT, 20) == 0);
- So(nng_dialer_setopt_ms(d, NNG_OPT_ZT_PING_TIME, 2000) == 0);
- So(nng_listener_setopt_int(l, NNG_OPT_ZT_PING_COUNT, 0) == 0);
- So(nng_listener_setopt_ms(l, NNG_OPT_ZT_PING_TIME, 0) == 0);
});
Convey("Home property works", {
@@ -159,20 +116,6 @@ check_props(nng_msg *msg, nng_listener l, nng_dialer d)
z = sizeof(v);
So(nng_pipe_getopt(p, NNG_OPT_ZT_HOME, v, &z) == 0);
So(strlen(v) < sizeof(v));
-
- z = sizeof(v);
- So(nng_dialer_getopt(d, NNG_OPT_ZT_HOME, v, &z) == 0);
- So(strlen(v) < sizeof(v));
-
- z = sizeof(v);
- So(nng_listener_getopt(l, NNG_OPT_ZT_HOME, v, &z) == 0);
- So(strlen(v) < sizeof(v));
-
- z = strlen("/tmp/bogus") + 1;
- So(nng_dialer_setopt(d, NNG_OPT_ZT_HOME, "/tmp/bogus", z) ==
- NNG_ESTATE);
- So(nng_listener_setopt(l, NNG_OPT_ZT_HOME, "/tmp/bogus", z) ==
- NNG_ESTATE);
});
Convey("MTU property works", {
@@ -187,11 +130,10 @@ check_props(nng_msg *msg, nng_listener l, nng_dialer d)
Convey("Network name property works", {
char name[NNG_MAXADDRLEN];
size_t namesz;
- int status;
namesz = sizeof(name);
- So(nng_listener_getopt(
- l, NNG_OPT_ZT_NETWORK_NAME, name, &namesz) == 0);
+ So(nng_pipe_getopt(
+ p, NNG_OPT_ZT_NETWORK_NAME, name, &namesz) == 0);
So(strcmp(name, "nng_test_open") == 0);
});