1#!/bin/sh 2# @configure_input@ 3 4# Copying and distribution of this file, with or without modification, 5# are permitted in any medium without royalty provided the copyright 6# notice and this notice are preserved. 7 8set -e 9 10srcdir=@abs_srcdir@ 11builddir=@abs_builddir@ 12 13unset TESEQ_COLORS 14 15get_vars() 16{ 17 teseq_options='' 18 input=input 19 output=output 20 expected=expected 21 invocation='' 22 diffcmd='' 23 r_output=r-output 24 r_invocation='' 25 r_diffcmd='' 26 run_reseq=true 27 if [ -f "$testin/vars" ] 28 then 29 . "$testin/vars" 30 fi 31 invocation=${invocation:-'"$TESEQ" $teseq_options \ 32 "$testin/$input" "$testout/$output"'} 33 diffcmd=${diffcmd:-'diff -u "$testin/$expected" "$testout/$output"'} 34 r_invocation=${r_invocation:-'"$RESEQ" -- "$testin/$r_input" \ 35 "$testout/$r_output"'} 36 r_diffcmd=${r_diffcmd:-'cmp -- "$testin/$r_expected" \ 37 "$testout/$r_output"'} 38 r_input="${r_input:-$expected}" 39 r_expected="${r_expected:-$input}" 40} 41 42if [ "$#" -ge 1 -a X"${1}" = X"-r" ] 43then 44 echo 45 echo "RUNNING RESEQ TESTS" 46 echo 47 # Test reseq 48 run_test() 49 ( 50 test="$1" 51 testin="$srcdir/tests/$test" 52 testout="$builddir/tests/$test" 53 mkdir -p "$testout" 54 cd "$testout" 55 rm -f r-output 56 get_vars 57 if ! $run_reseq 58 then 59 echo ' (skipped)' 60 return 0 61 fi 62 eval "$r_invocation" 63 result="$?" 64 if [ "$result" -ne 0 ] 65 then 66 return "$result" 67 fi 68 eval "$r_diffcmd" 69 return $? 70 ) 71else 72 echo 73 echo "RUNNING TESEQ TESTS" 74 echo 75 # Test teseq 76 run_test() 77 ( 78 test="$1" 79 testin="$srcdir/tests/$test" 80 testout="$builddir/tests/$test" 81 mkdir -p "$testout" 82 cd "$testout" 83 rm -f output 84 get_vars 85 eval "$invocation" 86 result="$?" 87 if [ "$result" -ne 0 ] 88 then 89 return "$result" 90 fi 91 eval "$diffcmd" 92 return $? 93 ) 94fi 95 96######################################## 97 98: ${TESEQ=${builddir}/teseq} 99: ${RESEQ=${builddir}/reseq} 100: ${TESEQ_TESTS=' 101 empty 102 cmdline-in-out 103 cmdline-- 104 basic-text 105 wrap 106 prompt 107 prompt-descript 108 prompt-descript-only 109 function-labels 110 esc-seq-versus-not 111 T.416 112 params 113 iso-2022 114 cntrl-esc 115 high-val 116 hardstatus 117 hardstatus-color 118 controls 119 csi-interm 120 csi-desc 121 modes 122 single-functions 123 extensions 124 sgr 125 timing 126 timing-header-only 127 timing-no-eol 128 limits 129'} 130 131nt=0 132np=0 133nf=0 134ft='' 135for test in $TESEQ_TESTS 136do 137 echo $test 138 if run_test $test 139 then 140 np=$((np+1)) 141 else 142 nf=$((nf+1)) 143 echo 144 echo FAILED: $test 145 echo 146 ft="$ft $test" 147 fi 148 nt=$((nt+1)) 149done 150 151set +e 152echo 153echo "Ran $nt total tests" 154if [ $nf -eq 0 ] 155then 156 tput setaf 2 2>/dev/null 157 tput bold 2>/dev/null 158 echo PASSED 159 tput sgr0 2>/dev/null 160else 161 tput setaf 1 2>/dev/null 162 tput bold 2>/dev/null 163 echo FAILED 164 tput sgr0 2>/dev/null 165fi 166echo "Passed: $np" 167echo "Failed: $nf" 168echo 169echo "$ft" 170 171exit $nf 172 173# vim:sw=8 sts=8 ts=8 noet 174