[libvirt] [PATCH 3/4] Remove test case average timing

Eric Blake eblake at redhat.com
Wed Sep 25 17:52:27 UTC 2013


On 09/25/2013 11:23 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange at redhat.com>
> 
> Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
> ---

>  tests/testutils.c                 | 45 ++++++++++-----------------------------
>  tests/testutils.h                 |  1 -

Largely mechanical; this is the interesting part.

> +++ b/tests/testutils.c
> @@ -123,16 +123,15 @@ void virtTestResult(const char *name, int ret, const char *msg, ...)
>  }
>  
>  /*
> - * Runs test and count average time (if the nloops is grater than 1)

Bonus: you are fixing the s/grater/greater/ typo by deleting it :)

> + * Runs test
>   *
>   * returns: -1 = error, 0 = success
>   */
>  int
> -virtTestRun(const char *title, int nloops, int (*body)(const void *data), const void *data)
> +virtTestRun(const char *title,
> +            int (*body)(const void *data), const void *data)
>  {
>      int ret = 0;
> -    size_t i;
> -    double *ts = NULL;
>  
>      if (testCounter == 0 && !virTestGetVerbose())
>          fprintf(stderr, "      ");
> @@ -149,37 +148,16 @@ virtTestRun(const char *title, int nloops, int (*body)(const void *data), const
>      if (virTestGetVerbose())
>          fprintf(stderr, "%2zu) %-65s ... ", testCounter, title);
>  
> -    if (nloops > 1 && (VIR_ALLOC_N(ts, nloops) < 0))
> -        return -1;
> -
> -    for (i=0; i < nloops; i++) {
> -        struct timeval before, after;
> -
> -        if (ts)
> -            GETTIMEOFDAY(&before);
> -
> -        virResetLastError();
> -        ret = body(data);
> -        virErrorPtr err = virGetLastError();
> -        if (err) {
> -            if (virTestGetVerbose() || virTestGetDebug())
> -                virDispatchError(NULL);
> -        }
> -
> -        if (ret != 0) {
> -            break;
> -        }
> -
> -        if (ts) {
> -            GETTIMEOFDAY(&after);
> -            ts[i] = DIFF_MSEC(&after, &before);
> -        }
> +    virResetLastError();
> +    ret = body(data);
> +    virErrorPtr err = virGetLastError();
> +    if (err) {
> +        if (virTestGetVerbose() || virTestGetDebug())
> +            virDispatchError(NULL);
>      }
> +
>      if (virTestGetVerbose()) {
> -        if (ret == 0 && ts)
> -            fprintf(stderr, "OK     [%.5f ms]\n",
> -                    virtTestCountAverage(ts, nloops));
> -        else if (ret == 0)
> +        if (ret == 0)
>              fprintf(stderr, "OK\n");
>          else if (ret == EXIT_AM_SKIP)
>              fprintf(stderr, "SKIP\n");
> @@ -199,7 +177,6 @@ virtTestRun(const char *title, int nloops, int (*body)(const void *data), const
>              fprintf(stderr, "!");
>      }
>  
> -    VIR_FREE(ts);
>      return ret;
>  }

ACK.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130925/455c06d0/attachment-0001.sig>


More information about the libvir-list mailing list