[PATCH 5/5] tests: Test IOThread related functions for test driver

Luke Yue lukedyue at gmail.com
Tue Jul 6 10:31:58 UTC 2021


Signed-off-by: Luke Yue <lukedyue at gmail.com>
---
 examples/xml/test/testdomfc4.xml |  4 ++++
 tests/virshtest.c                | 40 ++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)

diff --git a/examples/xml/test/testdomfc4.xml b/examples/xml/test/testdomfc4.xml
index 26b7f25a06..25ad45365a 100644
--- a/examples/xml/test/testdomfc4.xml
+++ b/examples/xml/test/testdomfc4.xml
@@ -11,6 +11,10 @@
   <memory>261072</memory>
   <currentMemory>131072</currentMemory>
   <vcpu>1</vcpu>
+  <iothreads>1</iothreads>
+  <iothreadids>
+    <iothread id="2"/>
+  </iothreadids>
   <devices>
     <disk type='file'>
       <source file='/u/fc4.img'/>
diff --git a/tests/virshtest.c b/tests/virshtest.c
index c1974c46cb..10ff5a4b78 100644
--- a/tests/virshtest.c
+++ b/tests/virshtest.c
@@ -250,6 +250,34 @@ static int testCompareDomstateByName(const void *data G_GNUC_UNUSED)
     return testCompareOutputLit(exp, NULL, argv);
 }
 
+static int testIOThreadAdd(const void *data G_GNUC_UNUSED)
+{
+    const char *const argv[] = { VIRSH_CUSTOM, "iothreadadd", "--domain", "fc4", "--id", "1", NULL};
+    const char *exp = "\n";
+
+    return testCompareOutputLit(exp, NULL, argv);
+}
+
+static int testIOThreadDel(const void *data G_GNUC_UNUSED)
+{
+    const char *const argv[] = { VIRSH_CUSTOM, "iothreaddel", "--domain", "fc4", "--id", "2", NULL};
+    const char *exp = "\n";
+
+    return testCompareOutputLit(exp, NULL, argv);
+}
+
+static int testIOThreadInfo(const void *data G_GNUC_UNUSED)
+{
+    const char *const argv[] = { VIRSH_CUSTOM, "iothreadinfo", "--domain", "fc4", NULL};
+    const char *exp = "\
+ IOThread ID   CPU Affinity\n\
+-----------------------------\n\
+ 2             0-7\n\
+\n";
+
+    return testCompareOutputLit(exp, NULL, argv);
+}
+
 struct testInfo {
     const char *const *argv;
     const char *result;
@@ -334,6 +362,18 @@ mymain(void)
                    testCompareDomstateByName, NULL) != 0)
         ret = -1;
 
+    if (virTestRun("virsh iothreadadd",
+                   testIOThreadAdd, NULL) != 0)
+        ret = -1;
+
+    if (virTestRun("virsh iothreaddel",
+                   testIOThreadDel, NULL) != 0)
+        ret = -1;
+
+    if (virTestRun("virsh iothreadinfo",
+                   testIOThreadInfo, 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