1 # This file is sourced by init.sh, *before* its initialization.
3 # Copyright (C) 2010-2021 Free Software Foundation, Inc.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <https://www.gnu.org/licenses/>.
18 # Skip the current test if valgrind doesn't work,
19 # which could happen if not installed,
20 # or hasn't support for the built architecture,
21 # or hasn't appropriate error suppressions installed etc.
23 # This goes hand in hand with the "exec 9>&2;" in tests/Makefile.am's
24 # TESTS_ENVIRONMENT definition.
27 # Having an unsearchable directory in PATH causes execve to fail with EACCES
28 # when applied to an unresolvable program name, contrary to the desired ENOENT.
29 # Avoid the problem by rewriting PATH to exclude unsearchable directories.
30 # Also, if PATH lacks /sbin and/or /usr/sbin, append it/them.
33 # FIXME: remove double quotes around $IFS when all tests use init.sh.
34 # They constitute a work-around for a bug in FreeBSD 8.1's /bin/sh.
35 local saved_IFS="$IFS"
44 test -z "$d" && d1=. || d1=$d
45 if ls -d "$d1/." > /dev/null 2>&1; then
46 new_path="$new_path$colon$d"
51 for d in /sbin /usr/sbin ; do
52 case "$PATH_SEPARATOR$new_path$PATH_SEPARATOR" in
53 *$PATH_SEPARATOR$d$PATH_SEPARATOR*) ;;
54 *) new_path="$new_path$PATH_SEPARATOR$d" ;;
64 valgrind --error-exitcode=1 true 2>/dev/null ||
65 skip_ "requires a working valgrind"