From 47a24ef23a26cec269471202d80a69fda7a191d1 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Thu, 30 Jul 2015 13:58:00 +0300 Subject: [PATCH] FileSystem: update test case --- tests/FSWrapper/FSWrapper.ino | 37 ++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/tests/FSWrapper/FSWrapper.ino b/tests/FSWrapper/FSWrapper.ino index 95632f35e..1da05a59a 100644 --- a/tests/FSWrapper/FSWrapper.ino +++ b/tests/FSWrapper/FSWrapper.ino @@ -1,6 +1,7 @@ #include #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"; @@ -62,12 +63,38 @@ void setup() { { Dir root = SPIFFS.openDir("/"); while (root.next()) { - String fileName = root.fileName(); - File f = root.openFile("r"); - Serial.printf("%s: %d\r\n", fileName.c_str(), f.size()); + String fileName = root.fileName(); + File f = root.openFile("r"); + Serial.printf("%s: %d\r\n", fileName.c_str(), f.size()); } } + { + 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"); }