Fix typo
[freeradius.git] / src / tests / Makefile
index f8ccd8d..d6c41ca 100644 (file)
@@ -8,16 +8,29 @@
 #
 include ../../Make.inc
 
-TESTS  = user_password chap mschapv1 digest-01/digest* test.example.com
+BUILD_PATH := $(top_builddir)/build
+TEST_PATH := $(top_builddir)/src/tests
+BIN_PATH := $(BUILD_PATH)/bin/local
+LIB_PATH := $(BUILD_PATH)/lib/.libs/
+DYLD_LIBRARY_PATH := $(DYLD_LIBRARY_PATH):$(LIB_PATH)
+
+export DYLD_LIBRARY_PATH
+
+RADDB_PATH := $(top_builddir)/raddb
+
+TESTS  = user_password chap mschapv1 digest-01/digest* test.example.com \
+       wimax
 
 PORT    = 12340
+#PORT   = 1812
 ACCTPORT = $(shell expr $(PORT) + 1)
 
 #      example.com stripped.example.com
 
 EAPOL_TEST = eapol_test
 
-EAP_TLS_TESTS = eap-ttls-pap.conf eap-ttls-mschapv2.conf peap-mschapv2.conf
+EAP_TLS_TESTS = eap-ttls-pap.conf eap-mschapv2.conf \
+             eap-ttls-mschapv2.conf peap-mschapv2.conf
 
 SECRET = testing123
 
@@ -29,7 +42,7 @@ SECRET        = testing123
 all: tests
 
 clean:
-       @rm -f ../../raddb/test.conf test.conf dictionary
+       @rm -f $(RADDB_PATH)/test.conf test.conf dictionary
 
 dictionary:
        @echo "# test dictionary not install.  Delete at any time." > dictionary
@@ -38,8 +51,8 @@ dictionary:
 
 test.conf: dictionary
        @echo "# test configuration file.  Do not install.  Delete at any time." > test.conf
-       @echo "libdir =" $(top_builddir)/src/modules/lib >> test.conf
-       @echo "testdir =" $(top_builddir)/src/tests/ >> test.conf
+       @echo "libdir =" $(LIB_PATH) >> test.conf
+       @echo "testdir =" $(TEST_PATH) >> test.conf
        @echo 'dictionary = $${testdir}' >> test.conf
        @echo 'logdir = $${testdir}' >> test.conf
        @echo 'radacctdir = $${testdir}' >> test.conf
@@ -47,8 +60,8 @@ test.conf: dictionary
        @echo '$$INCLUDE radiusd.conf' >> test.conf
        @echo '$$INCLUDE $${testdir}/config/' >> test.conf
 
-radiusd.pid: ../../raddb/test.conf test.conf
-       @../main/radiusd -txxl `pwd`/radius.log -md ../../raddb/ -n test -i 127.0.0.1 -p $(PORT)
+radiusd.pid: $(RADDB_PATH)/test.conf test.conf raddb
+       @$(BIN_PATH)/radiusd -txxl $(TEST_PATH)/radius.log -md $(RADDB_PATH) -n test -i 127.0.0.1 -p $(PORT) || tail -n 20 $(TEST_PATH)/radius.log
 
 # We can't make this depend on radiusd.pid, because then make will create
 # radiusd.pid when we make radiusd.kill, which we don't want.
@@ -59,27 +72,42 @@ radiusd.kill:
        fi
        @rm -f radiusd.pid
 
+# As test.conf includes radiusd.conf and as radiusd.conf includes everything in
+# mods-enabled and sites-enable we need to ensure those directories have been
+# created and are up to date.
+.PHONY: raddb
+raddb:
+       @$(MAKE) -C $(RADDB_PATH) mods-enabled sites-enabled
+
 #  Link from the main database directory to here
-../../raddb/test.conf: test.conf
-       @[ -f ../../raddb/test.conf ] || ln -s ../src/tests/test.conf ../../raddb/
+$(RADDB_PATH)/test.conf: test.conf
+       @[ -f $(RADDB_PATH)/test.conf ] || ln -s ../src/tests/test.conf $(RADDB_PATH)/
 
 # kill the server (if it's running)
 # start the server
 # run the tests (ignoring any failures)
 # kill the server
 # remove the changes to raddb/
-tests: ../../raddb/test.conf radiusd.kill
+tests: $(RADDB_PATH)/test.conf radiusd.kill
+       @chmod a+x runtests.sh
+       @rm -f radius.log
+       @$(MAKE) radiusd.pid
+       @BIN_PATH="$(BIN_PATH)" PORT="$(PORT)" ./runtests.sh $(TESTS)
+       @$(MAKE) radiusd.kill
+       @rm -f $(RADDB_PATH)/test.conf
+
+tests.eap: $(RADDB_PATH)/test.conf radiusd.kill
        @chmod a+x runtests.sh
        @rm -f radius.log
        @$(MAKE) radiusd.pid
-       @./runtests.sh $(TESTS)
+       @$(MAKE) eap
        @$(MAKE) radiusd.kill
-       @rm -f ../../raddb/test.conf
+       @rm -f $(RADDB_PATH)/test.conf
 
 eap: $(EAP_TLS_TESTS)
-       $(EAPOL_TEST) -c eap-ttls-pap.conf -s $(SECRET) 
-       $(EAPOL_TEST) -c peap-mschapv2.conf -s $(SECRET)
-       $(EAPOL_TEST) -c eap-ttls-mschapv2.conf -s $(SECRET)
+       for x in $(EAP_TLS_TESTS); do \
+               $(EAPOL_TEST) -c $$x -p $(PORT) -s $(SECRET); \
+       done
 
 md5:
        $(EAPOL_TEST) -c eap-md5.conf -s $(SECRET) 
@@ -95,3 +123,14 @@ peap:
 
 leap:
        $(EAPOL_TEST) -c leap.conf -s $(SECRET)
+
+ATTRS  := rfc.txt errors.txt extended.txt lucent.txt wimax.txt
+
+attrs: $(ATTRS) ../main/radattr
+       ../main/radattr -d ../../share rfc.txt
+
+${LIBRADIUS}: $(wildcard ../include/*.h) $(wildcard ../lib/*.c)
+       $(MAKE) -C ../lib all
+
+../main/radattr: ${LIBRADIUS} ../main/radattr.c
+       $(MAKE) -C ../main radattr