Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- input=/tmp/shuffle_test0$$
- output=/tmp/shuffle_test1$$
- sorted_output=/tmp/shuffle_test2$$
- all_output=/tmp/shuffle_test3$$
- number_of_lines=4
- number_of_test_runs=256
- i=1
- factorial=1
- while test $i -le $number_of_lines
- do
- echo $i
- factorial=$(($factorial * $i))
- i=$(($i + 1))
- done >$input
- run=1
- while test $run -le $number_of_test_runs
- do
- ./shuffle.pl <$input >$output
- sort -n $output >$sorted_output
- if diff $sorted_output $input >/dev/null
- then
- echo `cat $output` >>$all_output
- else
- echo Testing failed, input was:
- cat $input
- echo Testing failed, output was:
- cat $output
- exit 1
- fi
- run=$(($run + 1))
- done
- n_different_outputs=`sort $all_output|uniq|wc -l`
- if test $n_different_outputs -eq $factorial
- then
- echo All possible outputs produced
- exit 0
- else
- echo In $number_of_test_runs executions only $n_different_outputs of $factorial outputs produced
- exit 1
- fi
- rm -f $input $output $sorted_output $all_output
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement