mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 17:34:18 +03:00
virshtest: Adapt tests for domain id lookup and state query to DO_TEST_SCRIPT
All of the commands can be tested in one 'virsh' run in batch mode and tested against a file rather than hardcoded strings. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
4b8581b8ef
commit
a5e203417a
@ -18,59 +18,10 @@ main(void)
|
||||
|
||||
#else
|
||||
|
||||
# define DOM_FC4_UUID "ef861801-45b9-11cb-88e3-afbfe5370493"
|
||||
# define DOM_FC5_UUID "08721f99-3d1d-4aec-96eb-97803297bb36"
|
||||
# define SECURITY_LABEL "libvirt-test (enforcing)"
|
||||
# define FC4_MESSAGES "tainted: network configuration using opaque shell scripts"
|
||||
# define FC5_MESSAGES "tainted: running with undesirable elevated privileges\n\
|
||||
tainted: network configuration using opaque shell scripts\n\
|
||||
tainted: use of host cdrom passthrough\n\
|
||||
tainted: custom device tree blob used\n\
|
||||
tainted: use of deprecated configuration settings\n\
|
||||
deprecated configuration: CPU model Deprecated-Test"
|
||||
# define GET_BLKIO_PARAMETER "/dev/hda,700"
|
||||
# define SET_BLKIO_PARAMETER "/dev/hda,1000"
|
||||
# define EQUAL "="
|
||||
|
||||
static const char *dominfo_fc4 = "\
|
||||
Id: 2\n\
|
||||
Name: fc4\n\
|
||||
UUID: " DOM_FC4_UUID "\n\
|
||||
OS Type: linux\n\
|
||||
State: running\n\
|
||||
CPU(s): 1\n\
|
||||
Max memory: 261072 KiB\n\
|
||||
Used memory: 131072 KiB\n\
|
||||
Persistent: yes\n\
|
||||
Autostart: disable\n\
|
||||
Managed save: no\n\
|
||||
Security model: testSecurity\n\
|
||||
Security DOI: \n\
|
||||
Security label: " SECURITY_LABEL "\n\
|
||||
Messages: " FC4_MESSAGES "\n\
|
||||
\n";
|
||||
static const char *domuuid_fc4 = DOM_FC4_UUID "\n\n";
|
||||
static const char *domid_fc4 = "2\n\n";
|
||||
static const char *domname_fc4 = "fc4\n\n";
|
||||
static const char *domstate_fc4 = "running\n\n";
|
||||
static const char *dominfo_fc5 = "\
|
||||
Id: 3\n\
|
||||
Name: fc5\n\
|
||||
UUID: " DOM_FC5_UUID "\n\
|
||||
OS Type: linux\n\
|
||||
State: running\n\
|
||||
CPU(s): 4\n\
|
||||
Max memory: 2097152 KiB\n\
|
||||
Used memory: 2097152 KiB\n\
|
||||
Persistent: yes\n\
|
||||
Autostart: disable\n\
|
||||
Managed save: no\n\
|
||||
Security model: testSecurity\n\
|
||||
Security DOI: \n\
|
||||
Security label: " SECURITY_LABEL "\n\
|
||||
Messages: " FC5_MESSAGES "\n\
|
||||
\n";
|
||||
|
||||
static const char *get_blkio_parameters = "\
|
||||
weight : 800\n\
|
||||
device_weight : " GET_BLKIO_PARAMETER "\n\
|
||||
@ -159,104 +110,6 @@ static char *custom_uri;
|
||||
"--connect", \
|
||||
custom_uri
|
||||
|
||||
static int testCompareDominfoByID(const void *data)
|
||||
{
|
||||
const char *const argv[] = { VIRSH_CUSTOM, "dominfo", "2", NULL };
|
||||
const char *exp = dominfo_fc4;
|
||||
return testCompareOutputLit((const char *) data, exp, "\nCPU time:", argv);
|
||||
}
|
||||
|
||||
static int testCompareDominfoByUUID(const void *data)
|
||||
{
|
||||
const char *const argv[] = { VIRSH_CUSTOM, "dominfo", DOM_FC4_UUID, NULL };
|
||||
const char *exp = dominfo_fc4;
|
||||
return testCompareOutputLit((const char *) data, exp, "\nCPU time:", argv);
|
||||
}
|
||||
|
||||
static int testCompareDominfoByName(const void *data)
|
||||
{
|
||||
const char *const argv[] = { VIRSH_CUSTOM, "dominfo", "fc4", NULL };
|
||||
const char *exp = dominfo_fc4;
|
||||
return testCompareOutputLit((const char *) data, exp, "\nCPU time:", argv);
|
||||
}
|
||||
|
||||
static int testCompareTaintedDominfoByName(const void *data)
|
||||
{
|
||||
const char *const argv[] = { VIRSH_CUSTOM, "dominfo", "fc5", NULL };
|
||||
const char *exp = dominfo_fc5;
|
||||
return testCompareOutputLit((const char *) data, exp, "\nCPU time:", argv);
|
||||
}
|
||||
|
||||
static int testCompareDomuuidByID(const void *data)
|
||||
{
|
||||
const char *const argv[] = { VIRSH_CUSTOM, "domuuid", "2", NULL };
|
||||
const char *exp = domuuid_fc4;
|
||||
return testCompareOutputLit((const char *) data, exp, NULL, argv);
|
||||
}
|
||||
|
||||
static int testCompareDomuuidByName(const void *data)
|
||||
{
|
||||
const char *const argv[] = { VIRSH_CUSTOM, "domuuid", "fc4", NULL };
|
||||
const char *exp = domuuid_fc4;
|
||||
return testCompareOutputLit((const char *) data, exp, NULL, argv);
|
||||
}
|
||||
|
||||
static int testCompareDomidByName(const void *data)
|
||||
{
|
||||
const char *const argv[] = { VIRSH_CUSTOM, "domid", "fc4", NULL };
|
||||
const char *exp = domid_fc4;
|
||||
return testCompareOutputLit((const char *) data, exp, NULL, argv);
|
||||
}
|
||||
|
||||
static int testCompareDomidByUUID(const void *data)
|
||||
{
|
||||
const char *const argv[] = { VIRSH_CUSTOM, "domid", DOM_FC4_UUID, NULL };
|
||||
const char *exp = domid_fc4;
|
||||
return testCompareOutputLit((const char *) data, exp, NULL, argv);
|
||||
}
|
||||
|
||||
static int testCompareDomnameByID(const void *data)
|
||||
{
|
||||
const char *const argv[] = { VIRSH_CUSTOM, "domname", "2", NULL };
|
||||
const char *exp = domname_fc4;
|
||||
return testCompareOutputLit((const char *) data, exp, NULL, argv);
|
||||
}
|
||||
|
||||
static int testCompareDomnameByUUID(const void *data)
|
||||
{
|
||||
const char *const argv[] = { VIRSH_CUSTOM, "domname", DOM_FC4_UUID, NULL };
|
||||
const char *exp = domname_fc4;
|
||||
return testCompareOutputLit((const char *) data, exp, NULL, argv);
|
||||
}
|
||||
|
||||
static int testCompareDomstateByID(const void *data)
|
||||
{
|
||||
const char *const argv[] = { VIRSH_CUSTOM, "domstate", "2", NULL };
|
||||
const char *exp = domstate_fc4;
|
||||
return testCompareOutputLit((const char *) data, exp, NULL, argv);
|
||||
}
|
||||
|
||||
static int testCompareDomstateByUUID(const void *data)
|
||||
{
|
||||
const char *const argv[] = { VIRSH_CUSTOM, "domstate", DOM_FC4_UUID, NULL };
|
||||
const char *exp = domstate_fc4;
|
||||
return testCompareOutputLit((const char *) data, exp, NULL, argv);
|
||||
}
|
||||
|
||||
static int testCompareDomstateByName(const void *data)
|
||||
{
|
||||
const char *const argv[] = { VIRSH_CUSTOM, "domstate", "fc4", NULL };
|
||||
const char *exp = domstate_fc4;
|
||||
return testCompareOutputLit((const char *) data, exp, NULL, argv);
|
||||
}
|
||||
|
||||
static int testCompareDomControlInfoByName(const void *data)
|
||||
{
|
||||
const char *const argv[] = { VIRSH_CUSTOM, "domcontrol", "fc4", NULL };
|
||||
const char *exp = "ok\n\n";
|
||||
return testCompareOutputLit((const char *) data, exp, NULL, argv);
|
||||
}
|
||||
|
||||
static int testCompareGetBlkioParameters(const void *data)
|
||||
{
|
||||
const char *const argv[] = { VIRSH_CUSTOM, "blkiotune", "fv0", NULL };
|
||||
@ -404,62 +257,6 @@ mymain(void)
|
||||
custom_uri = g_strdup_printf("test://%s/../examples/xml/test/testnode.xml",
|
||||
abs_srcdir);
|
||||
|
||||
if (virTestRun("virsh dominfo (by id)",
|
||||
testCompareDominfoByID, NULL) != 0)
|
||||
ret = -1;
|
||||
|
||||
if (virTestRun("virsh dominfo (by uuid)",
|
||||
testCompareDominfoByUUID, NULL) != 0)
|
||||
ret = -1;
|
||||
|
||||
if (virTestRun("virsh dominfo (by name)",
|
||||
testCompareDominfoByName, NULL) != 0)
|
||||
ret = -1;
|
||||
|
||||
if (virTestRun("virsh dominfo (by name, more tainted messages)",
|
||||
testCompareTaintedDominfoByName, NULL) != 0)
|
||||
ret = -1;
|
||||
|
||||
if (virTestRun("virsh domid (by name)",
|
||||
testCompareDomidByName, NULL) != 0)
|
||||
ret = -1;
|
||||
|
||||
if (virTestRun("virsh domid (by uuid)",
|
||||
testCompareDomidByUUID, NULL) != 0)
|
||||
ret = -1;
|
||||
|
||||
if (virTestRun("virsh domuuid (by id)",
|
||||
testCompareDomuuidByID, NULL) != 0)
|
||||
ret = -1;
|
||||
|
||||
if (virTestRun("virsh domuuid (by name)",
|
||||
testCompareDomuuidByName, NULL) != 0)
|
||||
ret = -1;
|
||||
|
||||
if (virTestRun("virsh domname (by id)",
|
||||
testCompareDomnameByID, NULL) != 0)
|
||||
ret = -1;
|
||||
|
||||
if (virTestRun("virsh domname (by uuid)",
|
||||
testCompareDomnameByUUID, NULL) != 0)
|
||||
ret = -1;
|
||||
|
||||
if (virTestRun("virsh domstate (by id)",
|
||||
testCompareDomstateByID, NULL) != 0)
|
||||
ret = -1;
|
||||
|
||||
if (virTestRun("virsh domstate (by uuid)",
|
||||
testCompareDomstateByUUID, NULL) != 0)
|
||||
ret = -1;
|
||||
|
||||
if (virTestRun("virsh domstate (by name)",
|
||||
testCompareDomstateByName, NULL) != 0)
|
||||
ret = -1;
|
||||
|
||||
if (virTestRun("virsh domcontrol (by name)",
|
||||
testCompareDomControlInfoByName, NULL) != 0)
|
||||
ret = -1;
|
||||
|
||||
if (virTestRun("virsh blkiotune (get parameters)",
|
||||
testCompareGetBlkioParameters, NULL) != 0)
|
||||
ret = -1;
|
||||
@ -506,6 +303,7 @@ mymain(void)
|
||||
|
||||
DO_TEST_SCRIPT("info-default", NULL, VIRSH_DEFAULT);
|
||||
DO_TEST_SCRIPT("info-custom", NULL, VIRSH_CUSTOM);
|
||||
DO_TEST_SCRIPT("domain-id", "\nCPU time:", VIRSH_CUSTOM);
|
||||
|
||||
# define DO_TEST_FULL(testname_, filter, ...) \
|
||||
do { \
|
||||
|
18
tests/virshtestdata/domain-id.in
Normal file
18
tests/virshtestdata/domain-id.in
Normal file
@ -0,0 +1,18 @@
|
||||
dominfo ef861801-45b9-11cb-88e3-afbfe5370493
|
||||
dominfo fc4
|
||||
dominfo fc5
|
||||
|
||||
domid fc4
|
||||
domid ef861801-45b9-11cb-88e3-afbfe5370493
|
||||
|
||||
domuuid 2
|
||||
domuuid fc4
|
||||
|
||||
domname 2
|
||||
domname ef861801-45b9-11cb-88e3-afbfe5370493
|
||||
|
||||
domstate 2
|
||||
domstate ef861801-45b9-11cb-88e3-afbfe5370493
|
||||
domstate fc4
|
||||
|
||||
domcontrol fc4
|
73
tests/virshtestdata/domain-id.out
Normal file
73
tests/virshtestdata/domain-id.out
Normal file
@ -0,0 +1,73 @@
|
||||
Id: 2
|
||||
Name: fc4
|
||||
UUID: ef861801-45b9-11cb-88e3-afbfe5370493
|
||||
OS Type: linux
|
||||
State: running
|
||||
CPU(s): 1
|
||||
Max memory: 261072 KiB
|
||||
Used memory: 131072 KiB
|
||||
Persistent: yes
|
||||
Autostart: disable
|
||||
Managed save: no
|
||||
Security model: testSecurity
|
||||
Security DOI:
|
||||
Security label: libvirt-test (enforcing)
|
||||
Messages: tainted: network configuration using opaque shell scripts
|
||||
|
||||
Id: 2
|
||||
Name: fc4
|
||||
UUID: ef861801-45b9-11cb-88e3-afbfe5370493
|
||||
OS Type: linux
|
||||
State: running
|
||||
CPU(s): 1
|
||||
Max memory: 261072 KiB
|
||||
Used memory: 131072 KiB
|
||||
Persistent: yes
|
||||
Autostart: disable
|
||||
Managed save: no
|
||||
Security model: testSecurity
|
||||
Security DOI:
|
||||
Security label: libvirt-test (enforcing)
|
||||
Messages: tainted: network configuration using opaque shell scripts
|
||||
|
||||
Id: 3
|
||||
Name: fc5
|
||||
UUID: 08721f99-3d1d-4aec-96eb-97803297bb36
|
||||
OS Type: linux
|
||||
State: running
|
||||
CPU(s): 4
|
||||
Max memory: 2097152 KiB
|
||||
Used memory: 2097152 KiB
|
||||
Persistent: yes
|
||||
Autostart: disable
|
||||
Managed save: no
|
||||
Security model: testSecurity
|
||||
Security DOI:
|
||||
Security label: libvirt-test (enforcing)
|
||||
Messages: tainted: running with undesirable elevated privileges
|
||||
tainted: network configuration using opaque shell scripts
|
||||
tainted: use of host cdrom passthrough
|
||||
tainted: custom device tree blob used
|
||||
tainted: use of deprecated configuration settings
|
||||
deprecated configuration: CPU model Deprecated-Test
|
||||
|
||||
2
|
||||
|
||||
2
|
||||
|
||||
ef861801-45b9-11cb-88e3-afbfe5370493
|
||||
|
||||
ef861801-45b9-11cb-88e3-afbfe5370493
|
||||
|
||||
fc4
|
||||
|
||||
fc4
|
||||
|
||||
running
|
||||
|
||||
running
|
||||
|
||||
running
|
||||
|
||||
ok
|
||||
|
Loading…
Reference in New Issue
Block a user