@ISA = qw(Exporter);
($VERSION = '$Revision: 1.5 $ ') =~ tr/[0-9].//cd;
-@EXPORT = qw (run_tests triple_test);
+@EXPORT = qw (run_tests triple_test getlimits);
my $debug = $ENV{DEBUG};
return $s;
}
+sub getlimits()
+{
+ my $NV;
+ open $NV, "getlimits |" or die "Error running getlimits\n";
+ my %limits = map {split /=|\n/} <$NV>;
+ return \%limits;
+}
+
# FIXME: cleanup on interrupt
# FIXME: extract `do_1_test' function
use strict;
+my $limits = getlimits ();
+
# Turn off localization of executable's output.
@ENV{qw(LANGUAGE LANG LC_ALL)} = ('C') x 3;
[t_subst "a:1\nb:1\n", t_subst "a:2:\nb:2:\n"],
t_subst "a:1:2:\nb:1:2:\n", 0],
-['bigfield', '-1 340282366920938463463374607431768211456 -2 2',
+# fields > SIZE_MAX are silently interpreted as SIZE_MAX
+['bigfield1', "-1 $limits->{'UINTMAX_OFLOW'} -2 2",
+ ["a\n", "b\n"], " a b\n", 0],
+['bigfield2', "-1 $limits->{'SIZE_OFLOW'} -2 2",
["a\n", "b\n"], " a b\n", 0],
# FIXME: change this to ensure the diagnostic makes sense
fi
. $srcdir/test-lib.sh
+getlimits_
fail=0
"$prog" '9 %*dx\n' -2 0 >>out || fail=1
-"$prog" '10 %.*dx\n' -2147483648 0 >>out || fail=1
+"$prog" '10 %.*dx\n' $INT_UFLOW 0 >>out || fail=1
+"$prog" '%.*dx\n' $INT_OFLOW 0 >>out 2> /dev/null && fail=1
"$prog" '11 %*c\n' 2 x >>out || fail=1
fi
. $srcdir/test-lib.sh
+getlimits_
# Run this test only with glibc and sizeof (long double) > sizeof (double).
# Otherwise, there are known failures:
|| skip_test_ \
'this test runs only on systems with glibc and long double != double'
-a=9223372036854775807
-b=$(echo $a|sed 's/7$/8/')
+a=$INTMAX_MAX
+b=$INTMAX_OFLOW
fail=0
seq $a $b > out || fail=1
use strict;
+my $limits = getlimits ();
+
my $prog = 'sort';
# Turn off localization of executable's output.
['nul-tab', "-k2,2 -t '\\0'",
{IN=>"a\0z\01\nb\0y\02\n"}, {OUT=>"b\0y\02\na\0z\01\n"}],
-["bigfield", qw(-k 340282366920938463463374607431768211456),
+# fields > SIZE_MAX are silently interpreted as SIZE_MAX
+["bigfield1", "-k $limits->{'UINTMAX_OFLOW'}",
+ {IN=>"2\n1\n"}, {OUT=>"1\n2\n"}],
+["bigfield2", "-k $limits->{'SIZE_OFLOW'}",
{IN=>"2\n1\n"}, {OUT=>"1\n2\n"}],
# Using an old-style key-specifying option like +1 with an invalid
use strict;
+my $limits = getlimits ();
+
(my $program_name = $0) =~ s|.*/||;
my $prog = 'sort';
# don't need to check for existence, since we're running in a temp dir
my $badtmp = 'does/not/exist';
-# 2^64+1
-my $bigint = "18446744073709551617";
+my $bigint = $limits->{'UINTMAX_OFLOW'};
my @Tests =
(
fi
. $srcdir/test-lib.sh
+getlimits_
touch in || framework_failure
# Then make sure that -0 evokes a failure.
split -0 in 2> /dev/null && fail=1
-# Ensure that split --lines=N and --bytes=N work for N=2^32,
-# assuming our host supports integers that wide.
-if _4gb=`expr 4294967296 + 0 2>/dev/null`; then
- split --lines=$_4gb in || fail=1
- split --bytes=$_4gb in || fail=1
-fi
-
-# Currently (coreutils-5.0.1) split --line-bytes=M fails
-# with `invalid number of bytes' for M=2^32 or larger. Actually,
-# the limit is SIZE_MAX, which is 2^32 on 32-bit systems.
-# On 64-bit systems, there's no problem with a count of 2^32,
-# So disable this test in order to avoid the `failure' on 64-bit systems.
-#split --line-bytes=$_4gb 2> /dev/null in && fail=1
+split --lines=$UINTMAX_MAX in || fail=1
+split --bytes=$UINTMAX_MAX in || fail=1
+split --line-bytes=$SIZE_OFLOW 2> /dev/null in && fail=1
# Make sure that a huge obsolete option evokes the right failure.
split -99999999999999999991 2> out && fail=1
use strict;
+my $limits = getlimits ();
+
my $prog = 'test';
# Turn off localization of executable's output.
['eq-3', qw(0 -eq 00)],
['eq-4', qw(8 -eq 9), {EXIT=>1}],
['eq-5', qw(1 -eq 0), {EXIT=>1}],
- ['eq-6', qw(340282366920938463463374607431768211456 -eq 0), {EXIT=>1}],
+ ['eq-6', "$limits->{'UINTMAX_OFLOW'} -eq 0", {EXIT=>1}],
['gt-1', qw(5 -gt 5), {EXIT=>1}],
['gt-2', qw(5 -gt 4)],
['gt-3', qw(4 -gt 5), {EXIT=>1}],
['gt-4', qw(-1 -gt -2)],
- ['gt-5', qw(18446744073709551616 -gt -18446744073709551616)],
+ ['gt-5', "$limits->{'UINTMAX_OFLOW'} -gt $limits->{'INTMAX_UFLOW'}"],
['lt-1', qw(5 -lt 5), {EXIT=>1}],
['lt-2', qw(5 -lt 4), {EXIT=>1}],
['lt-3', qw(4 -lt 5)],
['lt-4', qw(-1 -lt -2), {EXIT=>1}],
- ['lt-5', qw(-18446744073709551616 -lt 18446744073709551616)],
+ ['lt-5', "$limits->{'INTMAX_UFLOW'} -lt $limits->{'UINTMAX_OFLOW'}"],
['inv-1', qw(0x0 -eq 00), {EXIT=>2},
{ERR=>"$prog: invalid integer `0x0'\n"}],
fi
. $srcdir/test-lib.sh
+getlimits_
fail=0
timeout 42D sleep 0 && fail=1
# timeout overflow
-timeout 4294967296 sleep 0 && fail=1
+timeout $UINT_OFLOW sleep 0 && fail=1
# timeout overflow
-timeout 49711d sleep 0 && fail=1
+timeout $(expr $UINT_MAX / 86400 + 1)d sleep 0 && fail=1
# invalid signal spec
timeout --signal=invalid 1 sleep 0 && fail=1
fi
. $srcdir/test-lib.sh
+getlimits_
fail=0
echo > non-empty-file
-truncate -s2147483648 -c no-such-file && _FILE_OFFSET_BITS=64
+# signed overflow
+truncate -s$OFF_T_OFLOW file && fail=1
-if [ $_FILE_OFFSET_BITS -eq 64 ]; then
- # signed overflow
- truncate -s9223372036854775808 file && fail=1
+# += signed overflow
+truncate -s+$OFF_T_MAX non-empty-file && fail=1
- # *= signed overflow
- truncate --io-blocks --size="1E" file && fail=1
-
- # += signed overflow
- truncate -s+9223372036854775807 non-empty-file && fail=1
-else
- # signed overflow
- truncate -s2147483648 file && fail=1
-
- # *= signed overflow
- truncate --io-blocks --size="1G" file && fail=1
-
- # += signed overflow
- truncate -s+2147483647 non-empty-file && fail=1
-fi
+# *= signed overflow
+IO_BLOCK_OFLOW=$(expr $OFF_T_MAX / $(stat -f -c%s .) + 1)
+truncate --io-blocks --size=$IO_BLOCK_OFLOW file && fail=1
Exit $fail
use strict;
+my $limits = getlimits ();
+
(my $program_name = $0) =~ s|.*/||;
# Turn off localization of executable's output.
# It is debatable whether this test should require an environment
# setting of e.g., _POSIX2_VERSION=1.
- ['obs-ovflo', '-18446744073709551617', {IN=>''}, {OUT=>''},
+ ['obs-ovflo', "-$limits->{'UINTMAX_OFLOW'}", {IN=>''}, {OUT=>''},
{EXIT => 1}, {ERR => "$prog: tab stop value is too large\n"}],
);
use strict;
+my $limits = getlimits ();
+
my $prog = 'uniq';
my $try = "Try \`$prog --help' for more information.\n";
. $try}],
# Check that -d and -u suppress all output, as POSIX requires.
['120', qw(-d -u), {IN=>"a\na\n\b"}, {OUT=>""}],
- ['121', qw(-d -u -w340282366920938463463374607431768211456), {IN=>"a\na\n\b"}, {OUT=>""}],
+ ['121', "-d -u -w$limits->{'UINTMAX_OFLOW'}", {IN=>"a\na\n\b"}, {OUT=>""}],
+ ['122', "-d -u -w$limits->{'SIZE_OFLOW'}", {IN=>"a\na\n\b"}, {OUT=>""}],
# Check that --zero-terminated is synonymous with -z.
- ['122', '--zero-terminated', {IN=>"a\na\nb"}, {OUT=>"a\na\nb\0"}],
- ['123', '--zero-terminated', {IN=>"a\0a\0b"}, {OUT=>"a\0b\0"}],
+ ['123', '--zero-terminated', {IN=>"a\na\nb"}, {OUT=>"a\na\nb\0"}],
+ ['124', '--zero-terminated', {IN=>"a\0a\0b"}, {OUT=>"a\0b\0"}],
);
# Set _POSIX2_VERSION=199209 in the environment of each obs-plus* test.
Exit 77
}
+getlimits_()
+{
+ eval $(getlimits)
+ test "$INT_MAX" ||
+ error_ "Error running getlimits"
+}
+
require_acl_()
{
getfacl --version < /dev/null > /dev/null 2>&1 \