mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +03:00
device tests: some of them can be run on host (#6912)
* device tests: mock scripts + rename some tests to enable mock-testing them * move symbol
This commit is contained in:
parent
d1237fd016
commit
d40dbb4584
@ -1,6 +1,5 @@
|
|||||||
SHELL := /bin/bash
|
SHELL := /bin/bash
|
||||||
V ?= 0
|
V ?= 0
|
||||||
TEST_LIST ?= $(wildcard test_*/*.ino)
|
|
||||||
ESP8266_CORE_PATH ?= $(realpath ../..)
|
ESP8266_CORE_PATH ?= $(realpath ../..)
|
||||||
BUILD_DIR ?= $(PWD)/.build
|
BUILD_DIR ?= $(PWD)/.build
|
||||||
HARDWARE_DIR ?= $(PWD)/.hardware
|
HARDWARE_DIR ?= $(PWD)/.hardware
|
||||||
@ -18,6 +17,12 @@ TEST_CONFIG := test_env.cfg
|
|||||||
TEST_REPORT_XML := test_report.xml
|
TEST_REPORT_XML := test_report.xml
|
||||||
TEST_REPORT_HTML := test_report.html
|
TEST_REPORT_HTML := test_report.html
|
||||||
|
|
||||||
|
ifeq ("$(MOCK)", "1")
|
||||||
|
# To enable a test for mock testing, just rename dir+files to '*_sw_*'
|
||||||
|
TEST_LIST ?= $(wildcard test_sw_*/*.ino)
|
||||||
|
else
|
||||||
|
TEST_LIST ?= $(wildcard test_*/*.ino)
|
||||||
|
endif
|
||||||
|
|
||||||
ifneq ("$(V)","1")
|
ifneq ("$(V)","1")
|
||||||
SILENT = @
|
SILENT = @
|
||||||
@ -29,10 +34,14 @@ else
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
help:
|
help:
|
||||||
@echo 'make list - show list of tests'
|
@echo
|
||||||
@echo 'make [V=1] sometest/sometest.ino - run one test'
|
@echo 'make list - show list of tests'
|
||||||
@echo 'make [V=1] all - run all tests'
|
@echo 'make sometest/sometest.ino - run one test'
|
||||||
@echo 'variables needed: $$ARDUINO_IDE_PATH'
|
@echo 'make all - run all tests'
|
||||||
|
@echo 'make MOCK=1 all - run all emulation-on-host compatible tests'
|
||||||
|
@echo 'variables needed: $$ARDUINO_IDE_PATH $$ESP8266_CORE_PATH'
|
||||||
|
@echo 'make options: V=1 NO_BUILD=1 NO_UPLOAD=1 NO_RUN=1 MOCK=1'
|
||||||
|
@echo
|
||||||
|
|
||||||
list: showtestlist
|
list: showtestlist
|
||||||
|
|
||||||
@ -53,6 +62,18 @@ $(TEST_LIST):
|
|||||||
@echo "--------------------------------"
|
@echo "--------------------------------"
|
||||||
@echo "Running test '$@' of $(words $(TEST_LIST)) tests"
|
@echo "Running test '$@' of $(words $(TEST_LIST)) tests"
|
||||||
$(SILENT)mkdir -p $(LOCAL_BUILD_DIR)
|
$(SILENT)mkdir -p $(LOCAL_BUILD_DIR)
|
||||||
|
ifeq ("$(MOCK)", "1")
|
||||||
|
@echo Compiling $(notdir $@)
|
||||||
|
(cd ../host; make ULIBDIRS=../device/libraries/BSTest ../device/$(@:%.ino=%))
|
||||||
|
$(SILENT)source $(BS_DIR)/virtualenv/bin/activate && \
|
||||||
|
$(PYTHON) $(BS_DIR)/runner.py \
|
||||||
|
$(RUNNER_DEBUG_FLAG) \
|
||||||
|
-e "$(ESP8266_CORE_PATH)/tests/host/bin/$(@:%.ino=%)" \
|
||||||
|
-n $(basename $(notdir $@)) \
|
||||||
|
-o $(LOCAL_BUILD_DIR)/test_result.xml \
|
||||||
|
--env-file $(TEST_CONFIG) \
|
||||||
|
`test -f $(addsuffix .py, $(basename $@)) && echo "-m $(addsuffix .py, $(basename $@))" || echo ""`
|
||||||
|
else
|
||||||
ifneq ("$(NO_BUILD)","1")
|
ifneq ("$(NO_BUILD)","1")
|
||||||
@test -n "$(ARDUINO_IDE_PATH)" || (echo "Please export ARDUINO_IDE_PATH" && exit 1)
|
@test -n "$(ARDUINO_IDE_PATH)" || (echo "Please export ARDUINO_IDE_PATH" && exit 1)
|
||||||
@echo Compiling $(notdir $@)
|
@echo Compiling $(notdir $@)
|
||||||
@ -108,6 +129,7 @@ ifneq ("$(NO_RUN)","1")
|
|||||||
--env-file $(TEST_CONFIG) \
|
--env-file $(TEST_CONFIG) \
|
||||||
`test -f $(addsuffix .py, $(basename $@)) && echo "-m $(addsuffix .py, $(basename $@))" || echo ""`
|
`test -f $(addsuffix .py, $(basename $@)) && echo "-m $(addsuffix .py, $(basename $@))" || echo ""`
|
||||||
endif
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
$(TEST_REPORT_XML): $(HARDWARE_DIR) virtualenv
|
$(TEST_REPORT_XML): $(HARDWARE_DIR) virtualenv
|
||||||
$(SILENT)$(BS_DIR)/xunitmerge $(shell find $(BUILD_DIR) -name 'test_result.xml' | xargs echo) $(TEST_REPORT_XML)
|
$(SILENT)$(BS_DIR)/xunitmerge $(shell find $(BUILD_DIR) -name 'test_result.xml' | xargs echo) $(TEST_REPORT_XML)
|
||||||
|
@ -210,6 +210,7 @@ TEST_CASE("HTTPS GET request", "[HTTPClient]")
|
|||||||
//
|
//
|
||||||
// Same tests with axTLS
|
// Same tests with axTLS
|
||||||
//
|
//
|
||||||
|
#if !CORE_MOCK
|
||||||
{
|
{
|
||||||
// small request
|
// small request
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
@ -242,6 +243,7 @@ TEST_CASE("HTTPS GET request", "[HTTPClient]")
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
@ -174,7 +174,7 @@ void control_c (int sig)
|
|||||||
int main (int argc, char* const argv [])
|
int main (int argc, char* const argv [])
|
||||||
{
|
{
|
||||||
bool fast = false;
|
bool fast = false;
|
||||||
bool blocking_uart = false;
|
blocking_uart = false; // global
|
||||||
|
|
||||||
signal(SIGINT, control_c);
|
signal(SIGINT, control_c);
|
||||||
if (geteuid() == 0)
|
if (geteuid() == 0)
|
||||||
|
@ -39,6 +39,8 @@
|
|||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
|
bool blocking_uart = true; // system default
|
||||||
|
|
||||||
static int s_uart_debug_nr = UART1;
|
static int s_uart_debug_nr = UART1;
|
||||||
|
|
||||||
static uart_t *UART[2] = { NULL, NULL };
|
static uart_t *UART[2] = { NULL, NULL };
|
||||||
@ -190,6 +192,13 @@ uart_read(uart_t* uart, char* userbuffer, size_t usersize)
|
|||||||
if(uart == NULL || !uart->rx_enabled)
|
if(uart == NULL || !uart->rx_enabled)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
if (!blocking_uart)
|
||||||
|
{
|
||||||
|
char c;
|
||||||
|
if (read(0, &c, 1) == 1)
|
||||||
|
uart_new_data(0, c);
|
||||||
|
}
|
||||||
|
|
||||||
size_t ret = 0;
|
size_t ret = 0;
|
||||||
while (ret < usersize && uart_rx_available_unsafe(uart->rx_buffer))
|
while (ret < usersize && uart_rx_available_unsafe(uart->rx_buffer))
|
||||||
{
|
{
|
||||||
|
@ -104,12 +104,14 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
int ets_printf (const char* fmt, ...) __attribute__ ((format (printf, 1, 2)));
|
int ets_printf (const char* fmt, ...) __attribute__ ((format (printf, 1, 2)));
|
||||||
#define os_printf_plus printf
|
#define os_printf_plus printf
|
||||||
|
#define ets_vsnprintf vsnprintf
|
||||||
|
|
||||||
int mockverbose (const char* fmt, ...) __attribute__ ((format (printf, 1, 2)));
|
int mockverbose (const char* fmt, ...) __attribute__ ((format (printf, 1, 2)));
|
||||||
|
|
||||||
extern const char* host_interface; // cmdline parameter
|
extern const char* host_interface; // cmdline parameter
|
||||||
extern bool serial_timestamp;
|
extern bool serial_timestamp;
|
||||||
extern int mock_port_shifter;
|
extern int mock_port_shifter;
|
||||||
|
extern bool blocking_uart;
|
||||||
|
|
||||||
#define NO_GLOBAL_BINDING 0xffffffff
|
#define NO_GLOBAL_BINDING 0xffffffff
|
||||||
extern uint32_t global_ipv4_netfmt; // selected interface addresse to bind to
|
extern uint32_t global_ipv4_netfmt; // selected interface addresse to bind to
|
||||||
|
Loading…
x
Reference in New Issue
Block a user