mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
Don't print all test suite errors to stderr in vmx2xmltest
The vmx2xmltest test would print all errors to stderr, which is not helpful when running OOM tests, and differs from the behaviour of other tests. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
a8412f868b
commit
1bf1b38773
@ -73,51 +73,38 @@ testCapsInit(void)
|
|||||||
static int
|
static int
|
||||||
testCompareFiles(const char *vmx, const char *xml)
|
testCompareFiles(const char *vmx, const char *xml)
|
||||||
{
|
{
|
||||||
int result = -1;
|
int ret = -1;
|
||||||
char *vmxData = NULL;
|
char *vmxData = NULL;
|
||||||
char *xmlData = NULL;
|
char *xmlData = NULL;
|
||||||
char *formatted = NULL;
|
char *formatted = NULL;
|
||||||
virDomainDefPtr def = NULL;
|
virDomainDefPtr def = NULL;
|
||||||
virErrorPtr err = NULL;
|
|
||||||
|
|
||||||
if (virtTestLoadFile(vmx, &vmxData) < 0) {
|
if (virtTestLoadFile(vmx, &vmxData) < 0)
|
||||||
goto failure;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
if (virtTestLoadFile(xml, &xmlData) < 0) {
|
if (virtTestLoadFile(xml, &xmlData) < 0)
|
||||||
goto failure;
|
goto cleanup;
|
||||||
}
|
|
||||||
|
|
||||||
def = virVMXParseConfig(&ctx, xmlopt, vmxData);
|
if (!(def = virVMXParseConfig(&ctx, xmlopt, vmxData)))
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
if (def == NULL) {
|
if (!(formatted = virDomainDefFormat(def, VIR_DOMAIN_XML_SECURE)))
|
||||||
err = virGetLastError();
|
goto cleanup;
|
||||||
fprintf(stderr, "ERROR: %s\n", err != NULL ? err->message : "<unknown>");
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
formatted = virDomainDefFormat(def, VIR_DOMAIN_XML_SECURE);
|
|
||||||
|
|
||||||
if (formatted == NULL) {
|
|
||||||
err = virGetLastError();
|
|
||||||
fprintf(stderr, "ERROR: %s\n", err != NULL ? err->message : "<unknown>");
|
|
||||||
goto failure;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (STRNEQ(xmlData, formatted)) {
|
if (STRNEQ(xmlData, formatted)) {
|
||||||
virtTestDifference(stderr, xmlData, formatted);
|
virtTestDifference(stderr, xmlData, formatted);
|
||||||
goto failure;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = 0;
|
ret = 0;
|
||||||
|
|
||||||
failure:
|
cleanup:
|
||||||
VIR_FREE(vmxData);
|
VIR_FREE(vmxData);
|
||||||
VIR_FREE(xmlData);
|
VIR_FREE(xmlData);
|
||||||
VIR_FREE(formatted);
|
VIR_FREE(formatted);
|
||||||
virDomainDefFree(def);
|
virDomainDefFree(def);
|
||||||
|
|
||||||
return result;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct testInfo {
|
struct testInfo {
|
||||||
@ -128,7 +115,7 @@ struct testInfo {
|
|||||||
static int
|
static int
|
||||||
testCompareHelper(const void *data)
|
testCompareHelper(const void *data)
|
||||||
{
|
{
|
||||||
int result = -1;
|
int ret = -1;
|
||||||
const struct testInfo *info = data;
|
const struct testInfo *info = data;
|
||||||
char *vmx = NULL;
|
char *vmx = NULL;
|
||||||
char *xml = NULL;
|
char *xml = NULL;
|
||||||
@ -140,13 +127,13 @@ testCompareHelper(const void *data)
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = testCompareFiles(vmx, xml);
|
ret = testCompareFiles(vmx, xml);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(vmx);
|
VIR_FREE(vmx);
|
||||||
VIR_FREE(xml);
|
VIR_FREE(xml);
|
||||||
|
|
||||||
return result;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
@ -195,7 +182,7 @@ testParseVMXFileName(const char *fileName, void *opaque ATTRIBUTE_UNUSED)
|
|||||||
static int
|
static int
|
||||||
mymain(void)
|
mymain(void)
|
||||||
{
|
{
|
||||||
int result = 0;
|
int ret = 0;
|
||||||
|
|
||||||
# define DO_TEST(_in, _out) \
|
# define DO_TEST(_in, _out) \
|
||||||
do { \
|
do { \
|
||||||
@ -203,7 +190,7 @@ mymain(void)
|
|||||||
virResetLastError(); \
|
virResetLastError(); \
|
||||||
if (virtTestRun("VMware VMX-2-XML "_in" -> "_out, 1, \
|
if (virtTestRun("VMware VMX-2-XML "_in" -> "_out, 1, \
|
||||||
testCompareHelper, &info) < 0) { \
|
testCompareHelper, &info) < 0) { \
|
||||||
result = -1; \
|
ret = -1; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
@ -299,7 +286,7 @@ mymain(void)
|
|||||||
virObjectUnref(caps);
|
virObjectUnref(caps);
|
||||||
virObjectUnref(xmlopt);
|
virObjectUnref(xmlopt);
|
||||||
|
|
||||||
return result == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
VIRT_TEST_MAIN(mymain)
|
VIRT_TEST_MAIN(mymain)
|
||||||
|
Loading…
Reference in New Issue
Block a user