tests: Test BlkioParameters related functions for test driver

Signed-off-by: Luke Yue <lukedyue@gmail.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
Luke Yue 2021-08-19 18:04:31 +08:00 committed by Martin Kletzander
parent 2dfc2ab48a
commit ba32bf03b2
3 changed files with 77 additions and 0 deletions

View File

@ -38,4 +38,15 @@
</disk>
<graphics type='vnc' port='5904'/>
</devices>
<blkiotune>
<weight>800</weight>
<device>
<path>/dev/hda</path>
<weight>700</weight>
<read_bytes_sec>700</read_bytes_sec>
<write_bytes_sec>700</write_bytes_sec>
<read_iops_sec>700</read_iops_sec>
<write_iops_sec>700</write_iops_sec>
</device>
</blkiotune>
</domain>

View File

@ -48,6 +48,17 @@
</disk>
<graphics type="vnc" port="5904"/>
</devices>
<blkiotune>
<weight>800</weight>
<device>
<path>/dev/hda</path>
<weight>700</weight>
<read_bytes_sec>700</read_bytes_sec>
<write_bytes_sec>700</write_bytes_sec>
<read_iops_sec>700</read_iops_sec>
<write_iops_sec>700</write_iops_sec>
</device>
</blkiotune>
</domain>
<domain type="test">
<name>fc4</name>

View File

@ -30,6 +30,8 @@ main(void)
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"
static const char *dominfo_fc4 = "\
Id: 2\n\
@ -70,6 +72,25 @@ 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\
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 int testFilterLine(char *buffer,
const char *toRemove)
{
@ -291,6 +312,32 @@ static int testCompareDomControlInfoByName(const void *data G_GNUC_UNUSED)
return testCompareOutputLit(exp, NULL, argv);
}
static int testCompareGetBlkioParameters(const void *data G_GNUC_UNUSED)
{
const char *const argv[] = { VIRSH_CUSTOM, "blkiotune", "fv0", NULL };
const char *exp = get_blkio_parameters;
return testCompareOutputLit(exp, NULL, argv);
}
static int testCompareSetBlkioParameters(const void *data G_GNUC_UNUSED)
{
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(exp, NULL, argv);
}
struct testInfo {
const char *const *argv;
const char *result;
@ -383,6 +430,14 @@ mymain(void)
testCompareDomControlInfoByName, NULL) != 0)
ret = -1;
if (virTestRun("virsh blkiotune (get parameters)",
testCompareGetBlkioParameters, NULL) != 0)
ret = -1;
if (virTestRun("virsh blkiotune (set parameters)",
testCompareSetBlkioParameters, NULL) != 0)
ret = -1;
/* It's a bit awkward listing result before argument, but that's a
* limitation of C99 vararg macros. */
# define DO_TEST(i, result, ...) \