Moved spiff test to a test case. Reset retries in test runner

This commit is contained in:
sheinz 2016-10-24 21:47:29 +03:00
parent ddf834c781
commit 78d95431f5
8 changed files with 43 additions and 56 deletions

6
.gitmodules vendored
View file

@ -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

View file

@ -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

View file

@ -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.

@ -1 +0,0 @@
Subproject commit 2ad547adc5f725594b3c6752f036ff4401b221fc

View file

@ -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)

View file

@ -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");
}
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);
}

1
tests/fs-test Submodule

@ -0,0 +1 @@
Subproject commit e531bc0d4f75887e5f0e081aae3efbf4a50e2f54

View file

@ -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 """
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 not self._port.wait_line(lambda line: line == TESTRUNNER_BANNER):
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):