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

Luke Yue lukedyue at gmail.com
Wed Sep 15 15:30:32 UTC 2021


testIOThreadAdd tests iothreadinfo and iothreadadd
testIOThreadDel tests iothreadinfo and iothreaddel
testIOThreadSet tests domstats and iothreadset
testIOThreadPin tests iothreadadd, iothreadinfo and iothreadpin

Above tests should cover the IOThreads related APIs for test driver

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

diff --git a/tests/virshtest.c b/tests/virshtest.c
index 87da1f5889..c2c892c60d 100644
--- a/tests/virshtest.c
+++ b/tests/virshtest.c
@@ -32,6 +32,7 @@ main(void)
                 deprecated configuration: CPU model Deprecated-Test"
 # define GET_BLKIO_PARAMETER "/dev/hda,700"
 # define SET_BLKIO_PARAMETER "/dev/hda,1000"
+# define EQUAL "="
 
 static const char *dominfo_fc4 = "\
 Id:             2\n\
@@ -338,6 +339,99 @@ static int testCompareSetBlkioParameters(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, "iothreadinfo --domain fc4;\
+                                 iothreadadd --domain fc4 --id 6;\
+                                 iothreadinfo --domain fc4", NULL};
+    const char *exp = "\
+ IOThread ID   CPU Affinity\n\
+-----------------------------\n\
+ 2             0\n\
+ 4             0\n\
+\n\
+\n\
+ IOThread ID   CPU Affinity\n\
+-----------------------------\n\
+ 2             0\n\
+ 4             0\n\
+ 6             0\n\
+\n";
+    return testCompareOutputLit(exp, NULL, argv);
+}
+
+static int testIOThreadDel(const void *data G_GNUC_UNUSED)
+{
+    const char *const argv[] = { VIRSH_CUSTOM, "iothreadinfo --domain fc4;\
+                                 iothreaddel --domain fc4 --id 2;\
+                                 iothreadinfo --domain fc4", NULL};
+    const char *exp = "\
+ IOThread ID   CPU Affinity\n\
+-----------------------------\n\
+ 2             0\n\
+ 4             0\n\
+\n\
+\n\
+ IOThread ID   CPU Affinity\n\
+-----------------------------\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, "domstats --domain fc4;\
+                                 iothreadset --domain fc4\
+                                 --id 2 --poll-max-ns 100\
+                                 --poll-shrink 10 --poll-grow 10;\
+                                 domstats --domain fc4", NULL};
+    const char *exp = "\
+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\
+\n\
+Domain: 'fc4'\n\
+  state.state" EQUAL "1\n\
+  state.reason" EQUAL "0\n\
+  iothread.count" EQUAL "2\n\
+  iothread.2.poll-max-ns" EQUAL "100\n\
+  iothread.2.poll-grow" EQUAL "10\n\
+  iothread.2.poll-shrink" EQUAL "10\n\
+  iothread.4.poll-max-ns" EQUAL "32768\n\
+  iothread.4.poll-grow" EQUAL "0\n\
+  iothread.4.poll-shrink" EQUAL "0\n\n";
+    return testCompareOutputLit(exp, NULL, argv);
+}
+
+static int testIOThreadPin(const void *data G_GNUC_UNUSED)
+{
+    const char *const argv[] = { VIRSH_CUSTOM,
+                                 "iothreadadd --domain fc5 --id 2;\
+                                 iothreadinfo --domain fc5;\
+                                 iothreadpin --domain fc5 --iothread 2\
+                                 --cpulist 0;\
+                                 iothreadinfo --domain fc5", NULL};
+    const char *exp = "\n\
+ IOThread ID   CPU Affinity\n\
+-----------------------------\n\
+ 2             0-3\n\
+\n\
+\n\
+ IOThread ID   CPU Affinity\n\
+-----------------------------\n\
+ 2             0\n\
+\n";
+    return testCompareOutputLit(exp, NULL, argv);
+}
+
 struct testInfo {
     const char *const *argv;
     const char *result;
@@ -438,6 +532,22 @@ mymain(void)
                    testCompareSetBlkioParameters, 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 iothreadset",
+                   testIOThreadSet, NULL) != 0)
+        ret = -1;
+
+    if (virTestRun("virsh iothreadpin",
+                   testIOThreadPin, 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.33.0




More information about the libvir-list mailing list