mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-01 17:35:17 +00:00
tests: utils: Introduce helper for dispatching libvirt errors
In cases when we call a libvirt helper which reports an error the error would be hidden unless libvirt library debug is on. This produces a lot of output and is hard to debug. The helper provides a way to dispatch the libvirt error in specific cases sice we do already dispatch it in case when virTestRun is used. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
5f5542b44e
commit
d154807d5b
@ -81,6 +81,30 @@ virTestGetFlag(const char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* virTestPropagateLibvirtError:
|
||||||
|
*
|
||||||
|
* In cases when a libvirt utility function which reports libvirt errors is
|
||||||
|
* used in the test suite outside of the virTestRun call and the failure of such
|
||||||
|
* a function would cause an test failure the error message reported by that
|
||||||
|
* function will not be propagated to the user as the error callback is not
|
||||||
|
* invoked.
|
||||||
|
*
|
||||||
|
* In cases when the error message may be beneficial in debugging this helper
|
||||||
|
* provides means to dispatch the errors including invocation of the error
|
||||||
|
* callback.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
virTestPropagateLibvirtError(void)
|
||||||
|
{
|
||||||
|
if (virGetLastErrorCode() == VIR_ERR_OK)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (virTestGetVerbose() || virTestGetDebug())
|
||||||
|
virDispatchError(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Runs test
|
* Runs test
|
||||||
*
|
*
|
||||||
@ -112,10 +136,7 @@ virTestRun(const char *title,
|
|||||||
|
|
||||||
virResetLastError();
|
virResetLastError();
|
||||||
ret = body(data);
|
ret = body(data);
|
||||||
if (virGetLastErrorCode()) {
|
virTestPropagateLibvirtError();
|
||||||
if (virTestGetVerbose() || virTestGetDebug())
|
|
||||||
virDispatchError(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (virTestGetVerbose()) {
|
if (virTestGetVerbose()) {
|
||||||
if (ret == 0)
|
if (ret == 0)
|
||||||
|
@ -84,6 +84,7 @@ unsigned int virTestGetDebug(void);
|
|||||||
unsigned int virTestGetVerbose(void);
|
unsigned int virTestGetVerbose(void);
|
||||||
unsigned int virTestGetExpensive(void);
|
unsigned int virTestGetExpensive(void);
|
||||||
unsigned int virTestGetRegenerate(void);
|
unsigned int virTestGetRegenerate(void);
|
||||||
|
void virTestPropagateLibvirtError(void);
|
||||||
|
|
||||||
#define VIR_TEST_DEBUG(fmt, ...) \
|
#define VIR_TEST_DEBUG(fmt, ...) \
|
||||||
do { \
|
do { \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user