icetindil | 82838a2 | 2013-10-11 16:41:18 -0700 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | |
| 3 | TMP=/tmp/verify_ |
| 4 | |
| 5 | if [ $# -lt "2" ] |
| 6 | then |
| 7 | echo "Usage: `basename $0` result.txt result.T.txt [-u]" |
| 8 | exit $E_BADARGS |
| 9 | fi |
| 10 | |
| 11 | args=( $@ ) |
| 12 | for i in 0 1 |
| 13 | do |
| 14 | f=${args[$i]} |
| 15 | ### Assume second argument is alredy sorted and with no duplicates |
| 16 | if [ "$i" -eq "0" ] |
| 17 | then |
| 18 | sort $3 $f > $TMP$i |
| 19 | else |
| 20 | rm $TMP$i 2> /dev/null |
| 21 | ln -s $PWD/$f $TMP$i |
| 22 | fi |
| 23 | if [ "$?" -ne "0" ] |
| 24 | then |
| 25 | echo Fail -- preprocessing |
| 26 | exit 1 |
| 27 | fi |
| 28 | |
| 29 | l[$i]=`wc --lines $TMP$i | cut --delimiter=" " --fields=1` |
| 30 | if [ "$?" -ne "0" ] |
| 31 | then |
| 32 | echo Fail -- preprocessing |
| 33 | exit 1 |
| 34 | fi |
| 35 | done |
| 36 | |
| 37 | |
| 38 | ### Test 1 |
| 39 | if [ "${l[0]}" -ne "${l[1]}" ] |
| 40 | then |
| 41 | echo $1 ${l[0]} |
| 42 | echo $2 ${l[1]} |
| 43 | echo Fail -- different number of tokens |
| 44 | exit 1 |
| 45 | fi |
| 46 | |
| 47 | ### Test 2 |
| 48 | diff --brief ${TMP}0 ${TMP}1 |
| 49 | if [ "$?" -ne "0" ] |
| 50 | then |
| 51 | echo Fail -- differnt tokens |
| 52 | exit 1 |
| 53 | fi |
| 54 | rm ${TMP}0 ${TMP}1 |
| 55 | |
| 56 | echo Pass |