mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
tests: Allow testing for parse failures in vmx2xmltest
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
c1286d50e2
commit
152be66eaf
@ -66,7 +66,7 @@ testCapsInit(void)
|
||||
}
|
||||
|
||||
static int
|
||||
testCompareFiles(const char *vmx, const char *xml)
|
||||
testCompareFiles(const char *vmx, const char *xml, bool should_fail_parse)
|
||||
{
|
||||
int ret = -1;
|
||||
char *vmxData = NULL;
|
||||
@ -74,9 +74,17 @@ testCompareFiles(const char *vmx, const char *xml)
|
||||
virDomainDefPtr def = NULL;
|
||||
|
||||
if (virTestLoadFile(vmx, &vmxData) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (!(def = virVMXParseConfig(&ctx, xmlopt, caps, vmxData)))
|
||||
def = virVMXParseConfig(&ctx, xmlopt, caps, vmxData);
|
||||
if (should_fail_parse) {
|
||||
if (!def)
|
||||
ret = 0;
|
||||
else
|
||||
VIR_TEST_DEBUG("passed instead of expected failure");
|
||||
goto cleanup;
|
||||
}
|
||||
if (!def)
|
||||
goto cleanup;
|
||||
|
||||
if (!virDomainDefCheckABIStability(def, def, xmlopt)) {
|
||||
@ -104,6 +112,7 @@ testCompareFiles(const char *vmx, const char *xml)
|
||||
struct testInfo {
|
||||
const char *input;
|
||||
const char *output;
|
||||
bool should_fail;
|
||||
};
|
||||
|
||||
static int
|
||||
@ -119,7 +128,7 @@ testCompareHelper(const void *data)
|
||||
xml = g_strdup_printf("%s/vmx2xmldata/vmx2xml-%s.xml", abs_srcdir,
|
||||
info->output);
|
||||
|
||||
ret = testCompareFiles(vmx, xml);
|
||||
ret = testCompareFiles(vmx, xml, info->should_fail);
|
||||
|
||||
VIR_FREE(vmx);
|
||||
VIR_FREE(xml);
|
||||
@ -171,9 +180,9 @@ mymain(void)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
# define DO_TEST(_in, _out) \
|
||||
# define DO_TEST_FULL(_in, _out, _should_fail) \
|
||||
do { \
|
||||
struct testInfo info = { _in, _out }; \
|
||||
struct testInfo info = { _in, _out, _should_fail }; \
|
||||
virResetLastError(); \
|
||||
if (virTestRun("VMware VMX-2-XML "_in" -> "_out, \
|
||||
testCompareHelper, &info) < 0) { \
|
||||
@ -181,6 +190,9 @@ mymain(void)
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
# define DO_TEST(_in, _out) DO_TEST_FULL(_in, _out, false)
|
||||
# define DO_TEST_FAIL(_in, _out) DO_TEST_FULL(_in, _out, true)
|
||||
|
||||
testCapsInit();
|
||||
|
||||
if (caps == NULL)
|
||||
|
Loading…
Reference in New Issue
Block a user