[Libguestfs] [PATCH nbdkit v3 4/4] tests: Valgrind is only enabled when NBDKIT_VALGRIND = 1, not any other values.

Eric Blake eblake at redhat.com
Wed Nov 14 14:43:32 UTC 2018


On 11/14/18 8:27 AM, Richard W.M. Jones wrote:
> Fix the tests so they only enable valgrind workarounds or skips when
> NBDKIT_VALGRIND is exactly set to "1" and not any other values
> (including empty string, or not set).
> 
> Thanks: Eric Blake.
> ---

> +++ b/tests/test-dump-plugin.sh
> @@ -55,7 +55,8 @@ fi
>   # However some of these tests are expected to fail.
>   test ()
>   {
> -    case "$1${NBDKIT_VALGRIND:+-valgrind}" in
> +    [ "$NBDKIT_VALGRIND" = "1" ] && vg="-valgrind"
> +    case "$1$vg" in

Could misbehave if I have 'export vg=-valgrind' in my environment but 
not NBDKIT_VALGRIND (cure by prepping with 'vg=' before the [...]).  Not 
sure if that is worth worrying about (someone playing that hard with 
their environment to try and break the testsuite deserves their problems).

Bash has sane rules even if I have NBDKIT_VALGRIND='!' or 
NBDKIT_VALGRIND='(', but not all other implementations do; the most 
common ways to ensure that user-supplied input can't cause an unexpected 
misparse of [ is to use either '[ "x$NBDKIT_VALGRIND" = "x1" ]' or '[ 1 
= "$NBDKIT_VALGRIND" ]'.  Not sure if that is worth worrying about, 
since the tests require bash.

> +++ b/tests/test-lang-plugins.c
> @@ -49,6 +49,7 @@ main (int argc, char *argv[])
>   {
>     guestfs_h *g;
>     int r;
> +  const char *s;
>     char *data;
>   
>     /* These languages currently fail completely when run under
> @@ -56,7 +57,8 @@ main (int argc, char *argv[])
>      */
>   #pragma GCC diagnostic push
>   #pragma GCC diagnostic ignored "-Wunused-result"
> -  if (getenv ("NBDKIT_VALGRIND") != NULL &&
> +  s = getenv ("NBDKIT_VALGRIND");
> +  if (s && strcmp (s, "1") == 0 &&
>         (strcmp (LANG, "python") == 0 ||
>          strcmp (LANG, "ruby") == 0 ||
>          strcmp (LANG, "tcl") == 0)) {

Do we still need the #pragma here?

Series is looking good now.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org




More information about the Libguestfs mailing list