mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-29 05:21:37 +03:00
add support for environment variables in device tests
Previously device tests included information such as access point SSID/password at compile time. This made it difficult to compile test binaries once and then send them to multiple test runners for execution. This change adds a command to the test library to set environment variable on the target device: “setenv key value”. C library setenv/getenv facility is used to store variables. Test runner, tests, and makefile are updated to use this functionality.
This commit is contained in:
committed by
Ivan Grokhotkov
parent
2315ac20bc
commit
8bd26f2ded
@ -12,17 +12,10 @@ 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)
|
||||
BUILD_TOOL := $(ARDUINO_IDE_PATH)/arduino-builder
|
||||
TEST_CONFIG := libraries/test_config/test_config.h
|
||||
TEST_CONFIG := test_env.cfg
|
||||
TEST_REPORT_XML := test_report.xml
|
||||
TEST_REPORT_HTML := test_report.html
|
||||
|
||||
ifeq ("$(UPLOAD_PORT)","")
|
||||
$(error "Failed to detect upload port, please export UPLOAD_PORT manually")
|
||||
endif
|
||||
|
||||
ifeq ("$(ARDUINO_IDE_PATH)","")
|
||||
$(error "Please export ARDUINO_IDE_PATH")
|
||||
endif
|
||||
|
||||
ifneq ("$(V)","1")
|
||||
SILENT = @
|
||||
@ -35,16 +28,17 @@ endif
|
||||
|
||||
all: count tests test_report
|
||||
|
||||
count:
|
||||
@echo Running $(words $(TEST_LIST)) tests
|
||||
$(TEST_LIST): | virtualenv $(TEST_CONFIG) $(BUILD_DIR) $(HARDWARE_DIR)
|
||||
|
||||
tests: $(BUILD_DIR) $(HARDWARE_DIR) virtualenv $(TEST_CONFIG) $(TEST_LIST)
|
||||
tests: $(TEST_LIST)
|
||||
|
||||
$(TEST_LIST): LOCAL_BUILD_DIR=$(BUILD_DIR)/$(notdir $@)
|
||||
|
||||
$(TEST_LIST):
|
||||
@echo Running $(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 $@)
|
||||
$(SILENT)$(BUILD_TOOL) -compile -logger=human \
|
||||
-libraries "$(PWD)/libraries" \
|
||||
@ -59,6 +53,7 @@ ifneq ("$(NO_BUILD)","1")
|
||||
$@
|
||||
endif
|
||||
ifneq ("$(NO_UPLOAD)","1")
|
||||
@test -n "$(UPLOAD_PORT)" || (echo "Failed to detect upload port, please export UPLOAD_PORT manually" && exit 1)
|
||||
@echo Uploading binary
|
||||
$(SILENT)$(ESPTOOL) $(UPLOAD_VERBOSE_FLAG) \
|
||||
-cp $(UPLOAD_PORT) \
|
||||
@ -67,6 +62,7 @@ ifneq ("$(NO_UPLOAD)","1")
|
||||
-cf $(LOCAL_BUILD_DIR)/$(notdir $@).bin
|
||||
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) -cp $(UPLOAD_PORT) -cd $(UPLOAD_BOARD) -cr
|
||||
@source $(BS_DIR)/virtualenv/bin/activate && \
|
||||
@ -75,6 +71,7 @@ ifneq ("$(NO_RUN)","1")
|
||||
-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
|
||||
|
||||
@ -95,7 +92,7 @@ $(HARDWARE_DIR):
|
||||
cd $(HARDWARE_DIR)/esp8266com && ln -s $(realpath $(ESP8266_CORE_PATH)) esp8266
|
||||
|
||||
virtualenv:
|
||||
make -C $(BS_DIR) virtualenv
|
||||
@make -C $(BS_DIR) virtualenv
|
||||
|
||||
clean:
|
||||
rm -rf $(BUILD_DIR)
|
||||
@ -104,9 +101,9 @@ clean:
|
||||
|
||||
$(TEST_CONFIG):
|
||||
@echo "****** "
|
||||
@echo "****** libraries/test_config/test_config.h does not exist"
|
||||
@echo "****** Create one from libraries/test_config/test_config.h.template"
|
||||
@echo "****** $(TEST_CONFIG) does not exist"
|
||||
@echo "****** Create one from $(TEST_CONFIG).template"
|
||||
@echo "****** "
|
||||
false
|
||||
@false
|
||||
|
||||
.PHONY: tests all count virtualenv test_report $(BUILD_DIR) $(TEST_LIST)
|
||||
.PHONY: tests all count virtualenv test_report $(TEST_LIST)
|
||||
|
Reference in New Issue
Block a user