From 2564d154d7c879f42939a40dce8eb10b6712df29 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 3 Jan 2021 02:03:33 +0100
Subject: [PATCH] valgrind-tests: Really enable the valgrind options test.

* m4/valgrind-tests.m4 (gl_VALGRIND_TESTS): Don't assume that the
valgrind options --error-exitcode=1 --leak-check=full always work.
---
 ChangeLog            |  6 ++++++
 m4/valgrind-tests.m4 | 13 ++++++++-----
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 183e877033..9d9c280324 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2021-01-02  Bruno Haible  <bruno@clisp.org>
+
+	valgrind-tests: Really enable the valgrind options test.
+	* m4/valgrind-tests.m4 (gl_VALGRIND_TESTS): Don't assume that the
+	valgrind options --error-exitcode=1 --leak-check=full always work.
+
 2021-01-02  Bruno Haible  <bruno@clisp.org>
 
 	utimensat: Fix test failures on macOS 10.13.
diff --git a/m4/valgrind-tests.m4 b/m4/valgrind-tests.m4
index c642f4e72e..499759dd55 100644
--- a/m4/valgrind-tests.m4
+++ b/m4/valgrind-tests.m4
@@ -1,4 +1,4 @@
-# valgrind-tests.m4 serial 4
+# valgrind-tests.m4 serial 5
 dnl Copyright (C) 2008-2021 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -23,10 +23,13 @@ AC_DEFUN([gl_VALGRIND_TESTS],
     if test "$VALGRIND"; then
       AC_CACHE_CHECK([for valgrind options for tests],
         [gl_cv_opt_valgrind_tests],
-        [gl_cv_opt_valgrind_tests="-q --error-exitcode=1 --leak-check=full"
-         $VALGRIND $gl_valgrind_opts ls > /dev/null 2>&1 ||
-           gl_cv_opt_valgrind_tests=no])
-
+        [gl_valgrind_opts='-q --error-exitcode=1 --leak-check=full'
+         if $VALGRIND $gl_valgrind_opts ls > /dev/null 2>&1; then
+           gl_cv_opt_valgrind_tests="$gl_valgrind_opts"
+         else
+           gl_cv_opt_valgrind_tests=no
+         fi
+        ])
       if test "$gl_cv_opt_valgrind_tests" != no; then
         VALGRIND="$VALGRIND $gl_cv_opt_valgrind_tests"
       else
-- 
2.39.5