tests: avoid false failure in tail inotify test
[coreutils.git] / tests / misc / sort-stale-thread-mem.sh
blob1ec0e5b0743d20ef6fc7e63bdead9dc79d29a964
1 #!/bin/sh
2 # Trigger a bug that would cause 'sort' to reference stale thread stack memory.
4 # Copyright (C) 2010-2016 Free Software Foundation, Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # written by Jim Meyering and Paul Eggert
21 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
22 print_ver_ sort
24 very_expensive_
25 require_valgrind_
27 grep '^#define HAVE_PTHREAD_T 1' "$CONFIG_HEADER" > /dev/null ||
28 skip_ 'requires pthreads'
30 # gensort output seems to trigger the failure more often,
31 # so prefer gensort if it is available.
32 (gensort -a 10000 in) 2>/dev/null ||
33 seq -f %-98f 10000 | shuf > in ||
34 framework_failure_
36 # On Fedora-17-beta (valgrind-3.7.0-2.fc17.x86_64), this evokes two
37 # "Conditional jump or move depends on uninitialised value(s)" errors,
38 # each originating from _dl_start.
39 valgrind --quiet --error-exitcode=3 sort --version > /dev/null ||
40 framework_failure_ 'valgrind fails for trivial sort invocation'
42 # With the bug, 'sort' would fail under valgrind about half the time,
43 # on some circa-2010 multicore Linux platforms. Run the test 100 times
44 # so that the probability of missing the bug should be about 1 in
45 # 2**100 on these hosts.
46 for i in $(seq 100); do
47 valgrind --quiet --error-exitcode=3 \
48 sort -S 100K --parallel=2 in > /dev/null ||
49 { fail=$?; echo iteration $i failed; Exit $fail; }
50 done
52 Exit $fail