]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
maint: adjustments related to previous shuf crash fix
authorDaiki Ueno <ueno@gnu.org>
Tue, 6 Jan 2015 03:36:57 +0000 (03:36 +0000)
committerPádraig Brady <P@draigBrady.com>
Thu, 8 Jan 2015 14:16:01 +0000 (14:16 +0000)
* tests/misc/shuf.sh: Improve the test so it detects
crashes in more cases.
* NEWS: Mention the previous fix.

NEWS
tests/misc/shuf.sh

diff --git a/NEWS b/NEWS
index b81154d86db169e9d95509233c53e57c5402f557..f59bfc1d6339e825efd6a0cf99e4b2c49ebaf33d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -32,6 +32,9 @@ GNU coreutils NEWS                                    -*- outline -*-
   rm indicates the correct number of arguments in its confirmation prompt,
   on all platforms.  [bug introduced in coreutils-8.22]
 
+  shuf -i with a single redundant operand, would crash instead of issuing
+  a diagnostic.  [bug introduced in coreutils-8.22]
+
 ** New features
 
   chroot accepts the new --skip-chdir option to not change the working directory
index 5e85d9acade070f102d64987c1f121b15ab78a17..34f422507d8a77ea77d96c75ba20ba8f792b230d 100755 (executable)
@@ -47,7 +47,8 @@ test "$t" = 'a b c d e' || { fail=1; echo "not a permutation" 1>&2; }
 shuf -er
 test $? -eq 1 || fail=1
 
-# coreutils-8.23 dumps core.
+# coreutils-8.22 and 8.23 dump core
+# with a single redundant operand with --input-range
 shuf -i0-0 1
 test $? -eq 1 || fail=1
 
@@ -70,7 +71,7 @@ touch unreadable || framework_failure_
 chmod 0 unreadable || framework_failure_
 if ! test -r unreadable; then
   shuf -n0 unreadable || fail=1
-  shuf -n1 unreadable && fail=1
+  { shuf -n1 unreadable || test $? -ne 1; } && fail=1
 fi
 
 # Multiple -n is accepted, should use the smallest value
@@ -81,25 +82,25 @@ test "$c" -eq 3 || { fail=1; echo "Multiple -n failed">&2 ; }
 # Test error conditions
 
 # -i and -e must not be used together
-: | shuf -i0-9 -e A B &&
+: | { shuf -i0-9 -e A B || test $? -ne 1; } &&
   { fail=1; echo "shuf did not detect erroneous -e and -i usage.">&2 ; }
 # Test invalid value for -n
-: | shuf -nA &&
+: | { shuf -nA || test $? -ne 1; } &&
   { fail=1; echo "shuf did not detect erroneous -n usage.">&2 ; }
 # Test multiple -i
-shuf -i0-9 -n10 -i8-90 &&
+{ shuf -i0-9 -n10 -i8-90 || test $? -ne 1; } &&
   { fail=1; echo "shuf did not detect multiple -i usage.">&2 ; }
 # Test invalid range
 for ARG in '1' 'A' '1-' '1-A'; do
-  shuf -i$ARG &&
+    { shuf -i$ARG || test $? -ne 1; } &&
     { fail=1; echo "shuf did not detect erroneous -i$ARG usage.">&2 ; }
 done
 
 # multiple -o are forbidden
-shuf -i0-9 -o A -o B &&
+{ shuf -i0-9 -o A -o B || test $? -ne 1; } &&
   { fail=1; echo "shuf did not detect erroneous multiple -o usage.">&2 ; }
 # multiple random-sources are forbidden
-shuf -i0-9 --random-source A --random-source B &&
+{ shuf -i0-9 --random-source A --random-source B || test $? -ne 1; } &&
   { fail=1; echo "shuf did not detect multiple --random-source usage.">&2 ; }
 
 # Test --repeat option