Signed-off-by: Luke Yue <lukedyue(a)gmail.com>
---
tests/virshtest.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 90 insertions(+)
diff --git a/tests/virshtest.c b/tests/virshtest.c
index fe0c420958..4b10be9c0c 100644
--- a/tests/virshtest.c
+++ b/tests/virshtest.c
@@ -22,6 +22,7 @@ main(void)
# define DOM_UUID "ef861801-45b9-11cb-88e3-afbfe5370493"
# define SECURITY_LABEL "libvirt-test (enforcing)"
+# define EQUAL "="
static const char *dominfo_fc4 = "\
Id: 2\n\
@@ -43,6 +44,17 @@ static const char *domuuid_fc4 = DOM_UUID "\n\n";
static const char *domid_fc4 = "2\n\n";
static const char *domname_fc4 = "fc4\n\n";
static const char *domstate_fc4 = "running\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)
@@ -257,6 +269,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-7\n\
+ 4 0-7\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;
@@ -345,6 +411,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