]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Use macros for testing virSystemd APIs
authorJán Tomko <jtomko@redhat.com>
Thu, 23 Feb 2017 11:25:33 +0000 (12:25 +0100)
committerJán Tomko <jtomko@redhat.com>
Mon, 6 Mar 2017 14:34:33 +0000 (15:34 +0100)
This hides the unused third parameter from every line
and prepares for resetting the environment after each test
case in the future.

tests/virsystemdtest.c

index f0cfabfb1c4848aec40c2e922482155bc8bf8f61..177cccc2f91ef1eadd3b2f0871216e6dfc07b0f2 100644 (file)
@@ -518,25 +518,21 @@ mymain(void)
     if (virUUIDParse("c7a5fdbd-edaf-9455-926a-d65c16db1809", uuid) < 0)
         return EXIT_FAILURE;
 
-    if (virTestRun("Test create container ", testCreateContainer, NULL) < 0)
-        ret = -1;
-    if (virTestRun("Test terminate container ", testTerminateContainer, NULL) < 0)
-        ret = -1;
-    if (virTestRun("Test create machine ", testCreateMachine, NULL) < 0)
-        ret = -1;
-    if (virTestRun("Test terminate machine ", testTerminateMachine, NULL) < 0)
-        ret = -1;
-    if (virTestRun("Test create no systemd ", testCreateNoSystemd, NULL) < 0)
-        ret = -1;
-    if (virTestRun("Test create systemd not running ",
-                   testCreateSystemdNotRunning, NULL) < 0)
-        ret = -1;
-    if (virTestRun("Test create bad systemd ", testCreateBadSystemd, NULL) < 0)
-        ret = -1;
-    if (virTestRun("Test create with network ", testCreateNetwork, NULL) < 0)
-        ret = -1;
-    if (virTestRun("Test getting machine name ", testGetMachineName, NULL) < 0)
-        ret = -1;
+# define DO_TEST(_name, func)                                           \
+    do {                                                                \
+        if (virTestRun(_name, func, NULL) < 0)                          \
+            ret = -1;                                                   \
+    } while (0)
+
+    DO_TEST("Test create container ", testCreateContainer);
+    DO_TEST("Test terminate container ", testTerminateContainer);
+    DO_TEST("Test create machine ", testCreateMachine);
+    DO_TEST("Test terminate machine ", testTerminateMachine);
+    DO_TEST("Test create no systemd ", testCreateNoSystemd);
+    DO_TEST("Test create systemd not running ", testCreateSystemdNotRunning);
+    DO_TEST("Test create bad systemd ", testCreateBadSystemd);
+    DO_TEST("Test create with network ", testCreateNetwork);
+    DO_TEST("Test getting machine name ", testGetMachineName);
 
 # define TEST_SCOPE(_name, unitname, _legacy)                           \
     do {                                                                \