mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-07-06 09:55:46 +00:00
tests: Fix detection of expected errors
This commit is contained in:
parent
2f723ea74d
commit
645c92297a
@ -25,7 +25,7 @@ static char *abs_srcdir;
|
|||||||
|
|
||||||
static int testCompareXMLToXMLFiles(const char *inxml,
|
static int testCompareXMLToXMLFiles(const char *inxml,
|
||||||
const char *outxml,
|
const char *outxml,
|
||||||
bool expect_warning) {
|
bool expect_error) {
|
||||||
char inXmlData[MAX_FILE];
|
char inXmlData[MAX_FILE];
|
||||||
char *inXmlPtr = &(inXmlData[0]);
|
char *inXmlPtr = &(inXmlData[0]);
|
||||||
char outXmlData[MAX_FILE];
|
char outXmlData[MAX_FILE];
|
||||||
@ -33,26 +33,21 @@ static int testCompareXMLToXMLFiles(const char *inxml,
|
|||||||
char *actual = NULL;
|
char *actual = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
virNWFilterDefPtr dev = NULL;
|
virNWFilterDefPtr dev = NULL;
|
||||||
char *log;
|
|
||||||
|
|
||||||
if (virtTestLoadFile(inxml, &inXmlPtr, MAX_FILE) < 0)
|
if (virtTestLoadFile(inxml, &inXmlPtr, MAX_FILE) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
if (virtTestLoadFile(outxml, &outXmlPtr, MAX_FILE) < 0)
|
if (virtTestLoadFile(outxml, &outXmlPtr, MAX_FILE) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
virResetLastError();
|
||||||
|
|
||||||
if (!(dev = virNWFilterDefParseString(NULL, inXmlData)))
|
if (!(dev = virNWFilterDefParseString(NULL, inXmlData)))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if ((log = virtTestLogContentAndReset()) == NULL)
|
if (!!virGetLastError() != expect_error)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if ((*log != '\0') != expect_warning) {
|
if (expect_error) {
|
||||||
free(log);
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
free(log);
|
|
||||||
|
|
||||||
if (expect_warning) {
|
|
||||||
/* need to suppress the errors */
|
/* need to suppress the errors */
|
||||||
virResetLastError();
|
virResetLastError();
|
||||||
}
|
}
|
||||||
|
@ -84,6 +84,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
|
|||||||
|
|
||||||
|
|
||||||
free(virtTestLogContentAndReset());
|
free(virtTestLogContentAndReset());
|
||||||
|
virResetLastError();
|
||||||
|
|
||||||
if (qemudBuildCommandLine(conn, &driver,
|
if (qemudBuildCommandLine(conn, &driver,
|
||||||
vmdef, &monitor_chr, 0, flags,
|
vmdef, &monitor_chr, 0, flags,
|
||||||
@ -91,11 +92,8 @@ static int testCompareXMLToArgvFiles(const char *xml,
|
|||||||
NULL, NULL, migrateFrom, NULL) < 0)
|
NULL, NULL, migrateFrom, NULL) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if ((log = virtTestLogContentAndReset()) == NULL)
|
if (!!virGetLastError() != expectError) {
|
||||||
goto fail;
|
if (virTestGetDebug() && (log = virtTestLogContentAndReset()))
|
||||||
|
|
||||||
if (!!strstr(log, ": error :") != expectError) {
|
|
||||||
if (virTestGetDebug())
|
|
||||||
fprintf(stderr, "\n%s", log);
|
fprintf(stderr, "\n%s", log);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user