mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-11-09 23:10:08 +00:00
virshtest: Replace list and nodeinfo tests by equivalent VIR_TEST_SCRIPT variant
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@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
e8e79e38e5
commit
4b8581b8ef
@ -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_; \
|
||||
|
2
tests/virshtestdata/info-custom.in
Normal file
2
tests/virshtestdata/info-custom.in
Normal file
@ -0,0 +1,2 @@
|
||||
list
|
||||
nodeinfo
|
15
tests/virshtestdata/info-custom.out
Normal file
15
tests/virshtestdata/info-custom.out
Normal file
@ -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
|
||||
|
2
tests/virshtestdata/info-default.in
Normal file
2
tests/virshtestdata/info-default.in
Normal file
@ -0,0 +1,2 @@
|
||||
list
|
||||
nodeinfo
|
13
tests/virshtestdata/info-default.out
Normal file
13
tests/virshtestdata/info-default.out
Normal file
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user