From: Arran Cudbard-Bell Date: Fri, 22 Apr 2022 20:49:05 +0000 (-0500) Subject: Horrible hacks to get EAPOL tests to run in parallel X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=372f34252e217dc6ee4ba25922da85d75936314d;p=thirdparty%2Ffreeradius-server.git Horrible hacks to get EAPOL tests to run in parallel --- diff --git a/src/tests/eapol_test/all.mk b/src/tests/eapol_test/all.mk index 7b169bb6488..8a59c2f208a 100644 --- a/src/tests/eapol_test/all.mk +++ b/src/tests/eapol_test/all.mk @@ -33,7 +33,6 @@ $(eval $(call TEST_BOOTSTRAP)) TEST_PATH := ${top_srcdir}/src/tests/eapol_test CONFIG_PATH := $(TEST_PATH)/config -RADIUS_LOG := $(OUTPUT)/radiusd.log GDB_LOG := $(OUTPUT)/gdb.log TEST_BIN := $(BUILD_DIR)/bin/local @@ -69,7 +68,19 @@ $(foreach x,$(patsubst $(DIR)/%.conf,%,$(EAPOL_TEST_FILES)),$(eval $(call ADD_TE # Generic rules to start / stop the radius service. # include src/tests/radiusd.mk -$(eval $(call RADIUSD_SERVICE,servers,$(OUTPUT))) + +define ADD_TEST_EAP_OUTPUT +$(OUTPUT)/${1}: + $(Q)mkdir -p $$@ +endef + +# +# Setup rules to spawn a different RADIUSD instance for each EAP type +# +$(foreach TEST,$(addprefix test., $(subst _,-,$(EAP_TYPES))),$(eval $(call RADIUSD_SERVICE,servers,$(OUTPUT)/$(TEST)))$(eval $(call ADD_TEST_EAP_OUTPUT,$(TEST)))) + +# Reset +TEST := test.eap # # Print the disabled list. @@ -88,29 +99,28 @@ test.eap.check: $(IGNORED_EAP_TYPES) | $(OUTPUT) $(GENERATED_CERT_FILES) # We don't depend on server build artifacts when we are executing from the post-install test environment # $(OUTPUT)/%.ok: $(DIR)/%.conf $(if $(POST_INSTALL_MAKEFILE_ARG),,$(BUILD_DIR)/lib/libfreeradius-server.la $(BUILD_DIR)/lib/libfreeradius-util.la) | $(GENERATED_CERT_FILES) - @echo "EAPOL-TEST $(notdir $(patsubst %.conf,%,$<))" - ${Q}$(MAKE) $(POST_INSTALL_MAKEFILE_ARG) --no-print-directory test.eap.radiusd_kill - ${Q}$(MAKE) $(POST_INSTALL_MAKEFILE_ARG) --no-print-directory METHOD=$(basename $(notdir $@)) test.eap.radiusd_start $(POST_INSTALL_RADIUSD_BIN_ARG) - ${Q} [ -f $(dir $@)/radiusd.pid ] || exit 1 - $(eval OUT := $(patsubst %.ok,%.log,$@)) + $(eval EAPOL_TEST_LOG := $(patsubst %.ok,%.log,$@)) + $(eval METHOD := $(notdir $(patsubst %.conf,%,$<))) $(eval KEY := $(shell grep key_mgmt=NONE $< | sed 's/key_mgmt=NONE/-n/')) - ${Q}if ! $(EAPOL_TEST) -t 10 -c $< -p $(PORT) -s $(SECRET) $(KEY) > $(OUT) 2>&1; then \ - echo "Last entries in supplicant log ($(patsubst %.conf,%.log,$@)):"; \ - tail -n 40 "$(patsubst %.conf,%.log,$@)"; \ + $(eval RADIUS_LOG := $(dir $@)/test.$(METHOD)/radiusd.log) + @echo "EAPOL-TEST $(METHOD)" + ${Q}$(MAKE) $(POST_INSTALL_MAKEFILE_ARG) --no-print-directory test.$(METHOD).radiusd_kill + ${Q}PORT=`PRINT_PORT=1 $(MAKE) $(POST_INSTALL_MAKEFILE_ARG) --no-print-directory test.$(METHOD).radiusd_start`; \ + if ! $(EAPOL_TEST) -t 10 -c $< -p $${PORT} -s $(SECRET) $(KEY) > $(EAPOL_TEST_LOG) 2>&1; then \ + echo "Last entries in supplicant log ($(EAPOL_TEST_LOG):"; \ + tail -n 40 "$(EAPOL_TEST_LOG)"; \ echo "--------------------------------------------------"; \ tail -n 40 "$(RADIUS_LOG)"; \ echo "Last entries in server log ($(RADIUS_LOG)):"; \ echo "--------------------------------------------------"; \ - echo "$(EAPOL_TEST) -c \"$<\" -p $(PORT) -s $(SECRET)"; \ - $(MAKE) $(POST_INSTALL_MAKEFILE_ARG) test.eap.radiusd_kill; \ - echo "RADIUSD : OUTPUT=$(dir $@) TESTDIR=$(dir $<) METHOD=$(notdir $(patsubst %.conf,%,$<)) TEST_PORT=$(PORT) $(RADIUSD_BIN) -fxxx -n servers -d $(dir $<)config -D $(DICT_PATH) -lstdout -f";\ - echo "EAPOL : $(EAPOL_TEST) -c \"$<\" -p $(PORT) -s $(SECRET) $(KEY) "; \ + echo "RADIUSD : OUTPUT=$(dir $@) TESTDIR=$(dir $<) TEST=$(METHOD) TEST_PORT=$(PORT) $(RADIUSD_BIN) -fxxx -n servers -d $(dir $<)config -D $(DICT_PATH) -lstdout -f";\";\ + echo "EAPOL : $(EAPOL_TEST) -c \"$<\" -p $${PORT} -s $(SECRET) $(KEY) "; \ echo " log is in $(OUT)"; \ rm -f $(BUILD_DIR)/tests/test.eap; \ - $(MAKE) $(POST_INSTALL_MAKEFILE_ARG) --no-print-directory test.eap.radiusd_kill; \ + $(MAKE) $(POST_INSTALL_MAKEFILE_ARG) --no-print-directory test.$(METHOD).radiusd_kill; \ exit 1;\ fi - ${Q}$(MAKE) $(POST_INSTALL_MAKEFILE_ARG) --no-print-directory test.eap.radiusd_stop + ${Q}$(MAKE) $(POST_INSTALL_MAKEFILE_ARG) --no-print-directory test.$(METHOD).radiusd_stop ${Q}touch $@ $(TEST): $(EAPOL_OK_FILES) diff --git a/src/tests/eapol_test/config/servers.conf b/src/tests/eapol_test/config/servers.conf index 584b36ad789..d8b807eb61a 100644 --- a/src/tests/eapol_test/config/servers.conf +++ b/src/tests/eapol_test/config/servers.conf @@ -58,7 +58,7 @@ modules { # Include the modules which are enabled for this particular # test. # - $-INCLUDE ${testdir}/config/$ENV{METHOD}/mods-enabled/ + $-INCLUDE ${testdir}/config/$ENV{TEST}/mods-enabled/ eap { # @@ -99,7 +99,7 @@ modules { # # This method MUST exist because we're running it. # - $INCLUDE ${testdir}/config/$ENV{METHOD}/methods-enabled/$ENV{METHOD} + $INCLUDE ${testdir}/config/$ENV{TEST}/methods-enabled/$ENV{TEST} } } @@ -165,6 +165,6 @@ server test { } # -# Some methods don't have a sites-enabld. Tho arguably they should. +# Some methods don't have a sites-enabled. Tho arguably they should. # -$-INCLUDE ${testdir}/config/$ENV{METHOD}/sites-enabled/$ENV{METHOD} +$-INCLUDE ${testdir}/config/$ENV{TEST}/sites-enabled/$ENV{TEST} diff --git a/src/tests/radiusd.mk b/src/tests/radiusd.mk index c12e5a75a20..bdc279feef3 100644 --- a/src/tests/radiusd.mk +++ b/src/tests/radiusd.mk @@ -9,7 +9,6 @@ # # - Defined by the target # -# PORT := Run the service # TEST := test.$target # # - Parameter @@ -17,6 +16,11 @@ # ${1} config-name found in $(DIR)/config, e.g: src/tests/$target/config/${config-name}.conf # ${2} output directory # +# - Available in calling rule +# +# PORT The port the server started on +# RADIUSD_RUN The server invocation +# # - How to use # # 1. $(eval $(call RADIUSD_SERVICE,myconfig,directory/path/)) @@ -39,6 +43,7 @@ include Make.inc define RADIUSD_SERVICE $$(eval RADIUSD_BIN := $(JLIBTOOL) --silent --mode=execute $$(TEST_BIN)/radiusd) +$$(eval PORT := $(shell echo $$(($(PORT)+1)))) # # Kill it. We don't care if it failed or not. However, we do care @@ -91,8 +96,12 @@ $(TEST).radiusd_stop: | ${2} # Start radiusd instance # ${2}/radiusd.pid: ${2} - $$(eval RADIUSD_RUN := TESTDIR=$(DIR) OUTPUT=$(OUTPUT) TEST_PORT=$(PORT) $$(RADIUSD_BIN) -Pxxx -d $(DIR)/config -n ${1} -D $(DICT_PATH) -l ${2}/radiusd.log) + $$(eval PORT=$(PORT)) + $$(eval RADIUSD_RUN := TESTDIR=$(DIR) OUTPUT=${2} TEST_PORT=$(PORT) TEST=$(subst test.,,$(TEST)) $$(RADIUSD_BIN) -Pxxx -d $(DIR)/config -n ${1} -D $(DICT_PATH) -l ${2}/radiusd.log) ${Q}rm -f ${2}/radiusd.log + ${Q}if test ! -z "$$(PRINT_PORT)"; then \ + echo "$(PORT)"; \ + fi ${Q}if ! $$(RADIUSD_RUN); then \ echo "FAILED STARTING RADIUSD"; \ grep 'Error :' "${2}/radiusd.log"; \