[PATCH 5/5] tests: Test detach-device and detach-device-alias for test driver

Luke Yue lukedyue at gmail.com
Mon Aug 16 11:19:49 UTC 2021


Signed-off-by: Luke Yue <lukedyue at gmail.com>
---
 tests/virshtest.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/tests/virshtest.c b/tests/virshtest.c
index 53db2aa19a..273596d636 100644
--- a/tests/virshtest.c
+++ b/tests/virshtest.c
@@ -291,6 +291,22 @@ static int testCompareDomControlInfoByName(const void *data G_GNUC_UNUSED)
     return testCompareOutputLit(exp, NULL, argv);
 }
 
+static int testCompareDetachDevice(const void *data G_GNUC_UNUSED)
+{
+    const char *const argv[] = { VIRSH_CUSTOM, "detach-device", "fc5",
+                                 "../examples/xml/test/testdevif.xml", NULL };
+    const char *exp = "Device detached successfully\n\n";
+    return testCompareOutputLit(exp, NULL, argv);
+}
+
+static int testCompareDetachDeviceAlias(const void *data G_GNUC_UNUSED)
+{
+    const char *const argv[] = { VIRSH_CUSTOM, "detach-device-alias", "fc5",
+                                 "ua-testCD", NULL };
+    const char *exp = "Device detach request sent successfully\n\n";
+    return testCompareOutputLit(exp, NULL, argv);
+}
+
 struct testInfo {
     const char *const *argv;
     const char *result;
@@ -383,6 +399,14 @@ mymain(void)
                    testCompareDomControlInfoByName, NULL) != 0)
         ret = -1;
 
+    if (virTestRun("virsh detach-device",
+                   testCompareDetachDevice, NULL) != 0)
+        ret = -1;
+
+    if (virTestRun("virsh detach-device-alias",
+                   testCompareDetachDeviceAlias, NULL) != 0)
+        ret = -1;
+
     /* It's a bit awkward listing result before argument, but that's a
      * limitation of C99 vararg macros.  */
 # define DO_TEST(i, result, ...) \
-- 
2.32.0




More information about the libvir-list mailing list