mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2025-09-10 07:59:52 +02:00
tests: simplify since expr now works on bignums
* cfg.mk (sc_prohibit_expr_unsigned): Remove. * tests/dd/skip-seek-past-dev.sh (DEV_OFLOW): * tests/id/setgid.sh (gp1): * tests/misc/cut-huge-range.sh (CUT_MAX): * tests/misc/expr.pl: * tests/misc/sort-discrim.sh: Assume expr works on bignums. * tests/misc/cut-huge-range.sh (subtract_one): Remove; no longer needed.
This commit is contained in:
8
cfg.mk
8
cfg.mk
@@ -609,14 +609,6 @@ sc_prohibit_test_empty:
|
||||
halt='use `compare /dev/null ...`, not `test -s ...` in tests/' \
|
||||
$(_sc_search_regexp)
|
||||
|
||||
# Ensure that expr doesn't work directly on various unsigned int types,
|
||||
# as that's not generally supported without GMP.
|
||||
sc_prohibit_expr_unsigned:
|
||||
@prohibit='expr .*(UINT|ULONG|[^S]SIZE|[UGP]ID|UINTMAX)' \
|
||||
halt='avoid passing unsigned limits to `expr` (without GMP)' \
|
||||
in_vc_files='^tests/' \
|
||||
$(_sc_search_regexp)
|
||||
|
||||
# Programs like sort, ls, expr use PROG_FAILURE in place of EXIT_FAILURE.
|
||||
# Others, use the EXIT_CANCELED, EXIT_ENOENT, etc. macros defined in system.h.
|
||||
# In those programs, ensure that EXIT_FAILURE is not used by mistake.
|
||||
|
||||
@@ -39,8 +39,7 @@ dev_size=$(get_device_size "$device") ||
|
||||
skip_ "failed to determine size of $device"
|
||||
|
||||
# Don't use shell arithmetic as older versions of dash use longs
|
||||
DEV_OFLOW=$(expr $dev_size + 1) ||
|
||||
skip_ "failed to adjust device size $dev_size"
|
||||
DEV_OFLOW=$(expr $dev_size + 1) || framework_failure_
|
||||
|
||||
timeout 10 dd bs=1 skip=$DEV_OFLOW count=0 status=noxfer < "$device" 2> err
|
||||
test "$?" = "1" || fail=1
|
||||
|
||||
@@ -24,8 +24,7 @@ getlimits_
|
||||
|
||||
# Construct a different group number
|
||||
gp1=$NON_ROOT_GID
|
||||
gp1=$(expr $gp1 + 1) ||
|
||||
skip_ "failed to adjust GID $NON_ROOT_GID"
|
||||
gp1=$(expr $gp1 + 1) || framework_failure_
|
||||
|
||||
test "$gp1" -lt $GID_T_MAX ||
|
||||
skip_ "GID $gp1 is reserved on some systems"
|
||||
|
||||
@@ -23,30 +23,10 @@ getlimits_
|
||||
vm=$(get_min_ulimit_v_ returns_ 0 cut -b1 /dev/null) \
|
||||
|| skip_ "this shell lacks ulimit support"
|
||||
|
||||
# sed script to subtract one from the input.
|
||||
# Each input line should consist of a positive decimal number.
|
||||
# Each output line's number is one less than the input's.
|
||||
# There's no limit (other than line length) on the number's magnitude.
|
||||
subtract_one='
|
||||
s/$/@/
|
||||
: again
|
||||
s/0@/@9/
|
||||
s/1@/0/
|
||||
s/2@/1/
|
||||
s/3@/2/
|
||||
s/4@/3/
|
||||
s/5@/4/
|
||||
s/6@/5/
|
||||
s/7@/6/
|
||||
s/8@/7/
|
||||
s/9@/8/
|
||||
t again
|
||||
'
|
||||
|
||||
# Ensure we can cut up to our sentinel value.
|
||||
# Don't use expr to subtract one,
|
||||
# since UINTMAX_MAX may exceed its maximum value.
|
||||
CUT_MAX=$(echo $UINTMAX_MAX | sed "$subtract_one")
|
||||
CUT_MAX=$(expr $UINTMAX_MAX - 1) || framework_failure_
|
||||
|
||||
# From coreutils-8.10 through 8.20, this would make cut try to allocate
|
||||
# a 256MiB bit vector.
|
||||
|
||||
@@ -193,10 +193,6 @@ my @Tests =
|
||||
{ERR=>"$prog: syntax error: expecting ')' instead of 'a'\n"}],
|
||||
);
|
||||
|
||||
# If using big numbers fails, remove all /^bignum-/ tests
|
||||
qx!expr $big_prod '*' $big_prod '*' $big_prod!
|
||||
or @Tests = grep {$_->[0] !~ /^bignum-/} @Tests;
|
||||
|
||||
# Append a newline to end of each expected 'OUT' string.
|
||||
my $t;
|
||||
foreach $t (@Tests)
|
||||
|
||||
@@ -42,40 +42,38 @@ compare exp out || fail=1
|
||||
# looks at the number plus two decimal digits, but if -h is
|
||||
# used it looks at one decimal place plus a 4-bit SI prefix value.
|
||||
# In both cases, there's an extra factor of 2 for the sign.
|
||||
# Note INTMAX_MAX is used below as that's that largest number
|
||||
# expr can handle on all systems (without GMP).
|
||||
max_int100=$(expr $INTMAX_MAX / 100) &&
|
||||
max_frac100=$(printf '%.2d' $(expr $INTMAX_MAX % 100)) &&
|
||||
max_int160=$(expr $INTMAX_MAX / 160) &&
|
||||
max_frac160=$(expr $INTMAX_MAX / 16 % 10) &&
|
||||
max_int200=$(expr $UINTMAX_MAX / 200) &&
|
||||
max_frac200=$(printf '%.2d' $(expr $UINTMAX_MAX / 2 % 100)) &&
|
||||
max_int320=$(expr $UINTMAX_MAX / 320) &&
|
||||
max_frac320=$(expr $UINTMAX_MAX / 32 % 10) &&
|
||||
{ printf -- "\
|
||||
-$UINTMAX_OFLOW
|
||||
-$UINTMAX_MAX
|
||||
-${max_int100}0.1
|
||||
-${max_int100}0
|
||||
-${max_int100}0.0
|
||||
-${max_int160}0.1
|
||||
-${max_int160}0
|
||||
-${max_int160}0.0
|
||||
-$max_int100.${max_frac100}1
|
||||
-$max_int100.$max_frac100
|
||||
-$max_int160.${max_frac160}1
|
||||
-$max_int160.$max_frac160
|
||||
-${max_int200}0.1
|
||||
-${max_int200}0
|
||||
-${max_int200}0.0
|
||||
-${max_int320}0.1
|
||||
-${max_int320}0
|
||||
-${max_int320}0.0
|
||||
-$max_int200.${max_frac200}1
|
||||
-$max_int200.$max_frac200
|
||||
-$max_int320.${max_frac320}1
|
||||
-$max_int320.$max_frac320
|
||||
" &&
|
||||
seq -- -10 .001 10 &&
|
||||
printf "\
|
||||
$max_int160
|
||||
$max_int160.$max_frac160
|
||||
$max_int160.${max_frac160}1
|
||||
$max_int100
|
||||
$max_int100.$max_frac100
|
||||
$max_int100.${max_frac100}1
|
||||
${max_int160}0
|
||||
${max_int160}0.0
|
||||
${max_int160}0.1
|
||||
${max_int100}0
|
||||
${max_int100}0.0
|
||||
${max_int100}0.1
|
||||
$max_int320
|
||||
$max_int320.$max_frac320
|
||||
$max_int320.${max_frac320}1
|
||||
$max_int200
|
||||
$max_int200.$max_frac200
|
||||
$max_int200.${max_frac200}1
|
||||
${max_int320}0
|
||||
${max_int320}0.0
|
||||
${max_int320}0.1
|
||||
${max_int200}0
|
||||
${max_int200}0.0
|
||||
${max_int200}0.1
|
||||
$UINTMAX_MAX
|
||||
$UINTMAX_OFLOW
|
||||
"
|
||||
|
||||
Reference in New Issue
Block a user