diff options
| author | Garrett D'Amore <garrett@damore.org> | 2020-01-01 23:00:35 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2020-01-01 23:10:47 -0800 |
| commit | 835821497a9bbd0d65c20714279c6a2c102016c1 (patch) | |
| tree | b5c6e0ea177a5d120c0662929ab990a91c0ba737 /tests/testutil.h | |
| parent | 11985f8c59cccc0364bde7dd314e246ea53cff90 (diff) | |
| download | nng-835821497a9bbd0d65c20714279c6a2c102016c1.tar.gz nng-835821497a9bbd0d65c20714279c6a2c102016c1.tar.bz2 nng-835821497a9bbd0d65c20714279c6a2c102016c1.zip | |
fixes #1088 REP protocol does not signal SENDFD properly
We've also added some TEST_NNG_SEND_STR and TEST_NNG_RECV_STR to
help with convenience when writing test code.
Diffstat (limited to 'tests/testutil.h')
| -rw-r--r-- | tests/testutil.h | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/tests/testutil.h b/tests/testutil.h index 14cc1712..008c8061 100644 --- a/tests/testutil.h +++ b/tests/testutil.h @@ -55,7 +55,7 @@ extern int testutil_marry(nng_socket, nng_socket); #define TEST_NNG_PASS(cond) \ do { \ int result_ = (cond); \ - TEST_CHECK_(result_ == 0, "%s succeeds", #cond); \ + TEST_CHECK_(result_ == 0, "%s succeeds", #cond); \ TEST_MSG("%s: expected success, got %s (%d)", #cond, \ nng_strerror(result_), result_); \ } while (0) @@ -70,6 +70,21 @@ extern int testutil_marry(nng_socket, nng_socket); result_); \ } while (0) +#define TEST_NNG_SEND_STR(sock, string) \ + TEST_NNG_PASS(nng_send(sock, string, strlen(string) + 1, 0)) + +#define TEST_NNG_RECV_STR(sock, string) \ + do { \ + char * buf_; \ + size_t sz_; \ + int rv_ = nng_recv(sock, &buf_, &sz_, NNG_FLAG_ALLOC); \ + TEST_CHECK_( \ + rv_ == 0, "nng_recv (%d %s)", rv_, nng_strerror(rv_)); \ + TEST_CHECK(sz_ == strlen(string) + 1); \ + TEST_CHECK(strcmp(string, buf_) == 0); \ + nng_free(buf_, sz_); \ + } while (0) + #ifdef __cplusplus }; #endif |
