From a42342912b9ac7da5e67cae9426817b89d3ea41b Mon Sep 17 00:00:00 2001 From: Roman Bogorodskiy Date: Sat, 19 Nov 2016 20:42:27 +0300 Subject: [PATCH] tests: eventtest: fix build on macOS macOS doesn't support clock_gettime(2), at least versions prior 10.12 (I didn't actually check 10.12 though). So, use its own routines in eventtest. * configure.ac: check for requires symbols and define HAVE_MACH_CLOCK_ROUTINES if found * tests/eventtest.c: add clock_get_time() based implementation --- configure.ac | 9 +++++++++ tests/eventtest.c | 16 ++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/configure.ac b/configure.ac index fd50ff80e2..342db894df 100644 --- a/configure.ac +++ b/configure.ac @@ -2524,6 +2524,15 @@ AC_CHECK_MEMBERS([struct if_data.ifi_oqdrops], [#include ]) +AC_CHECK_DECLS([clock_serv_t, host_get_clock_service, clock_get_time], + [AC_DEFINE([HAVE_MACH_CLOCK_ROUTINES], + [1], + [whether Mach clock routines are available])], + [], + [#include + #include + ]) + # Check if we need to look for ifconfig if test "$want_ifconfig" = "yes"; then AC_PATH_PROG([IFCONFIG_PATH], [ifconfig]) diff --git a/tests/eventtest.c b/tests/eventtest.c index 011bedc33f..03ab318472 100644 --- a/tests/eventtest.c +++ b/tests/eventtest.c @@ -26,6 +26,11 @@ #include #include +#if HAVE_MACH_CLOCK_ROUTINES +# include +# include +#endif + #include "testutils.h" #include "internal.h" #include "virfile.h" @@ -262,7 +267,18 @@ finishJob(const char *name, int handle, int timer) { struct timespec waitTime; int rc; +#if HAVE_MACH_CLOCK_ROUTINES + clock_serv_t cclock; + mach_timespec_t mts; + + host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock); + clock_get_time(cclock, &mts); + mach_port_deallocate(mach_task_self(), cclock); + waitTime.tv_sec = mts.tv_sec; + waitTime.tv_nsec = mts.tv_nsec; +#else clock_gettime(CLOCK_REALTIME, &waitTime); +#endif waitTime.tv_sec += 5; rc = 0; while (!eventThreadJobDone && rc == 0) -- 2.39.5