On 06.04.2014 11:52, Roman Bogorodskiy wrote:
In preparation of adding more tests for bhyve, move common bhyve utils to testutilsbhyve --- tests/Makefile.am | 6 ++++-- tests/bhyvexml2argvtest.c | 28 +--------------------------- tests/testutilsbhyve.c | 34 ++++++++++++++++++++++++++++++++++ tests/testutilsbhyve.h | 7 +++++++ 4 files changed, 46 insertions(+), 29 deletions(-) create mode 100644 tests/testutilsbhyve.c create mode 100644 tests/testutilsbhyve.h diff --git a/tests/Makefile.am b/tests/Makefile.am index 6e15af8..dfa0851 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -630,10 +630,12 @@ bhyve_LDADDS = ../src/libvirt_driver_bhyve_impl.la bhyve_LDADDS += $(LDADDS) bhyvexml2argvtest_SOURCES = \ bhyvexml2argvtest.c \ - testutils.c testutils.h + testutils.c testutils.h \ + testutilsbhyve.c testutilsbhyve.h bhyvexml2argvtest_LDADD = $(bhyve_LDADDS) else ! WITH_BHYVE -EXTRA_DIST += bhyvexml2argvtest.c bhyvexml2argvmock.c +EXTRA_DIST += bhyvexml2argvtest.c bhyvexml2argvmock.c \ + testutilsbhyve.c testutilsbhyve.h endif ! WITH_BHYVE networkxml2xmltest_SOURCES = \ diff --git a/tests/bhyvexml2argvtest.c b/tests/bhyvexml2argvtest.c index b37fbb0..c55de10 100644 --- a/tests/bhyvexml2argvtest.c +++ b/tests/bhyvexml2argvtest.c @@ -8,38 +8,12 @@ # include "bhyve/bhyve_utils.h" # include "bhyve/bhyve_command.h" +# include "testutilsbhyve.h" # define VIR_FROM_THIS VIR_FROM_BHYVE static bhyveConn driver; -static virCapsPtr -testBhyveBuildCapabilities(void) -{ - virCapsPtr caps; - virCapsGuestPtr guest; - - if ((caps = virCapabilitiesNew(virArchFromHost(), - 0, 0)) == NULL) - return NULL; - - if ((guest = virCapabilitiesAddGuest(caps, "hvm", - VIR_ARCH_X86_64, - "bhyve", - NULL, 0, NULL)) == NULL) - goto error; - - if (virCapabilitiesAddGuestDomain(guest, - "bhyve", NULL, NULL, 0, NULL) == NULL) - goto error; - - return caps; - - error: - virObjectUnref(caps); - return NULL; -} - static int testCompareXMLToArgvFiles(const char *xml, const char *cmdline) { diff --git a/tests/testutilsbhyve.c b/tests/testutilsbhyve.c new file mode 100644 index 0000000..1032523 --- /dev/null +++ b/tests/testutilsbhyve.c @@ -0,0 +1,34 @@ +#include <config.h> + +#ifdef WITH_BHYVE + +# include "testutilsbhyve.h" + +virCapsPtr +testBhyveBuildCapabilities(void) +{ + virCapsPtr caps; + virCapsGuestPtr guest; + + if ((caps = virCapabilitiesNew(virArchFromHost(), + 0, 0)) == NULL) + return NULL; + + if ((guest = virCapabilitiesAddGuest(caps, "hvm", + VIR_ARCH_X86_64, + "bhyve", + NULL, 0, NULL)) == NULL) + goto error; + + if (virCapabilitiesAddGuestDomain(guest, + "bhyve", NULL, NULL, 0, NULL) == NULL) + goto error; + + return caps; + + error: + virObjectUnref(caps); + return NULL; +}
This is the same function as virBhyveCapsBuild in src/bhyve/bhyve_capabilities.c. I think we don't need this one then.
Michal -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list