From 99be9078383e7fc95bf84b42ea6a0e50afbe6ff4 Mon Sep 17 00:00:00 2001 From: Pádraig Brady Date: Fri, 12 Dec 2008 10:25:34 +0000 Subject: tests: refactor to use the new getlimits utility * tests/Coreutils.pm: Add function to make limits available * tests/test-lib.sh: ditto * tests/misc/join: Check for both SIZE_OFLOW and UINTMAX_OFLOW rather than using arbitrary 2^128 * tests/misc/sort: ditto * tests/misc/uniq: ditto * tests/misc/printf: Check for both INT_OFLOW and INT_UFLOW rather than using arbitrary -2^31 * tests/misc/seq-long-double: Check for INTMAX_OFLOW rather than using arbitrary 2^63 * tests/misc/split-fail: Check --lines --bytes and --line-bytes options limits on all platforms. Note getlimits obviates the need to use expr to check if 32 bit integers are supported, which I think was invalid anyway as expr now supports bignum? * tests/misc/test: Check for UINTMAX_OFLOW rather than using arbitrary 2^64 and 2^128. Check for INTMAX_UFLOW rather than using arbitrary -2^64 * tests/misc/timeout-parameters: Check for UINT_OFLOW rather than using arbitrary 2^32 * tests/misc/truncate-overflow: Don't depend on truncate to determine if we're on a 32 or 64 bit platform and instead use the various OFF_T limits * tests/misc/sort-merge: Check for UINTMAX_OFLOW rather than using arbitrary 2^64+1 * tests/misc/unexpand: ditto --- tests/misc/truncate-overflow | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) (limited to 'tests/misc/truncate-overflow') diff --git a/tests/misc/truncate-overflow b/tests/misc/truncate-overflow index b903244e6..3f486c58d 100755 --- a/tests/misc/truncate-overflow +++ b/tests/misc/truncate-overflow @@ -22,6 +22,7 @@ if test "$VERBOSE" = yes; then fi . $srcdir/test-lib.sh +getlimits_ fail=0 @@ -30,26 +31,14 @@ truncate -s-1 create-zero-len-file || fail=1 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 -- cgit v1.2.3-54-g00ecf