diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/testutil.c | 17 | ||||
| -rw-r--r-- | tests/testutil.h | 6 |
2 files changed, 15 insertions, 8 deletions
diff --git a/tests/testutil.c b/tests/testutil.c index 6934d4ad..2f6bf24d 100644 --- a/tests/testutil.c +++ b/tests/testutil.c @@ -328,19 +328,24 @@ married(nng_pipe p, nng_pipe_ev ev, void *arg) int testutil_marry(nng_socket s1, nng_socket s2) { - return (testutil_marry_ex(s1, s2, NULL, NULL)); + return (testutil_marry_ex(s1, s2, NULL, NULL, NULL)); } int -testutil_marry_ex(nng_socket s1, nng_socket s2, nng_pipe *p1, nng_pipe *p2) +testutil_marry_ex( + nng_socket s1, nng_socket s2, const char *url, nng_pipe *p1, nng_pipe *p2) { struct marriage_notice note; nng_time timeout; int rv; char addr[32]; - (void) snprintf(addr, sizeof(addr), "inproc://marry%04x%04x%04x%04x", - nng_random(), nng_random(), nng_random(), nng_random()); + if (url == NULL) { + (void) snprintf(addr, sizeof(addr), + "inproc://marry%04x%04x%04x%04x", nng_random(), + nng_random(), nng_random(), nng_random()); + url = addr; + } note.cnt1 = 0; note.cnt2 = 0; @@ -354,8 +359,8 @@ testutil_marry_ex(nng_socket s1, nng_socket s2, nng_pipe *p1, nng_pipe *p2) s1, NNG_PIPE_EV_ADD_POST, married, ¬e)) != 0) || ((rv = nng_pipe_notify( s2, NNG_PIPE_EV_ADD_POST, married, ¬e)) != 0) || - ((rv = nng_listen(s1, addr, NULL, 0)) != 0) || - ((rv = nng_dial(s2, addr, NULL, 0)) != 0)) { + ((rv = nng_listen(s1, url, NULL, 0)) != 0) || + ((rv = nng_dial(s2, url, NULL, 0)) != 0)) { goto done; } diff --git a/tests/testutil.h b/tests/testutil.h index 88d978de..a297b603 100644 --- a/tests/testutil.h +++ b/tests/testutil.h @@ -51,8 +51,10 @@ extern void testutil_scratch_addr(const char *, size_t, char *); extern int testutil_marry(nng_socket, nng_socket); // testutil_marry_ex is like testutil_marry, but returns the pipes that -// were connected. The pipe pointers may be NULL if not needed. -extern int testutil_marry_ex(nng_socket, nng_socket, nng_pipe *, nng_pipe *); +// were connected, and includes an optional URL. The pipe pointers and the +// URL may be NULL if not needed. +extern int testutil_marry_ex( + nng_socket, nng_socket, const char *, nng_pipe *, nng_pipe *); // TEST_NNG_PASS tests for NNG success. It reports the failure if it // did not. |
