Skip to content

tests/host: fixes and updates #5537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions libraries/ESP8266mDNS/src/LEAmDNS_Transfer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1005,7 +1005,7 @@ bool MDNSResponder::_udpRead16(uint16_t& p_ru16Value) {
bool bResult = false;

if (_udpReadBuffer((unsigned char*)&p_ru16Value, sizeof(p_ru16Value))) {
p_ru16Value = ntohs(p_ru16Value);
p_ru16Value = lwip_ntohs(p_ru16Value);
bResult = true;
}
return bResult;
Expand All @@ -1019,7 +1019,7 @@ bool MDNSResponder::_udpRead32(uint32_t& p_ru32Value) {
bool bResult = false;

if (_udpReadBuffer((unsigned char*)&p_ru32Value, sizeof(p_ru32Value))) {
p_ru32Value = ntohl(p_ru32Value);
p_ru32Value = lwip_ntohl(p_ru32Value);
bResult = true;
}
return bResult;
Expand Down Expand Up @@ -1052,7 +1052,7 @@ bool MDNSResponder::_udpAppend8(uint8_t p_u8Value) {
*/
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)));
}

Expand All @@ -1061,7 +1061,7 @@ bool MDNSResponder::_udpAppend16(uint16_t p_u16Value) {
*/
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)));
}

Expand Down
10 changes: 7 additions & 3 deletions tests/host/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 \
Expand Down
1 change: 1 addition & 0 deletions tests/host/common/Arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion tests/host/common/ClientContextSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
6 changes: 6 additions & 0 deletions tests/host/common/HostWiring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
10 changes: 9 additions & 1 deletion tests/host/common/MockWiFiServerSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions tests/host/common/include/UdpContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,24 @@ class UdpContext
_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");
}

Expand Down
12 changes: 12 additions & 0 deletions tests/host/common/mock.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down