mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-11-09 23:10:08 +00:00
virshtest: Adapt 'blkiotune' tests to DO_TEST_SCRIPT
The query and update can be tested in one run and validated against files 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
a5e203417a
commit
b65f3a01a8
@ -18,29 +18,8 @@ main(void)
|
||||
|
||||
#else
|
||||
|
||||
# define GET_BLKIO_PARAMETER "/dev/hda,700"
|
||||
# define SET_BLKIO_PARAMETER "/dev/hda,1000"
|
||||
# define EQUAL "="
|
||||
|
||||
static const char *get_blkio_parameters = "\
|
||||
weight : 800\n\
|
||||
device_weight : " GET_BLKIO_PARAMETER "\n\
|
||||
device_read_iops_sec: " GET_BLKIO_PARAMETER "\n\
|
||||
device_write_iops_sec: " GET_BLKIO_PARAMETER "\n\
|
||||
device_read_bytes_sec: " GET_BLKIO_PARAMETER "\n\
|
||||
device_write_bytes_sec: " GET_BLKIO_PARAMETER "\n\
|
||||
\n";
|
||||
|
||||
static const char *set_blkio_parameters = "\
|
||||
\n\
|
||||
weight : 500\n\
|
||||
device_weight : " SET_BLKIO_PARAMETER "\n\
|
||||
device_read_iops_sec: " SET_BLKIO_PARAMETER "\n\
|
||||
device_write_iops_sec: " SET_BLKIO_PARAMETER "\n\
|
||||
device_read_bytes_sec: " SET_BLKIO_PARAMETER "\n\
|
||||
device_write_bytes_sec: " SET_BLKIO_PARAMETER "\n\
|
||||
\n";
|
||||
|
||||
static void testFilterLine(char *buffer,
|
||||
const char *toRemove)
|
||||
{
|
||||
@ -110,32 +89,6 @@ static char *custom_uri;
|
||||
"--connect", \
|
||||
custom_uri
|
||||
|
||||
static int testCompareGetBlkioParameters(const void *data)
|
||||
{
|
||||
const char *const argv[] = { VIRSH_CUSTOM, "blkiotune", "fv0", NULL };
|
||||
const char *exp = get_blkio_parameters;
|
||||
return testCompareOutputLit((const char *) data, exp, NULL, argv);
|
||||
}
|
||||
|
||||
static int testCompareSetBlkioParameters(const void *data)
|
||||
{
|
||||
const char *const argv[] = { VIRSH_CUSTOM, "blkiotune fv0\
|
||||
--weight 500\
|
||||
--device-weights\
|
||||
" SET_BLKIO_PARAMETER "\
|
||||
--device-read-iops-sec\
|
||||
" SET_BLKIO_PARAMETER "\
|
||||
--device-write-iops-sec\
|
||||
" SET_BLKIO_PARAMETER "\
|
||||
--device-read-bytes-sec\
|
||||
" SET_BLKIO_PARAMETER "\
|
||||
--device-write-bytes-sec\
|
||||
" SET_BLKIO_PARAMETER ";\
|
||||
blkiotune fv0", NULL };
|
||||
const char *exp = set_blkio_parameters;
|
||||
return testCompareOutputLit((const char *) data, exp, NULL, argv);
|
||||
}
|
||||
|
||||
static int testIOThreadAdd(const void *data)
|
||||
{
|
||||
const char *const argv[] = { VIRSH_CUSTOM, "iothreadinfo --domain fc4;\
|
||||
@ -257,14 +210,6 @@ mymain(void)
|
||||
custom_uri = g_strdup_printf("test://%s/../examples/xml/test/testnode.xml",
|
||||
abs_srcdir);
|
||||
|
||||
if (virTestRun("virsh blkiotune (get parameters)",
|
||||
testCompareGetBlkioParameters, NULL) != 0)
|
||||
ret = -1;
|
||||
|
||||
if (virTestRun("virsh blkiotune (set parameters)",
|
||||
testCompareSetBlkioParameters, NULL) != 0)
|
||||
ret = -1;
|
||||
|
||||
if (virTestRun("virsh iothreadadd",
|
||||
testIOThreadAdd, NULL) != 0)
|
||||
ret = -1;
|
||||
@ -304,6 +249,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);
|
||||
DO_TEST_SCRIPT("blkiotune", NULL, VIRSH_CUSTOM);
|
||||
|
||||
# define DO_TEST_FULL(testname_, filter, ...) \
|
||||
do { \
|
||||
|
3
tests/virshtestdata/blkiotune.in
Normal file
3
tests/virshtestdata/blkiotune.in
Normal file
@ -0,0 +1,3 @@
|
||||
blkiotune fv0
|
||||
blkiotune fv0 --weight 500 --device-weights /dev/hda,1000 --device-read-iops-sec /dev/hda,1000 --device-write-iops-sec /dev/hda,1000 --device-read-bytes-sec /dev/hda,1000 --device-write-bytes-sec /dev/hda,1000
|
||||
blkiotune fv0
|
15
tests/virshtestdata/blkiotune.out
Normal file
15
tests/virshtestdata/blkiotune.out
Normal file
@ -0,0 +1,15 @@
|
||||
weight : 800
|
||||
device_weight : /dev/hda,700
|
||||
device_read_iops_sec: /dev/hda,700
|
||||
device_write_iops_sec: /dev/hda,700
|
||||
device_read_bytes_sec: /dev/hda,700
|
||||
device_write_bytes_sec: /dev/hda,700
|
||||
|
||||
|
||||
weight : 500
|
||||
device_weight : /dev/hda,1000
|
||||
device_read_iops_sec: /dev/hda,1000
|
||||
device_write_iops_sec: /dev/hda,1000
|
||||
device_read_bytes_sec: /dev/hda,1000
|
||||
device_write_bytes_sec: /dev/hda,1000
|
||||
|
Loading…
Reference in New Issue
Block a user