| 273 | } |
| 274 | |
| 275 | int runUnityTests(void) { |
| 276 | UNITY_BEGIN(); |
| 277 | |
| 278 | // Suite-level setup |
| 279 | microStore::FileSystem filesystem{microStore::Adapters::UniversalFileSystem()}; |
| 280 | filesystem.init(); |
| 281 | //FileSystem::listDir("./"); |
| 282 | //FileSystem::listDir("./cache"); |
| 283 | RNS::Utilities::OS::register_filesystem(filesystem); |
| 284 | |
| 285 | size_t pre_memory = RNS::Utilities::Memory::heap_available(); |
| 286 | TRACEF("testFileSystem: pre-mem: %u", pre_memory); |
| 287 | |
| 288 | // CBA Seems that first call to write_file allocates some memory (at least with NRF52 LittleFS) so get that out of the way first |
| 289 | { |
| 290 | RNS::Bytes data("foo"); |
| 291 | RNS::Utilities::OS::write_file("./foo", data); |
| 292 | RNS::Utilities::OS::remove_file("./foo"); |
| 293 | } |
| 294 | |
| 295 | size_t post_memory = RNS::Utilities::Memory::heap_available(); |
| 296 | size_t diff_memory = (int)pre_memory - (int)post_memory; |
| 297 | TRACEF("testFileSystem: post-mem: %u", post_memory); |
| 298 | TRACEF("testFileSystem: diff-mem: %u", diff_memory); |
| 299 | |
| 300 | // Run tests |
| 301 | RUN_TEST(testListDirectory); |
| 302 | RUN_TEST(testWriteFile); |
| 303 | RUN_TEST(testReadFile); |
| 304 | RUN_TEST(testOverwriteFile); |
| 305 | RUN_TEST(testReadNonexistantFile); |
| 306 | //RUN_TEST(testWriteFail(); |
| 307 | RUN_TEST(testWriteFileStream); |
| 308 | RUN_TEST(testReadFileStream); |
| 309 | //RUN_TEST(testStdStream); |
| 310 | //RUN_TEST(testCacheWrite); |
| 311 | |
| 312 | // Suite-level teardown |
| 313 | removeFile(test_file_path); |
| 314 | removeFile(test_stream_path); |
| 315 | TRACEF("testFileSystem: size: %u", filesystem.storageSize()); |
| 316 | TRACEF("testFileSystem: available: %u", filesystem.storageAvailable()); |
| 317 | RNS::Utilities::OS::deregister_filesystem(); |
| 318 | |
| 319 | return UNITY_END(); |
| 320 | } |
| 321 | |
| 322 | // For native dev-platform or for some embedded frameworks |
| 323 | int main(void) { |
no test coverage detected