mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
virshtest: Adapt 'iothread' tests to DO_TEST_SCRIPT
Adapt the tests to be invoked in one run. Note that multiple fake VMs were used for the distinct tests so that they don't influence each other. This is the final coversion of tests to run in batch mode which halved the runtime of 'virshtest' on my machine (1.11s vs 2.33s). Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
b65f3a01a8
commit
cf0d80344e
@ -18,8 +18,6 @@ main(void)
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
# define EQUAL "="
|
|
||||||
|
|
||||||
static void testFilterLine(char *buffer,
|
static void testFilterLine(char *buffer,
|
||||||
const char *toRemove)
|
const char *toRemove)
|
||||||
{
|
{
|
||||||
@ -89,99 +87,6 @@ static char *custom_uri;
|
|||||||
"--connect", \
|
"--connect", \
|
||||||
custom_uri
|
custom_uri
|
||||||
|
|
||||||
static int testIOThreadAdd(const void *data)
|
|
||||||
{
|
|
||||||
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((const char *) data, exp, NULL, argv);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int testIOThreadDel(const void *data)
|
|
||||||
{
|
|
||||||
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((const char *) data, exp, NULL, argv);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int testIOThreadSet(const void *data)
|
|
||||||
{
|
|
||||||
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((const char *) data, exp, NULL, argv);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int testIOThreadPin(const void *data)
|
|
||||||
{
|
|
||||||
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((const char *) data, exp, NULL, argv);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct testInfo {
|
struct testInfo {
|
||||||
const char *testname; /* used to generate output filename */
|
const char *testname; /* used to generate output filename */
|
||||||
const char *filter;
|
const char *filter;
|
||||||
@ -210,22 +115,6 @@ mymain(void)
|
|||||||
custom_uri = g_strdup_printf("test://%s/../examples/xml/test/testnode.xml",
|
custom_uri = g_strdup_printf("test://%s/../examples/xml/test/testnode.xml",
|
||||||
abs_srcdir);
|
abs_srcdir);
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
# define DO_TEST_SCRIPT(testname_, testfilter, ...) \
|
# define DO_TEST_SCRIPT(testname_, testfilter, ...) \
|
||||||
{ \
|
{ \
|
||||||
const char *testname = testname_; \
|
const char *testname = testname_; \
|
||||||
@ -250,6 +139,7 @@ mymain(void)
|
|||||||
DO_TEST_SCRIPT("info-custom", NULL, VIRSH_CUSTOM);
|
DO_TEST_SCRIPT("info-custom", NULL, VIRSH_CUSTOM);
|
||||||
DO_TEST_SCRIPT("domain-id", "\nCPU time:", VIRSH_CUSTOM);
|
DO_TEST_SCRIPT("domain-id", "\nCPU time:", VIRSH_CUSTOM);
|
||||||
DO_TEST_SCRIPT("blkiotune", NULL, VIRSH_CUSTOM);
|
DO_TEST_SCRIPT("blkiotune", NULL, VIRSH_CUSTOM);
|
||||||
|
DO_TEST_SCRIPT("iothreads", NULL, VIRSH_CUSTOM);
|
||||||
|
|
||||||
# define DO_TEST_FULL(testname_, filter, ...) \
|
# define DO_TEST_FULL(testname_, filter, ...) \
|
||||||
do { \
|
do { \
|
||||||
|
14
tests/virshtestdata/iothreads.in
Normal file
14
tests/virshtestdata/iothreads.in
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
iothreadinfo --domain fc4
|
||||||
|
iothreadadd --domain fc4 --id 6
|
||||||
|
iothreadinfo --domain fc4
|
||||||
|
iothreaddel --domain fc4 --id 2
|
||||||
|
iothreadinfo --domain fc4
|
||||||
|
|
||||||
|
domstats --domain fc4
|
||||||
|
iothreadset --domain fc4 --id 6 --poll-max-ns 100 --poll-shrink 10 --poll-grow 10
|
||||||
|
domstats --domain fc4
|
||||||
|
|
||||||
|
iothreadadd --domain fc5 --id 2
|
||||||
|
iothreadinfo --domain fc5
|
||||||
|
iothreadpin --domain fc5 --iothread 2 --cpulist 0
|
||||||
|
iothreadinfo --domain fc5
|
51
tests/virshtestdata/iothreads.out
Normal file
51
tests/virshtestdata/iothreads.out
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
IOThread ID CPU Affinity
|
||||||
|
-----------------------------
|
||||||
|
2 0
|
||||||
|
4 0
|
||||||
|
|
||||||
|
|
||||||
|
IOThread ID CPU Affinity
|
||||||
|
-----------------------------
|
||||||
|
2 0
|
||||||
|
4 0
|
||||||
|
6 0
|
||||||
|
|
||||||
|
|
||||||
|
IOThread ID CPU Affinity
|
||||||
|
-----------------------------
|
||||||
|
4 0
|
||||||
|
6 0
|
||||||
|
|
||||||
|
Domain: 'fc4'
|
||||||
|
state.state=1
|
||||||
|
state.reason=0
|
||||||
|
iothread.count=2
|
||||||
|
iothread.4.poll-max-ns=32768
|
||||||
|
iothread.4.poll-grow=0
|
||||||
|
iothread.4.poll-shrink=0
|
||||||
|
iothread.6.poll-max-ns=32768
|
||||||
|
iothread.6.poll-grow=0
|
||||||
|
iothread.6.poll-shrink=0
|
||||||
|
|
||||||
|
|
||||||
|
Domain: 'fc4'
|
||||||
|
state.state=1
|
||||||
|
state.reason=0
|
||||||
|
iothread.count=2
|
||||||
|
iothread.4.poll-max-ns=32768
|
||||||
|
iothread.4.poll-grow=0
|
||||||
|
iothread.4.poll-shrink=0
|
||||||
|
iothread.6.poll-max-ns=100
|
||||||
|
iothread.6.poll-grow=10
|
||||||
|
iothread.6.poll-shrink=10
|
||||||
|
|
||||||
|
|
||||||
|
IOThread ID CPU Affinity
|
||||||
|
-----------------------------
|
||||||
|
2 0-3
|
||||||
|
|
||||||
|
|
||||||
|
IOThread ID CPU Affinity
|
||||||
|
-----------------------------
|
||||||
|
2 0
|
||||||
|
|
Loading…
Reference in New Issue
Block a user