06c54ade921087d4e40b9dca8a60f0cda3680fce
[platform/upstream/diffutils.git] / tests / init.cfg
1 # This file is sourced by init.sh, *before* its initialization.
2
3 # Copyright (C) 2010-2018 Free Software Foundation, Inc.
4
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.
9
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.
14
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/>.
17
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.
22
23 # This goes hand in hand with the "exec 9>&2;" in tests/Makefile.am's
24 # TESTS_ENVIRONMENT definition.
25 stderr_fileno_=9
26
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.
31 sanitize_path_()
32 {
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"
36     IFS=:
37     set -- $PATH
38   IFS=$saved_IFS
39
40   local d d1
41   local colon=
42   local new_path=
43   for d in "$@"; do
44     test -z "$d" && d1=. || d1=$d
45     if ls -d "$d1/." > /dev/null 2>&1; then
46       new_path="$new_path$colon$d"
47       colon=':'
48     fi
49   done
50
51   for d in /sbin /usr/sbin ; do
52     case ":$new_path:" in
53       *:$d:*) ;;
54       *) new_path="$new_path:$d" ;;
55     esac
56   done
57
58   PATH=$new_path
59   export PATH
60 }
61
62 require_valgrind_()
63 {
64   valgrind --error-exitcode=1 true 2>/dev/null ||
65     skip_ "requires a working valgrind"
66 }
67
68 sanitize_path_