[libvirt] [PATCH 1/2] tests: use virGetLastErrorMessage()

Cole Robinson crobinso at redhat.com
Tue May 10 22:15:24 UTC 2016


On 05/10/2016 08:16 AM, Jovanka Gulicoska wrote:
> ---
>  tests/commandtest.c              | 81 ++++++++++++++--------------------------
>  tests/libvirtdconftest.c         | 26 ++++++-------
>  tests/openvzutilstest.c          |  7 +---
>  tests/securityselinuxlabeltest.c |  6 +--
>  tests/securityselinuxtest.c      |  6 +--
>  tests/virpolkittest.c            | 18 ++++-----
>  6 files changed, 55 insertions(+), 89 deletions(-)
> 

There's a couple other test instances

- tests/qemucapsprobe.c
- tests/nodeinfo.c:linuxTestCompareFiles : you'll want to do

if (virGetLastError())
    VIR_TEST_DEBUG("\n%s\n", error->message);

to preserve the behavior

Comments inline

> diff --git a/tests/libvirtdconftest.c b/tests/libvirtdconftest.c
> index 61d861d..daa2b90 100644
> --- a/tests/libvirtdconftest.c
> +++ b/tests/libvirtdconftest.c
> @@ -102,7 +102,7 @@ testCorrupt(const void *opaque)
>                                  data->params,
>                                  data->paramnum,
>                                  &type);
> -    virErrorPtr err = NULL;
> +    const char *err = NULL;
>  
>      if (!newdata)
>          return -1;
> @@ -115,15 +115,15 @@ testCorrupt(const void *opaque)
>          goto cleanup;
>      }
>  
> -    err = virGetLastError();
> -    if (!err || !err->message) {
> +    err = virGetLastErrorMessage();
> +    if (!err) {
>          VIR_DEBUG("No error or message %p", err);
>          ret = -1;
>          goto cleanup;
>      }
>  

virGetLastErrorMessage() doesn't return NULL, so this check will never
trigger. I think it's better to just not change libvirtdconftest.c. Same with
virpolkittest.c which is similar

Thanks,
Cole




More information about the libvir-list mailing list