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

Luke Yue lukedyue at gmail.com
Thu Aug 12 10:50:02 UTC 2021


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

diff --git a/tests/virshtest.c b/tests/virshtest.c
index 53db2aa19a..e2d6ddd72b 100644
--- a/tests/virshtest.c
+++ b/tests/virshtest.c
@@ -30,6 +30,7 @@ main(void)
                 tainted: custom device tree blob used\n\
                 tainted: use of deprecated configuration settings\n\
                 deprecated configuration: CPU model Deprecated-Test"
+# define EQUAL "="
 
 static const char *dominfo_fc4 = "\
 Id:             2\n\
@@ -69,6 +70,17 @@ Security DOI:   \n\
 Security label: " SECURITY_LABEL "\n\
 Messages:       " FC5_MESSAGES "\n\
 \n";
+static const char *domstats_fc4 = "\
+Domain: 'fc4'\n\
+  state.state" EQUAL "1\n\
+  state.reason" EQUAL "0\n\
+  iothread.count" EQUAL "2\n\
+  iothread.2.poll-max-ns" EQUAL "32768\n\
+  iothread.2.poll-grow" EQUAL "0\n\
+  iothread.2.poll-shrink" EQUAL "0\n\
+  iothread.4.poll-max-ns" EQUAL "32768\n\
+  iothread.4.poll-grow" EQUAL "0\n\
+  iothread.4.poll-shrink" EQUAL "0\n\n";
 
 static int testFilterLine(char *buffer,
                           const char *toRemove)
@@ -291,6 +303,60 @@ static int testCompareDomControlInfoByName(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\n\
+ 4             0\n\
+\n";
+    return testCompareOutputLit(exp, NULL, argv);
+}
+
+static int testIOThreadSet(const void *data G_GNUC_UNUSED)
+{
+    const char *const argv[] = { VIRSH_CUSTOM,  "iothreadset", "--domain",
+                                 "fc4", "--id", "2", "--poll-max-ns", "100",
+                                 "--poll-shrink", "10", "--poll-grow",
+                                 "10", NULL};
+    const char *exp = "\n";
+    return testCompareOutputLit(exp, NULL, argv);
+}
+
+static int testIOThreadPin(const void *data G_GNUC_UNUSED)
+{
+    const char *const argv[] = { VIRSH_CUSTOM, "iothreadpin", "fc4",
+                                 "--iothread", "2", "--cpulist", "0", NULL};
+    const char *exp = "\n";
+    return testCompareOutputLit(exp, NULL, argv);
+}
+
+static int testDomStats(const void *data G_GNUC_UNUSED)
+{
+    const char *const argv[] = { VIRSH_CUSTOM, "domstats", "fc4", NULL };
+    const char *exp = domstats_fc4;
+    return testCompareOutputLit(exp, NULL, argv);
+}
+
 struct testInfo {
     const char *const *argv;
     const char *result;
@@ -383,6 +449,30 @@ mymain(void)
                    testCompareDomControlInfoByName, 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;
+
+    if (virTestRun("virsh iothreadset",
+                   testIOThreadSet, NULL) != 0)
+        ret = -1;
+
+    if (virTestRun("virsh iothreadpin",
+                   testIOThreadPin, NULL) != 0)
+        ret = -1;
+
+    if (virTestRun("virsh domstats (by name)",
+                   testDomStats, 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