Add the basic list and info commands into a script and run it via
VIR_TEST_RUN_SCRIPT to simplify the code and save up on 'virsh'
instances exec'd for the test.
Signed-off-by: Peter Krempa <pkrempa(a)redhat.com>
---
tests/virshtest.c | 79 ++--------------------------
tests/virshtestdata/info-custom.in | 2 +
tests/virshtestdata/info-custom.out | 15 ++++++
tests/virshtestdata/info-default.in | 2 +
tests/virshtestdata/info-default.out | 13 +++++
5 files changed, 35 insertions(+), 76 deletions(-)
create mode 100644 tests/virshtestdata/info-custom.in
create mode 100644 tests/virshtestdata/info-custom.out
create mode 100644 tests/virshtestdata/info-default.in
create mode 100644 tests/virshtestdata/info-default.out
diff --git a/tests/virshtest.c b/tests/virshtest.c
index ef2b8e7ec5..cdd5468bc1 100644
--- a/tests/virshtest.c
+++ b/tests/virshtest.c
@@ -159,66 +159,6 @@ static char *custom_uri;
"--connect", \
custom_uri
-static int testCompareListDefault(const void *data)
-{
- const char *const argv[] = { VIRSH_DEFAULT, "list", NULL };
- const char *exp = "\
- Id Name State\n\
-----------------------\n\
- 1 test running\n\
-\n";
- return testCompareOutputLit((const char *) data, exp, NULL, argv);
-}
-
-static int testCompareListCustom(const void *data)
-{
- const char *const argv[] = { VIRSH_CUSTOM, "list", NULL };
- const char *exp = "\
- Id Name State\n\
-----------------------\n\
- 1 fv0 running\n\
- 2 fc4 running\n\
- 3 fc5 running\n\
-\n";
- return testCompareOutputLit((const char *) data, exp, NULL, argv);
-}
-
-static int testCompareNodeinfoDefault(const void *data)
-{
- const char *const argv[] = { VIRSH_DEFAULT, "nodeinfo", NULL };
- const char *exp = "\
-CPU model: i686\n\
-CPU(s): 16\n\
-CPU frequency: 1400 MHz\n\
-CPU socket(s): 2\n\
-Core(s) per socket: 2\n\
-Thread(s) per core: 2\n\
-NUMA cell(s): 2\n\
-Memory size: 3145728 KiB\n\
-\n";
- return testCompareOutputLit((const char *) data, exp, NULL, argv);
-}
-
-static int testCompareNodeinfoCustom(const void *data)
-{
- const char *const argv[] = {
- VIRSH_CUSTOM,
- "nodeinfo",
- NULL
- };
- const char *exp = "\
-CPU model: i986\n\
-CPU(s): 50\n\
-CPU frequency: 6000 MHz\n\
-CPU socket(s): 4\n\
-Core(s) per socket: 4\n\
-Thread(s) per core: 2\n\
-NUMA cell(s): 4\n\
-Memory size: 8192000 KiB\n\
-\n";
- return testCompareOutputLit((const char *) data, exp, NULL, argv);
-}
-
static int testCompareDominfoByID(const void *data)
{
const char *const argv[] = { VIRSH_CUSTOM, "dominfo", "2", NULL
};
@@ -464,22 +404,6 @@ mymain(void)
custom_uri =
g_strdup_printf("test://%s/../examples/xml/test/testnode.xml",
abs_srcdir);
- if (virTestRun("virsh list (default)",
- testCompareListDefault, NULL) != 0)
- ret = -1;
-
- if (virTestRun("virsh list (custom)",
- testCompareListCustom, NULL) != 0)
- ret = -1;
-
- if (virTestRun("virsh nodeinfo (default)",
- testCompareNodeinfoDefault, NULL) != 0)
- ret = -1;
-
- if (virTestRun("virsh nodeinfo (custom)",
- testCompareNodeinfoCustom, NULL) != 0)
- ret = -1;
-
if (virTestRun("virsh dominfo (by id)",
testCompareDominfoByID, NULL) != 0)
ret = -1;
@@ -580,6 +504,9 @@ mymain(void)
ret = -1; \
} while (0);
+ DO_TEST_SCRIPT("info-default", NULL, VIRSH_DEFAULT);
+ DO_TEST_SCRIPT("info-custom", NULL, VIRSH_CUSTOM);
+
# define DO_TEST_FULL(testname_, filter, ...) \
do { \
const char *testname = testname_; \
diff --git a/tests/virshtestdata/info-custom.in b/tests/virshtestdata/info-custom.in
new file mode 100644
index 0000000000..7767ef1c49
--- /dev/null
+++ b/tests/virshtestdata/info-custom.in
@@ -0,0 +1,2 @@
+list
+nodeinfo
diff --git a/tests/virshtestdata/info-custom.out b/tests/virshtestdata/info-custom.out
new file mode 100644
index 0000000000..8307baf4eb
--- /dev/null
+++ b/tests/virshtestdata/info-custom.out
@@ -0,0 +1,15 @@
+ Id Name State
+----------------------
+ 1 fv0 running
+ 2 fc4 running
+ 3 fc5 running
+
+CPU model: i986
+CPU(s): 50
+CPU frequency: 6000 MHz
+CPU socket(s): 4
+Core(s) per socket: 4
+Thread(s) per core: 2
+NUMA cell(s): 4
+Memory size: 8192000 KiB
+
diff --git a/tests/virshtestdata/info-default.in b/tests/virshtestdata/info-default.in
new file mode 100644
index 0000000000..7767ef1c49
--- /dev/null
+++ b/tests/virshtestdata/info-default.in
@@ -0,0 +1,2 @@
+list
+nodeinfo
diff --git a/tests/virshtestdata/info-default.out b/tests/virshtestdata/info-default.out
new file mode 100644
index 0000000000..56559ab3e4
--- /dev/null
+++ b/tests/virshtestdata/info-default.out
@@ -0,0 +1,13 @@
+ Id Name State
+----------------------
+ 1 test running
+
+CPU model: i686
+CPU(s): 16
+CPU frequency: 1400 MHz
+CPU socket(s): 2
+Core(s) per socket: 2
+Thread(s) per core: 2
+NUMA cell(s): 2
+Memory size: 3145728 KiB
+
--
2.44.0