From 7c9f9c94c63558afdcf00679eec5da76475db9db Mon Sep 17 00:00:00 2001 From: David Gauchard Date: Thu, 29 Nov 2018 12:34:20 +0100 Subject: [PATCH 1/3] update HTTPCLIENT_1_1_COMPATIBLE: #if instead if #ifdef, set to 1 by default host emulation updates --- .../src/ESP8266HTTPClient.cpp | 20 +++++++++---------- .../ESP8266HTTPClient/src/ESP8266HTTPClient.h | 10 ++++++---- tests/host/Makefile | 17 +++++++++++----- tests/host/README.txt | 18 ++++++++--------- tests/host/common/mock.h | 12 +++++++++++ 5 files changed, 49 insertions(+), 28 deletions(-) diff --git a/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp b/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp index a3fbdd9b24..9e8f0a81a1 100644 --- a/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp +++ b/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.cpp @@ -25,7 +25,7 @@ #include "ESP8266HTTPClient.h" -#ifdef HTTPCLIENT_1_1_COMPATIBLE +#if HTTPCLIENT_1_1_COMPATIBLE #include #include #endif @@ -33,7 +33,7 @@ #include #include -#ifdef HTTPCLIENT_1_1_COMPATIBLE +#if HTTPCLIENT_1_1_COMPATIBLE class TransportTraits { public: @@ -112,7 +112,7 @@ class BearSSLTraits : public TransportTraits HTTPClient::HTTPClient() { _client = nullptr; -#ifdef HTTPCLIENT_1_1_COMPATIBLE +#if HTTPCLIENT_1_1_COMPATIBLE _tcpDeprecated.reset(nullptr); #endif } @@ -147,7 +147,7 @@ void HTTPClient::clear() * @return success bool */ bool HTTPClient::begin(WiFiClient &client, String url) { -#ifdef HTTPCLIENT_1_1_COMPATIBLE +#if HTTPCLIENT_1_1_COMPATIBLE if(_tcpDeprecated) { DEBUG_HTTPCLIENT("[HTTP-Client][begin] mix up of new and deprecated api\n"); _canReuse = false; @@ -186,7 +186,7 @@ bool HTTPClient::begin(WiFiClient &client, String url) { */ bool HTTPClient::begin(WiFiClient &client, String host, uint16_t port, String uri, bool https) { -#ifdef HTTPCLIENT_1_1_COMPATIBLE +#if HTTPCLIENT_1_1_COMPATIBLE if(_tcpDeprecated) { DEBUG_HTTPCLIENT("[HTTP-Client][begin] mix up of new and deprecated api\n"); _canReuse = false; @@ -205,7 +205,7 @@ bool HTTPClient::begin(WiFiClient &client, String host, uint16_t port, String ur } -#ifdef HTTPCLIENT_1_1_COMPATIBLE +#if HTTPCLIENT_1_1_COMPATIBLE bool HTTPClient::begin(String url, String httpsFingerprint) { if(_client && !_tcpDeprecated) { @@ -317,7 +317,7 @@ bool HTTPClient::beginInternal(String url, const char* expectedProtocol) return true; } -#ifdef HTTPCLIENT_1_1_COMPATIBLE +#if HTTPCLIENT_1_1_COMPATIBLE bool HTTPClient::begin(String host, uint16_t port, String uri) { if(_client && !_tcpDeprecated) { @@ -423,7 +423,7 @@ void HTTPClient::disconnect() _client->stop(); _client = nullptr; } -#ifdef HTTPCLIENT_1_1_COMPATIBLE +#if HTTPCLIENT_1_1_COMPATIBLE if(_tcpDeprecated) { _transportTraits.reset(nullptr); _tcpDeprecated.reset(nullptr); @@ -1035,7 +1035,7 @@ bool HTTPClient::connect(void) return true; } -#ifdef HTTPCLIENT_1_1_COMPATIBLE +#if HTTPCLIENT_1_1_COMPATIBLE if(!_client && _transportTraits) { _tcpDeprecated = _transportTraits->create(); _client = _tcpDeprecated.get(); @@ -1056,7 +1056,7 @@ bool HTTPClient::connect(void) DEBUG_HTTPCLIENT("[HTTP-Client] connected to %s:%u\n", _host.c_str(), _port); -#ifdef HTTPCLIENT_1_1_COMPATIBLE +#if HTTPCLIENT_1_1_COMPATIBLE if (_tcpDeprecated && !_transportTraits->verify(*_tcpDeprecated, _host.c_str())) { DEBUG_HTTPCLIENT("[HTTP-Client] transport level verify failed\n"); _client->stop(); diff --git a/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h b/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h index fb9cfa8736..78a3625ff1 100644 --- a/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h +++ b/libraries/ESP8266HTTPClient/src/ESP8266HTTPClient.h @@ -26,7 +26,9 @@ #ifndef ESP8266HTTPClient_H_ #define ESP8266HTTPClient_H_ -#define HTTPCLIENT_1_1_COMPATIBLE +#ifndef HTTPCLIENT_1_1_COMPATIBLE +#define HTTPCLIENT_1_1_COMPATIBLE 1 +#endif #include #include @@ -128,7 +130,7 @@ typedef enum { HTTPC_TE_CHUNKED } transferEncoding_t; -#ifdef HTTPCLIENT_1_1_COMPATIBLE +#if HTTPCLIENT_1_1_COMPATIBLE class TransportTraits; typedef std::unique_ptr TransportTraitsPtr; #endif @@ -148,7 +150,7 @@ class HTTPClient bool begin(WiFiClient &client, String url); bool begin(WiFiClient &client, String host, uint16_t port, String uri = "/", bool https = false); -#ifdef HTTPCLIENT_1_1_COMPATIBLE +#if HTTPCLIENT_1_1_COMPATIBLE // Plain HTTP connection, unencrypted bool begin(String url) __attribute__ ((deprecated)); bool begin(String host, uint16_t port, String uri = "/") __attribute__ ((deprecated)); @@ -222,7 +224,7 @@ class HTTPClient int writeToStreamDataBlock(Stream * stream, int len); -#ifdef HTTPCLIENT_1_1_COMPATIBLE +#if HTTPCLIENT_1_1_COMPATIBLE TransportTraitsPtr _transportTraits; std::unique_ptr _tcpDeprecated; #endif diff --git a/tests/host/Makefile b/tests/host/Makefile index bc520ce036..8d482266ab 100644 --- a/tests/host/Makefile +++ b/tests/host/Makefile @@ -120,8 +120,10 @@ DEBUG += -DDEBUG_ESP_PORT=Serial DEBUG += -DDEBUG_ESP_SSL -DDEBUG_ESP_TLS_MEM -DDEBUG_ESP_HTTP_CLIENT -DDEBUG_ESP_HTTP_SERVER -DDEBUG_ESP_CORE -DDEBUG_ESP_WIFI -DDEBUG_ESP_HTTP_UPDATE -DDEBUG_ESP_UPDATER -DDEBUG_ESP_OTA -DDEBUG_ESP_MDNS endif -FLAGS += $(DEBUG) -Wall -Werror -coverage $(OPTZ) -fno-common -g $(M32) +FLAGS += $(DEBUG) -Wall -coverage $(OPTZ) -fno-common -g $(M32) +FLAGS += -DHTTPCLIENT_1_1_COMPATIBLE=0 FLAGS += -DLWIP_IPV6=0 +FLAGS += $(MKFLAGS) CXXFLAGS += -std=c++11 $(FLAGS) CFLAGS += -std=c99 $(FLAGS) LDFLAGS += -coverage $(OPTZ) -g $(M32) @@ -145,7 +147,10 @@ COVERAGE_FILES = $(OBJECTS:.o=.gc*) all: help -CI: build-info $(OUTPUT_BINARY) valgrind test gcov # run CI +CI: + $(MAKE) -f $(MAKEFILE) MKFLAGS=-Werror FORCE32=0 OPTZ=-O0 doCI + +doCI: build-info $(OUTPUT_BINARY) valgrind test gcov # run CI test: $(OUTPUT_BINARY) # run host test for CI $(OUTPUT_BINARY) @@ -203,6 +208,7 @@ ARDUINO_LIBS := \ $(addprefix $(CORE_PATH)/,\ IPAddress.cpp \ Updater.cpp \ + base64.cpp \ ) \ $(addprefix ../../libraries/,\ $(addprefix ESP8266WiFi/src/,\ @@ -263,6 +269,7 @@ ULIBPATHS = $(shell echo $(ULIBDIRS) | sed 's,:, ,g') USERLIBDIRS = $(shell test -z "$(ULIBPATHS)" || for d in $(ULIBPATHS); do for dd in $$d $$d/src; do test -d $$dd && { echo -I$$dd; echo "userlib: using directory '$$dd'" 1>&2; } done; done) USERLIBSRCS = $(shell test -z "$(ULIBPATHS)" || for d in $(ULIBPATHS); do for ss in $$d/*.cpp $$d/src/*.cpp; do test -r $$ss && echo $$ss; done; done) INC_PATHS += $(USERLIBDIRS) +INC_PATHS += -I$(INODIR)/.. CPP_OBJECTS_CORE_EMU = $(CPP_SOURCES_CORE_EMU:.cpp=.cpp.o) $(USERLIBSRCS:.cpp=.cpp.o) bin/fullcore.a: $(C_OBJECTS) $(CPP_OBJECTS_CORE_EMU) @@ -279,18 +286,18 @@ ifeq ($(INO),) %: %.ino @# recursive 'make' with paths - $(MAKE) -f $(MAKEFILE) INODIR=$(dir $@) INO=$(notdir $@) $(BINDIR)/$(notdir $@)/$(notdir $@) + $(MAKE) -f $(MAKEFILE) MKFLAGS=-Wextra INODIR=$(dir $@) INO=$(notdir $@) $(BINDIR)/$(notdir $@)/$(notdir $@) @# see below the new build rule with fixed output path outside from core location ##################### -# recursive call on ino targer +# recursive call on ino target else $(BINDIR)/$(INO)/$(INO).ino.cpp: @# arduino builder would come around here (.ino -> .ino.cpp) @mkdir -p $(BINDIR)/$(INO); \ ( \ - echo "#include \"$(INODIR)/$(INO).ino\""; \ + echo "#include <$(INODIR)/$(INO).ino>"; \ for i in $(INODIR)/*.ino; do \ test "$$i" = $(INODIR)/$(INO).ino || echo "#include \"$$i\""; \ done; \ diff --git a/tests/host/README.txt b/tests/host/README.txt index 8bc0dac85c..37415b83bc 100644 --- a/tests/host/README.txt +++ b/tests/host/README.txt @@ -29,7 +29,7 @@ Show the core example list: Build one example - make D=1 ../../libraries/esp8266/examples/Blink/Blink + make -j D=1 ../../libraries/esp8266/examples/Blink/Blink run it: ./bin/Blink/Blink -h @@ -41,19 +41,19 @@ Optional 'FORCE32=0' will use native/default gcc (default is FORCE32=1 unless gc Non exhaustive list of working examples: - make D=1 ../../libraries/ESP8266WiFi/examples/udp/udp - make D=1 ../../libraries/ESP8266WiFi/examples/WiFiClient/WiFiClient - make D=1 ../../libraries/ESP8266WebServer/examples/HelloServer/HelloServer - make D=1 ../../libraries/ESP8266WebServer/examples/AdvancedWebServer/AdvancedWebServer - make D=1 ../../libraries/ESP8266mDNS/examples/mDNS_Web_Server/mDNS_Web_Server - make D=1 ../../libraries/ESP8266WiFi/examples/BearSSL_Validation/BearSSL_Validation + make -j D=1 ../../libraries/ESP8266WiFi/examples/udp/udp + make -j D=1 ../../libraries/ESP8266WiFi/examples/WiFiClient/WiFiClient + make -j D=1 ../../libraries/ESP8266WebServer/examples/HelloServer/HelloServer + make -j D=1 ../../libraries/ESP8266WebServer/examples/AdvancedWebServer/AdvancedWebServer + make -j D=1 ../../libraries/ESP8266mDNS/examples/mDNS_Web_Server/mDNS_Web_Server + make -j D=1 ../../libraries/ESP8266WiFi/examples/BearSSL_Validation/BearSSL_Validation Compile other sketches: - library paths are specified using ULIBDIRS variable, separated by ':' - call 'make path-to-the-sketch-file' to build (without its '.ino' extension): - CAVEAT: functions must be declared *before* being called (arduino builder is not around) - make D=1 ULIBDIRS=/path/to/your/arduino/libraries/lib1:/path/to/another/place/lib2 /path/to/your/sketchdir/sketch/sketch + make -j D=1 ULIBDIRS=/path/to/your/arduino/libraries/lib1:/path/to/another/place/lib2 /path/to/your/sketchdir/sketch/sketch or: ULIBDIRS=/path/to/your/arduino/libraries/lib1:/path/to/another/place/lib2 make D=1 /path/to/your/sketchdir/sketch/sketch @@ -62,7 +62,7 @@ Compile other sketches: export D=1 export OPTZ=-O2 make clean - make /path/to/your/sketchdir/sketch/sketch + make -j /path/to/your/sketchdir/sketch/sketch ./bin/sketch/sketch diff --git a/tests/host/common/mock.h b/tests/host/common/mock.h index 5ef1d89924..a0768e0837 100644 --- a/tests/host/common/mock.h +++ b/tests/host/common/mock.h @@ -118,4 +118,16 @@ class InterruptLock { }; // +#define D0 0 +#define D1 1 +#define D2 3 +#define D3 3 +#define D4 4 +#define D5 5 +#define D6 6 +#define D7 7 +#define D8 8 + +// + #endif // __cplusplus From f4f632c67628fcd4390c11e9d56b9634104a3a5f Mon Sep 17 00:00:00 2001 From: David Gauchard Date: Thu, 29 Nov 2018 12:36:03 +0100 Subject: [PATCH 2/3] host CI: minor simplification --- tests/common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/common.sh b/tests/common.sh index dbbb070e1a..8deb65d5a1 100755 --- a/tests/common.sh +++ b/tests/common.sh @@ -134,7 +134,7 @@ function build_docs() function run_host_tests() { pushd host - make FORCE32=0 OPTZ=-O0 CI + make CI make clean-objects popd } From d5a9f068034b30f46253f064a900b58966a1fb02 Mon Sep 17 00:00:00 2001 From: David Gauchard Date: Thu, 29 Nov 2018 18:42:52 +0100 Subject: [PATCH 3/3] revert -j --- tests/host/README.txt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/host/README.txt b/tests/host/README.txt index 37415b83bc..8bc0dac85c 100644 --- a/tests/host/README.txt +++ b/tests/host/README.txt @@ -29,7 +29,7 @@ Show the core example list: Build one example - make -j D=1 ../../libraries/esp8266/examples/Blink/Blink + make D=1 ../../libraries/esp8266/examples/Blink/Blink run it: ./bin/Blink/Blink -h @@ -41,19 +41,19 @@ Optional 'FORCE32=0' will use native/default gcc (default is FORCE32=1 unless gc Non exhaustive list of working examples: - make -j D=1 ../../libraries/ESP8266WiFi/examples/udp/udp - make -j D=1 ../../libraries/ESP8266WiFi/examples/WiFiClient/WiFiClient - make -j D=1 ../../libraries/ESP8266WebServer/examples/HelloServer/HelloServer - make -j D=1 ../../libraries/ESP8266WebServer/examples/AdvancedWebServer/AdvancedWebServer - make -j D=1 ../../libraries/ESP8266mDNS/examples/mDNS_Web_Server/mDNS_Web_Server - make -j D=1 ../../libraries/ESP8266WiFi/examples/BearSSL_Validation/BearSSL_Validation + make D=1 ../../libraries/ESP8266WiFi/examples/udp/udp + make D=1 ../../libraries/ESP8266WiFi/examples/WiFiClient/WiFiClient + make D=1 ../../libraries/ESP8266WebServer/examples/HelloServer/HelloServer + make D=1 ../../libraries/ESP8266WebServer/examples/AdvancedWebServer/AdvancedWebServer + make D=1 ../../libraries/ESP8266mDNS/examples/mDNS_Web_Server/mDNS_Web_Server + make D=1 ../../libraries/ESP8266WiFi/examples/BearSSL_Validation/BearSSL_Validation Compile other sketches: - library paths are specified using ULIBDIRS variable, separated by ':' - call 'make path-to-the-sketch-file' to build (without its '.ino' extension): - CAVEAT: functions must be declared *before* being called (arduino builder is not around) - make -j D=1 ULIBDIRS=/path/to/your/arduino/libraries/lib1:/path/to/another/place/lib2 /path/to/your/sketchdir/sketch/sketch + make D=1 ULIBDIRS=/path/to/your/arduino/libraries/lib1:/path/to/another/place/lib2 /path/to/your/sketchdir/sketch/sketch or: ULIBDIRS=/path/to/your/arduino/libraries/lib1:/path/to/another/place/lib2 make D=1 /path/to/your/sketchdir/sketch/sketch @@ -62,7 +62,7 @@ Compile other sketches: export D=1 export OPTZ=-O2 make clean - make -j /path/to/your/sketchdir/sketch/sketch + make /path/to/your/sketchdir/sketch/sketch ./bin/sketch/sketch