]> xenbits.xensource.com Git - libvirt.git/commitdiff
test: Rework qemuMonitorJSONGetMigrationParams test
authorJiri Denemark <jdenemar@redhat.com>
Mon, 20 Jun 2016 15:07:55 +0000 (17:07 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Wed, 22 Jun 2016 13:54:21 +0000 (15:54 +0200)
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
tests/qemumonitorjsontest.c

index d0b5d9e875fe1d993c7fde8553c627e2499b3dae..a0079dd1da8f7b8beba02ea8a63e40aaedc28bbb 100644 (file)
@@ -1641,32 +1641,26 @@ testQemuMonitorJSONqemuMonitorJSONGetMigrationParams(const void *data)
                                           &params) < 0)
         goto cleanup;
 
-    if (!params.compressLevel_set ||
-        !params.compressThreads_set ||
-        !params.decompressThreads_set) {
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       "One of level, threads or dthreads flags is not set");
-        return -1;
-    }
+#define CHECK(VAR, FIELD, VALUE)                                            \
+    do {                                                                    \
+        if (!params.VAR ## _set) {                                          \
+            virReportError(VIR_ERR_INTERNAL_ERROR, "%s is not set", FIELD); \
+            goto cleanup;                                                   \
+        }                                                                   \
+        if (params.VAR != VALUE) {                                          \
+            virReportError(VIR_ERR_INTERNAL_ERROR,                          \
+                           "Invalid %s: %d, expected %d",                   \
+                           FIELD, params.VAR, VALUE);                       \
+            goto cleanup;                                                   \
+        }                                                                   \
+    } while (0)
+
+    CHECK(compressLevel, "compress-level", 1);
+    CHECK(compressThreads, "compress-threads", 8);
+    CHECK(decompressThreads, "decompress-threads", 2);
+
+#undef CHECK
 
-    if (params.compressLevel != 1) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       "Invalid decompress-threads: %d, expected 1",
-                       params.compressLevel);
-        goto cleanup;
-    }
-    if (params.compressThreads != 8) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       "Invalid decompress-threads: %d, expected 8",
-                       params.compressThreads);
-        goto cleanup;
-    }
-    if (params.decompressThreads != 2) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       "Invalid decompress-threads: %d, expected 2",
-                       params.decompressThreads);
-        goto cleanup;
-    }
     ret = 0;
 
  cleanup: