diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-08-09 16:13:24 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-08-09 16:13:24 -0700 |
| commit | 032c74653cc2035b539ee48183055a9354e9b888 (patch) | |
| tree | 0bbd532f8f91e796c80a63a89891132924d3651b /tests/trantest.h | |
| parent | e469d1084d144961a72c4db1fb84cbd29ed4df8a (diff) | |
| download | nng-032c74653cc2035b539ee48183055a9354e9b888.tar.gz nng-032c74653cc2035b539ee48183055a9354e9b888.tar.bz2 nng-032c74653cc2035b539ee48183055a9354e9b888.zip | |
fixes #48 tcp sometimes fails to get a port
Diffstat (limited to 'tests/trantest.h')
| -rw-r--r-- | tests/trantest.h | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/tests/trantest.h b/tests/trantest.h index 173c6b45..74e533bf 100644 --- a/tests/trantest.h +++ b/tests/trantest.h @@ -11,6 +11,7 @@ #include "convey.h" #include "core/nng_impl.h" #include "nng.h" +#include <stdlib.h> #include <string.h> // Transport common tests. By making a common test framework for transports, @@ -25,10 +26,34 @@ typedef struct { nni_tran * tran; } trantest; +unsigned trantest_port = 0; + +void +trantest_next_address(char *out, const char *template) +{ + if (trantest_port == 0) { + char *pstr; + trantest_port = 5555; + if (((pstr = ConveyGetEnv("TEST_PORT")) != NULL) && + (atoi(pstr) != 0)) { + trantest_port = atoi(pstr); + } + } + (void) snprintf(out, NNG_MAXADDRLEN, template, trantest_port); + trantest_port++; +} + +void +trantest_prev_address(char *out, const char *template) +{ + trantest_port--; + trantest_next_address(out, template); +} + void trantest_init(trantest *tt, const char *addr) { - (void) snprintf(tt->addr, sizeof(tt->addr), "%s", addr); + trantest_next_address(tt->addr, addr); So(nng_req_open(&tt->reqsock) == 0); So(nng_rep_open(&tt->repsock) == 0); |
