diff options
| author | Garrett D'Amore <garrett@damore.org> | 2020-01-20 16:03:45 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2020-01-20 16:03:45 -0800 |
| commit | 5e031e639df65d7f12a0d2f776f188fde1b98fd9 (patch) | |
| tree | 159f9a76efa89ce40bc0cbe32502d6524b28b985 /src/compat/nanomsg/compat_testutil.h | |
| parent | 8abf75857e8993a25e50d07bdd6d9628f028d7cc (diff) | |
| download | nng-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 'src/compat/nanomsg/compat_testutil.h')
| -rw-r--r-- | src/compat/nanomsg/compat_testutil.h | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/compat/nanomsg/compat_testutil.h b/src/compat/nanomsg/compat_testutil.h index afd75c34..113d6672 100644 --- a/src/compat/nanomsg/compat_testutil.h +++ b/src/compat/nanomsg/compat_testutil.h @@ -1,5 +1,5 @@ // -// Copyright 2019 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2020 Staysail Systems, Inc. <info@staysail.tech> // // This software is supplied under the terms of the MIT License, a // copy of which should be located in the distribution where this @@ -41,6 +41,36 @@ extern "C" { expect, nng_strerror(err_), result_); \ } while (0) +// These macros use some details of the socket and pipe which are not public. +// We do that to facilitate testing. Don't rely on this equivalence in your +// own application code. + +#define TEST_NN_MARRY(s1, s2) \ + do { \ + int rv_; \ + nng_socket s1_, s2_; \ + s1_.id = s1; \ + s2_.id = s2; \ + \ + TEST_CHECK_(testutil_marry(s1_, s2_) == 0, "marry %s", \ + nng_strerror(rv_)); \ + } while (0) + +#define TEST_NN_MARRY_EX(s1, s2, url, p1, p2) \ + do { \ + int rv_; \ + nng_socket s1_, s2_; \ + nng_pipe p1_, p2_; \ + s1_.id = s1; \ + s2_.id = s2; \ + rv_ = testutil_marry_ex(s1_, s2_, url, &p1_, &p2_); \ + TEST_CHECK_(rv_ == 0, "marry %s", nng_strerror(rv_)); \ + p1 = p1_.id; \ + p2 = p2_.id; \ + TEST_CHECK(p1 >= 0); \ + TEST_CHECK(p2 >= 0); \ + } while (0) + #ifdef __cplusplus }; #endif |
