Skip to content

Commit 638a5ba

Browse files
fixes on tests
1 parent 6bb89a9 commit 638a5ba

File tree

6 files changed

+96
-116
lines changed

6 files changed

+96
-116
lines changed

extras/tests/TestExisting/TestExisting.ino

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#include <Arduino_UnifiedStorage.h>
2-
#include "Utils.h"
31

42
#define ARDUINO_UNIFIED_STORAGE_DEBUG
53

4+
#include <Arduino_UnifiedStorage.h>
5+
66

77
InternalStorage internalStorage = InternalStorage();
88

@@ -19,10 +19,8 @@ void setup() {
1919

2020

2121

22-
23-
internalStorage.format(FS_LITTLEFS);
2422
internalStorage.begin();
25-
c
23+
2624

2725
Folder root = internalStorage.getRootFolder();
2826

@@ -34,10 +32,13 @@ void setup() {
3432

3533
debugPrint("Trying to create a folder on top of an existing one... without overwrite");
3634
Folder sourceFolder3 = root.createSubfolder("source_folder");
35+
3736

3837
debugPrint("Trying to create a folder on top of an existing one... with overwrite");
3938
Folder sourceFolder4 = root.createSubfolder("source_folder", true);
4039

40+
41+
4142
Folder destinationFolder2 = root.createSubfolder("destination_folder");
4243
debugPrint("Folder 2 created");
4344

@@ -51,8 +52,6 @@ void setup() {
5152
}
5253

5354

54-
55-
5655
// Test moveTo
5756
Folder sourceFolder = root.createSubfolder("source");
5857
Folder destinationFolder = root.createSubfolder("destination");
@@ -76,10 +75,10 @@ void setup() {
7675

7776

7877
bool success = someFile.copyTo(someOtherFolder);
79-
debugPrint("trying to copy file without overwrite: %d", success);
78+
debugPrint("trying to copy file without overwrite: " + String(success));
8079

8180
success = someFile.copyTo(someOtherFolder,true);
82-
debugPrint("trying to copy file with overwrite: %d ", success);
81+
debugPrint("trying to copy file with overwrite: " + String(success));
8382

8483
}
8584

extras/tests/TestFileOperations/TestFileOperations.ino

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1+
#define ARDUINO_UNIFIED_STORAGE_DEBUG
2+
13
#include <Arduino_UnifiedStorage.h>
2-
#include "Boards.h"
3-
#include "Utils.h"
44

5-
#define ARDUINO_UNIFIED_STORAGE_DEBUG
65

76
#if defined(HAS_USB)
87
USBStorage usb = USBStorage();

extras/tests/TestFolderOperations/TestFolderOperations.ino

Lines changed: 7 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
#define ARDUINO_UNIFIED_STORAGE_DEBUG
2+
13
#include <Arduino_UnifiedStorage.h>
24
#include "Boards.h"
35
#include "Utils.h"
46

5-
#define ARDUINO_UNIFIED_STORAGE_DEBUG
7+
68

79
#if defined(HAS_USB)
810
USBStorage usb = USBStorage();
@@ -16,29 +18,6 @@ SDStorage sd = SDStorage();
1618
InternalStorage internal = InternalStorage();
1719
#endif
1820

19-
void printFolderContents(Folder dir, int indentation = 0) {
20-
std::vector<Folder> directories = dir.getFolders();
21-
std::vector<UFile>files = dir.getFiles();
22-
23-
// Print directories
24-
for (Folder subdir : directories) {
25-
for (int i = 0; i < indentation; i++) {
26-
debugPrint(" ");
27-
}
28-
debugPrint("[D] ");
29-
debugPrint(subdir.getPath());
30-
printFolderContents(subdir, indentation + 1);
31-
}
32-
33-
// Print files
34-
for (UFile file : files) {
35-
for (int i = 0; i < indentation; i++) {
36-
debugPrint(" ");
37-
}
38-
debugPrint("[F] ");
39-
debugPrint(file.getPath());
40-
}
41-
}
4221

4322

4423
bool testFolderCreation(Folder root) {
@@ -141,8 +120,6 @@ void runTests(Arduino_UnifiedStorage * storage, String storageType) {
141120
testCopyingFolder(root);
142121
testMovingFolder(root);
143122

144-
debugPrint("========= FS Contents after Folder Tests =========");
145-
printFolderContents(root);
146123
storage->unmount();
147124
debugPrint("");
148125
}
@@ -156,15 +133,14 @@ void setup(){
156133
beginRS485(115200);
157134
#endif
158135

159-
160-
#if defined(HAS_USB)
161-
runTests(&usb, "USB");
162-
#endif
163-
164136
#if defined(HAS_QSPI)
165137
runTests(&internal, "QSPI");
166138
#endif
167139

140+
#if defined(HAS_USB)
141+
runTests(&usb, "USB");
142+
#endif
143+
168144
#if defined(HAS_SD)
169145
runTests(&sd, "SD");
170146
#endif

extras/tests/TestRepeatedFormatMount/TestRepeatedFormatMount.ino

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
#include <Arduino_UnifiedStorage.h>
2-
#include "Utils.h"
3-
#include "Boards.h"
4-
51
#define ARDUINO_UNIFIED_STORAGE_DEBUG
2+
#include <Arduino_UnifiedStorage.h>
63

74
#if defined(HAS_USB)
85
USBStorage usb = USBStorage();
@@ -24,9 +21,9 @@ void runRepeatedMountTest(Arduino_UnifiedStorage * storage, String storageType,
2421

2522
debugPrint("Mounting drive");
2623
if(mountResult != 1) {
27-
debugPrint(mountResult);
28-
debugPrint(getErrno());
29-
24+
debugPrint("Mounting drive failed: " + String(getErrno()));
25+
} else {
26+
debugPrint("Successfully mounted");
3027
}
3128

3229
Folder root = storage->getRootFolder();
@@ -39,9 +36,7 @@ void runRepeatedMountTest(Arduino_UnifiedStorage * storage, String storageType,
3936

4037
int umountResult = storage->unmount();
4138
if(!umountResult) {
42-
debugPrint("Unmounting drive");
43-
debugPrint(umountResult);
44-
debugPrint(getErrno());
39+
debugPrint("Unmounting drive failed: " + String(getErrno()));
4540
} else {
4641
debugPrint("Successfully unmounted");
4742
}
@@ -89,13 +84,13 @@ void setup(){
8984
#if defined(HAS_SD)
9085
debugPrint("RUNNING FORMAT AND REPEATED MOUNT - SD Card");
9186
debugPrint("Formatting SD drive as LittleFS: " + String(sd.format(FS_LITTLEFS)));
92-
runRepeatedMountTest(&&sd, "SD");
87+
runRepeatedMountTest(&sd, "SD");
9388
debugPrint("Formatting SD drive as FAT32: " + String(sd.format(FS_FAT)));
94-
runRepeatedMountTest(&&sd, "SD");
89+
runRepeatedMountTest(&sd, "SD");
9590
debugPrint("Formatting SD drive as LittleFS again: " + String(sd.format(FS_LITTLEFS)));
96-
runRepeatedMountTest(&&sd, "SD");
91+
runRepeatedMountTest(&sd, "SD");
9792
debugPrint("Formatting SD drive as FAT32 again: " + String(sd.format(FS_FAT)));
98-
runRepeatedMountTest(&&sd, "SD");
93+
runRepeatedMountTest(&sd, "SD");
9994
#endif
10095

10196

0 commit comments

Comments
 (0)