diff options
| author | Garrett D'Amore <garrett@damore.org> | 2025-01-12 15:39:06 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2025-01-12 15:39:06 -0800 |
| commit | d6de9bec7f1dbb969e872aa9e51103d70dee2316 (patch) | |
| tree | 606636492af384c7f09436b5b66fb960788e38c8 | |
| parent | 9368d350f363597fb59ac85cada364c42793f0e2 (diff) | |
| download | nng-d6de9bec7f1dbb969e872aa9e51103d70dee2316.tar.gz nng-d6de9bec7f1dbb969e872aa9e51103d70dee2316.tar.bz2 nng-d6de9bec7f1dbb969e872aa9e51103d70dee2316.zip | |
tests: start using nng_err in NUTS
| -rw-r--r-- | src/testing/marry.c | 8 | ||||
| -rw-r--r-- | src/testing/nuts.h | 24 |
2 files changed, 16 insertions, 16 deletions
diff --git a/src/testing/marry.c b/src/testing/marry.c index 36b879c7..6f2ec109 100644 --- a/src/testing/marry.c +++ b/src/testing/marry.c @@ -269,7 +269,7 @@ married(nng_pipe p, nng_pipe_ev ev, void *arg) nng_mtx_unlock(notice->mx); } -int +nng_err nuts_marry(nng_socket s1, nng_socket s2) { return (nuts_marry_ex(s1, s2, NULL, NULL, NULL)); @@ -301,13 +301,13 @@ replace_port_zero(const char *addr, char *buf, int port) buf[j] = '\0'; } -int +nng_err nuts_marry_ex( nng_socket s1, nng_socket s2, const char *url, nng_pipe *p1, nng_pipe *p2) { struct marriage_notice note; nng_time timeout; - int rv; + nng_err rv; char addr[64]; nng_listener l; int port; @@ -358,7 +358,7 @@ nuts_marry_ex( } } else if (rv == NNG_ENOTSUP) { url = "tcp://127.0.0.1:0"; - rv = 0; + rv = NNG_OK; } else { return (rv); } diff --git a/src/testing/nuts.h b/src/testing/nuts.h index 290af723..d821b359 100644 --- a/src/testing/nuts.h +++ b/src/testing/nuts.h @@ -84,14 +84,14 @@ extern void nuts_scratch_addr_zero(const char *, size_t, char *); // nuts_marry connects two sockets using inproc. It uses socket // pipe hooks to ensure that it does not return before both sockets // are fully connected. -extern int nuts_marry(nng_socket, nng_socket); +extern nng_err nuts_marry(nng_socket, nng_socket); // nuts_marry_ex is like nuts_marry, but returns the pipes that // were connected, and includes an optional URL. The pipe pointers and the // URL may be NULL if not needed. If a port number is part of the URL // and is zero (i.e. if the URL contains :0) then listen is done first, // and the actual bound port will be used for the client. -extern int nuts_marry_ex( +extern nng_err nuts_marry_ex( nng_socket, nng_socket, const char *, nng_pipe *, nng_pipe *); // nuts_stream_send_start and nuts_stream_recv_start are used @@ -208,21 +208,21 @@ extern const char *nuts_ecdsa_client_crt; // did not. #define NUTS_PASS(cond) \ do { \ - int result_ = (cond); \ - TEST_ASSERT_(result_ == 0, \ + nng_err result_ = (nng_err) (cond); \ + TEST_ASSERT_(result_ == NNG_OK, \ "%s: expected success, got %s (%d)", #cond, \ nng_strerror(result_), result_); \ } while (0) // NUTS_FAIL tests for a specific NNG error code. -#define NUTS_FAIL(cond, expect) \ - do { \ - int result_ = (cond); \ - TEST_CHECK_(result_ == (expect), "%s fails with %s", #cond, \ - nng_strerror(expect)); \ - TEST_MSG("%s: expected %s (%d), got %s (%d)", #cond, \ - nng_strerror(expect), expect, nng_strerror(result_), \ - result_); \ +#define NUTS_FAIL(cond, expect) \ + do { \ + nng_err result_ = (cond); \ + TEST_CHECK_(result_ == (nng_err) (expect), \ + "%s fails with %s", #cond, nng_strerror(expect)); \ + TEST_MSG("%s: expected %s (%d), got %s (%d)", #cond, \ + nng_strerror(expect), expect, nng_strerror(result_), \ + result_); \ } while (0) #define NUTS_SEND(sock, string) \ |
