[libvirt PATCH v2 09/10] nodedev: Add testing for 'mdevctl stop'

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

 



Test that we run 'mdevctl' with the proper arguments when we destroy
mediated devices with virNodeDeviceDestroy()

Signed-off-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>
---
 tests/nodedevmdevctldata/mdevctl-stop.argv |  1 +
 tests/nodedevmdevctltest.c                 | 43 ++++++++++++++++++++++
 2 files changed, 44 insertions(+)
 create mode 100644 tests/nodedevmdevctldata/mdevctl-stop.argv

diff --git a/tests/nodedevmdevctldata/mdevctl-stop.argv b/tests/nodedevmdevctldata/mdevctl-stop.argv
new file mode 100644
index 0000000000..25ee7145ce
--- /dev/null
+++ b/tests/nodedevmdevctldata/mdevctl-stop.argv
@@ -0,0 +1 @@
+/usr/sbin/mdevctl stop -u e2451f73-c95b-4124-b900-e008af37c576
diff --git a/tests/nodedevmdevctltest.c b/tests/nodedevmdevctltest.c
index 32a22246c2..58ebf976e2 100644
--- a/tests/nodedevmdevctltest.c
+++ b/tests/nodedevmdevctltest.c
@@ -98,6 +98,42 @@ testMdevctlStartHelper(const void *data)
                             jsonfile);
 }
 
+static int
+testMdevctlStopHelper(const void *data)
+{
+    const char *uuid = data;
+    virBuffer buf = VIR_BUFFER_INITIALIZER;
+    const char *actualCmdline = NULL;
+    int ret = -1;
+    g_autoptr(virCommand) cmd = NULL;
+
+    g_autofree char *cmdlinefile =
+        g_strdup_printf("%s/nodedevmdevctldata/mdevctl-stop.argv",
+                        abs_srcdir);
+
+    cmd = nodeDeviceGetMdevctlStopCommand(uuid, false);
+
+    if (!cmd)
+        goto cleanup;
+
+    virCommandSetDryRun(&buf, NULL, NULL);
+    if (virCommandRun(cmd, NULL) < 0)
+        goto cleanup;
+
+    if (!(actualCmdline = virBufferCurrentContent(&buf)))
+        goto cleanup;
+
+    if (virTestCompareToFile(actualCmdline, cmdlinefile) < 0)
+        goto cleanup;
+
+    ret = 0;
+
+ cleanup:
+    virBufferFreeAndReset(&buf);
+    virCommandSetDryRun(NULL, NULL, NULL);
+    return ret;
+}
+
 static void
 nodedevTestDriverFree(virNodeDeviceDriverStatePtr drv)
 {
@@ -248,6 +284,13 @@ mymain(void)
     DO_TEST("mdev_fedc4916_1ca8_49ac_b176_871d16c13076");
     DO_TEST("mdev_d2441d39_495e_4243_ad9f_beb3f14c23d9");
 
+    // Test mdevctl stop command, pass an arbitrary uuid
+    if (virTestRun("mdevctl stop", testMdevctlStopHelper,
+                   "e2451f73-c95b-4124-b900-e008af37c576") < 0)
+
+
+        ret = -1;
+
  done:
     nodedevTestDriverFree(driver);
 
-- 
2.21.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