1# #-- dynlibmod.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="../.." 9 10# compile the dynamic library module 11if grep "define USE_WINSOCK 1" $PRE/config.h; then 12 echo "compile dynamic library dll for mingw" 13 echo "x86_64-w64-mingw32-gcc -m64 -I$PRE -shared -Wall -fpic -o helloworld.dll $PRE/dynlibmod/examples/helloworld.c -L../.. -l:libunbound.a" 14 x86_64-w64-mingw32-gcc -m64 -I$PRE -shared -Wall -fpic -o helloworld.dll $PRE/dynlibmod/examples/helloworld.c -L../.. -l:libunbound.a 15 if test $? != 0; then 16 echo "compile failure" 17 exit 1; 18 fi 19else 20 echo "compile dynamic library" 21 echo "gcc -I$PRE -shared -Wall -fpic -o helloworld.so $PRE/dynlibmod/examples/helloworld.c" 22 gcc -I$PRE -shared -Wall -fpic -o helloworld.so $PRE/dynlibmod/examples/helloworld.c 23 if test $? != 0; then 24 echo "compile failure" 25 exit 1; 26 fi 27fi 28 29# start unbound in the background 30LD_LIBRARY_PATH="." $PRE/unbound -d -c ub.conf >unbound.log 2>&1 & 31UNBOUND_PID=$! 32echo "UNBOUND_PID=$UNBOUND_PID" >> .tpkg.var.test 33wait_unbound_up unbound.log 34 35# test if the server is up. 36echo "> dig www.example.com." 37dig @127.0.0.1 -p $UNBOUND_PORT www.example.com. | tee outfile 38echo "> check answer" 39if grep "10.20.30.40" outfile; then 40 echo "OK" 41else 42 echo "> cat logfiles" 43 cat fwd.log 44 cat unbound.log 45 echo "Not OK" 46 exit 1 47fi 48 49echo "> check log for dynlibmod info" 50# wait for a moment for filesystem to catch up. 51if grep "hello world from operate" unbound.log >/dev/null; then :; else sleep 1; fi 52if grep "hello world from operate" unbound.log >/dev/null; then :; else sleep 1; fi 53if grep "hello world from operate" unbound.log >/dev/null; then :; else sleep 1; fi 54if grep "hello world from operate" unbound.log >/dev/null; then :; else sleep 1; fi 55if grep "hello world from operate" unbound.log >/dev/null; then :; else sleep 1; fi 56if grep "hello world from operate" unbound.log >/dev/null; then :; else sleep 1; fi 57if grep "hello world from operate" unbound.log >/dev/null; then :; else sleep 10; fi 58if grep "hello world from operate" unbound.log; then echo "yes it is in unbound.log"; 59else 60 echo "information not in unbound.log" 61 echo "failed" 62 echo "> cat logfiles" 63 cat fwd.log 64 cat unbound.log 65 echo "Not OK" 66 exit 1 67fi 68 69echo "> cat logfiles" 70cat fwd.log 71cat unbound.log 72echo "> OK" 73exit 0 74