diff --git a/cores/esp8266/umm_malloc/umm_malloc.cpp b/cores/esp8266/umm_malloc/umm_malloc.cpp index 8314c5ec60..09cfbdda71 100644 --- a/cores/esp8266/umm_malloc/umm_malloc.cpp +++ b/cores/esp8266/umm_malloc/umm_malloc.cpp @@ -520,7 +520,7 @@ extern int umm_last_fail_alloc_size; #endif // Macro to place constant strings into PROGMEM and print them properly -#define printf(fmt, ...) do { static const char fstr[] PROGMEM = fmt; char rstr[sizeof(fmt)]; for (size_t i=0; i& /dev/null else BUILDER_DEBUG_FLAG = -verbose RUNNER_DEBUG_FLAG = -d @@ -50,10 +51,11 @@ $(TEST_LIST): ifneq ("$(NO_BUILD)","1") @test -n "$(ARDUINO_IDE_PATH)" || (echo "Please export ARDUINO_IDE_PATH" && exit 1) @echo Compiling $(notdir $@) + @rm -f $(LOCAL_BUILD_DIR)/build.options.json $(SILENT)$(BUILD_TOOL) -compile -logger=human \ -libraries "$(PWD)/libraries" \ -core-api-version="10608" \ - -warnings=none \ + -warnings=all \ $(BUILDER_DEBUG_FLAG) \ -build-path $(LOCAL_BUILD_DIR) \ -tools $(ARDUINO_IDE_PATH)/tools-builder \ @@ -64,16 +66,17 @@ ifneq ("$(NO_BUILD)","1") endif ifneq ("$(NO_UPLOAD)","1") @test -n "$(UPLOAD_PORT)" || (echo "Failed to detect upload port, please export UPLOAD_PORT manually" && exit 1) - @test -e $(dir $@)/make_spiffs.py && (echo "Generating and uploading SPIFFS" && \ - (cd $(dir $@) && $(PYTHON) ./make_spiffs.py) && \ + @test -e $(dir $@)/make_spiffs.py && ( \ + echo "Generating and uploading SPIFFS" && \ + (cd $(dir $@) && $(PYTHON) ./make_spiffs.py $(REDIR) ) && \ $(MKSPIFFS) --create $(dir $@)data/ --size 0xFB000 \ - --block 8192 --page 256 $(LOCAL_BUILD_DIR)/spiffs.img && \ + --block 8192 --page 256 $(LOCAL_BUILD_DIR)/spiffs.img $(REDIR) && \ $(ESPTOOL) $(UPLOAD_VERBOSE_FLAG) \ --chip esp8266 \ --port $(UPLOAD_PORT) \ --baud $(UPLOAD_BAUD) \ --after no_reset \ - write_flash 0x300000 $(LOCAL_BUILD_DIR)/spiffs.img ) \ + write_flash 0x300000 $(LOCAL_BUILD_DIR)/spiffs.img $(REDIR) ) \ || (echo "No SPIFFS to upload") @echo Uploading binary $(SILENT)$(ESPTOOL) $(UPLOAD_VERBOSE_FLAG) \ @@ -81,7 +84,7 @@ ifneq ("$(NO_UPLOAD)","1") --port $(UPLOAD_PORT) \ --baud $(UPLOAD_BAUD) \ --after no_reset \ - write_flash 0x0 $(LOCAL_BUILD_DIR)/$(notdir $@).bin # no reset + write_flash 0x0 $(LOCAL_BUILD_DIR)/$(notdir $@).bin $(REDIR) # no reset endif ifneq ("$(NO_RUN)","1") @test -n "$(UPLOAD_PORT)" || (echo "Failed to detect upload port, please export UPLOAD_PORT manually" && exit 1) @@ -90,7 +93,7 @@ ifneq ("$(NO_RUN)","1") --chip esp8266 \ --port $(UPLOAD_PORT) \ --baud $(UPLOAD_BAUD) \ - read_flash_status # reset + read_flash_status $(REDIR) # reset $(SILENT)source $(BS_DIR)/virtualenv/bin/activate && \ $(PYTHON) $(BS_DIR)/runner.py \ $(RUNNER_DEBUG_FLAG) \ diff --git a/tests/device/libraries/BSTest/runner.py b/tests/device/libraries/BSTest/runner.py index 5cf10f478b..9778f35ada 100644 --- a/tests/device/libraries/BSTest/runner.py +++ b/tests/device/libraries/BSTest/runner.py @@ -104,6 +104,10 @@ def run_tests(self): if res != BSTestRunner.SUCCESS: print('failed to set environment variables') break; + res = self.pretest() + if res != BSTestRunner.SUCCESS: + print('failed to run pretest init') + break; should_update_env = False if name in self.mocks: debug_print('setting up mocks') @@ -198,6 +202,21 @@ def update_env(self, env_to_set): return BSTestRunner.TIMEOUT return BSTestRunner.SUCCESS + def pretest(self): + # Environment now set up, call the pretest init (wifi connect, etc.) + self.sp.sendline('pretest'); + timeout = 10 + while timeout > 0: + res = self.sp.expect(['>>>>>bs_test_pretest result=1', EOF, TIMEOUT]) # Only expect a pass, abort testing if failure + if res == 0: + break + time.sleep(0.1) + timeout -= 0.1 + if res != 0: + return BSTestRunner.TIMEOUT + else: + return BSTestRunner.SUCCESS + def request_env(self, key): self.sp.sendline('getenv "{}"'.format(key)) timeout = 10 diff --git a/tests/device/libraries/BSTest/src/BSArgs.h b/tests/device/libraries/BSTest/src/BSArgs.h index e4a7008f15..060bcdf18c 100644 --- a/tests/device/libraries/BSTest/src/BSArgs.h +++ b/tests/device/libraries/BSTest/src/BSArgs.h @@ -69,7 +69,7 @@ inline size_t split_args(char *line, char **argv, size_t argv_size) const int ESCAPE = '\\'; const int SPACE = ' '; split_state_t state = SS_SPACE; - int argc = 0; + size_t argc = 0; char *next_arg_start = line; char *out_ptr = line; for (char *in_ptr = line; argc < argv_size - 1; ++in_ptr) { @@ -148,4 +148,4 @@ inline size_t split_args(char *line, char **argv, size_t argv_size) } // namespace protocol -#endif //BS_ARGS_H \ No newline at end of file +#endif //BS_ARGS_H diff --git a/tests/device/libraries/BSTest/src/BSProtocol.h b/tests/device/libraries/BSTest/src/BSProtocol.h index f4ed73bd7a..05a874f956 100644 --- a/tests/device/libraries/BSTest/src/BSProtocol.h +++ b/tests/device/libraries/BSTest/src/BSProtocol.h @@ -5,6 +5,8 @@ #define BS_LINE_PREFIX ">>>>>bs_test_" +extern bool pretest(); + namespace bs { namespace protocol @@ -58,6 +60,12 @@ void output_getenv_result(IO& io, const char* key, const char* value) io.printf(BS_LINE_PREFIX "getenv value=\"%s\"\n", value); } +template +void output_pretest_result(IO& io, bool res) +{ + io.printf(BS_LINE_PREFIX "pretest result=%d\n", res?1:0); +} + template bool input_handle(IO& io, char* line_buf, size_t line_buf_size, int& test_num) { @@ -87,6 +95,14 @@ bool input_handle(IO& io, char* line_buf, size_t line_buf_size, int& test_num) output_getenv_result(io, argv[1], (value != NULL) ? value : ""); return false; } + if (strcmp(argv[0], "pretest") == 0) { + if (argc != 1) { + return false; + } + bool res = ::pretest(); + output_pretest_result(io, res); + return false; + } /* not one of the commands, try to parse as test number */ char* endptr; test_num = (int) strtol(argv[0], &endptr, 10); diff --git a/tests/device/test_BearSSL/test_BearSSL.ino b/tests/device/test_BearSSL/test_BearSSL.ino index 675c24de60..e4db2fdc0e 100644 --- a/tests/device/test_BearSSL/test_BearSSL.ino +++ b/tests/device/test_BearSSL/test_BearSSL.ino @@ -33,6 +33,11 @@ void setup() { Serial.begin(115200); Serial.setDebugOutput(true); + BS_RUN(Serial); +} + +bool pretest() +{ WiFi.persistent(false); WiFi.mode(WIFI_STA); WiFi.begin(getenv("STA_SSID"), getenv("STA_PASS")); @@ -45,22 +50,11 @@ void setup() Serial.printf("Number of CA certs read: %d\n", numCerts); if (numCerts == 0) { Serial.printf("No certs found. Did you run certs-from-mozill.py and upload the SPIFFS directory before running?\n"); - REQUIRE(1==0); + return false; } - BS_RUN(Serial); -} - -static void stopAll() -{ - WiFiClient::stopAll(); -} - -static void disconnectWiFI() -{ - wifi_station_disconnect(); + return true; } - // Set time via NTP, as required for x.509 validation void setClock() { configTime(3 * 3600, 0, "pool.ntp.org", "time.nist.gov"); @@ -143,7 +137,7 @@ int run(const char *str) return maxUsage; } -#define TC(x) TEST_CASE("BearSSL - Maximum stack usage < 5600 bytes @ "x".badssl.org", "[bearssl]") { REQUIRE(run(x) < 5600); } +#define TC(x) TEST_CASE("BearSSL - Maximum stack usage < 5600 bytes @ " x ".badssl.org", "[bearssl]") { REQUIRE(run(x) < 5600); } TC("expired") TC("wrong.host") diff --git a/tests/device/test_ClientContext/test_ClientContext.ino b/tests/device/test_ClientContext/test_ClientContext.ino index 10cedf1076..25f4db2cf5 100644 --- a/tests/device/test_ClientContext/test_ClientContext.ino +++ b/tests/device/test_ClientContext/test_ClientContext.ino @@ -23,13 +23,18 @@ void setup() { Serial.begin(115200); Serial.setDebugOutput(true); + BS_RUN(Serial); +} + +bool pretest() +{ WiFi.persistent(false); WiFi.mode(WIFI_STA); WiFi.begin(getenv("STA_SSID"), getenv("STA_PASS")); while (WiFi.status() != WL_CONNECTED) { delay(500); } - BS_RUN(Serial); + return true; } TEST_CASE("WiFi release ClientContext", "[clientcontext]") diff --git a/tests/device/test_FS/test_FS.ino b/tests/device/test_FS/test_FS.ino index b516c8b16f..0a33dc8586 100644 --- a/tests/device/test_FS/test_FS.ino +++ b/tests/device/test_FS/test_FS.ino @@ -10,6 +10,10 @@ void setup() BS_RUN(Serial); } +bool pretest() +{ + return true; +} TEST_CASE("read-write test","[fs]") diff --git a/tests/device/test_Print_printf/test_Print_printf.ino b/tests/device/test_Print_printf/test_Print_printf.ino index 7396572625..1411467f9f 100644 --- a/tests/device/test_Print_printf/test_Print_printf.ino +++ b/tests/device/test_Print_printf/test_Print_printf.ino @@ -9,13 +9,18 @@ void setup() BS_RUN(Serial); } +bool pretest() +{ + return true; +} + TEST_CASE("Print::printf works for any reasonable output length", "[Print]") { auto test_printf = [](size_t size) { StreamString str; auto buf = new char[size + 1]; - for (int i = 0; i < size; ++i) { + for (size_t i = 0; i < size; ++i) { buf[i] = 'a'; } buf[size] = 0; diff --git a/tests/device/test_WiFiClient/test_WiFiClient.ino b/tests/device/test_WiFiClient/test_WiFiClient.ino index 4d7eb73913..239d44e35d 100644 --- a/tests/device/test_WiFiClient/test_WiFiClient.ino +++ b/tests/device/test_WiFiClient/test_WiFiClient.ino @@ -13,13 +13,18 @@ void setup() { Serial.begin(115200); Serial.setDebugOutput(true); + BS_RUN(Serial); +} + +bool pretest() +{ WiFi.persistent(false); WiFi.mode(WIFI_STA); WiFi.begin(getenv("STA_SSID"), getenv("STA_PASS")); while (WiFi.status() != WL_CONNECTED) { delay(500); } - BS_RUN(Serial); + return true; } static void stopAll() @@ -53,4 +58,4 @@ TEST_CASE("WiFi disconnect during WiFiClient::connect", "[wificlient]") void loop() { -} \ No newline at end of file +} diff --git a/tests/device/test_WiFiServer/test_WiFiServer.ino b/tests/device/test_WiFiServer/test_WiFiServer.ino index 2040df54c8..5af9cfce27 100644 --- a/tests/device/test_WiFiServer/test_WiFiServer.ino +++ b/tests/device/test_WiFiServer/test_WiFiServer.ino @@ -10,13 +10,18 @@ BS_ENV_DECLARE(); void setup() { Serial.begin(115200); + BS_RUN(Serial); +} + +bool pretest() +{ WiFi.persistent(false); WiFi.begin(getenv("STA_SSID"), getenv("STA_PASS")); while (WiFi.status() != WL_CONNECTED) { delay(500); } MDNS.begin("esp8266-wfs-test"); - BS_RUN(Serial); + return true; } TEST_CASE("Simple echo server", "[WiFiServer]") diff --git a/tests/device/test_WiFi_events/test_WiFi_events.ino b/tests/device/test_WiFi_events/test_WiFi_events.ino index 704f3c3c7d..88777b61ab 100644 --- a/tests/device/test_WiFi_events/test_WiFi_events.ino +++ b/tests/device/test_WiFi_events/test_WiFi_events.ino @@ -11,9 +11,14 @@ void setup() { Serial.begin(115200); Serial.setDebugOutput(false); + BS_RUN(Serial); +} + +bool pretest() +{ WiFi.persistent(false); WiFi.mode(WIFI_OFF); - BS_RUN(Serial); + return true; } static std::map sEventsReceived; @@ -29,10 +34,13 @@ TEST_CASE("WiFi.onEvent is called for specific events", "[wifi][events]") sEventsReceived[WIFI_EVENT_STAMODE_DISCONNECTED] = 0; sEventsReceived[WIFI_EVENT_STAMODE_GOT_IP] = 0; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" WiFi.onEvent(onWiFiEvent, WIFI_EVENT_STAMODE_CONNECTED); WiFi.onEvent(onWiFiEvent, WIFI_EVENT_STAMODE_DISCONNECTED); WiFi.onEvent(onWiFiEvent, WIFI_EVENT_STAMODE_GOT_IP); WiFi.onEvent(onWiFiEvent, WIFI_EVENT_ANY); +#pragma GCC diagnostic pop WiFi.mode(WIFI_STA); WiFi.begin(getenv("STA_SSID"), getenv("STA_PASS")); @@ -44,9 +52,12 @@ TEST_CASE("WiFi.onEvent is called for specific events", "[wifi][events]") WiFi.disconnect(); delay(100); WiFi.mode(WIFI_OFF); +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" REQUIRE(sEventsReceived[WIFI_EVENT_STAMODE_CONNECTED] == 2); REQUIRE(sEventsReceived[WIFI_EVENT_STAMODE_DISCONNECTED] >= 2 && sEventsReceived[WIFI_EVENT_STAMODE_DISCONNECTED] % 2 == 0); REQUIRE(sEventsReceived[WIFI_EVENT_STAMODE_GOT_IP] == 2); +#pragma GCC diagnostic pop } TEST_CASE("STA mode events are called both when using DHCP and static config", "[wifi][events]") @@ -54,14 +65,17 @@ TEST_CASE("STA mode events are called both when using DHCP and static config", " String events; auto handler1 = WiFi.onStationModeConnected([&](const WiFiEventStationModeConnected& evt){ + (void) evt; events += "connected,"; }); auto handler2 = WiFi.onStationModeDisconnected([&](const WiFiEventStationModeDisconnected& evt){ + (void) evt; if (events.length()) { events += "disconnected,"; } }); auto handler3 = WiFi.onStationModeGotIP([&](const WiFiEventStationModeGotIP& evt){ + (void) evt; events += "got_ip,"; }); @@ -104,12 +118,15 @@ TEST_CASE("Events are not called if handler is deleted", "[wifi][events]") String events; WiFi.onStationModeConnected([&](const WiFiEventStationModeConnected& evt){ + (void) evt; events += "connected,"; }); WiFi.onStationModeDisconnected([&](const WiFiEventStationModeDisconnected& evt){ + (void) evt; events += "disconnected,"; }); WiFi.onStationModeGotIP([&](const WiFiEventStationModeGotIP& evt){ + (void) evt; events += "got_ip,"; }); diff --git a/tests/device/test_http_client/test_http_client.ino b/tests/device/test_http_client/test_http_client.ino index c2c9b60e54..4757fdb4fe 100644 --- a/tests/device/test_http_client/test_http_client.ino +++ b/tests/device/test_http_client/test_http_client.ino @@ -11,12 +11,17 @@ void setup() { Serial.begin(115200); Serial.setDebugOutput(true); + BS_RUN(Serial); +} + +bool pretest() +{ WiFi.persistent(false); WiFi.begin(getenv("STA_SSID"), getenv("STA_PASS")); while (WiFi.status() != WL_CONNECTED) { delay(500); } - BS_RUN(Serial); + return true; } const char* fp = "44 40 9E 34 92 2D E4 61 A4 89 A8 D5 7F 71 B7 62 B3 FD DD E1"; @@ -43,7 +48,7 @@ TEST_CASE("HTTP GET & POST requests", "[HTTPClient]") String payload = http.getString(); auto len = payload.length(); REQUIRE(len == 8000); - for (int i = 0; i < len; ++i) { + for (size_t i = 0; i < len; ++i) { if (payload[i] != 'a') { REQUIRE(false); } @@ -196,7 +201,7 @@ TEST_CASE("HTTPS GET request", "[HTTPClient]") String payload = http.getString(); auto len = payload.length(); REQUIRE(len == 4000); - for (int i = 0; i < len; ++i) { + for (size_t i = 0; i < len; ++i) { if (payload[i] != 'a') { REQUIRE(false); } @@ -207,7 +212,10 @@ TEST_CASE("HTTPS GET request", "[HTTPClient]") // { // small request +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" axTLS::WiFiClientSecure client; +#pragma GCC diagnostic pop HTTPClient http; http.begin(client, getenv("SERVER_IP"), 8088, "/", fp); auto httpCode = http.GET(); @@ -217,7 +225,10 @@ TEST_CASE("HTTPS GET request", "[HTTPClient]") } { // request which returns 4000 bytes +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" axTLS::WiFiClientSecure client; +#pragma GCC diagnostic pop HTTPClient http; http.begin(client, getenv("SERVER_IP"), 8088, "/data?size=4000", fp); auto httpCode = http.GET(); @@ -225,7 +236,7 @@ TEST_CASE("HTTPS GET request", "[HTTPClient]") String payload = http.getString(); auto len = payload.length(); REQUIRE(len == 4000); - for (int i = 0; i < len; ++i) { + for (size_t i = 0; i < len; ++i) { if (payload[i] != 'a') { REQUIRE(false); } diff --git a/tests/device/test_http_server/test_http_server.ino b/tests/device/test_http_server/test_http_server.ino index c408555822..e9f8bda923 100644 --- a/tests/device/test_http_server/test_http_server.ino +++ b/tests/device/test_http_server/test_http_server.ino @@ -16,6 +16,11 @@ void setup() { Serial.begin(115200); Serial.setDebugOutput(true); + BS_RUN(Serial); +} + +bool pretest() +{ WiFi.persistent(false); WiFi.begin(getenv("STA_SSID"), getenv("STA_PASS")); while (WiFi.status() != WL_CONNECTED) { @@ -24,7 +29,7 @@ void setup() MDNS.begin("etd"); server.onNotFound([](){ server.send(404); }); server.begin(); - BS_RUN(Serial); + return true; } void handle_request() diff --git a/tests/device/test_iostream/test_iostream.ino b/tests/device/test_iostream/test_iostream.ino index b644882bf2..db803ffe82 100644 --- a/tests/device/test_iostream/test_iostream.ino +++ b/tests/device/test_iostream/test_iostream.ino @@ -11,6 +11,11 @@ void setup() BS_RUN(Serial); } +bool pretest() +{ + return true; +} + TEST_CASE("can print to std::cout", "[iostream]") { std::stringstream test_stream(""); diff --git a/tests/device/test_libc/test_libc.ino b/tests/device/test_libc/test_libc.ino index f4490fa2f9..a3ab6c223d 100644 --- a/tests/device/test_libc/test_libc.ino +++ b/tests/device/test_libc/test_libc.ino @@ -9,6 +9,11 @@ void setup() BS_RUN(Serial); } +bool pretest() +{ + return true; +} + extern "C" { extern void memmove_main(void); extern void memcpy_main(void); diff --git a/tests/device/test_millis_mm/test_millis_mm.ino b/tests/device/test_millis_mm/test_millis_mm.ino index e7cb59cea7..c5e25bdcdc 100644 --- a/tests/device/test_millis_mm/test_millis_mm.ino +++ b/tests/device/test_millis_mm/test_millis_mm.ino @@ -40,6 +40,8 @@ static uint32_t cntref = 0; // Ref. comparision count // Callback for usec counter overflow timer interrupt void us_overflow_tick ( void* arg ) { + (void) arg; + us_cnt = system_get_time(); // Check for usec counter overflow @@ -461,11 +463,17 @@ void setup () { Serial.begin(115200); WiFi.mode( WIFI_OFF ); - us_count_init(); // Start up timer overflow sampling BS_RUN(Serial); - } //setup + +//--------------------------------------------------------------------------- +bool pretest () +{ + us_count_init(); // Start up timer overflow sampling + return true; +} //pretest + //--------------------------------------------------------------------------- void loop(void) { diff --git a/tests/device/test_newlib/test_newlib.ino b/tests/device/test_newlib/test_newlib.ino index 46e9167347..32abbb9141 100644 --- a/tests/device/test_newlib/test_newlib.ino +++ b/tests/device/test_newlib/test_newlib.ino @@ -8,6 +8,11 @@ void setup() BS_RUN(Serial); } +bool pretest() +{ + return true; +} + TEST_CASE("Floating point formatting works", "[newlib]") { char buf[16]; diff --git a/tests/device/test_overrides/test_overrides.ino b/tests/device/test_overrides/test_overrides.ino index 655f12084d..e8737f7cb7 100644 --- a/tests/device/test_overrides/test_overrides.ino +++ b/tests/device/test_overrides/test_overrides.ino @@ -15,11 +15,16 @@ static unsigned setup_micros; void setup() { - setup_micros = micros(); + setup_micros = micros(); Serial.begin(115200); BS_RUN(Serial); } +bool pretest() +{ + return true; +} + TEST_CASE("ADC_MODE override works", "[core]") { auto vcc = ESP.getVcc(); diff --git a/tests/device/test_ping/test_ping.ino b/tests/device/test_ping/test_ping.ino index 1ac7c82699..a5bb98afff 100644 --- a/tests/device/test_ping/test_ping.ino +++ b/tests/device/test_ping/test_ping.ino @@ -10,13 +10,18 @@ void setup() { Serial.begin(115200); Serial.setDebugOutput(true); + BS_RUN(Serial); +} + +bool pretest() +{ WiFi.persistent(false); WiFi.mode(WIFI_STA); WiFi.begin(getenv("STA_SSID"), getenv("STA_PASS")); while (WiFi.status() != WL_CONNECTED) { delay(500); } - BS_RUN(Serial); + return true; } static struct ping_option po; diff --git a/tests/device/test_random/test_random.ino b/tests/device/test_random/test_random.ino index 5d71350d5e..39563b221c 100644 --- a/tests/device/test_random/test_random.ino +++ b/tests/device/test_random/test_random.ino @@ -8,16 +8,21 @@ void setup() BS_RUN(Serial); } +bool pretest() +{ + return true; +} + TEST_CASE("If randomSeed is not called, random() uses hardware PRNG", "[random]") { int32_t data[32]; srand(10); - for (int i = 0; i < sizeof(data)/sizeof(data[0]); ++i) { + for (size_t i = 0; i < sizeof(data)/sizeof(data[0]); ++i) { data[i] = random(0x7fffffff); } srand(10); - for (int i = 0; i < sizeof(data)/sizeof(data[0]); ++i) { + for (size_t i = 0; i < sizeof(data)/sizeof(data[0]); ++i) { CHECK(random(0x7fffffff) != data[i]); } } @@ -44,7 +49,7 @@ TEST_CASE("If randomSeed is called, we get same random sequence every time", "[r 730240988, 786466794, 1411137128, 1680096093, }; randomSeed(42); - for (int i = 0; i < sizeof(reference_sequence)/sizeof(reference_sequence[0]); ++i) { + for (size_t i = 0; i < sizeof(reference_sequence)/sizeof(reference_sequence[0]); ++i) { CHECK(random(0x7fffffff) == reference_sequence[i]); } } diff --git a/tests/device/test_schedule/test_schedule.ino b/tests/device/test_schedule/test_schedule.ino index 963635a681..26c7d114db 100644 --- a/tests/device/test_schedule/test_schedule.ino +++ b/tests/device/test_schedule/test_schedule.ino @@ -9,6 +9,10 @@ void setup() BS_RUN(Serial); } +bool pretest() +{ + return true; +} TEST_CASE("scheduled functions are executed", "[schedule]") { diff --git a/tests/device/test_serial/test_serial.ino b/tests/device/test_serial/test_serial.ino index 19481f91ff..6cdf2b2673 100644 --- a/tests/device/test_serial/test_serial.ino +++ b/tests/device/test_serial/test_serial.ino @@ -55,6 +55,11 @@ void setup() BS_RUN(Serial); } +bool pretest() +{ + return true; +} + void test_setup() { Serial.begin(BAUD); diff --git a/tests/device/test_stack_in_heap/test_stack_in_heap.ino b/tests/device/test_stack_in_heap/test_stack_in_heap.ino index 02cb11e9f1..79b513c9b3 100644 --- a/tests/device/test_stack_in_heap/test_stack_in_heap.ino +++ b/tests/device/test_stack_in_heap/test_stack_in_heap.ino @@ -11,6 +11,11 @@ void setup() BS_RUN(Serial); } +bool pretest() +{ + return true; +} + TEST_CASE("stack in user's HEAP ram", "[bs]") { bool sysstack = (((unsigned long)g_pcont) >> 16) == 0x3fff; diff --git a/tests/device/test_stack_in_sys/test_stack_in_sys.ino b/tests/device/test_stack_in_sys/test_stack_in_sys.ino index 6a1595c5ad..09270e9666 100644 --- a/tests/device/test_stack_in_sys/test_stack_in_sys.ino +++ b/tests/device/test_stack_in_sys/test_stack_in_sys.ino @@ -10,6 +10,11 @@ void setup() BS_RUN(Serial); } +bool pretest() +{ + return true; +} + TEST_CASE("stack in SYS ram", "[bs]") { bool sysstack = (((unsigned long)g_pcont) >> 16) == 0x3fff; diff --git a/tests/device/test_tests/test_tests.ino b/tests/device/test_tests/test_tests.ino index 2420805fc0..62110126b6 100644 --- a/tests/device/test_tests/test_tests.ino +++ b/tests/device/test_tests/test_tests.ino @@ -8,6 +8,11 @@ void setup() BS_RUN(Serial); } +bool pretest() +{ + return true; +} + TEST_CASE("this test runs successfully", "[bs]") { diff --git a/tests/device/test_time/test_time.ino b/tests/device/test_time/test_time.ino index 6642d3687c..a79c0c247f 100644 --- a/tests/device/test_time/test_time.ino +++ b/tests/device/test_time/test_time.ino @@ -8,20 +8,22 @@ BS_ENV_DECLARE(); void setup() { Serial.begin(115200); + BS_RUN(Serial); +} + +bool pretest() +{ WiFi.persistent(false); WiFi.begin(getenv("STA_SSID"), getenv("STA_PASS")); while (WiFi.status() != WL_CONNECTED) { delay(500); } - BS_RUN(Serial); + return true; } TEST_CASE("Can sync time", "[time]") { - int timezone = 3; - int dst = 0; - configTime(3 * 3600, 0, "pool.ntp.org", "time.nist.gov"); Serial.println("\nWaiting for time"); unsigned timeout = 5000; @@ -48,7 +50,7 @@ TEST_CASE("#1745 mktime and localtime", "[time]") const int years[] = {2012, 2013, 2014}; const time_t timestamps[] = {1332640800, 1364176800, 1395712800}; - for (int i = 0; i < sizeof(years)/sizeof(years[0]); ++i) { + for (size_t i = 0; i < sizeof(years)/sizeof(years[0]); ++i) { tm_in.tm_year = years[i] - 1900; tm_in.tm_mon = 2; tm_in.tm_mday = 25; diff --git a/tests/device/test_umm_malloc/test_umm_malloc.ino b/tests/device/test_umm_malloc/test_umm_malloc.ino index b805f73f7d..419b23c3c0 100644 --- a/tests/device/test_umm_malloc/test_umm_malloc.ino +++ b/tests/device/test_umm_malloc/test_umm_malloc.ino @@ -11,6 +11,11 @@ void setup() BS_RUN(Serial); } +bool pretest() +{ + return true; +} + TEST_CASE("umm_info can be called", "[umm_malloc]") { umm_info(NULL, 1);