From: Jorge Pereira Date: Wed, 9 Oct 2019 00:56:29 +0000 (-0300) Subject: Migrate digest tests to boiler scheme X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f8a9bec6c08046463b343ef9ec75d57cf2d834fd;p=thirdparty%2Ffreeradius-server.git Migrate digest tests to boiler scheme --- diff --git a/Makefile b/Makefile index be3df5caeda..ff330b2b05c 100644 --- a/Makefile +++ b/Makefile @@ -102,8 +102,18 @@ $(BUILD_DIR)/tests/radiusd-c: raddb/test.conf ${BUILD_DIR}/bin/radiusd $(GENERAT @echo "ok" @touch $@ -test: ${BUILD_DIR}/bin/radiusd ${BUILD_DIR}/bin/radclient test.bin test.trie test.unit test.xlat test.map test.keywords test.auth test.modules test.radmin $(BUILD_DIR)/tests/radiusd-c test.eap | build.raddb - @$(MAKE) -C src/tests tests +test: ${BUILD_DIR}/bin/radiusd ${BUILD_DIR}/bin/radclient $(BUILD_DIR)/tests/radiusd-c \ + test.bin \ + test.digest \ + test.trie \ + test.unit \ + test.xlat \ + test.map \ + test.keywords \ + test.auth \ + test.modules \ + test.radmin \ + test.eap | build.raddb clean: clean.test .PHONY: clean.test diff --git a/src/tests/Makefile b/src/tests/Makefile deleted file mode 100644 index 6b58c96b156..00000000000 --- a/src/tests/Makefile +++ /dev/null @@ -1,100 +0,0 @@ -# -*- makefile -*- -## -## Makefile -- Build and run tests for the server. -## -## http://www.freeradius.org/ -## $Id$ -## -# -include ../../Make.inc - -BUILD_PATH := $(top_builddir)/build -TEST_PATH := $(top_srcdir)/src/tests -BIN_PATH := $(BUILD_PATH)/bin/local -LIB_PATH := $(BUILD_PATH)/lib/local/.libs/ -FR_LIBRARY_PATH := $(BUILD_PATH)/lib/local/.libs/ - -export FR_LIBRARY_PATH - -RADDB_PATH := $(top_srcdir)/raddb - -TESTS = mschapv1 digest-01/digest* test.example.com - -PORT := 12340 - -# example.com stripped.example.com -SECRET := testing123 - -.PHONY: all eap clean - -# -# Build the directory for testing the server -# -all: parse tests - -clean: - @rm -f test.conf *.ok *.log - -test.conf: dictionary - @echo "# test configuration file. Do not install. Delete at any time." > $@ - @echo "testdir =" $(TEST_PATH) >> $@ - @echo 'logdir = $${testdir}' >> $@ - @echo 'maindir = ${top_srcdir}/raddb/' >> $@ - @echo 'radacctdir = $${testdir}' >> $@ - @echo 'pidfile = $${testdir}/radiusd.pid' >> $@ - @echo 'panic_action = "gdb -batch -x ${testdir}/panic.gdb %e %p > ${testdir}/gdb.log 2>&1; cat ${testdir}/gdb.log"' >> $@ - @echo 'security {' >> $@ - @echo ' allow_vulnerable_openssl = yes' >> $@ - @echo '}' >> $@ - @echo >> $@ - @echo 'modconfdir = $${maindir}mods-config' >> $@ - @echo 'certdir = $${maindir}/certs' >> $@ - @echo 'cadir = $${maindir}/certs' >> $@ - @echo '$$INCLUDE $${testdir}/config/' >> $@ - -radiusd.pid: test.conf - @rm -f $(TEST_PATH)/gdb.log $(TEST_PATH)/radius.log - @printf "TEST-SERVER Starting server... " - @if ! TEST_PORT=$(PORT) $(BIN_PATH)/radiusd -Pxxl stdout -d ${top_srcdir}/src/tests -n test -D "${top_srcdir}/share/dictionary/" > ${top_srcdir}/src/tests/radius.log 2>&1 ; then\ - echo "failed"; \ - echo "Last log entries were:"; \ - tail -n 20 "$(TEST_PATH)/radius.log"; \ - echo "Last entries in server log $(TEST_PATH)/radius.log"; \ - fi - @echo "ok" - @echo "TEST_PORT=$(PORT) $(BIN_PATH)/radiusd -Pfxxxxl stdout -d ${top_builddir}/src/tests -n test -D \"${top_srcdir}/share/dictionary/\""; - @echo "Server logging to \"$(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. -.PHONY: radiusd.kill -radiusd.kill: - @if [ -f radiusd.pid ]; then \ - ret=0; \ - if ! ps `cat $(TEST_PATH)/radiusd.pid` >/dev/null 2>&1; then \ - echo "FreeRADIUS terminated during test"; \ - echo "GDB output was:"; \ - cat "$(TEST_PATH)/gdb.log"; \ - echo "Last log entries were:"; \ - tail -n 20 $(TEST_PATH)/radius.log; \ - echo "Last entries in server log $(TEST_PATH)/radius.log"; \ - ret=1; \ - elif ! kill -TERM `cat $(TEST_PATH)/radiusd.pid` >/dev/null 2>&1; then \ - echo "Failed terminating FreeRADIUS process"; \ - ret=1; \ - fi; \ - rm -f radiusd.pid \ - exit $$ret; \ - fi - - -# 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: test.conf | radiusd.kill radiusd.pid - @chmod a+x runtests.sh - @echo BIN_PATH="$(BIN_PATH)" PORT="$(PORT)" ./runtests.sh $(TESTS) - @BIN_PATH="$(BIN_PATH)" PORT="$(PORT)" TOP_BUILDDIR="${top_builddir}" ./runtests.sh $(TESTS) - @$(MAKE) radiusd.kill diff --git a/src/tests/digest/all.mk b/src/tests/digest/all.mk new file mode 100644 index 00000000000..ad7e4199f2c --- /dev/null +++ b/src/tests/digest/all.mk @@ -0,0 +1,49 @@ +# +# Unit tests for digest against the radiusd. +# + +# +# Test name +# +TEST := test.digest +FILES := $(subst $(DIR)/%,,$(wildcard $(DIR)/*.txt)) +$(eval $(call TEST_BOOTSTRAP)) + +# +# Config settings +# +RADCLIENT_BIN := $(TESTBINDIR)/radclient +DIGEST_BUILD_DIR := $(BUILD_DIR)/tests/digest +DIGEST_RADIUS_LOG := $(DIGEST_BUILD_DIR)/radiusd.log +DIGEST_GDB_LOG := $(DIGEST_BUILD_DIR)/gdb.log +DIGEST_TEST_FILES := $(wildcard $(DIR)/*.txt) + +# +# Generic rules to start / stop the radius service. +# +include src/tests/radiusd.mk +PORT := 12340 +$(eval $(call RADIUSD_SERVICE,digest,$(OUTPUT))) + +# +# Run the digest commands against the radiusd. +# +$(OUTPUT)/%: $(DIR)/% test.digest.radiusd_kill test.digest.radiusd_start + $(eval TARGET := $(patsubst %.txt,%,$(notdir $@))) + ${Q}awk '/^#.*TESTS/ { print $$3 }' $< | while read _num; do \ + echo "DIGEST-TEST $(TARGET)_$${_num}"; \ + cp -f $< $@.request; \ + echo "Test-Name = \"$(TARGET)\"" >> $@.request; \ + echo "Test-Number = \"$${_num}\"" >> $@.request; \ + if ! $(RADCLIENT_BIN) -f $@.request -xF -d src/tests/digest/config -D share/dictionary 127.0.0.1:$(PORT) auth $(SECRET) > $@.out; then \ + echo "Problems with $(RADCLIENT_BIN) -f $@_request -xF -d src/tests/digest/config -D share/dictionary 127.0.0.1:$(PORT) auth $(SECRET)"; \ + cat $@.out; \ + $(MAKE) test.digest.radiusd_kill; \ + exit 1; \ + else \ + touch $@; \ + fi; \ + done + +$(TEST): $(FILES) + ${Q}$(MAKE) test.digest.radiusd_kill