1#!/bin/sh 2 3if [ $# -lt 1 ] ; then 4 echo 'Specify binary to run as the first argument' 5 exit 1 6fi 7 8 9for _tin in ${TEST_DIR}/*.in ; do 10 _t=`echo $_tin | sed -e 's/.in$//'` 11 $1 $_t.in $_t.out 12 if [ $? -ne 0 ] ; then 13 echo "Test: $_t failed, output:" 14 cat $_t.out 15 rm $_t.out 16 exit 1 17 fi 18 if [ -f $_t.res ] ; then 19 diff -s $_t.out $_t.res -u 2>/dev/null 20 if [ $? -ne 0 ] ; then 21 rm $_t.out 22 echo "Test: $_t output missmatch" 23 exit 1 24 fi 25 fi 26 rm $_t.out 27done 28 29if [ $# -gt 2 ] ; then 30 $3 ${TEST_DIR}/generate.out 31 diff -s ${TEST_DIR}/generate.out ${TEST_DIR}/generate.res -u 2>/dev/null 32 if [ $? -ne 0 ] ; then 33 rm ${TEST_DIR}/generate.out 34 echo "Test: generate.res output missmatch" 35 exit 1 36 fi 37 rm ${TEST_DIR}/generate.out 38fi 39 40sh -c "xz -c < /dev/null > /dev/null" 41if [ $? -eq 0 -a $# -gt 1 ] ; then 42 echo 'Running speed tests' 43 for _tin in ${TEST_DIR}/*.xz ; do 44 echo "Unpacking $_tin..." 45 xz -cd < $_tin > ${TEST_DIR}/test_file 46 # Preread file to cheat benchmark! 47 cat ${TEST_DIR}/test_file > /dev/null 48 echo "Starting benchmarking for $_tin..." 49 $2 ${TEST_DIR}/test_file 50 if [ $? -ne 0 ] ; then 51 echo "Test: $_tin failed" 52 rm ${TEST_DIR}/test_file 53 exit 1 54 fi 55 rm ${TEST_DIR}/test_file 56 done 57fi 58 59