1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-13 13:01:55 +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

@ -148,10 +148,10 @@ COVERAGE_FILES = $(OBJECTS:.o=.gc*)
all: help
CI:
CI: # run CI
$(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
$(OUTPUT_BINARY)
@ -232,7 +232,11 @@ ARDUINO_LIBS := \
Parsing.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 \
DNSServer/src/DNSServer.cpp \
ESP8266AVRISP/src/ESP8266AVRISP.cpp \

View File

@ -218,6 +218,7 @@ extern "C" {
void loop(void);
void yield(void);
void esp_yield(void);
void optimistic_yield(uint32_t interval_us);
#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)
{
ret = ::write(sock, data, size);
//ret = ::write(sock, data, size);
ret = ::send(sock, data, size, MSG_NOSIGNAL);
if (ret == -1)
{
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);
}
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 <poll.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#define int2pcb(x) ((tcp_pcb*)(intptr_t)(x))
#define pcb2int(x) ((int)(intptr_t)(x))
@ -50,7 +52,13 @@ int serverAccept (int srvsock)
n = sizeof(client);
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);
}
return clisock;

View File

@ -79,14 +79,24 @@ public:
_sock = -1;
}
#if 0
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:
_dst.addr = staticMCastAddr;
}
void setMulticastTTL(int ttl)
{
(void)ttl;
//fprintf(stderr, MOCK "TODO: UdpContext::setMulticastTTL\n");
}

View File

@ -36,6 +36,18 @@
#include <vector>
#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
#include <stdint.h>