]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: simplify since expr now works on bignums
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 8 Jul 2020 14:45:05 +0000 (07:45 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 8 Jul 2020 15:11:57 +0000 (08:11 -0700)
* 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.

cfg.mk
tests/dd/skip-seek-past-dev.sh
tests/id/setgid.sh
tests/misc/cut-huge-range.sh
tests/misc/expr.pl
tests/misc/sort-discrim.sh

diff --git a/cfg.mk b/cfg.mk
index c7cdd01d89d63cf40b22bf2387d272fd04614c93..d352aac941db62c6da431e633401449beec38f44 100644 (file)
--- a/cfg.mk
+++ b/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.
index 5fdf637a00e5ed8ca4c90b9b0e9c54f89a9c0133..39dd35ac46ef19b95f4ac2ced761e08ab23c10c2 100755 (executable)
@@ -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
index dc793d13cf5e1c737f6d081a9da2153a830db2bb..1cb240031ea63394c4527606108bbfb5bf0a2ede 100755 (executable)
@@ -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"
index dae2632ca6f720638da75e0e3863e7110e9a6b00..2362908c87da379b8e8cf3b49b0c52425289bfe7 100755 (executable)
@@ -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.
index e45f8e7abec04ca28e548eb06946c51e6d9ba23e..166358011ba8603500c938180aa2ea161cd4ed23 100755 (executable)
@@ -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)
index 9fc3acdc55d69e55fc8de1e2ae0acdec452780c0..dc275a0d1f586fe0c29489c6d0a32a4e06d0d411 100755 (executable)
@@ -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
 "