aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2016-12-23 11:04:57 -0800
committerGarrett D'Amore <garrett@damore.org>2016-12-23 11:05:36 -0800
commita12baf41fb17ef51a8b1d0c82e31113454c5beae (patch)
tree9e9368ae235a08ff4f9a1738d9e9148f567442e1 /tests
parent6f5f10fd56da48aa7d95f80e5f3f03c4097f8132 (diff)
downloadnng-a12baf41fb17ef51a8b1d0c82e31113454c5beae.tar.gz
nng-a12baf41fb17ef51a8b1d0c82e31113454c5beae.tar.bz2
nng-a12baf41fb17ef51a8b1d0c82e31113454c5beae.zip
nng_setopt works (rcvtimeout, etc.) External API adjustments.
The external API now uses simpler names for various things, notably we ditch the whole nng_socket_xx prefix. For example, intstead of nng_socket_create, we just use nng_open(). There are no more nng_socket_xxx calls.
Diffstat (limited to 'tests')
-rw-r--r--tests/sock.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/tests/sock.c b/tests/sock.c
index 137e6e7f..4bdc684b 100644
--- a/tests/sock.c
+++ b/tests/sock.c
@@ -16,24 +16,35 @@ TestMain("Socket Operations", {
int rv;
nng_socket *sock = NULL;
- rv = nng_socket_create(&sock, NNG_PROTO_PAIR);
+ rv = nng_open(&sock, NNG_PROTO_PAIR);
So(rv == 0);
So(sock != NULL);
Convey("And we can close it", {
- rv = nng_socket_close(sock);
+ rv = nng_close(sock);
So(rv == 0);
})
Convey("It's type is still proto", {
- So(nng_socket_protocol(sock) == NNG_PROTO_PAIR);
+ So(nng_protocol(sock) == NNG_PROTO_PAIR);
})
- Convey("Recv on with no pipes times out", {
+ Convey("Recv with no pipes times out correctly", {
nng_msg *msg = NULL;
+ int64_t when = 500000;
+ uint64_t now;
+
+ extern uint64_t nni_clock(void);
+ now = nni_clock();
+
+ rv = nng_setopt(sock, NNG_OPT_RCVTIMEO, &when,
+ sizeof (when));
+ So(rv == 0);
rv = nng_recvmsg(sock, &msg, 0);
So(rv == NNG_ETIMEDOUT);
So(msg == NULL);
+ So(nni_clock() > (now + 500000));
+ So(nni_clock() < (now + 1000000));
})
Convey("Recv nonblock with no pipes gives EAGAIN", {