tests: factor 350 fail=0 initializations into test-lib.sh
[platform/upstream/coreutils.git] / tests / misc / seq-long-double
1 #!/bin/sh
2 # Test for this fix: 461231f022bdb3ee392622d31dc475034adceeb2.
3 # Ensure that seq prints exactly two numbers for a 2-number integral
4 # range at the limit of floating point precision.
5
6 # Copyright (C) 2008-2009 Free Software Foundation, Inc.
7
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
12
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17
18 # You should have received a copy of the GNU General Public License
19 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
21 if test "$VERBOSE" = yes; then
22   set -x
23   seq --version
24 fi
25
26 . $srcdir/test-lib.sh
27 getlimits_
28
29 # Run this test only with glibc and sizeof (long double) > sizeof (double).
30 # Otherwise, there are known failures:
31 # http://thread.gmane.org/gmane.comp.gnu.coreutils.bugs/14939/focus=14944
32 cat <<\EOF > long.c
33 #include <features.h>
34 #if defined __GNU_LIBRARY__ && __GLIBC__ >= 2
35 int foo[sizeof (long double) - sizeof (double) - 1];
36 #else
37 "run this test only with glibc"
38 #endif
39 EOF
40 $CC -c long.c \
41   || skip_test_ \
42      'this test runs only on systems with glibc and long double != double'
43
44 a=$INTMAX_MAX
45 b=$INTMAX_OFLOW
46
47 seq $a $b > out || fail=1
48 printf "$a\n$b\n" > exp || fail=1
49 compare out exp || fail=1
50
51 Exit $fail