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