From 3f7561417bec08226bcfeb107d94be0dbf71b09e Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sat, 21 Dec 2019 10:20:55 -0800 Subject: fixes #1032 Figure out Darwin bustedness fixes #1035 Convey is awkward -- consider acutest.h This represents a rather large effort towards cleaning up our testing and optional configuration infrastructure. A separate test library is built by default, which is static, and includes some useful utilities design to make it easier to write shorter and more robust (not timing dependent) tests. This also means that we can cover pretty nearly all the tests (protocols etc.) in every case, even if the shipped image will be minimized. Subsystems which are optional can now use a few new macros to configure what they need see nng_sources_if, nng_headers_if, and nng_defines_if. This goes a long way to making the distributed CMakefiles a lot simpler. Additionally, tests for different parts of the tree can now be located outside of the tests/ tree, so that they can be placed next to the code that they are testing. Beyond the enabling work, the work has only begun, but these changes have resolved the most often failing tests for Darwin in the cloud. --- tests/testutil.h | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 tests/testutil.h (limited to 'tests/testutil.h') diff --git a/tests/testutil.h b/tests/testutil.h new file mode 100644 index 00000000..97540f36 --- /dev/null +++ b/tests/testutil.h @@ -0,0 +1,49 @@ +// +// Copyright 2019 Staysail Systems, Inc. +// +// 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. +// + +#ifndef TESTUTIL_H +#define TESTUTIL_H + +#include +#include + +// The following headers are provided for test code convenience. +#include + +#ifdef __cplusplus +extern "C" { +#endif + +// testutil_clock returns the current time in milliseconds. +// The reference clock may be any point in the past (typically since +// the program started running.) +extern uint64_t testutil_clock(void); + +// testutil_pollfd tests if the given file descriptor polls as readable. +extern bool testutil_pollfd(int); + +// testutil_htons is just htons portably. +extern uint16_t testutil_htons(uint16_t); + +// testutil_sleep sleeps the specified number of msec +extern void testutil_sleep(int); + +// testutil_next_port returns a new port number (presumably unique) +extern uint16_t testutil_next_port(void); + +// testutil_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 testutil_marry(nng_socket, nng_socket); + +#ifdef __cplusplus +}; +#endif + +#endif // TESTUTIL_H -- cgit v1.2.3-70-g09d2