提交 1bf1b387 编写于 作者: D Daniel P. Berrange

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: NDaniel P. Berrange <berrange@redhat.com>
上级 a8412f86
...@@ -73,51 +73,38 @@ testCapsInit(void) ...@@ -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) {
goto failure;
}
def = virVMXParseConfig(&ctx, xmlopt, vmxData);
if (def == NULL) { if (virtTestLoadFile(xml, &xmlData) < 0)
err = virGetLastError(); goto cleanup;
fprintf(stderr, "ERROR: %s\n", err != NULL ? err->message : "<unknown>");
goto failure;
}
formatted = virDomainDefFormat(def, VIR_DOMAIN_XML_SECURE); if (!(def = virVMXParseConfig(&ctx, xmlopt, vmxData)))
goto cleanup;
if (formatted == 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;
}
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 { ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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) ...@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册