
On 15.09.2015 10:05, Ján Tomko wrote:
From: Pavel Fedin <p.fedin@samsung.com>
Two utility functions are introduced for proper initialization and cleanup of the driver.
Signed-off-by: Pavel Fedin <p.fedin@samsung.com> Signed-off-by: Ján Tomko <jtomko@redhat.com> --- tests/domainsnapshotxml2xmltest.c | 10 +++------- tests/qemuagenttest.c | 11 ++++++----- tests/qemuargv2xmltest.c | 12 ++---------- tests/qemuhotplugtest.c | 9 ++------- tests/qemuxml2argvtest.c | 11 ++--------- tests/qemuxml2xmltest.c | 8 +++----- tests/qemuxmlnstest.c | 11 +++-------- tests/testutilsqemu.c | 30 ++++++++++++++++++++++++++++++ tests/testutilsqemu.h | 2 ++ 9 files changed, 53 insertions(+), 51 deletions(-)
diff --git a/tests/domainsnapshotxml2xmltest.c b/tests/domainsnapshotxml2xmltest.c index 3955a19..b66af3e 100644 --- a/tests/domainsnapshotxml2xmltest.c +++ b/tests/domainsnapshotxml2xmltest.c @@ -152,13 +152,10 @@ mymain(void) { int ret = 0;
- if ((driver.caps = testQemuCapsInit()) == NULL) + if (qemuTestDriverInit(&driver) < 0) return EXIT_FAILURE;
- if (!(driver.xmlopt = virQEMUDriverCreateXMLConf(&driver))) { - virObjectUnref(driver.caps); - return EXIT_FAILURE; - } + driver.config->allowDiskFormatProbing = true;
Apart from what Martin already pointed out ...
if (VIR_ALLOC(testSnapshotXMLVariableLineRegex) < 0) goto cleanup; @@ -227,8 +224,7 @@ mymain(void) if (testSnapshotXMLVariableLineRegex) regfree(testSnapshotXMLVariableLineRegex); VIR_FREE(testSnapshotXMLVariableLineRegex); - virObjectUnref(driver.caps); - virObjectUnref(driver.xmlopt); + qemuTestDriverFree(&driver);
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; } diff --git a/tests/qemuagenttest.c b/tests/qemuagenttest.c index 52cc834..1ebc030 100644 --- a/tests/qemuagenttest.c +++ b/tests/qemuagenttest.c @@ -31,6 +31,8 @@
#define VIR_FROM_THIS VIR_FROM_NONE
+static virQEMUDriver driver; +
There's no need for this variable to be global. Put it into mymain() please.
static int testQemuAgentFSFreeze(const void *data) { @@ -909,7 +911,6 @@ static int mymain(void) { int ret = 0; - virDomainXMLOptionPtr xmlopt;
#if !WITH_YAJL fputs("libvirt not compiled with yajl, skipping this test\n", stderr); @@ -917,13 +918,13 @@ mymain(void) #endif
if (virThreadInitialize() < 0 || - !(xmlopt = virQEMUDriverCreateXMLConf(NULL))) + qemuTestDriverInit(&driver) < 0) return EXIT_FAILURE;
virEventRegisterDefaultImpl();
-#define DO_TEST(name) \ - if (virtTestRun(# name, testQemuAgent ## name, xmlopt) < 0) \ +#define DO_TEST(name) \ + if (virtTestRun(# name, testQemuAgent ## name, driver.xmlopt) < 0) \ ret = -1
DO_TEST(FSFreeze); @@ -938,7 +939,7 @@ mymain(void)
DO_TEST(Timeout); /* Timeout should always be called last */
- virObjectUnref(xmlopt); + qemuTestDriverFree(&driver);
return (ret == 0) ? EXIT_SUCCESS : EXIT_FAILURE; }
Michal