2016-06-30 14:38:05 +00:00
|
|
|
#include "espressif/esp_common.h"
|
|
|
|
#include "esp/uart.h"
|
2016-07-14 21:08:34 +00:00
|
|
|
#include "esp/timer.h"
|
2016-06-30 14:38:05 +00:00
|
|
|
#include "FreeRTOS.h"
|
|
|
|
#include "task.h"
|
|
|
|
#include "esp8266.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "esp_spiffs.h"
|
|
|
|
#include "spiffs.h"
|
|
|
|
|
2016-11-05 20:12:14 +00:00
|
|
|
#include "fs_test.h"
|
|
|
|
|
|
|
|
#include "testcase.h"
|
|
|
|
|
|
|
|
DEFINE_SOLO_TESTCASE(05_spiffs)
|
2016-06-30 14:38:05 +00:00
|
|
|
|
2016-07-14 21:08:34 +00:00
|
|
|
static fs_time_t get_current_time()
|
|
|
|
{
|
|
|
|
return timer_get_count(FRC2) / 5000; // to get roughly 1ms resolution
|
|
|
|
}
|
2016-06-30 14:38:05 +00:00
|
|
|
|
2016-11-05 20:12:14 +00:00
|
|
|
static void test_task(void *pvParameters)
|
2016-06-30 14:38:05 +00:00
|
|
|
{
|
2016-07-15 12:22:03 +00:00
|
|
|
esp_spiffs_init();
|
2016-06-30 14:38:05 +00:00
|
|
|
esp_spiffs_mount();
|
2016-07-15 12:22:03 +00:00
|
|
|
SPIFFS_unmount(&fs); // FS must be unmounted before formating
|
2016-06-30 14:38:05 +00:00
|
|
|
if (SPIFFS_format(&fs) == SPIFFS_OK) {
|
|
|
|
printf("Format complete\n");
|
|
|
|
} else {
|
|
|
|
printf("Format failed\n");
|
|
|
|
}
|
|
|
|
esp_spiffs_mount();
|
|
|
|
|
2016-11-05 20:12:14 +00:00
|
|
|
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();
|
2016-06-30 14:38:05 +00:00
|
|
|
}
|
2016-11-05 20:12:14 +00:00
|
|
|
TEST_PASS();
|
2016-06-30 14:38:05 +00:00
|
|
|
}
|
|
|
|
|
2016-11-05 20:12:14 +00:00
|
|
|
static void a_05_spiffs(void)
|
2016-06-30 14:38:05 +00:00
|
|
|
{
|
2016-10-21 09:40:36 +00:00
|
|
|
xTaskCreate(test_task, "test_task", 1024, NULL, 2, NULL);
|
2016-06-30 14:38:05 +00:00
|
|
|
}
|