From 835821497a9bbd0d65c20714279c6a2c102016c1 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Wed, 1 Jan 2020 23:00:35 -0800 Subject: 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. --- tests/testutil.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'tests') 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 -- cgit v1.2.3-70-g09d2