summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBob Proulx <bob@proulx.com>2007-07-26 02:26:13 -0600
committerJim Meyering <jim@meyering.net>2007-07-26 10:32:21 +0200
commit26468bd5a2bab9585ea622bbe05a102551663c18 (patch)
tree1adc763621969a34a377c9550893d593f1f92c18 /tests
parent813d66cea7bab1a98c5a096b325bdba49b5e2eac (diff)
downloadcoreutils-26468bd5a2bab9585ea622bbe05a102551663c18.tar.xz
sort: Improve sort --random-sort test.
Jim Meyering wrote: > so if your test were to run sort -R twice, and compare *those* outputs, > then it would trigger on this bug. Thanks. I don't have a system with the failure so I was working blind. Here is a rework of the patch. Bob >From 76dafb0dde4f8d685eb2b4b43fbf3c1cf9f0ff4b Mon Sep 17 00:00:00 2001 From: Bob Proulx <bob@proulx.com> Date: Thu, 26 Jul 2007 02:19:49 -0600 Subject: [PATCH] sort: Improve sort --random-sort test. * tests/misc/sort-rand: If "locale" is available pick a random non-C locale and check "sort --random-sort" behavior using it. Signed-off-by: Bob Proulx <bob@proulx.com>
Diffstat (limited to 'tests')
-rwxr-xr-xtests/misc/sort-rand14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/misc/sort-rand b/tests/misc/sort-rand
index 0380af8c2..c6dd597e3 100755
--- a/tests/misc/sort-rand
+++ b/tests/misc/sort-rand
@@ -49,4 +49,18 @@ cmp in out > /dev/null && { fail=1; echo "not random?" 1>&2; }
sort -n out > out1
cmp in out1 || { fail=1; echo "not a permutation" 1>&2; }
+# If locale is available then use it to find a random non-C locale.
+if (locale --version) > /dev/null 2>&1; then
+ locale=`locale -a | sort --random-sort | awk '/^.._/{print;exit}'`
+ LC_ALL=$locale sort --random-sort in > out1 || fail=1
+ LC_ALL=$locale sort --random-sort in > out2 || fail=1
+
+ # Fail if the output "randomly" is the same twice in a row.
+ cmp out1 out2 > /dev/null && { fail=1; echo "not random with LC_ALL=$locale" 1>&2; }
+
+ # Fail if the sorted output is not the same as the input.
+ sort -n out > out1
+ cmp in out1 || { fail=1; echo "not a permutation with LC_ALL=$locale" 1>&2; }
+fi
+
(exit $fail); exit $fail