]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemumonitorjsontest: Rename 1st CHECK macro in migration params test
authorJiri Denemark <jdenemar@redhat.com>
Thu, 26 Oct 2017 18:50:35 +0000 (20:50 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Thu, 2 Nov 2017 21:14:19 +0000 (22:14 +0100)
The first CHECK macro in the test is used for checking integer values.
Let's make it a bit more generic to be usable for any numeric type and
use it for a new CHECK_INT macro.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
tests/qemumonitorjsontest.c

index 4d3b738e526fd43024e45819456e4122011f24c2..1dcff6672feda1c84cae6b0a856a3054f04adbe4 100644 (file)
@@ -1813,7 +1813,7 @@ testQemuMonitorJSONqemuMonitorJSONGetMigrationParams(const void *data)
                                           &params) < 0)
         goto cleanup;
 
-#define CHECK(VAR, FIELD, VALUE)                                            \
+#define CHECK_NUM(VAR, FIELD, VALUE, FMT)                                   \
     do {                                                                    \
         if (!params.VAR ## _set) {                                          \
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s is not set", FIELD); \
@@ -1821,19 +1821,23 @@ testQemuMonitorJSONqemuMonitorJSONGetMigrationParams(const void *data)
         }                                                                   \
         if (params.VAR != VALUE) {                                          \
             virReportError(VIR_ERR_INTERNAL_ERROR,                          \
-                           "Invalid %s: %d, expected %d",                   \
+                           "Invalid %s: " FMT ", expected " FMT,            \
                            FIELD, params.VAR, VALUE);                       \
             goto cleanup;                                                   \
         }                                                                   \
     } while (0)
 
-    CHECK(compressLevel, "compress-level", 1);
-    CHECK(compressThreads, "compress-threads", 8);
-    CHECK(decompressThreads, "decompress-threads", 2);
-    CHECK(cpuThrottleInitial, "cpu-throttle-initial", 20);
-    CHECK(cpuThrottleIncrement, "cpu-throttle-increment", 10);
+#define CHECK_INT(VAR, FIELD, VALUE)                                        \
+    CHECK_NUM(VAR, FIELD, VALUE, "%d")
 
-#undef CHECK
+    CHECK_INT(compressLevel, "compress-level", 1);
+    CHECK_INT(compressThreads, "compress-threads", 8);
+    CHECK_INT(decompressThreads, "decompress-threads", 2);
+    CHECK_INT(cpuThrottleInitial, "cpu-throttle-initial", 20);
+    CHECK_INT(cpuThrottleIncrement, "cpu-throttle-increment", 10);
+
+#undef CHECK_NUM
+#undef CHECK_INT
 
 #define CHECK(VAR, FIELD, VALUE)                                            \
     do {                                                                    \