]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
tests: Introduce testQemuDataInit() and testQemuDataReset()
authorAndrea Bolognani <abologna@redhat.com>
Thu, 7 Mar 2019 13:22:37 +0000 (14:22 +0100)
committerAndrea Bolognani <abologna@redhat.com>
Wed, 13 Mar 2019 10:06:56 +0000 (11:06 +0100)
These functions don't do anything too interesting right now,
but will be extended later on.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Acked-by: Peter Krempa <pkrempa@redhat.com>
tests/qemucapabilitiestest.c
tests/qemucaps2xmltest.c

index 8d47133e6f3a7db6a8931320e368b06323b30bcd..882fa5748584943bd8b3ff2c5773fe53c752a73f 100644 (file)
@@ -40,6 +40,23 @@ struct _testQemuData {
 };
 
 
+static int
+testQemuDataInit(testQemuDataPtr data)
+{
+    if (qemuTestDriverInit(&data->driver) < 0)
+        return -1;
+
+    return 0;
+}
+
+
+static void
+testQemuDataReset(testQemuDataPtr data)
+{
+    qemuTestDriverFree(&data->driver);
+}
+
+
 static int
 testQemuCaps(const void *opaque)
 {
@@ -164,12 +181,14 @@ mymain(void)
     return EXIT_AM_SKIP;
 #endif
 
-    if (virThreadInitialize() < 0 ||
-        qemuTestDriverInit(&data.driver) < 0)
+    if (virThreadInitialize() < 0)
         return EXIT_FAILURE;
 
     virEventRegisterDefaultImpl();
 
+    if (testQemuDataInit(&data) < 0)
+        return EXIT_FAILURE;
+
 #define DO_TEST(arch, name) \
     do { \
         data.archName = arch; \
@@ -227,7 +246,7 @@ mymain(void)
      * "tests/qemucapsfixreplies foo.replies" to fix the replies ids.
      */
 
-    qemuTestDriverFree(&data.driver);
+    testQemuDataReset(&data);
 
     return (ret == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
 }
index 0d9b4e679a5eae04a78e6954b2ee71b8876167be..7b2335b91cf976529e813551d0d6633b74f2554c 100644 (file)
@@ -32,6 +32,12 @@ struct _testQemuData {
     const char *archName;
 };
 
+static int
+testQemuDataInit(testQemuDataPtr data ATTRIBUTE_UNUSED)
+{
+    return 0;
+}
+
 static virQEMUCapsPtr
 testQemuGetCaps(char *caps)
 {
@@ -176,6 +182,9 @@ mymain(void)
 
     virEventRegisterDefaultImpl();
 
+    if (testQemuDataInit(&data) < 0)
+        return EXIT_FAILURE;
+
 #define DO_TEST(arch, name) \
     data.archName = arch; \
     data.base = name; \