3 ## Makefile -- Build and run tests for the server.
5 ## http://www.freeradius.org/
11 BUILD_PATH := $(top_builddir)/build
12 BIN_PATH := $(BUILD_PATH)/bin/local
13 LIB_PATH := $(BUILD_PATH)/lib/local/.libs/
14 DYLD_LIBRARY_PATH := $(DYLD_LIBRARY_PATH):$(LIB_PATH)
16 export DYLD_LIBRARY_PATH
18 RADDB_PATH := $(top_builddir)/raddb
20 TESTS = user_password chap mschapv1 digest-01/digest* test.example.com \
24 ACCTPORT = $(shell expr $(PORT) + 1)
26 # example.com stripped.example.com
28 EAPOL_TEST = eapol_test
30 EAP_TLS_TESTS = eap-ttls-pap.conf eap-mschapv2.conf \
31 eap-ttls-mschapv2.conf peap-mschapv2.conf
35 .PHONY: all eap dictionary clean
38 # Build the directory for testing the server
43 @rm -f $(RADDB_PATH)/test.conf test.conf dictionary
46 @echo "# test dictionary not install. Delete at any time." > dictionary
47 @echo '$$INCLUDE ' $(top_builddir)/share/dictionary >> dictionary
48 @echo '$$INCLUDE ' $(top_builddir)/src/tests/dictionary.test >> dictionary
51 @echo "# test configuration file. Do not install. Delete at any time." > test.conf
52 @echo "libdir =" $(LIB_PATH) >> test.conf
53 @echo "testdir =" $(top_builddir)/src/tests/ >> test.conf
54 @echo 'dictionary = $${testdir}' >> test.conf
55 @echo 'logdir = $${testdir}' >> test.conf
56 @echo 'radacctdir = $${testdir}' >> test.conf
57 @echo 'pidfile = $${testdir}/radiusd.pid' >> test.conf
58 @echo '$$INCLUDE radiusd.conf' >> test.conf
59 @echo '$$INCLUDE $${testdir}/config/' >> test.conf
61 radiusd.pid: $(RADDB_PATH)/test.conf test.conf raddb
62 @$(BIN_PATH)/radiusd -txxl `pwd`/radius.log -md $(RADDB_PATH)/ -n test -i 127.0.0.1 -p $(PORT)
64 # We can't make this depend on radiusd.pid, because then make will create
65 # radiusd.pid when we make radiusd.kill, which we don't want.
68 @if [ -f radiusd.pid ]; then \
69 (kill -TERM `cat radiusd.pid` >/dev/null 2>&1) || exit 0; \
73 # As test.conf includes radiusd.conf and as radiusd.conf includes everything in
74 # mods-enabled and sites-enable we need to ensure those directories have been
75 # created and are up to date.
78 @$(MAKE) -C $(RADDB_PATH) mods-enabled sites-enabled
80 # Link from the main database directory to here
81 $(RADDB_PATH)/test.conf: test.conf
82 @[ -f $(RADDB_PATH)/test.conf ] || ln -s ../src/tests/test.conf $(RADDB_PATH)/
84 # kill the server (if it's running)
86 # run the tests (ignoring any failures)
88 # remove the changes to raddb/
89 tests: $(RADDB_PATH)/test.conf radiusd.kill
90 @chmod a+x runtests.sh
93 @BIN_PATH="$(BIN_PATH)" ./runtests.sh $(TESTS)
95 @rm -f $(RADDB_PATH)/test.conf
97 tests.eap: $(RADDB_PATH)/test.conf radiusd.kill
98 @chmod a+x runtests.sh
102 @$(MAKE) radiusd.kill
103 @rm -f $(RADDB_PATH)/test.conf
105 eap: $(EAP_TLS_TESTS)
106 for x in $(EAP_TLS_TESTS); do \
107 $(EAPOL_TEST) -c $$x -p $(PORT) -s $(SECRET); \
111 $(EAPOL_TEST) -c eap-md5.conf -s $(SECRET)
114 $(EAPOL_TEST) -c eap-ttls-tls.conf -s $(SECRET)
117 $(EAPOL_TEST) -c eap-ttls-pap.conf -s $(SECRET)
120 $(EAPOL_TEST) -c peap-mschapv2.conf -s $(SECRET)
123 $(EAPOL_TEST) -c leap.conf -s $(SECRET)
125 ATTRS := rfc.txt errors.txt extended.txt lucent.txt wimax.txt
127 attrs: $(ATTRS) ../main/radattr
128 ../main/radattr -d ../../share rfc.txt
130 ${LIBRADIUS}: $(wildcard ../include/*.h) $(wildcard ../lib/*.c)
131 $(MAKE) -C ../lib all
133 ../main/radattr: ${LIBRADIUS} ../main/radattr.c
134 $(MAKE) -C ../main radattr