On Sat, Jul 16, 2016 at 02:42:54AM +0200, Tomasz Flendrich wrote:
It was previously working only with attachments/detachments to the live domain. Now it can test attaching/detaching to the persistent domain too. --- tests/qemuhotplugtest.c | 43 +++++++++++++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 8 deletions(-) diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c index da361a2..5cf29e5 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c @@ -234,12 +234,29 @@ testQemuHotplug(const void *data) if (virAsprintf(&domain_filename, "%s/qemuhotplugtestdomains/qemuhotplug-%s.xml", abs_srcdir, test->domain_filename) < 0 || virAsprintf(&device_filename, "%s/qemuhotplugtestdevices/qemuhotplug-%s.xml", - abs_srcdir, test->device_filename) < 0 || - virAsprintf(&result_filename, + abs_srcdir, test->device_filename) < 0) + goto cleanup; + + switch (target) { + case VIR_DOMAIN_AFFECT_LIVE: + if (virAsprintf(&result_filename, "%s/qemuhotplugtestdomains/qemuhotplug-%s+%s.xml", abs_srcdir, test->domain_filename, test->device_filename) < 0)
Indentation is off here.
+ goto cleanup; + break; + case VIR_DOMAIN_AFFECT_CONFIG: + if (virAsprintf(&result_filename, + "%s/qemuhotplugtestdomains/qemuhotplug-%s+%s+config.xml", + abs_srcdir, test->domain_filename, + test->device_filename) < 0) + goto cleanup; + break; + default:
No need to do default in case the switch condition is an enum, although I'm not sure how that works with flags (non-continuous values).
+ VIR_TEST_VERBOSE("target can either be VIR_DOMAIN_AFFECT_LIVE" + " or VIR_DOMAIN_AFFECT_CONFIG\n");
We should also take into account the fact that it can be both, but should not be _CURRENT in tests. That way we don't have to do two lines of DO_TEST_ATTACH_. Although that might cause confusion with the 'keep' parameter.
goto cleanup; + } if (virTestLoadFile(domain_filename, &domain_xml) < 0 || virTestLoadFile(device_filename, &device_xml) < 0) @@ -303,16 +320,26 @@ testQemuHotplug(const void *data) * envelope */ VIR_FREE(dev); } - if (ret == 0 || fail) - ret = testQemuHotplugCheckResult(vm->def, result_xml, - result_filename, fail); + if (ret == 0 || fail) { + if (target == VIR_DOMAIN_AFFECT_LIVE) + ret = testQemuHotplugCheckResult(vm->def, result_xml, + result_filename, fail); + else if (target == VIR_DOMAIN_AFFECT_CONFIG) + ret = testQemuHotplugCheckResult(vm->newDef, result_xml, + result_filename, fail); + } break; case DETACH: ret = testQemuHotplugDetach(vm, dev, device_xml, target); - if (ret == 0 || fail) - ret = testQemuHotplugCheckResult(vm->def, domain_xml, - domain_filename, fail); + if (ret == 0 || fail) { + if (target == VIR_DOMAIN_AFFECT_LIVE) + ret = testQemuHotplugCheckResult(vm->def, domain_xml, + domain_filename, fail); + else if (target == VIR_DOMAIN_AFFECT_CONFIG) + ret = testQemuHotplugCheckResult(vm->newDef, domain_xml, + domain_filename, fail); + } break; case UPDATE: -- 2.7.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list
Attachment:
signature.asc
Description: Digital signature
-- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list