mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-24 19:42:27 +03:00
* Fix device test environment variables Device tests were not connecting properly to WiFi because the environment variables were not set when WiFi.connect was called. This would result in tests sometimes working *if* the prior sketch run on the ESP saved WiFi connection information and auto-connect was enabled. But, in most cases, the tests would simply never connect to any WiFi and fail. getenv() works only after BS_RUN is called (because BS_RUN handles the actual parsing of environment variables sent from the host). Add a "pretest" function to all tests which is called by the host test controller only after all environment variables are set. Move all WiFi/etc. operations that were in each separate test's setup() into it. So the order of operations for tests now is: ESP: setup() -> Set serial baud -> Call BS_RUN() HOST: Send environment Send "do pretest" ESP: pretest() -> Set Wifi using env. ariables, etc. return "true" on success HOST: Send "run test 1" ESP: Run 1st test, return result HOST: Send "run test 2" ESP: Run 2nd test, return result <and so forth> If nothing is needed to be set up, just return true from the pretest function. All tests now run and at least connect to WiFi. There still seem to be some actual test errors, but not because of the WiFi/environment variables anymore. * Remove unneeded debug prints * Silence esptool.py output when not in V=1 mode Esptool-ck.exe had an option to be silent, but esptool.py doesn't so the output is very chatty and makes looking a the run logs hard (60 lines of esptool.py output, 3 lines of actual test reports). Redirect esptool.py STDOUT to /dev/null unless V=1 to clear this up. * Speed up builds massively by removing old JSON arduino-builder checks the build.options.json file and then goes off and pegs my CPU at 100% for over a minute on each test compile checking if files have been modified. Simply deleting any pre-existing options.json file causes this step to be skipped and a quick, clean recompile is done in siginificantly less time. * Enable compile warnings, fix any that show up Enable all GCC warnings when building the tests and fix any that came up (mostly signed/unsigned, unused, and deprecated ones). * Fix UMM_MALLOC printf crash, umm_test Printf can now handle PROGMEM addresses, so simplify and correct the debug printouts in umm_info and elsewhere.
143 lines
4.6 KiB
Makefile
143 lines
4.6 KiB
Makefile
SHELL := /bin/bash
|
|
V ?= 0
|
|
TEST_LIST ?= $(wildcard test_*/*.ino)
|
|
ESP8266_CORE_PATH ?= $(realpath ../..)
|
|
BUILD_DIR ?= $(PWD)/.build
|
|
HARDWARE_DIR ?= $(PWD)/.hardware
|
|
#PYTHON ?= python3
|
|
PYTHON ?= python
|
|
ESPTOOL ?= $(PYTHON) $(ESP8266_CORE_PATH)/tools/esptool/esptool.py
|
|
MKSPIFFS ?= $(ESP8266_CORE_PATH)/tools/mkspiffs/mkspiffs
|
|
UPLOAD_PORT ?= $(shell ls /dev/tty* | grep -m 1 -i USB)
|
|
UPLOAD_BAUD ?= 460800
|
|
UPLOAD_BOARD ?= nodemcu
|
|
BS_DIR ?= libraries/BSTest
|
|
DEBUG_LEVEL ?= DebugLevel=None____
|
|
#FQBN ?= esp8266com:esp8266:generic:CpuFrequency=80,FlashFreq=40,FlashMode=dio,UploadSpeed=115200,FlashSize=4M1M,LwIPVariant=v2mss536,ResetMethod=none,Debug=Serial,$(DEBUG_LEVEL)
|
|
FQBN ?= esp8266com:esp8266:generic:xtal=80,FlashFreq=40,FlashMode=dio,baud=115200,eesz=4M1M,ip=lm2f,ResetMethod=none,dbg=Serial,$(DEBUG_LEVEL)
|
|
BUILD_TOOL := $(ARDUINO_IDE_PATH)/arduino-builder
|
|
TEST_CONFIG := test_env.cfg
|
|
TEST_REPORT_XML := test_report.xml
|
|
TEST_REPORT_HTML := test_report.html
|
|
|
|
|
|
ifneq ("$(V)","1")
|
|
SILENT = @
|
|
REDIR = >& /dev/null
|
|
else
|
|
BUILDER_DEBUG_FLAG = -verbose
|
|
RUNNER_DEBUG_FLAG = -d
|
|
#UPLOAD_VERBOSE_FLAG = -v
|
|
endif
|
|
|
|
|
|
all: count tests test_report
|
|
|
|
$(TEST_LIST): | virtualenv $(TEST_CONFIG) $(BUILD_DIR) $(HARDWARE_DIR)
|
|
|
|
tests: showtestlist $(TEST_LIST)
|
|
|
|
showtestlist:
|
|
@echo "-------------------------------- test list:"
|
|
@echo $(TEST_LIST)
|
|
@echo "--------------------------------"
|
|
|
|
$(TEST_LIST): LOCAL_BUILD_DIR=$(BUILD_DIR)/$(notdir $@)
|
|
|
|
$(TEST_LIST):
|
|
@echo "--------------------------------"
|
|
@echo "Running test '$@' of $(words $(TEST_LIST)) tests"
|
|
$(SILENT)mkdir -p $(LOCAL_BUILD_DIR)
|
|
ifneq ("$(NO_BUILD)","1")
|
|
@test -n "$(ARDUINO_IDE_PATH)" || (echo "Please export ARDUINO_IDE_PATH" && exit 1)
|
|
@echo Compiling $(notdir $@)
|
|
@rm -f $(LOCAL_BUILD_DIR)/build.options.json
|
|
$(SILENT)$(BUILD_TOOL) -compile -logger=human \
|
|
-libraries "$(PWD)/libraries" \
|
|
-core-api-version="10608" \
|
|
-warnings=all \
|
|
$(BUILDER_DEBUG_FLAG) \
|
|
-build-path $(LOCAL_BUILD_DIR) \
|
|
-tools $(ARDUINO_IDE_PATH)/tools-builder \
|
|
-hardware $(HARDWARE_DIR)\
|
|
-hardware $(ARDUINO_IDE_PATH)/hardware \
|
|
-fqbn=$(FQBN) \
|
|
$@
|
|
endif
|
|
ifneq ("$(NO_UPLOAD)","1")
|
|
@test -n "$(UPLOAD_PORT)" || (echo "Failed to detect upload port, please export UPLOAD_PORT manually" && exit 1)
|
|
@test -e $(dir $@)/make_spiffs.py && ( \
|
|
echo "Generating and uploading SPIFFS" && \
|
|
(cd $(dir $@) && $(PYTHON) ./make_spiffs.py $(REDIR) ) && \
|
|
$(MKSPIFFS) --create $(dir $@)data/ --size 0xFB000 \
|
|
--block 8192 --page 256 $(LOCAL_BUILD_DIR)/spiffs.img $(REDIR) && \
|
|
$(ESPTOOL) $(UPLOAD_VERBOSE_FLAG) \
|
|
--chip esp8266 \
|
|
--port $(UPLOAD_PORT) \
|
|
--baud $(UPLOAD_BAUD) \
|
|
--after no_reset \
|
|
write_flash 0x300000 $(LOCAL_BUILD_DIR)/spiffs.img $(REDIR) ) \
|
|
|| (echo "No SPIFFS to upload")
|
|
@echo Uploading binary
|
|
$(SILENT)$(ESPTOOL) $(UPLOAD_VERBOSE_FLAG) \
|
|
--chip esp8266 \
|
|
--port $(UPLOAD_PORT) \
|
|
--baud $(UPLOAD_BAUD) \
|
|
--after no_reset \
|
|
write_flash 0x0 $(LOCAL_BUILD_DIR)/$(notdir $@).bin $(REDIR) # no reset
|
|
endif
|
|
ifneq ("$(NO_RUN)","1")
|
|
@test -n "$(UPLOAD_PORT)" || (echo "Failed to detect upload port, please export UPLOAD_PORT manually" && exit 1)
|
|
@echo Running tests
|
|
$(SILENT)$(ESPTOOL) $(UPLOAD_VERBOSE_FLAG) \
|
|
--chip esp8266 \
|
|
--port $(UPLOAD_PORT) \
|
|
--baud $(UPLOAD_BAUD) \
|
|
read_flash_status $(REDIR) # reset
|
|
$(SILENT)source $(BS_DIR)/virtualenv/bin/activate && \
|
|
$(PYTHON) $(BS_DIR)/runner.py \
|
|
$(RUNNER_DEBUG_FLAG) \
|
|
-p $(UPLOAD_PORT) \
|
|
-n $(basename $(notdir $@)) \
|
|
-o $(LOCAL_BUILD_DIR)/test_result.xml \
|
|
--env-file $(TEST_CONFIG) \
|
|
`test -f $(addsuffix .py, $(basename $@)) && echo "-m $(addsuffix .py, $(basename $@))" || echo ""`
|
|
endif
|
|
|
|
$(TEST_REPORT_XML): $(HARDWARE_DIR) virtualenv
|
|
$(SILENT)$(BS_DIR)/virtualenv/bin/xunitmerge $(shell find $(BUILD_DIR) -name 'test_result.xml' | xargs echo) $(TEST_REPORT_XML)
|
|
|
|
$(TEST_REPORT_HTML): $(TEST_REPORT_XML) | virtualenv
|
|
$(SILENT)$(BS_DIR)/virtualenv/bin/junit2html $< $@
|
|
|
|
test_report: $(TEST_REPORT_HTML)
|
|
@echo "Test report generated in $(TEST_REPORT_HTML)"
|
|
|
|
$(BUILD_DIR):
|
|
mkdir -p $(BUILD_DIR)
|
|
|
|
$(HARDWARE_DIR):
|
|
mkdir -p $(HARDWARE_DIR)/esp8266com
|
|
cd $(HARDWARE_DIR)/esp8266com && ln -s $(realpath $(ESP8266_CORE_PATH)) esp8266
|
|
|
|
virtualenv:
|
|
@make -C $(BS_DIR) PYTHON=$(PYTHON) virtualenv
|
|
|
|
clean:
|
|
rm -rf $(BUILD_DIR)
|
|
rm -rf $(HARDWARE_DIR)
|
|
rm -f $(TEST_REPORT_HTML) $(TEST_REPORT_XML)
|
|
|
|
distclean: clean
|
|
rm -rf libraries/BSTest/virtualenv/
|
|
find . -name "*pyc" -exec rm -f {} \;
|
|
|
|
$(TEST_CONFIG):
|
|
@echo "****** "
|
|
@echo "****** $(TEST_CONFIG) does not exist"
|
|
@echo "****** Create one from $(TEST_CONFIG).template"
|
|
@echo "****** "
|
|
@false
|
|
|
|
.PHONY: tests all count virtualenv test_report $(TEST_LIST)
|