diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-01-21 22:05:55 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-01-21 22:05:55 -0800 |
| commit | 769f9a2b66aca629eb4dd240a072849a48aa300f (patch) | |
| tree | 5fc475839caa1e7f9bf1362f8721ce63f6c58aa5 /tests | |
| parent | 99a78ade3a6034784e40d5dfa70cc72aa09021ca (diff) | |
| download | nng-769f9a2b66aca629eb4dd240a072849a48aa300f.tar.gz nng-769f9a2b66aca629eb4dd240a072849a48aa300f.tar.bz2 nng-769f9a2b66aca629eb4dd240a072849a48aa300f.zip | |
Whoops, forgot to add the pipe implementations to git!!
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | tests/pollfd.c | 56 |
2 files changed, 57 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f6751566..2b7a816e 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -64,6 +64,7 @@ add_nng_test(list 5) add_nng_test(platform 5) add_nng_test(reqrep 5) add_nng_test(pipeline 5) +add_nng_test(pollfd 5) add_nng_test(pubsub 5) add_nng_test(sock 5) add_nng_test(survey 5) diff --git a/tests/pollfd.c b/tests/pollfd.c new file mode 100644 index 00000000..899547c6 --- /dev/null +++ b/tests/pollfd.c @@ -0,0 +1,56 @@ +// +// Copyright 2017 Garrett D'Amore <garrett@damore.org> +// +// This software is supplied under the terms of the MIT License, a +// copy of which should be located in the distribution where this +// file was obtained (LICENSE.txt). A copy of the license may also be +// found online at https://opensource.org/licenses/MIT. +// + +#include "convey.h" +#include "nng.h" + +#ifdef _WIN32 +#include <windows.h> +#include <winsock2.h> +#else +#include <unistd.h> +#define INVALID_SOCKET -1 +#endif + +// Inproc tests. + +TestMain("Poll FDs", { + + Convey("Given a connected pair of sockets", { + nng_socket s1; + nng_socket s2; + + So(nng_open(&s1, NNG_PROTO_PAIR) == 0); + So(nng_open(&s2, NNG_PROTO_PAIR) == 0); + Reset({ + nng_close(s1); + nng_close(s2); + }) + So(nng_listen(s1, "inproc://yeahbaby", NULL, 0) == 0); + So(nng_dial(s2, "inproc://yeahbaby", NULL, NNG_FLAG_SYNCH) == 0); + + Convey("We can get a recv FD", { + int fd; + size_t sz; + + sz = sizeof (fd); + So(nng_getopt(s1, NNG_OPT_RECVFD, &fd, &sz) == 0); + So(fd != INVALID_SOCKET); + }) + + Convey("We can get a send FD", { + int fd; + size_t sz; + + sz = sizeof (fd); + So(nng_getopt(s1, NNG_OPT_SENDFD, &fd, &sz) == 0); + So(fd != INVALID_SOCKET); + }) + }) +}) |
