New build path variable
[freeradius.git] / src / tests / Makefile
1 # -*- text -*-
2 ##
3 ## Makefile -- Build and run tests for the server.
4 ##
5 ##      http://www.freeradius.org/
6 ##      $Id$
7 ##
8 #
9 include ../../Make.inc
10
11 TESTS   = user_password chap mschapv1 digest-01/digest* test.example.com \
12         wimax
13
14 PORT     = 12340
15 ACCTPORT = $(shell expr $(PORT) + 1)
16
17 #       example.com stripped.example.com
18
19 EAPOL_TEST = eapol_test
20
21 EAP_TLS_TESTS = eap-ttls-pap.conf eap-ttls-mschapv2.conf peap-mschapv2.conf
22
23 SECRET  = testing123
24
25 .PHONY: all eap dictionary clean
26
27 #
28 #       Build the directory for testing the server
29 #
30 all: tests
31
32 clean:
33         @rm -f ../../raddb/test.conf test.conf dictionary
34
35 dictionary:
36         @echo "# test dictionary not install.  Delete at any time." > dictionary
37         @echo '$$INCLUDE ' $(top_builddir)/share/dictionary >> dictionary
38         @echo '$$INCLUDE ' $(top_builddir)/src/tests/dictionary.test >> dictionary
39
40 test.conf: dictionary
41         @echo "# test configuration file.  Do not install.  Delete at any time." > test.conf
42         @echo "libdir =" $(top_builddir)/src/modules/lib >> test.conf
43         @echo "testdir =" $(top_builddir)/src/tests/ >> test.conf
44         @echo 'dictionary = $${testdir}' >> test.conf
45         @echo 'logdir = $${testdir}' >> test.conf
46         @echo 'radacctdir = $${testdir}' >> test.conf
47         @echo 'pidfile = $${testdir}/radiusd.pid' >> test.conf
48         @echo '$$INCLUDE radiusd.conf' >> test.conf
49         @echo '$$INCLUDE $${testdir}/config/' >> test.conf
50
51 radiusd.pid: ../../raddb/test.conf test.conf
52         @../main/radiusd -txxl `pwd`/radius.log -md ../../raddb/ -n test -i 127.0.0.1 -p $(PORT)
53
54 # We can't make this depend on radiusd.pid, because then make will create
55 # radiusd.pid when we make radiusd.kill, which we don't want.
56 .PHONY: radiusd.kill
57 radiusd.kill:
58         @if [ -f radiusd.pid ]; then \
59                 (kill -TERM `cat radiusd.pid` >/dev/null 2>&1) || exit 0; \
60         fi
61         @rm -f radiusd.pid
62
63 #  Link from the main database directory to here
64 ../../raddb/test.conf: test.conf
65         @[ -f ../../raddb/test.conf ] || ln -s ../src/tests/test.conf ../../raddb/
66
67 # kill the server (if it's running)
68 # start the server
69 # run the tests (ignoring any failures)
70 # kill the server
71 # remove the changes to raddb/
72 tests: ../../raddb/test.conf radiusd.kill
73         @chmod a+x runtests.sh
74         @rm -f radius.log
75         @$(MAKE) radiusd.pid
76         @./runtests.sh $(TESTS)
77         @$(MAKE) radiusd.kill
78         @rm -f ../../raddb/test.conf
79
80 eap: $(EAP_TLS_TESTS)
81         $(EAPOL_TEST) -c eap-ttls-pap.conf -s $(SECRET) 
82         $(EAPOL_TEST) -c peap-mschapv2.conf -s $(SECRET)
83         $(EAPOL_TEST) -c eap-ttls-mschapv2.conf -s $(SECRET)
84
85 md5:
86         $(EAPOL_TEST) -c eap-md5.conf -s $(SECRET) 
87
88 tls:
89         $(EAPOL_TEST) -c eap-ttls-tls.conf -s $(SECRET)
90
91 ttls:
92         $(EAPOL_TEST) -c eap-ttls-pap.conf -s $(SECRET)
93
94 peap:
95         $(EAPOL_TEST) -c peap-mschapv2.conf -s $(SECRET)
96
97 leap:
98         $(EAPOL_TEST) -c leap.conf -s $(SECRET)