aboutsummaryrefslogtreecommitdiff
path: root/tests/testutil.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2020-01-20 16:03:45 -0800
committerGarrett D'Amore <garrett@damore.org>2020-01-20 16:03:45 -0800
commit5e031e639df65d7f12a0d2f776f188fde1b98fd9 (patch)
tree159f9a76efa89ce40bc0cbe32502d6524b28b985 /tests/testutil.c
parent8abf75857e8993a25e50d07bdd6d9628f028d7cc (diff)
downloadnng-5e031e639df65d7f12a0d2f776f188fde1b98fd9.tar.gz
nng-5e031e639df65d7f12a0d2f776f188fde1b98fd9.tar.bz2
nng-5e031e639df65d7f12a0d2f776f188fde1b98fd9.zip
fixes #1163 compat tests are very brittle
This only addresses the newly rewitten compat_tcp test, but it sets the groundwork for the other tests, so that when they are updated to the new acutest.h they can use the new marry code to establish connections cleanly and safely.
Diffstat (limited to 'tests/testutil.c')
-rw-r--r--tests/testutil.c17
1 files changed, 11 insertions, 6 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, &note)) != 0) ||
((rv = nng_pipe_notify(
s2, NNG_PIPE_EV_ADD_POST, married, &note)) != 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;
}