From 78d95431f5db6227a01ab6fdeb64ace7dd7117f2 Mon Sep 17 00:00:00 2001 From: sheinz Date: Mon, 24 Oct 2016 21:47:29 +0300 Subject: [PATCH] Moved spiff test to a test case. Reset retries in test runner --- .gitmodules | 6 ++-- examples/posix_fs/Makefile | 11 ------ examples/posix_fs/README.md | 10 ------ examples/posix_fs/fs-test | 1 - tests/Makefile | 12 +++++-- .../cases/05_spiffs.c | 35 ++++++++----------- tests/fs-test | 1 + tests/test_runner.py | 23 +++++++----- 8 files changed, 43 insertions(+), 56 deletions(-) delete mode 100644 examples/posix_fs/Makefile delete mode 100644 examples/posix_fs/README.md delete mode 160000 examples/posix_fs/fs-test rename examples/posix_fs/posix_fs_example.c => tests/cases/05_spiffs.c (51%) create mode 160000 tests/fs-test diff --git a/.gitmodules b/.gitmodules index 4c7cd9e..d9d5e4c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -13,9 +13,9 @@ [submodule "extras/spiffs/spiffs"] path = extras/spiffs/spiffs url = https://github.com/pellepl/spiffs.git -[submodule "examples/posix_fs/fs-test"] - path = examples/posix_fs/fs-test - url = https://github.com/sheinz/fs-test [submodule "tests/unity"] path = tests/unity url = https://github.com/ThrowTheSwitch/Unity.git +[submodule "tests/fs-test"] + path = tests/fs-test + url = https://github.com/sheinz/fs-test diff --git a/examples/posix_fs/Makefile b/examples/posix_fs/Makefile deleted file mode 100644 index bf45ed7..0000000 --- a/examples/posix_fs/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -PROGRAM=posix_fs_example -PROGRAM_EXTRA_SRC_FILES=./fs-test/fs_test.c - -EXTRA_COMPONENTS = extras/spiffs -FLASH_SIZE = 32 - -# spiffs configuration -SPIFFS_BASE_ADDR = 0x200000 -SPIFFS_SIZE = 0x100000 - -include ../../common.mk diff --git a/examples/posix_fs/README.md b/examples/posix_fs/README.md deleted file mode 100644 index 7f05bd4..0000000 --- a/examples/posix_fs/README.md +++ /dev/null @@ -1,10 +0,0 @@ -# POSIX file access example - -This example runs several file system tests on ESP8266. -It uses fs-test library to perform file operations test. fs-test library uses -only POSIX file functions so can be run on host system as well. - -Currently included tests: - * File system load test. Perform multiple file operations in random order. - * File system speed test. Measures files read/write speed. - diff --git a/examples/posix_fs/fs-test b/examples/posix_fs/fs-test deleted file mode 160000 index 2ad547a..0000000 --- a/examples/posix_fs/fs-test +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2ad547adc5f725594b3c6752f036ff4401b221fc diff --git a/tests/Makefile b/tests/Makefile index 67595f1..48ad146 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,12 +1,18 @@ PROGRAM=tests -EXTRA_COMPONENTS=extras/dhcpserver +EXTRA_COMPONENTS=extras/dhcpserver extras/spiffs PROGRAM_SRC_DIR = . ./cases +FLASH_SIZE = 32 + +# spiffs configuration +SPIFFS_BASE_ADDR = 0x200000 +SPIFFS_SIZE = 0x100000 + # Add unity test framework headers & core source file -PROGRAM_INC_DIR = ./unity/src -PROGRAM_EXTRA_SRC_FILES = ./unity/src/unity.c +PROGRAM_INC_DIR = ./unity/src ./fs-test +PROGRAM_EXTRA_SRC_FILES = ./unity/src/unity.c ./fs-test/fs_test.c TESTCASE_SRC_FILES = $(wildcard $(PROGRAM_DIR)cases/*.c) diff --git a/examples/posix_fs/posix_fs_example.c b/tests/cases/05_spiffs.c similarity index 51% rename from examples/posix_fs/posix_fs_example.c rename to tests/cases/05_spiffs.c index 2f5ad14..71f174e 100644 --- a/examples/posix_fs/posix_fs_example.c +++ b/tests/cases/05_spiffs.c @@ -9,14 +9,18 @@ #include "esp_spiffs.h" #include "spiffs.h" -#include "fs-test/fs_test.h" +#include "fs_test.h" + +#include "testcase.h" + +DEFINE_SOLO_TESTCASE(05_spiffs) static fs_time_t get_current_time() { return timer_get_count(FRC2) / 5000; // to get roughly 1ms resolution } -void test_task(void *pvParameters) +static void test_task(void *pvParameters) { esp_spiffs_init(); esp_spiffs_mount(); @@ -28,28 +32,19 @@ void test_task(void *pvParameters) } esp_spiffs_mount(); - while (1) { - vTaskDelay(5000 / portTICK_RATE_MS); - if (fs_load_test_run(100)) { - printf("PASS\n"); - } else { - printf("FAIL\n"); - } + TEST_ASSERT_TRUE_MESSAGE(fs_load_test_run(100), "Load test failed"); - vTaskDelay(5000 / portTICK_RATE_MS); - float write_rate, read_rate; - if (fs_speed_test_run(get_current_time, &write_rate, &read_rate)) { - printf("Read speed: %.0f bytes/s\n", read_rate * 1000); - printf("Write speed: %.0f bytes/s\n", write_rate * 1000); - } else { - printf("FAIL\n"); - } + float write_rate, read_rate; + if (fs_speed_test_run(get_current_time, &write_rate, &read_rate)) { + printf("Read speed: %.0f bytes/s\n", read_rate * 1000); + printf("Write speed: %.0f bytes/s\n", write_rate * 1000); + } else { + TEST_FAIL(); } + TEST_PASS(); } -void user_init(void) +static void a_05_spiffs(void) { - uart_set_baud(0, 115200); - xTaskCreate(test_task, (signed char *)"test_task", 1024, NULL, 2, NULL); } diff --git a/tests/fs-test b/tests/fs-test new file mode 160000 index 0000000..e531bc0 --- /dev/null +++ b/tests/fs-test @@ -0,0 +1 @@ +Subproject commit e531bc0d4f75887e5f0e081aae3efbf4a50e2f54 diff --git a/tests/test_runner.py b/tests/test_runner.py index f31d4f3..ab69a6f 100755 --- a/tests/test_runner.py +++ b/tests/test_runner.py @@ -10,8 +10,9 @@ import time SHORT_OUTPUT_TIMEOUT = 0.25 # timeout for resetting and/or waiting for more lines of output -TESTCASE_TIMEOUT = 30 +TESTCASE_TIMEOUT = 60 TESTRUNNER_BANNER = "esp-open-rtos test runner." +RESET_RETRIES = 10 # retries to receive test runner banner after reset def main(): @@ -213,13 +214,19 @@ class TestEnvironment(object): def reset(self): """ Resets the test board, and waits for the test runner program to start up """ - self._port.setDTR(False) - self._port.setRTS(True) - time.sleep(0.05) - self._port.flushInput() - self._port.setRTS(False) - verbose_print("Waiting for test runner startup...") - if not self._port.wait_line(lambda line: line == TESTRUNNER_BANNER): + for i in range(RESET_RETRIES): + self._port.setDTR(False) + self._port.setRTS(True) + time.sleep(0.05) + self._port.flushInput() + self._port.setRTS(False) + verbose_print("Waiting for test runner startup...") + if self._port.wait_line(lambda line: line == TESTRUNNER_BANNER): + return + else: + verbose_print("Retrying to reset the test board, attempt=%d" % + (i + 1)) + continue raise TestRunnerError("Port %s failed to start test runner" % self._port) def get_testlist(self):