aboutsummaryrefslogtreecommitdiff
path: root/tests/sock.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2016-12-25 18:08:44 -0800
committerGarrett D'Amore <garrett@damore.org>2016-12-25 18:08:44 -0800
commit0cd2fa7310f1fdf45443a8a9e3335658b1c3c64c (patch)
tree1098c7f4976033bb311b45c378079700c9330b62 /tests/sock.c
parent64de60d98e8e4a896f9d13e4aa70343f329d88b4 (diff)
downloadnng-0cd2fa7310f1fdf45443a8a9e3335658b1c3c64c.tar.gz
nng-0cd2fa7310f1fdf45443a8a9e3335658b1c3c64c.tar.bz2
nng-0cd2fa7310f1fdf45443a8a9e3335658b1c3c64c.zip
Substantial fixes for listen & dialers.
At this point listening and dialing operations appear to function properly. As part of this I had to break the close logic up since otherwise we had a loop trying to reap a thread from itself. So there is now a separate reaper thread for pipes per-socket. I also changed lists to be a bit more rigid, and allocations now zero memory initially. (We had bugs due to uninitialized memory, and rather than hunt them all down, lets just init them to sane zero values.)
Diffstat (limited to 'tests/sock.c')
-rw-r--r--tests/sock.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/tests/sock.c b/tests/sock.c
index c4fcbee0..1179dca9 100644
--- a/tests/sock.c
+++ b/tests/sock.c
@@ -24,6 +24,10 @@ TestMain("Socket Operations", {
So(rv == 0);
})
+ Reset({
+ nng_close(sock);
+ })
+
Convey("It's type is still proto", {
So(nng_protocol(sock) == NNG_PROTO_PAIR);
})
@@ -101,14 +105,39 @@ TestMain("Socket Operations", {
})
})
- Convey("Dialing bogus address not supported", {
- rv = nng_dial(sock, "bogus://somewhere", NULL, 0);
- So(rv == NNG_ENOTSUP);
+ Convey("Bogus URLs not supported", {
+ Convey("Dialing fails properly", {
+ rv = nng_dial(sock, "bogus://somewhere", NULL, 0);
+ So(rv == NNG_ENOTSUP);
+ })
+ Convey("Listening fails properly", {
+ rv = nng_listen(sock, "bogus://elsewhere", NULL, 0);
+ So(rv == NNG_ENOTSUP);
+ })
})
Convey("Dialing synch can get refused", {
rv = nng_dial(sock, "inproc://notthere", NULL, NNG_FLAG_SYNCH);
So(rv == NNG_ECONNREFUSED);
})
+
+ Convey("Listening works", {
+ rv = nng_listen(sock, "inproc://here", NULL, NNG_FLAG_SYNCH);
+ So(rv == 0);
+
+ Convey("Second listen fails ADDRINUSE", {
+ rv = nng_listen(sock, "inproc://here", NULL, NNG_FLAG_SYNCH);
+ So(rv == NNG_EADDRINUSE);
+ })
+
+ Convey("We can connect to it", {
+ nng_socket *sock2 = NULL;
+ rv = nng_open(&sock2, NNG_PROTO_PAIR);
+ So(rv == 0);
+ rv = nng_dial(sock2, "inproc://here", NULL, NNG_FLAG_SYNCH);
+ So(rv == 0);
+ nng_close(sock2);
+ })
+ })
})
}) \ No newline at end of file