[libvirt] [PATCH 1/2] tests: mock gnutls_dh_params_generate2

Peter Krempa pkrempa at redhat.com
Fri Jun 17 11:16:35 UTC 2016


On Thu, Jun 16, 2016 at 10:46:42 +0200, Ján Tomko wrote:
> This function generates some big random numbers.
> Skip it in tests to save time.
> ---
>  tests/virnettlscontexttest.c |  2 +-
>  tests/virnettlssessiontest.c |  2 +-
>  tests/virrandommock.c        | 12 ++++++++++++
>  3 files changed, 14 insertions(+), 2 deletions(-)

[...]

> diff --git a/tests/virrandommock.c b/tests/virrandommock.c
> index 6df5e20..05c7a23 100644
> --- a/tests/virrandommock.c
> +++ b/tests/virrandommock.c
> @@ -37,3 +37,15 @@ virRandomBytes(unsigned char *buf,
>  
>      return 0;
>  }
> +
> +#ifdef WITH_GNUTLS
> +# include <stdio.h>
> +# include <gnutls/gnutls.h>
> +
> +int
> +gnutls_dh_params_generate2(gnutls_dh_params_t dparams ATTRIBUTE_UNUSED,
> +                           unsigned int bits ATTRIBUTE_UNUSED)
> +{

I'm not okay with completely removing this function here since
virnettlssessiontest is creating a session and thus this might either
reduce test coverage or introduce a problem in some cases.

I suggest that you call it just once and then use gnutls_dh_params_cpy
to cache it in the test itself rather than just skipping the init.





More information about the libvir-list mailing list