diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-01-16 00:43:03 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-01-16 00:43:03 -0800 |
| commit | 39dbff5615631522d3ef98b83141957038502c0d (patch) | |
| tree | 89becbf88ebb79df9c9202450acd476bd790bde0 /tests/stubs.h | |
| parent | f71209a0b429cddcd44f1f2473c49e986c9b4be7 (diff) | |
| download | nng-39dbff5615631522d3ef98b83141957038502c0d.tar.gz nng-39dbff5615631522d3ef98b83141957038502c0d.tar.bz2 nng-39dbff5615631522d3ef98b83141957038502c0d.zip | |
Various complaints found in AppVeyor build.
Diffstat (limited to 'tests/stubs.h')
| -rw-r--r-- | tests/stubs.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/stubs.h b/tests/stubs.h new file mode 100644 index 00000000..9bd9c279 --- /dev/null +++ b/tests/stubs.h @@ -0,0 +1,47 @@ +// +// 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" +#include <string.h> +#include <stdio.h> +#include <stdlib.h> +#include <stdarg.h> + +#ifdef _WIN32 +#include <windows.h> +#else +#include <sys/time.h> +#endif + +// Stub handlers for some common things. + +uint64_t +getms(void) +{ +#ifdef _WIN32 + return (GetTickCount64()) ; +#else + static time_t epoch; + struct timeval tv; + + if (epoch == 0) { + epoch = time(NULL); + } + gettimeofday(&tv, NULL); + + if (tv.tv_sec < epoch) { + // Broken clock. + // This will force all other timing tests to fail + return (0); + } + tv.tv_sec -= epoch; + return (((uint64_t)(tv.tv_sec ) * 1000) + (tv.tv_usec / 1000)); +#endif +} |
