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

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)

50
tests/cases/05_spiffs.c Normal file
View file

@ -0,0 +1,50 @@
#include "espressif/esp_common.h"
#include "esp/uart.h"
#include "esp/timer.h"
#include "FreeRTOS.h"
#include "task.h"
#include "esp8266.h"
#include <stdio.h>
#include "esp_spiffs.h"
#include "spiffs.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
}
static void test_task(void *pvParameters)
{
esp_spiffs_init();
esp_spiffs_mount();
SPIFFS_unmount(&fs); // FS must be unmounted before formating
if (SPIFFS_format(&fs) == SPIFFS_OK) {
printf("Format complete\n");
} else {
printf("Format failed\n");
}
esp_spiffs_mount();
TEST_ASSERT_TRUE_MESSAGE(fs_load_test_run(100), "Load test failed");
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();
}
static void a_05_spiffs(void)
{
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 """
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):