On 03/30/2016 11:13 AM, Martin Kletzander wrote: > For now, the test was dumping an XML of inactive domain (well, setting > the id to '-1' to be precise) when checking the results. This patch > enables future additions to test the live XML output as well. > > Signed-off-by: Martin Kletzander <mklet...@redhat.com> > --- > tests/qemuhotplugtest.c | 27 +++++++++++++++++---------- > 1 file changed, 17 insertions(+), 10 deletions(-) > > diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c > index 1eb2b6a881f2..2b0de94fb4a6 100644 > --- a/tests/qemuhotplugtest.c > +++ b/tests/qemuhotplugtest.c > @@ -52,6 +52,7 @@ struct qemuHotplugTestData { > bool keep; > virDomainObjPtr vm; > bool deviceDeletedEvent; > + bool live; > }; > > static int > @@ -177,12 +178,13 @@ static int > testQemuHotplugCheckResult(virDomainObjPtr vm, > const char *expected, > const char *expectedFile, > - bool fail) > + bool fail, bool live) > { > char *actual; > int ret; > > - vm->def->id = -1; > + if (!live) > + vm->def->id = -1; > actual = virDomainDefFormat(vm->def, driver.caps, > VIR_DOMAIN_DEF_FORMAT_SECURE); > if (!actual) > @@ -219,6 +221,7 @@ testQemuHotplug(const void *data) > const char *const *tmp; > bool fail = test->fail; > bool keep = test->keep; > + bool live = test->live; > unsigned int device_parse_flags = 0; > virDomainObjPtr vm = NULL; > virDomainDeviceDefPtr dev = NULL; > @@ -300,14 +303,14 @@ testQemuHotplug(const void *data) > } > if (ret == 0 || fail) > ret = testQemuHotplugCheckResult(vm, result_xml, > - result_filename, fail); > + result_filename, fail, live); > break; > > case DETACH: > ret = testQemuHotplugDetach(vm, dev); > if (ret == 0 || fail) > ret = testQemuHotplugCheckResult(vm, domain_xml, > - domain_filename, fail); > + domain_filename, fail, live); > break; > > case UPDATE: > @@ -371,7 +374,7 @@ mymain(void) > /* wait only 100ms for DEVICE_DELETED event */ > qemuDomainRemoveDeviceWaitTime = 100; > > -#define DO_TEST(file, ACTION, dev, event, fial, kep, ...) \ > +#define DO_TEST(file, ACTION, dev, event, fial, kep, liv, ...) \
"Typically" rather than misspelling "fail", "keep", or "live" one would use an underscore, such as "_fail", "_keep", and "_live" in order to represent a macro argument... Not required for ACK, but nice nonetheless John > do { \ > const char *my_mon[] = { __VA_ARGS__, NULL}; \ > const char *name = file " " #ACTION " " dev; \ > @@ -381,25 +384,29 @@ mymain(void) > data.fail = fial; \ > data.mon = my_mon; \ > data.keep = kep; \ > + data.live = liv; \ > data.deviceDeletedEvent = event; \ > if (virtTestRun(name, testQemuHotplug, &data) < 0) \ > ret = -1; \ > } while (0) > > #define DO_TEST_ATTACH(file, dev, fial, kep, ...) \ > - DO_TEST(file, ATTACH, dev, false, fial, kep, __VA_ARGS__) > + DO_TEST(file, ATTACH, dev, false, fial, kep, false, __VA_ARGS__) > + > +#define DO_TEST_ATTACH_LIVE(file, dev, fial, kep, ...) \ > + DO_TEST(file, ATTACH, dev, false, fial, kep, true, __VA_ARGS__) > > #define DO_TEST_DETACH(file, dev, fial, kep, ...) \ > - DO_TEST(file, DETACH, dev, false, fial, kep, __VA_ARGS__) > + DO_TEST(file, DETACH, dev, false, fial, kep, false, __VA_ARGS__) > > #define DO_TEST_ATTACH_EVENT(file, dev, fial, kep, ...) \ > - DO_TEST(file, ATTACH, dev, true, fial, kep, __VA_ARGS__) > + DO_TEST(file, ATTACH, dev, true, fial, kep, false, __VA_ARGS__) > > #define DO_TEST_DETACH_EVENT(file, dev, fial, kep, ...) \ > - DO_TEST(file, DETACH, dev, true, fial, kep, __VA_ARGS__) > + DO_TEST(file, DETACH, dev, true, fial, kep, false, __VA_ARGS__) > > #define DO_TEST_UPDATE(file, dev, fial, kep, ...) \ > - DO_TEST(file, UPDATE, dev, false, fial, kep, __VA_ARGS__) > + DO_TEST(file, UPDATE, dev, false, fial, kep, false, __VA_ARGS__) > > > #define QMP_OK "{\"return\": {}}" > -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list