1# #-- 04-checkconf.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 7PRE="../.." 8# test that failed exit code is used 9$PRE/unbound-checkconf bla bla bla>/dev/null 10if test $? != 1; then 11 echo "exit code for usage wrong" 12 exit 1 13fi 14$PRE/unbound-checkconf -h >/dev/null 15if test $? != 1; then 16 echo "exit code for usage wrong" 17 exit 1 18fi 19$PRE/unbound-checkconf notexist_file 20if test $? != 1; then 21 echo "exit code for nofile wrong" 22 exit 1 23fi 24 25# detect windows 26if grep "define UB_ON_WINDOWS 1" ../../config.h; then 27 onwin=1 28else 29 onwin=0 30fi 31# detect dnscrypt 32if grep "define USE_DNSCRYPT 1" ../../config.h; then 33 with_dnscrypt=1 34else 35 with_dnscrypt=0 36fi 37 38# test check of config files. 39for f in bad.*; do 40 echo 41 echo $PRE/unbound-checkconf $f 42 if test $f = "bad.user" -a $onwin -eq 1; then 43 echo "skipped on windows" 44 continue 45 fi 46 if test $f = "bad.proxy-and-dnscrypt" -a $with_dnscrypt -eq 0; then 47 echo "skipped; no DNSCRYPT support" 48 continue 49 fi 50 51 $PRE/unbound-checkconf $f 52 if test $? != 1; then 53 echo "exit code case $f wrong" 54 exit 1 55 fi 56done 57for f in good.*; do 58 echo 59 echo $PRE/unbound-checkconf $f 60 $PRE/unbound-checkconf $f 61 if test $? != 0; then 62 echo "exit code case $f wrong" 63 exit 1 64 fi 65done 66 67echo $PRE/unbound-checkconf warn.algo 68$PRE/unbound-checkconf warn.algo > outfile 2>&1 69if test $? != 0; then 70 cat outfile 71 echo "wrong exit code, warning should not fail with error" 72 exit 1 73fi 74cat outfile 75if grep "unsupported algo" outfile; then 76 echo "OK" 77else 78 echo "Failed, should print warning" 79 exit 1 80fi 81 82exit 0 83