]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virshtest: Adapt 'iothread' tests to DO_TEST_SCRIPT
authorPeter Krempa <pkrempa@redhat.com>
Wed, 20 Mar 2024 16:58:39 +0000 (17:58 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 2 Apr 2024 12:24:30 +0000 (14:24 +0200)
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>
tests/virshtest.c
tests/virshtestdata/iothreads.in [new file with mode: 0644]
tests/virshtestdata/iothreads.out [new file with mode: 0644]

index 6c2d4cfc671f5911e2192ad83cc0a668fcf7ed31..02bfb363c44e41b72cd79f3a808c57dfac440452 100644 (file)
@@ -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 (file)
index 0000000..25ebcb5
--- /dev/null
@@ -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 (file)
index 0000000..1e38733
--- /dev/null
@@ -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
+