[libvirt] [PATCH 2/2] tests: fix eventtest build on macOS
Roman Bogorodskiy
bogorodskiy at gmail.com
Thu Nov 24 16:14:44 UTC 2016
Andrea Bolognani wrote:
> On Sat, 2016-11-19 at 21:16 +0300, Roman Bogorodskiy wrote:
> > 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
> > * tests/Makefile.am: don't explicitly LDADD -lrt, use
> > $(LIB_CLOCK_GETTIME)
> > ---
> > configure.ac | 9 +++++++++
> > tests/Makefile.am | 2 +-
> > tests/eventtest.c | 16 ++++++++++++++++
> > 3 files changed, 26 insertions(+), 1 deletion(-)
> >
> > diff --git a/configure.ac b/configure.ac
> > index 66d88c4..c1b0ca0 100644
> > --- a/configure.ac
> > +++ b/configure.ac
> > @@ -2522,6 +2522,15 @@ AC_CHECK_MEMBERS([struct if_data.ifi_oqdrops],
> > [#include <net/if.h>
> > ])
> >
> > +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 <mach/clock.h>
> > + #include <mach/mach.h>
> > + ])
> > +
> > # Check if we need to look for ifconfig
> > if test "$want_ifconfig" = "yes"; then
> > AC_PATH_PROG([IFCONFIG_PATH], [ifconfig])
> > diff --git a/tests/Makefile.am b/tests/Makefile.am
> > index 924029a..6a24861 100644
> > --- a/tests/Makefile.am
> > +++ b/tests/Makefile.am
> > @@ -1310,7 +1310,7 @@ endif WITH_DRIVER_MODULES
> > if WITH_LIBVIRTD
> > eventtest_SOURCES = \
> > eventtest.c testutils.h testutils.c
> > -eventtest_LDADD = -lrt $(LDADDS)
> > +eventtest_LDADD = $(LIB_CLOCK_GETTIME) $(LDADDS)
> > endif WITH_LIBVIRTD
>
> This is really a separate bugfix, please move this hunk
> to its own commit.
>
> > libshunload_la_SOURCES = shunloadhelper.c
> > diff --git a/tests/eventtest.c b/tests/eventtest.c
> > index 011bedc..ed1089e 100644
> > --- a/tests/eventtest.c
> > +++ b/tests/eventtest.c
> > @@ -26,6 +26,11 @@
> > #include <signal.h>
> > #include <time.h>
> >
> > +#if HAVE_MACH_CLOCK_ROUTINES
> > +#include <mach/clock.h>
> > +#include <mach/mach.h>
>
> These two includes trip 'make syntax-check'.
>
> > +#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;
>
> I'll assume the macOS code is doing what it's supposed to
> do, as I have no way of verifying that myself. It looks
> reasonable enough :)
>
> > +#else
> > clock_gettime(CLOCK_REALTIME, &waitTime);
> > +#endif
> > waitTime.tv_sec += 5;
> > rc = 0;
> > while (!eventThreadJobDone && rc == 0)
>
> ACK if you move the LIB_CLOCK_GETTIME fix to its own commit
> and tweak includes to make syntax-check happy.
Addressed that and pushed, thanks!
Roman Bogorodskiy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 455 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20161124/96ca4d94/attachment-0001.sig>
More information about the libvir-list
mailing list