1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

tests/host: fixes and updates (#5537)

(LEAmDNS, broken pipe, non blocking accepted sockets, digitalRead)
This commit is contained in:
david gauchard 2018-12-22 07:03:11 +01:00 committed by Develo
parent 2388102a97
commit 228ad7ed75
8 changed files with 51 additions and 9 deletions

View File

@ -1005,7 +1005,7 @@ bool MDNSResponder::_udpRead16(uint16_t& p_ru16Value) {
bool bResult = false; bool bResult = false;
if (_udpReadBuffer((unsigned char*)&p_ru16Value, sizeof(p_ru16Value))) { if (_udpReadBuffer((unsigned char*)&p_ru16Value, sizeof(p_ru16Value))) {
p_ru16Value = ntohs(p_ru16Value); p_ru16Value = lwip_ntohs(p_ru16Value);
bResult = true; bResult = true;
} }
return bResult; return bResult;
@ -1019,7 +1019,7 @@ bool MDNSResponder::_udpRead32(uint32_t& p_ru32Value) {
bool bResult = false; bool bResult = false;
if (_udpReadBuffer((unsigned char*)&p_ru32Value, sizeof(p_ru32Value))) { if (_udpReadBuffer((unsigned char*)&p_ru32Value, sizeof(p_ru32Value))) {
p_ru32Value = ntohl(p_ru32Value); p_ru32Value = lwip_ntohl(p_ru32Value);
bResult = true; bResult = true;
} }
return bResult; return bResult;
@ -1052,7 +1052,7 @@ bool MDNSResponder::_udpAppend8(uint8_t p_u8Value) {
*/ */
bool MDNSResponder::_udpAppend16(uint16_t p_u16Value) { bool MDNSResponder::_udpAppend16(uint16_t p_u16Value) {
p_u16Value = htons(p_u16Value); p_u16Value = lwip_htons(p_u16Value);
return (_udpAppendBuffer((unsigned char*)&p_u16Value, sizeof(p_u16Value))); return (_udpAppendBuffer((unsigned char*)&p_u16Value, sizeof(p_u16Value)));
} }
@ -1061,7 +1061,7 @@ bool MDNSResponder::_udpAppend16(uint16_t p_u16Value) {
*/ */
bool MDNSResponder::_udpAppend32(uint32_t p_u32Value) { bool MDNSResponder::_udpAppend32(uint32_t p_u32Value) {
p_u32Value = htonl(p_u32Value); p_u32Value = lwip_htonl(p_u32Value);
return (_udpAppendBuffer((unsigned char*)&p_u32Value, sizeof(p_u32Value))); return (_udpAppendBuffer((unsigned char*)&p_u32Value, sizeof(p_u32Value)));
} }

View File

@ -148,10 +148,10 @@ COVERAGE_FILES = $(OBJECTS:.o=.gc*)
all: help all: help
CI: CI: # run CI
$(MAKE) -f $(MAKEFILE) MKFLAGS=-Werror FORCE32=0 OPTZ=-O0 doCI $(MAKE) -f $(MAKEFILE) MKFLAGS=-Werror FORCE32=0 OPTZ=-O0 doCI
doCI: build-info $(OUTPUT_BINARY) valgrind test gcov # run CI doCI: build-info $(OUTPUT_BINARY) valgrind test gcov
test: $(OUTPUT_BINARY) # run host test for CI test: $(OUTPUT_BINARY) # run host test for CI
$(OUTPUT_BINARY) $(OUTPUT_BINARY)
@ -232,7 +232,11 @@ ARDUINO_LIBS := \
Parsing.cpp \ Parsing.cpp \
detail/mimetable.cpp \ detail/mimetable.cpp \
) \ ) \
ESP8266mDNS/ESP8266mDNS.cpp \ ESP8266mDNS/src/LEAmDNS.cpp \
ESP8266mDNS/src/LEAmDNS_Control.cpp \
ESP8266mDNS/src/LEAmDNS_Helpers.cpp \
ESP8266mDNS/src/LEAmDNS_Structs.cpp \
ESP8266mDNS/src/LEAmDNS_Transfer.cpp \
ArduinoOTA/ArduinoOTA.cpp \ ArduinoOTA/ArduinoOTA.cpp \
DNSServer/src/DNSServer.cpp \ DNSServer/src/DNSServer.cpp \
ESP8266AVRISP/src/ESP8266AVRISP.cpp \ ESP8266AVRISP/src/ESP8266AVRISP.cpp \

View File

@ -218,6 +218,7 @@ extern "C" {
void loop(void); void loop(void);
void yield(void); void yield(void);
void esp_yield(void);
void optimistic_yield(uint32_t interval_us); void optimistic_yield(uint32_t interval_us);
#define digitalPinToPort(pin) (0) #define digitalPinToPort(pin) (0)

View File

@ -135,7 +135,8 @@ size_t mockWrite (int sock, const uint8_t* data, size_t size, int timeout_ms)
} }
if (ret) if (ret)
{ {
ret = ::write(sock, data, size); //ret = ::write(sock, data, size);
ret = ::send(sock, data, size, MSG_NOSIGNAL);
if (ret == -1) if (ret == -1)
{ {
fprintf(stderr, MOCK "ClientContext::read: write(%d): %s\n", sock, strerror(errno)); fprintf(stderr, MOCK "ClientContext::read: write(%d): %s\n", sock, strerror(errno));

View File

@ -69,3 +69,9 @@ void analogWriteRange(uint32_t range)
{ {
fprintf(stderr, MOCK "analogWriteRange(range=%d)\n", range); fprintf(stderr, MOCK "analogWriteRange(range=%d)\n", range);
} }
int digitalRead(uint8_t pin)
{
fprintf(stderr, MOCK "digitalRead(%d)\n", pin);
return 0;
}

View File

@ -36,6 +36,8 @@
#include <sys/socket.h> #include <sys/socket.h>
#include <poll.h> #include <poll.h>
#include <unistd.h> #include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#define int2pcb(x) ((tcp_pcb*)(intptr_t)(x)) #define int2pcb(x) ((tcp_pcb*)(intptr_t)(x))
#define pcb2int(x) ((int)(intptr_t)(x)) #define pcb2int(x) ((int)(intptr_t)(x))
@ -50,7 +52,13 @@ int serverAccept (int srvsock)
n = sizeof(client); n = sizeof(client);
if ((clisock = accept(srvsock, (struct sockaddr*)&client, &n)) == -1) if ((clisock = accept(srvsock, (struct sockaddr*)&client, &n)) == -1)
{ {
perror("accept()"); perror(MOCK "accept()");
exit(EXIT_FAILURE);
}
if (fcntl(clisock, F_SETFL, O_NONBLOCK) == -1)
{
fprintf(stderr, MOCK "ClientContext::accept: fcntl(O_NONBLOCK): %s\n", strerror(errno));
close(clisock);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
return clisock; return clisock;

View File

@ -79,14 +79,24 @@ public:
_sock = -1; _sock = -1;
} }
#if 0
void setMulticastInterface(const ip_addr_t& addr) void setMulticastInterface(const ip_addr_t& addr)
{ {
(void)addr;
// user multicast, and this is how it works with posix: send to multicast address:
_dst.addr = staticMCastAddr;
}
#endif
void setMulticastInterface(const ip_addr_t* addr)
{
(void)addr;
// user multicast, and this is how it works with posix: send to multicast address: // user multicast, and this is how it works with posix: send to multicast address:
_dst.addr = staticMCastAddr; _dst.addr = staticMCastAddr;
} }
void setMulticastTTL(int ttl) void setMulticastTTL(int ttl)
{ {
(void)ttl;
//fprintf(stderr, MOCK "TODO: UdpContext::setMulticastTTL\n"); //fprintf(stderr, MOCK "TODO: UdpContext::setMulticastTTL\n");
} }

View File

@ -36,6 +36,18 @@
#include <vector> #include <vector>
#endif #endif
#ifdef __cplusplus
extern "C" {
#endif
//#include <stdlib_noniso.h>
char* itoa (int val, char *s, int radix);
char* ltoa (long val, char *s, int radix);
#ifdef __cplusplus
}
#endif
// exotic typedefs used in the sdk // exotic typedefs used in the sdk
#include <stdint.h> #include <stdint.h>