[libvirt PATCH 03/11] tests: nodedev: switch all test macros to accept a filename

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Rather than specifying a UUID string to some test macros, just pass a
filename to an xml definition. This helps work toward unifying the test
macros and making it more maintainable.

Signed-off-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>
---
 tests/nodedevmdevctldata/mdevctl-create.argv  |  2 +-
 tests/nodedevmdevctldata/mdevctl-stop.argv    |  2 +-
 .../nodedevmdevctldata/mdevctl-undefine.argv  |  2 +-
 tests/nodedevmdevctltest.c                    | 34 ++++++++++++-------
 4 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/tests/nodedevmdevctldata/mdevctl-create.argv b/tests/nodedevmdevctldata/mdevctl-create.argv
index 802109340c..dc0ae7be0e 100644
--- a/tests/nodedevmdevctldata/mdevctl-create.argv
+++ b/tests/nodedevmdevctldata/mdevctl-create.argv
@@ -1 +1 @@
-$MDEVCTL_BINARY$ start -u 8a05ad83-3472-497d-8631-8142f31460e8
+$MDEVCTL_BINARY$ start -u d069d019-36ea-4111-8f0a-8c9a70e21366
diff --git a/tests/nodedevmdevctldata/mdevctl-stop.argv b/tests/nodedevmdevctldata/mdevctl-stop.argv
index 3dbaab671b..5bdb213a32 100644
--- a/tests/nodedevmdevctldata/mdevctl-stop.argv
+++ b/tests/nodedevmdevctldata/mdevctl-stop.argv
@@ -1 +1 @@
-$MDEVCTL_BINARY$ stop -u e2451f73-c95b-4124-b900-e008af37c576
+$MDEVCTL_BINARY$ stop -u d069d019-36ea-4111-8f0a-8c9a70e21366
diff --git a/tests/nodedevmdevctldata/mdevctl-undefine.argv b/tests/nodedevmdevctldata/mdevctl-undefine.argv
index 54717455f7..c2236727ef 100644
--- a/tests/nodedevmdevctldata/mdevctl-undefine.argv
+++ b/tests/nodedevmdevctldata/mdevctl-undefine.argv
@@ -1 +1 @@
-$MDEVCTL_BINARY$ undefine -u d76a6b78-45ed-4149-a325-005f9abc5281
+$MDEVCTL_BINARY$ undefine -u d069d019-36ea-4111-8f0a-8c9a70e21366
diff --git a/tests/nodedevmdevctltest.c b/tests/nodedevmdevctltest.c
index 050424116f..a95bdf6d6e 100644
--- a/tests/nodedevmdevctltest.c
+++ b/tests/nodedevmdevctltest.c
@@ -140,20 +140,25 @@ testMdevctlStartOrDefineHelper(const void *data)
 
 typedef virCommand* (*GetStopUndefineCmdFunc)(const char *uuid, char **errbuf);
 struct UuidCommandTestInfo {
-    const char *uuid;
+    const char *filename;
     MdevctlCmd command;
 };
 
 static int
-testMdevctlUuidCommand(const char *uuid, GetStopUndefineCmdFunc func, const char *outfile)
+testMdevctlUuidCommand(GetStopUndefineCmdFunc func,
+                       const char *mdevxml, const char *outfile)
 {
+    g_autoptr(virNodeDeviceDef) def = NULL;
     g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
     const char *actualCmdline = NULL;
     int ret = -1;
     g_autoptr(virCommand) cmd = NULL;
     g_autofree char *errmsg = NULL;
 
-    cmd = func(uuid, &errmsg);
+    if (!(def = virNodeDeviceDefParseFile(mdevxml, EXISTING_DEVICE, "QEMU")))
+        goto cleanup;
+
+    cmd = func(def->caps->data.mdev.uuid, &errmsg);
 
     if (!cmd)
         goto cleanup;
@@ -182,6 +187,7 @@ testMdevctlUuidCommandHelper(const void *data)
     GetStopUndefineCmdFunc func;
     const char *cmd;
     g_autofree char *cmdlinefile = NULL;
+    g_autofree char *mdevxml = NULL;
 
     if (info->command == MDEVCTL_CMD_STOP) {
         cmd = "stop";
@@ -196,10 +202,12 @@ testMdevctlUuidCommandHelper(const void *data)
         return -1;
     }
 
+    mdevxml = g_strdup_printf("%s/nodedevschemadata/%s.xml", abs_srcdir,
+                              info->filename);
     cmdlinefile = g_strdup_printf("%s/nodedevmdevctldata/mdevctl-%s.argv",
                                   abs_srcdir, cmd);
 
-    return testMdevctlUuidCommand(info->uuid, func, cmdlinefile);
+    return testMdevctlUuidCommand(func, mdevxml, cmdlinefile);
 }
 
 static int
@@ -427,14 +435,14 @@ mymain(void)
        } \
     while (0)
 
-#define DO_TEST_STOP(uuid) \
-    DO_TEST_UUID_COMMAND_FULL("mdevctl stop " uuid, uuid, MDEVCTL_CMD_STOP)
+#define DO_TEST_STOP(filename) \
+    DO_TEST_UUID_COMMAND_FULL("mdevctl stop " filename, filename, MDEVCTL_CMD_STOP)
 
-#define DO_TEST_UNDEFINE(uuid) \
-    DO_TEST_UUID_COMMAND_FULL("mdevctl undefine " uuid, uuid, MDEVCTL_CMD_UNDEFINE)
+#define DO_TEST_UNDEFINE(filename) \
+    DO_TEST_UUID_COMMAND_FULL("mdevctl undefine " filename, filename, MDEVCTL_CMD_UNDEFINE)
 
-#define DO_TEST_CREATE(uuid) \
-    DO_TEST_UUID_COMMAND_FULL("mdevctl create " uuid, uuid, MDEVCTL_CMD_CREATE)
+#define DO_TEST_CREATE(filename) \
+    DO_TEST_UUID_COMMAND_FULL("mdevctl create " filename, filename, MDEVCTL_CMD_CREATE)
 
 #define DO_TEST_LIST_DEFINED() \
     DO_TEST_FULL("mdevctl list --defined", testMdevctlListDefined, NULL)
@@ -448,7 +456,7 @@ mymain(void)
     DO_TEST_START("mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9");
 
     /* Test mdevctl stop command, pass an arbitrary uuid */
-    DO_TEST_STOP("e2451f73-c95b-4124-b900-e008af37c576");
+    DO_TEST_STOP("mdev_d069d019_36ea_4111_8f0a_8c9a70e21366");
 
     DO_TEST_LIST_DEFINED();
 
@@ -458,9 +466,9 @@ mymain(void)
     DO_TEST_DEFINE("mdev_fedc4916_1ca8_49ac_b176_871d16c13076");
     DO_TEST_DEFINE("mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9");
 
-    DO_TEST_UNDEFINE("d76a6b78-45ed-4149-a325-005f9abc5281");
+    DO_TEST_UNDEFINE("mdev_d069d019_36ea_4111_8f0a_8c9a70e21366");
 
-    DO_TEST_CREATE("8a05ad83-3472-497d-8631-8142f31460e8");
+    DO_TEST_CREATE("mdev_d069d019_36ea_4111_8f0a_8c9a70e21366");
 
  done:
     nodedevTestDriverFree(driver);
-- 
2.26.3




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux