Skip to content

Commit 818a55f

Browse files
d-a-vearlephilhower
authored andcommitted
device tests: updates for esptool.py (#6084)
Makefile new rule: 'make distclean' removes virtualenv attempt to use python3 (python2 is still default)
1 parent 2df33de commit 818a55f

File tree

3 files changed

+42
-23
lines changed

3 files changed

+42
-23
lines changed

tests/device/Makefile

+32-20
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ TEST_LIST ?= $(wildcard test_*/*.ino)
44
ESP8266_CORE_PATH ?= ../..
55
BUILD_DIR ?= $(PWD)/.build
66
HARDWARE_DIR ?= $(PWD)/.hardware
7-
ESPTOOL ?= $(ESP8266_CORE_PATH)/tools/esptool/esptool
7+
#PYTHON ?= python3
8+
PYTHON ?= python
9+
ESPTOOL ?= $(PYTHON) $(ESP8266_CORE_PATH)/tools/esptool/esptool.py
810
MKSPIFFS ?= $(ESP8266_CORE_PATH)/tools/mkspiffs/mkspiffs
911
UPLOAD_PORT ?= $(shell ls /dev/tty* | grep -m 1 -i USB)
10-
UPLOAD_BAUD ?= 921600
12+
UPLOAD_BAUD ?= 460800
1113
UPLOAD_BOARD ?= nodemcu
1214
BS_DIR ?= libraries/BSTest
1315
DEBUG_LEVEL ?= DebugLevel=None____
@@ -24,7 +26,7 @@ ifneq ("$(V)","1")
2426
else
2527
BUILDER_DEBUG_FLAG = -verbose
2628
RUNNER_DEBUG_FLAG = -d
27-
UPLOAD_VERBOSE_FLAG = -v
29+
#UPLOAD_VERBOSE_FLAG = -v
2830
endif
2931

3032

@@ -57,28 +59,34 @@ endif
5759
ifneq ("$(NO_UPLOAD)","1")
5860
@test -n "$(UPLOAD_PORT)" || (echo "Failed to detect upload port, please export UPLOAD_PORT manually" && exit 1)
5961
@test -e $(dir $@)/make_spiffs.py && (echo "Generating and uploading SPIFFS" && \
60-
(cd $(dir $@) && python ./make_spiffs.py) && \
61-
$(MKSPIFFS) --create $(dir $@)data/ --size 0xFB000 \
62+
(cd $(dir $@) && $(PYTHON) ./make_spiffs.py) && \
63+
$(SILENT)$(MKSPIFFS) --create $(dir $@)data/ --size 0xFB000 \
6264
--block 8192 --page 256 $(LOCAL_BUILD_DIR)/spiffs.img && \
63-
$(ESPTOOL) $(UPLOAD_VERBOSE_FLAG) \
64-
-cp $(UPLOAD_PORT) \
65-
-cb $(UPLOAD_BAUD) \
66-
-cd $(UPLOAD_BOARD) \
67-
-ca 0x300000 \
68-
-cf $(LOCAL_BUILD_DIR)/spiffs.img ) || (echo "No SPIFFS to upload")
65+
$(SILENT)$(ESPTOOL) $(UPLOAD_VERBOSE_FLAG) \
66+
--chip esp8266 \
67+
--port $(UPLOAD_PORT) \
68+
--baud $(UPLOAD_BAUD) \
69+
--after no_reset \
70+
write_flash 0x300000 $(LOCAL_BUILD_DIR)/spiffs.img ) \
71+
|| (echo "No SPIFFS to upload")
6972
@echo Uploading binary
7073
$(SILENT)$(ESPTOOL) $(UPLOAD_VERBOSE_FLAG) \
71-
-cp $(UPLOAD_PORT) \
72-
-cb $(UPLOAD_BAUD) \
73-
-cd $(UPLOAD_BOARD) \
74-
-cf $(LOCAL_BUILD_DIR)/$(notdir $@).bin
74+
--chip esp8266 \
75+
--port $(UPLOAD_PORT) \
76+
--baud $(UPLOAD_BAUD) \
77+
--after no_reset \
78+
write_flash 0x0 $(LOCAL_BUILD_DIR)/$(notdir $@).bin # no reset
7579
endif
7680
ifneq ("$(NO_RUN)","1")
7781
@test -n "$(UPLOAD_PORT)" || (echo "Failed to detect upload port, please export UPLOAD_PORT manually" && exit 1)
7882
@echo Running tests
79-
$(SILENT)$(ESPTOOL) $(UPLOAD_VERBOSE_FLAG) -cp $(UPLOAD_PORT) -cd $(UPLOAD_BOARD) -cr
83+
$(SILENT)$(ESPTOOL) $(UPLOAD_VERBOSE_FLAG) \
84+
--chip esp8266 \
85+
--port $(UPLOAD_PORT) \
86+
--baud $(UPLOAD_BAUD) \
87+
read_flash_status # reset
8088
@source $(BS_DIR)/virtualenv/bin/activate && \
81-
python $(BS_DIR)/runner.py \
89+
$(PYTHON) $(BS_DIR)/runner.py \
8290
$(RUNNER_DEBUG_FLAG) \
8391
-p $(UPLOAD_PORT) \
8492
-n $(basename $(notdir $@)) \
@@ -88,10 +96,10 @@ ifneq ("$(NO_RUN)","1")
8896
endif
8997

9098
$(TEST_REPORT_XML): $(HARDWARE_DIR) virtualenv
91-
@$(BS_DIR)/virtualenv/bin/xunitmerge $(shell find $(BUILD_DIR) -name 'test_result.xml' | xargs echo) $(TEST_REPORT_XML)
99+
$(SILENT)$(BS_DIR)/virtualenv/bin/xunitmerge $(shell find $(BUILD_DIR) -name 'test_result.xml' | xargs echo) $(TEST_REPORT_XML)
92100

93101
$(TEST_REPORT_HTML): $(TEST_REPORT_XML) | virtualenv
94-
@$(BS_DIR)/virtualenv/bin/junit2html $< $@
102+
$(SILENT)$(BS_DIR)/virtualenv/bin/junit2html $< $@
95103

96104
test_report: $(TEST_REPORT_HTML)
97105
@echo "Test report generated in $(TEST_REPORT_HTML)"
@@ -104,13 +112,17 @@ $(HARDWARE_DIR):
104112
cd $(HARDWARE_DIR)/esp8266com && ln -s $(realpath $(ESP8266_CORE_PATH)) esp8266
105113

106114
virtualenv:
107-
@make -C $(BS_DIR) virtualenv
115+
@make -C $(BS_DIR) PYTHON=$(PYTHON) virtualenv
108116

109117
clean:
110118
rm -rf $(BUILD_DIR)
111119
rm -rf $(HARDWARE_DIR)
112120
rm -f $(TEST_REPORT_HTML) $(TEST_REPORT_XML)
113121

122+
distclean: clean
123+
rm -rf libraries/BSTest/virtualenv/
124+
find . -name "*pyc" -exec rm -f {} \;
125+
114126
$(TEST_CONFIG):
115127
@echo "****** "
116128
@echo "****** $(TEST_CONFIG) does not exist"

tests/device/libraries/BSTest/Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
PYTHON_ENV_DIR=virtualenv
22
TEST_EXECUTABLE=test/test
3+
PYTHON ?= python3
34

45
all: test
56

@@ -10,7 +11,7 @@ clean:
1011
rm -rf $(TEST_EXECUTABLE)
1112

1213
$(PYTHON_ENV_DIR):
13-
virtualenv --no-site-packages $(PYTHON_ENV_DIR)
14+
virtualenv --python=$(PYTHON) --no-site-packages $(PYTHON_ENV_DIR)
1415
. $(PYTHON_ENV_DIR)/bin/activate && pip install -r requirements.txt
1516

1617
test: $(TEST_EXECUTABLE) $(PYTHON_ENV_DIR)

tests/device/libraries/BSTest/runner.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,18 @@
1414
except:
1515
from ConfigParser import ConfigParser
1616
import itertools
17-
from urlparse import urlparse
17+
try:
18+
from urllib.parse import urlparse, urlencode
19+
except ImportError:
20+
from urlparse import urlparse
1821
from junit_xml import TestSuite, TestCase
1922
try:
2023
from cStringIO import StringIO
2124
except:
22-
from StringIO import StringIO
25+
try:
26+
from StringIO import StringIO
27+
except ImportError:
28+
from io import StringIO
2329
import mock_decorators
2430

2531
debug = False

0 commit comments

Comments
 (0)