From cf0d80344e4790dc5e3f05ac6fe3144f4e9a0153 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Wed, 20 Mar 2024 17:58:39 +0100 Subject: [PATCH] virshtest: Adapt 'iothread' tests to DO_TEST_SCRIPT MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Ján Tomko --- tests/virshtest.c | 112 +----------------------------- tests/virshtestdata/iothreads.in | 14 ++++ tests/virshtestdata/iothreads.out | 51 ++++++++++++++ 3 files changed, 66 insertions(+), 111 deletions(-) create mode 100644 tests/virshtestdata/iothreads.in create mode 100644 tests/virshtestdata/iothreads.out diff --git a/tests/virshtest.c b/tests/virshtest.c index 6c2d4cfc67..02bfb363c4 100644 --- a/tests/virshtest.c +++ b/tests/virshtest.c @@ -18,8 +18,6 @@ main(void) #else -# define EQUAL "=" - static void testFilterLine(char *buffer, const char *toRemove) { @@ -89,99 +87,6 @@ static char *custom_uri; "--connect", \ 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 { const char *testname; /* used to generate output filename */ const char *filter; @@ -210,22 +115,6 @@ mymain(void) custom_uri = g_strdup_printf("test://%s/../examples/xml/test/testnode.xml", 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, ...) \ { \ const char *testname = testname_; \ @@ -250,6 +139,7 @@ mymain(void) DO_TEST_SCRIPT("info-custom", NULL, VIRSH_CUSTOM); DO_TEST_SCRIPT("domain-id", "\nCPU time:", VIRSH_CUSTOM); DO_TEST_SCRIPT("blkiotune", NULL, VIRSH_CUSTOM); + DO_TEST_SCRIPT("iothreads", NULL, VIRSH_CUSTOM); # define DO_TEST_FULL(testname_, filter, ...) \ do { \ diff --git a/tests/virshtestdata/iothreads.in b/tests/virshtestdata/iothreads.in new file mode 100644 index 0000000000..25ebcb5cda --- /dev/null +++ b/tests/virshtestdata/iothreads.in @@ -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 diff --git a/tests/virshtestdata/iothreads.out b/tests/virshtestdata/iothreads.out new file mode 100644 index 0000000000..1e38733bcf --- /dev/null +++ b/tests/virshtestdata/iothreads.out @@ -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 +