Skip to content

Commit b080c50

Browse files
authored
emulation on host: avoid closing STDIN (#8577)
- avoid closing STDIN - less verbose during compilation - better handling user directories - missing str{,n}case_P declarations
1 parent 8f71d2c commit b080c50

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

Diff for: tests/host/Makefile

+4-3
Original file line numberDiff line numberDiff line change
@@ -374,9 +374,10 @@ ssl: # download source and build BearSSL
374374
cd ../../tools/sdk/ssl && $(MAKE) native$(N32)
375375

376376
ULIBPATHS = $(shell echo $(ULIBDIRS) | sed 's,:, ,g')
377-
USERLIBDIRS = $(shell test -z "$(ULIBPATHS)" || for d in $(ULIBPATHS); do for dd in $$d $$d/src $$d/src/libmad; do test -d $$dd && { echo -I$$dd; echo "userlib: using directory '$$dd'" 1>&2; } done; done)
378-
USERLIBSRCS = $(shell test -z "$(ULIBPATHS)" || for d in $(ULIBPATHS); do for ss in $$d/*.cpp $$d/src/*.cpp $$d/src/libmad/*.c; do test -r $$ss && echo $$ss; done; done)
379-
INC_PATHS += $(USERLIBDIRS)
377+
USERLIBDIRS = $(shell test -z "$(ULIBPATHS)" || for d in $(ULIBPATHS); do for dd in $$d $$d/utility $$d/src $$d/src/utility; do test -d $$dd && echo $$dd; done; done)
378+
USERLIBSRCS := $(shell test -z "$(USERLIBDIRS)" || for d in $(USERLIBDIRS); do for ss in $$d/*.c $$d/*.cpp; do test -r $$ss && echo $$ss; done; done)
379+
USERLIBINCS = $(shell for d in $(USERLIBDIRS); do echo -I$$d; done)
380+
INC_PATHS += $(USERLIBINCS)
380381
INC_PATHS += -I$(INODIR)/..
381382
CPP_OBJECTS_CORE_EMU = $(CPP_SOURCES_CORE_EMU:.cpp=.cpp.o) $(USERLIBSRCS:.cpp=.cpp.o) $(USERCXXSOURCES:.cpp=.cpp.o)
382383
C_OBJECTS_CORE_EMU = $(USERCSOURCES:.c=.c.o)

Diff for: tests/host/common/ArduinoMain.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,14 @@ static int mock_stop_uart(void)
115115

116116
static uint8_t mock_read_uart(void)
117117
{
118-
uint8_t ch = 0;
119-
return (read(STDIN, &ch, 1) == 1) ? ch : 0;
118+
uint8_t ch = 0;
119+
int ret = read(STDIN, &ch, 1);
120+
if (ret == -1)
121+
{
122+
perror("read(STDIN,1)");
123+
return 0;
124+
}
125+
return (ret == 1) ? ch : 0;
120126
}
121127

122128
void help(const char* argv0, int exitcode)

Diff for: tests/host/common/MockWiFiServerSocket.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ bool WiFiServer::hasClient()
129129

130130
void WiFiServer::close()
131131
{
132-
if (pcb2int(_listen_pcb) >= 0)
132+
if (pcb2int(_listen_pcb) >= 3) // 0=stdin 1=stdout 2=stderr
133133
::close(pcb2int(_listen_pcb));
134134
_listen_pcb = int2pcb(-1);
135135
}

Diff for: tests/host/sys/pgmspace.h

+2
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,12 @@ inline int vsnprintf_P(char* str, size_t size, const char* format, va_list ap)
7575
#define memmove_P memmove
7676
#define strncpy_P strncpy
7777
#define strcmp_P strcmp
78+
#define strcasecmp_P strcasecmp
7879
#define memccpy_P memccpy
7980
#define snprintf_P snprintf
8081
#define sprintf_P sprintf
8182
#define strncmp_P strncmp
83+
#define strncasecmp_P strncasecmp
8284
#define strcat_P strcat
8385

8486
#endif

0 commit comments

Comments
 (0)