diff options
| author | Garrett D'Amore <garrett@damore.org> | 2018-05-25 19:35:52 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2018-05-29 16:05:23 -0700 |
| commit | 33dc5d611f578ace9833a80dc006a34b09da18af (patch) | |
| tree | 2351fd7d197530493dbd27034ae9e1546c2e299c /tests/tcp6.c | |
| parent | fe5336ec1f9f27045f2c27ac253285c8447aa653 (diff) | |
| download | nng-33dc5d611f578ace9833a80dc006a34b09da18af.tar.gz nng-33dc5d611f578ace9833a80dc006a34b09da18af.tar.bz2 nng-33dc5d611f578ace9833a80dc006a34b09da18af.zip | |
fixes #484 crashes in websocket transport
fixes #490 posix_epdesc use-after-free bug
fixes #489 Sanitizer based testing would help
fixes #492 Numerous memory leaks found with sanitizer
This introduces support for compiler-based sanitizers when using
clang or gcc (and not on Windows). See NNG_SANITIZER for possible
settings such as "thread" or "address".
Furthermore, we have fixed the issues we found with both the
thread and address sanitizers. We believe that the thread issues
pointed to a low frequency use-after-free responsible for rare
crashes in some of the tests.
The tests generally have their timeouts doubled when running under
a sanitizer, to account for the extra long times that the sanitizer
can cause these to take.
While here, we also changed the compat_ws test to avoid a particularly
painful and time consuming DNS lookup, and we made the nngcat_unlimited
test a bit more robust by waiting before sending traffic.
Diffstat (limited to 'tests/tcp6.c')
| -rw-r--r-- | tests/tcp6.c | 66 |
1 files changed, 32 insertions, 34 deletions
diff --git a/tests/tcp6.c b/tests/tcp6.c index c023997f..86898b46 100644 --- a/tests/tcp6.c +++ b/tests/tcp6.c @@ -45,46 +45,34 @@ check_props_v6(nng_msg *msg) memset(loopback, 0, sizeof(loopback)); loopback[15] = 1; - Convey("IPv6 Local address property works", { - nng_sockaddr la; - z = sizeof(nng_sockaddr); - p = nng_msg_get_pipe(msg); - So(nng_pipe_id(p) > 0); - So(nng_pipe_getopt(p, NNG_OPT_LOCADDR, &la, &z) == 0); - So(z == sizeof(la)); - So(la.s_family == NNG_AF_INET6); - // So(la.s_in.sa_port == (trantest_port - 1)); - So(la.s_in6.sa_port != 0); - So(memcmp(la.s_in6.sa_addr, loopback, 16) == 0); - }); - - Convey("IPv6 Remote address property works", { - nng_sockaddr ra; - z = sizeof(nng_sockaddr); - p = nng_msg_get_pipe(msg); - So(nng_pipe_id(p) > 0); - So(nng_pipe_getopt(p, NNG_OPT_REMADDR, &ra, &z) == 0); - So(z == sizeof(ra)); - So(ra.s_family == NNG_AF_INET6); - So(ra.s_in6.sa_port != 0); - So(memcmp(ra.s_in6.sa_addr, loopback, 16) == 0); - }); - - Convey("Malformed TCPv6 addresses do not panic", { - nng_socket s1; - So(nng_pair_open(&s1) == 0); - Reset({ nng_close(s1); }); - So(nng_dial(s1, "tcp://::1", NULL, 0) == NNG_EADDRINVAL); - So(nng_dial(s1, "tcp://::1:5055", NULL, 0) == NNG_EADDRINVAL); - So(nng_dial(s1, "tcp://[::1]", NULL, 0) == NNG_EADDRINVAL); - }); + // IPv6 Local address property works + nng_sockaddr la; + z = sizeof(nng_sockaddr); + p = nng_msg_get_pipe(msg); + So(nng_pipe_id(p) > 0); + So(nng_pipe_getopt(p, NNG_OPT_LOCADDR, &la, &z) == 0); + So(z == sizeof(la)); + So(la.s_family == NNG_AF_INET6); + // So(la.s_in.sa_port == (trantest_port - 1)); + So(la.s_in6.sa_port != 0); + So(memcmp(la.s_in6.sa_addr, loopback, 16) == 0); + + // IPv6 Remote address property works + nng_sockaddr ra; + z = sizeof(nng_sockaddr); + p = nng_msg_get_pipe(msg); + So(nng_pipe_id(p) > 0); + So(nng_pipe_getopt(p, NNG_OPT_REMADDR, &ra, &z) == 0); + So(z == sizeof(ra)); + So(ra.s_family == NNG_AF_INET6); + So(ra.s_in6.sa_port != 0); + So(memcmp(ra.s_in6.sa_addr, loopback, 16) == 0); return (0); } TestMain("TCP (IPv6) Transport", { - nni_init(); if (has_v6()) { @@ -93,5 +81,15 @@ TestMain("TCP (IPv6) Transport", { SkipSo("IPv6 not available"); } + Convey("Malformed TCPv6 addresses do not panic", { + nng_socket s1; + + So(nng_pair_open(&s1) == 0); + Reset({ nng_close(s1); }); + So(nng_dial(s1, "tcp://::1", NULL, 0) == NNG_EADDRINVAL); + So(nng_dial(s1, "tcp://::1:5055", NULL, 0) == NNG_EADDRINVAL); + So(nng_dial(s1, "tcp://[::1]", NULL, 0) == NNG_EADDRINVAL); + }); + nng_fini(); }) |
