On 01/03/2014 05:15 PM, Eric Blake wrote:
Ensure our testsuite has some coverage of old-style domain
event registration.
* tests/objecteventtest.c (testDomainCreateXMLOld): New test.
(mymain): Run it.
(testDomainCreateXML): Check return values.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
I verified that this test fails until you also apply patch
2/2 "event: make deregister return value match docs". Should
I squash them together or keep it as separate commits?
tests/objecteventtest.c | 67 ++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 58 insertions(+), 9 deletions(-)
I've only been able to apply up thru patch 5/5a... patch 2 didn't apply
as well:
Applying: event: make deregister return value match docs
error: patch failed: src/lxc/lxc_driver.c:1
error: src/lxc/lxc_driver.c: patch does not apply
error: patch failed: src/xen/xen_driver.c:1
error: src/xen/xen_driver.c: patch does not apply
Patch failed at 0001 event: make deregister return value match docs
Skipping 2, I was able to apply 3, 4, 5, & 5a before 6 failed as well.
In any case, this patch failed to build due to an uninitialized 'dom' in
the new function and the changed one (since there's now a goto before
dom gets initialized).
After inserting a couple of dom = NULL; - I had a core, I now assume the
core had to do with patch 2.
I think perhaps it'd be better to rebase and repost 2->12.
John
diff --git a/tests/objecteventtest.c b/tests/objecteventtest.c
index ae29792..f7b60cd 100644
--- a/tests/objecteventtest.c
+++ b/tests/objecteventtest.c
@@ -1,4 +1,5 @@
/*
+ * Copyright (C) 2014 Red Hat, Inc.
* Copyright (C) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
*
* This library is free software; you can redistribute it and/or
@@ -126,6 +127,46 @@ networkLifecycleCb(virConnectPtr conn ATTRIBUTE_UNUSED,
static int
+testDomainCreateXMLOld(const void *data)
+{
+ const objecteventTest *test = data;
+ lifecycleEventCounter counter;
+ virDomainPtr dom;
dom = NULL
+ int ret = -1;
+ bool registered = false;
+
+ lifecycleEventCounter_reset(&counter);
+
+ if (virConnectDomainEventRegister(test->conn,
+ domainLifecycleCb,
+ &counter, NULL) != 0)
+ goto cleanup;
+ registered = true;
+ dom = virDomainCreateXML(test->conn, domainDef, 0);
+
+ if (dom == NULL || virEventRunDefaultImpl() < 0)
+ goto cleanup;
+
+ if (counter.startEvents != 1 || counter.unexpectedEvents > 0)
+ goto cleanup;
+
+ if (virConnectDomainEventDeregister(test->conn, domainLifecycleCb) != 0)
+ goto cleanup;
+ registered = false;
+ ret = 0;
+
+cleanup:
+ if (registered)
+ virConnectDomainEventDeregister(test->conn, domainLifecycleCb);
+ if (dom != NULL) {
+ virDomainDestroy(dom);
+ virDomainFree(dom);
+ }
+
+ return ret;
+}
+
+static int
testDomainCreateXML(const void *data)
{
const objecteventTest *test = data;
@@ -133,27 +174,31 @@ testDomainCreateXML(const void *data)
int eventId = VIR_DOMAIN_EVENT_ID_LIFECYCLE;
virDomainPtr dom;
dom = NULL
int id;
- int ret = 0;
+ int ret = -1;
lifecycleEventCounter_reset(&counter);
id = virConnectDomainEventRegisterAny(test->conn, NULL, eventId,
VIR_DOMAIN_EVENT_CALLBACK(&domainLifecycleCb),
&counter, NULL);
+ if (id < 0)
+ goto cleanup;
dom = virDomainCreateXML(test->conn, domainDef, 0);
- if (dom == NULL || virEventRunDefaultImpl() < 0) {
- ret = -1;
+ if (dom == NULL || virEventRunDefaultImpl() < 0)
goto cleanup;
- }
- if (counter.startEvents != 1 || counter.unexpectedEvents > 0) {
- ret = -1;
+ if (counter.startEvents != 1 || counter.unexpectedEvents > 0)
goto cleanup;
- }
+
+ if (virConnectDomainEventDeregisterAny(test->conn, id) != 0)
+ goto cleanup;
+ id = -1;
+ ret = 0;
cleanup:
- virConnectDomainEventDeregisterAny(test->conn, id);
+ if (id >= 0)
+ virConnectDomainEventDeregisterAny(test->conn, id);
if (dom != NULL) {
virDomainDestroy(dom);
virDomainFree(dom);
@@ -388,7 +433,11 @@ mymain(void)
virtTestQuiesceLibvirtErrors(false);
/* Domain event tests */
- if (virtTestRun("Domain createXML start event ", testDomainCreateXML,
&test) < 0)
+ if (virtTestRun("Domain createXML start event (old API)",
+ testDomainCreateXMLOld, &test) < 0)
+ ret = EXIT_FAILURE;
+ if (virtTestRun("Domain createXML start event (new API)",
+ testDomainCreateXML, &test) < 0)
ret = EXIT_FAILURE;
if (virtTestRun("Domain (un)define events", testDomainDefine, &test)
< 0)
ret = EXIT_FAILURE;