[libvirt] [PATCH 8/9] virhostdevtest: Reset libvirt error on expected failure

Michal Privoznik posted 9 patches 6 years, 5 months ago
[libvirt] [PATCH 8/9] virhostdevtest: Reset libvirt error on expected failure
Posted by Michal Privoznik 6 years, 5 months ago
If a libvirt error occurred during a test, then virTestRun()
reports it (regardless of test returning success or failure).
For instance, in this specific case, a hostdev is detached twice
and the second attempt is expected to fail. It does fail and
libvirt error is reported which is then printed onto stderr.
Insert virResetLastError() calls on appropriate places to avoid
that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 tests/virhostdevtest.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tests/virhostdevtest.c b/tests/virhostdevtest.c
index 248a5493f3..b64ba58923 100644
--- a/tests/virhostdevtest.c
+++ b/tests/virhostdevtest.c
@@ -163,6 +163,7 @@ testVirHostdevPreparePCIHostdevs_unmanaged(void)
     if (virHostdevPreparePCIDevices(mgr, drv_name, dom_name, uuid,
                                     &hostdevs[0], 1, 0) == 0)
         return -1;
+    virResetLastError();
     CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, active_count);
     CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count);
 
@@ -170,6 +171,7 @@ testVirHostdevPreparePCIHostdevs_unmanaged(void)
     if (virHostdevPreparePCIDevices(mgr, drv_name, "test_domain1", uuid,
                                     &hostdevs[1], 1, 0) == 0)
         return -1;
+    virResetLastError();
     CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, active_count);
     CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count);
 
@@ -177,6 +179,7 @@ testVirHostdevPreparePCIHostdevs_unmanaged(void)
     if (virHostdevPreparePCIDevices(mgr, "test_driver1", dom_name, uuid,
                                     &hostdevs[2], 1, 0) == 0)
         return -1;
+    virResetLastError();
     CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, active_count);
     CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count);
 
@@ -244,6 +247,7 @@ testVirHostdevPreparePCIHostdevs_managed(bool mixed)
     if (virHostdevPreparePCIDevices(mgr, drv_name, dom_name, uuid,
                                     &hostdevs[0], 1, 0) == 0)
         return -1;
+    virResetLastError();
     CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, active_count);
     CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count);
 
@@ -251,6 +255,7 @@ testVirHostdevPreparePCIHostdevs_managed(bool mixed)
     if (virHostdevPreparePCIDevices(mgr, drv_name, "test_domain1", uuid,
                                     &hostdevs[1], 1, 0) == 0)
         return -1;
+    virResetLastError();
     CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, active_count);
     CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count);
 
@@ -258,6 +263,7 @@ testVirHostdevPreparePCIHostdevs_managed(bool mixed)
     if (virHostdevPreparePCIDevices(mgr, "test_driver1", dom_name, uuid,
                                     &hostdevs[2], 1, 0) == 0)
         return -1;
+    virResetLastError();
     CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, active_count);
     CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count);
 
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 8/9] virhostdevtest: Reset libvirt error on expected failure
Posted by Ján Tomko 6 years, 5 months ago
On Mon, Aug 12, 2019 at 01:54:24PM +0200, Michal Privoznik wrote:
>If a libvirt error occurred during a test, then virTestRun()
>reports it (regardless of test returning success or failure).
>For instance, in this specific case, a hostdev is detached twice
>and the second attempt is expected to fail. It does fail and
>libvirt error is reported which is then printed onto stderr.
>Insert virResetLastError() calls on appropriate places to avoid
>that.
>
>Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
>---
> tests/virhostdevtest.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>

Reviewed-by: Ján Tomko <jtomko@redhat.com>

Jano
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list