2 # Ensure that shuf randomizes its input.
4 if test "$VERBOSE" = yes; then
10 t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
11 trap 'status=$?; cd $pwd; chmod -R u+rwx $t0; rm -rf $t0 && exit $status' 0
12 trap '(exit $?); exit $?' 1 2 13 15
15 mkdir -p $tmp || framework_failure=1
16 cd $tmp || framework_failure=1
17 seq 100 > in || framework_failure=1
19 if test $framework_failure = 1; then
20 echo "$0: failure in testing framework" 1>&2
26 shuf in >out || fail=1
28 # Fail if the input is the same as the output.
29 # This is a probabilistic test :-)
30 # However, the odds of failure are very low: 1 in 100! (~ 1 in 10^158)
31 cmp in out > /dev/null && { fail=1; echo "not random?" 1>&2; }
33 # Fail if the sorted output is not the same as the input.
35 cmp in out1 || { fail=1; echo "not a permutation" 1>&2; }
37 (exit $fail); exit $fail