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. --- tests/test-dump-plugin.sh | 3 ++- tests/test-ext2.c | 4 +++- tests/test-help.sh | 3 ++- tests/test-lang-plugins.c | 4 +++- tests/test-ocaml.c | 4 +++- tests/test-python-exception.sh | 2 +- tests/test-version.sh | 3 ++- 7 files changed, 16 insertions(+), 7 deletions(-) diff --git a/tests/test-dump-plugin.sh b/tests/test-dump-plugin.sh index dc52742..6e0e3d7 100755 --- a/tests/test-dump-plugin.sh +++ 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 vddk | vddk-valgrind) # VDDK won't run without special environment variables # being set, so ignore it. diff --git a/tests/test-ext2.c b/tests/test-ext2.c index 6878028..59e9281 100644 --- a/tests/test-ext2.c +++ b/tests/test-ext2.c @@ -49,12 +49,14 @@ main (int argc, char *argv[]) { guestfs_h *g; int r; + const char *s; char *data; /* The ext2 test fails valgrind. It seems as if the ext2fs error * table cannot be freed. */ - if (getenv ("NBDKIT_VALGRIND") != NULL) { + s = getenv ("NBDKIT_VALGRIND"); + if (s && strcmp (s, "1") == 0) { fprintf (stderr, "ext2 test skipped under valgrind.\n"); exit (77); /* Tells automake to skip the test. */ } diff --git a/tests/test-help.sh b/tests/test-help.sh index 68e0bfc..8dc0675 100755 --- a/tests/test-help.sh +++ b/tests/test-help.sh @@ -45,7 +45,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 vddk | vddk-valgrind) # VDDK won't run without special environment variables # being set, so ignore it. diff --git a/tests/test-lang-plugins.c b/tests/test-lang-plugins.c index 46b0563..f569540 100644 --- a/tests/test-lang-plugins.c +++ 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)) { diff --git a/tests/test-ocaml.c b/tests/test-ocaml.c index 4cae8a6..fa61966 100644 --- a/tests/test-ocaml.c +++ b/tests/test-ocaml.c @@ -49,13 +49,15 @@ main (int argc, char *argv[]) { guestfs_h *g; int r; + const char *s; char *data; size_t i, size; /* The OCaml tests fail valgrind, so skip them. We should be able * to get this working with a bit of effort. XXX */ - if (getenv ("NBDKIT_VALGRIND") != NULL) { + s = getenv ("NBDKIT_VALGRIND"); + if (s && strcmp (s, "1") == 0) { fprintf (stderr, "ocaml test skipped under valgrind.\n"); exit (77); /* Tells automake to skip the test. */ } diff --git a/tests/test-python-exception.sh b/tests/test-python-exception.sh index 567853a..7813918 100755 --- a/tests/test-python-exception.sh +++ b/tests/test-python-exception.sh @@ -36,7 +36,7 @@ set -x # Python language leaks like a sieve as well as a lot of worrying # "Conditional jump or move depends on uninitialised value(s)". -if test -n "$NBDKIT_VALGRIND"; then +if [ "$NBDKIT_VALGRIND" = "1" ]; then echo "$0: skipping Python test under valgrind." exit 77 fi diff --git a/tests/test-version.sh b/tests/test-version.sh index 869d88c..a3b8a18 100755 --- a/tests/test-version.sh +++ b/tests/test-version.sh @@ -45,7 +45,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 vddk | vddk-valgrind) # VDDK won't run without special environment variables # being set, so ignore it. -- 2.19.0.rc0