mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
virshtest: Filter multiple occurences of string to drop in testFilterLine
Upcoming patches will require that possibly multiple occurences of the string to drop are present in the output string thus we need to adapt testFilterLine to handle them. Additionally we drop the unused return value. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
99392689cb
commit
f9dbd34c49
@ -90,21 +90,20 @@ device_read_bytes_sec: " SET_BLKIO_PARAMETER "\n\
|
|||||||
device_write_bytes_sec: " SET_BLKIO_PARAMETER "\n\
|
device_write_bytes_sec: " SET_BLKIO_PARAMETER "\n\
|
||||||
\n";
|
\n";
|
||||||
|
|
||||||
static int testFilterLine(char *buffer,
|
static void testFilterLine(char *buffer,
|
||||||
const char *toRemove)
|
const char *toRemove)
|
||||||
{
|
{
|
||||||
char *start;
|
char *start;
|
||||||
char *end;
|
|
||||||
|
|
||||||
if (!(start = strstr(buffer, toRemove)))
|
while ((start = strstr(buffer, toRemove))) {
|
||||||
return -1;
|
char *end;
|
||||||
|
|
||||||
if (!(end = strstr(start+1, "\n"))) {
|
if (!(end = strstr(start+1, "\n"))) {
|
||||||
*start = '\0';
|
*start = '\0';
|
||||||
} else {
|
} else {
|
||||||
memmove(start, end, strlen(end)+1);
|
memmove(start, end, strlen(end)+1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -134,8 +133,8 @@ testCompareOutputLit(const char *expectFile,
|
|||||||
actual = g_strdup_printf("%s\n## Exit code: %d\n", tmp, exitstatus);
|
actual = g_strdup_printf("%s\n## Exit code: %d\n", tmp, exitstatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (filter && testFilterLine(actual, filter) < 0)
|
if (filter)
|
||||||
return -1;
|
testFilterLine(actual, filter);
|
||||||
|
|
||||||
if (expectData) {
|
if (expectData) {
|
||||||
if (virTestCompareToString(expectData, actual) < 0)
|
if (virTestCompareToString(expectData, actual) < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user