1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

FileSystem: update test case

This commit is contained in:
Ivan Grokhotkov 2015-07-30 13:58:00 +03:00
parent 5b82668a75
commit 47a24ef23a

View File

@ -1,6 +1,7 @@
#include <ESP8266WiFi.h>
#include "FS.h"
void fail(const char* msg) {
Serial.println(msg);
while(true) {
@ -14,8 +15,8 @@ void setup() {
WiFi.mode(WIFI_OFF);
Serial.println("\n\nFS test\n");
if (!mount(SPIFFS, "/")) {
fail("mount failed");
if (!SPIFFS.begin()) {
fail("SPIFFS init failed");
}
String text = "write test";
@ -68,6 +69,32 @@ void setup() {
}
}
{
Dir root = SPIFFS.openDir("/");
while(root.next()) {
String fileName = root.fileName();
Serial.print("deleting ");
Serial.println(fileName);
if (!SPIFFS.remove(fileName)) {
fail("remove failed");
}
}
}
{
File tmp = SPIFFS.open("/tmp1.txt", "w");
tmp.println("rename test");
}
{
if (!SPIFFS.rename("/tmp1.txt", "/tmp2.txt")) {
fail("rename failed");
}
File tmp2 = SPIFFS.open("/tmp2.txt", "r");
if (!tmp2) {
fail("open tmp2 failed");
}
}
Serial.println("success");
}