1# #-- 03-testbound.test --# 2# source the master var file when it's there 3[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master 4# use .tpkg.var.test for in test variable passing 5[ -f .tpkg.var.test ] && source .tpkg.var.test 6 7. ../common.sh 8PRE="../.." 9get_make 10(cd $PRE ; $MAKE testbound) 11exitval=0 12# quiet="" to make verbose 13 14if test -f $PRE/unbound_do_valgrind_in_test; then 15 do_valgrind=yes 16else 17 do_valgrind=no 18fi 19VALGRIND_FLAGS="--leak-check=full --show-leak-kinds=all" 20# valgrind mode for debug 21#if grep "staticexe=-static" $PRE/Makefile >/dev/null 2>&1; then 22# if test -x "`which valgrind`"; then 23# do_valgrind=yes 24# fi 25#fi 26 27# self-test (unit test of testbound) 28if test $do_valgrind = "yes"; then 29 echo "valgrind yes" 30 echo 31 if (valgrind $VALGRIND_FLAGS $PRE/testbound -s >tmpout 2>&1;); then 32 echo "selftest OK " 33 else 34 echo "selftest FAILED" 35 exit 1 36 fi 37 if grep "All heap blocks were freed -- no leaks are possible" tmpout; then 38 : # clean 39 else 40 cat tmpout 41 echo "Memory leaked in selftest" 42 grep "in use at exit" tmpout 43 exit 1 44 fi 45 if grep "ERROR SUMMARY: 0 errors from 0 contexts" tmpout; then 46 : # clean 47 else 48 cat tmpout 49 echo "Errors in selftest" 50 grep "ERROR SUMMARY" tmpout 51 exit 1 52 fi 53else 54 if ($PRE/testbound -s >/dev/null 2>&1;); then 55 echo "selftest OK " 56 else 57 echo "selftest FAILED" 58 exit 1 59 fi 60fi 61 62 63# the .crpl are not always supported and need checking for SHA256 and GOST 64# support. 65# the .rpl should work on any system (portable). 66for input in $PRE/testdata/*.rpl $PRE/testdata/*.crpl; do 67 header=`grep SCENARIO_BEGIN $input | head -1 | sed -e 's/SCENARIO_BEGIN //'` 68 cleaninput=`echo $input | sed -e "s?$PRE/testdata/??"` 69 70 # detect if SHA256 is needed 71 if echo $cleaninput | grep sha2 >/dev/null 2>&1; then 72 if $PRE/testbound -2 >/dev/null 2>&1; then 73 : # the SHA256 is supported 74 else 75 continue 76 fi 77 fi 78 79 # detect if GOST is needed 80 if echo $cleaninput | grep gost >/dev/null 2>&1; then 81 if $PRE/testbound -g >/dev/null 2>&1; then 82 : # GOST is supported 83 else 84 continue 85 fi 86 fi 87 88 # detect if CLIENT_SUBNET is needed 89 if echo $cleaninput | grep subnet >/dev/null 2>&1; then 90 if $PRE/testbound -c >/dev/null 2>&1; then 91 : # CLIENT_SUBNET is supported 92 else 93 continue 94 fi 95 fi 96 97 # detect if IPSECMOD is needed 98 if echo $cleaninput | grep ipsecmod >/dev/null 2>&1; then 99 if $PRE/testbound -i >/dev/null 2>&1; then 100 : # IPSECMOD is supported 101 else 102 continue 103 fi 104 fi 105 106 # detect if cachedb is needed 107 if echo $cleaninput | grep cachedb >/dev/null 2>&1; then 108 if grep "define USE_CACHEDB 1" $PRE/config.h >/dev/null 2>&1; then 109 : # CACHEDB is supported 110 else 111 continue 112 fi 113 fi 114 115 if test $do_valgrind = "yes"; then 116 echo 117 if (valgrind $VALGRIND_FLAGS $PRE/testbound -p $input >tmpout 2>&1;); then 118 echo " OK $cleaninput: $header" 119 else 120 echo "FAILED $cleaninput: $header" 121 exitval=1 122 fi 123 if grep "All heap blocks were freed -- no leaks are possible" tmpout; then 124 : # clean 125 else 126 grep "^==" tmpout 127 echo "Memory leaked in $cleaninput" 128 grep "in use at exit" tmpout 129 exitval=1 130 fi 131 if grep "ERROR SUMMARY: 0 errors from 0 contexts" tmpout; then 132 : # clean 133 else 134 grep "^==" tmpout 135 echo "Errors in $cleaninput" 136 grep "ERROR SUMMARY" tmpout 137 exitval=1 138 fi 139 else 140 # do valgrind=no 141 if ($PRE/testbound -p $input >/dev/null 2>&1;); then 142 echo " OK $cleaninput: $header" 143 else 144 echo "FAILED $cleaninput: $header" 145 exitval=1 146 fi 147 fi 148 if test -f ublocktrace.0; then 149 if $PRE/lock-verify ublocktrace.*; then 150 #echo "lock-verify test $input worked." 151 i=i 152 else 153 echo "lock-verify test $input failed." 154 exitval=1 155 fi 156 fi 157done 158exit $exitval 159