Skip to content

Commit 18af867

Browse files
author
Kyle Kearney
committed
Filesystem test: Move lfs init in test startup
tests-filesystem-general_filesystem declares BlockDevice and FileSystem pointers as globals. If these are initialized to their respective default_instance values in the declaration, the LFS init happens during OS startup when __libc_init_array() is invoked by mbed_toolchain_init(). If the filesystem blockdevice does not currently contain a valid filesystem (e.g. the chip has just been erased), then LFS will flag this as corruption and abort the mounting process. This cleanup process can take long enough (and is running pre-main) that greentea times out waiting for the device to respond to its sync packet, and resets the device. To resolve this, move the initialization into the first test case (bd_init_fs_reformat) right before it initializes and formats the blockdevice and filesystem.
1 parent 6bd55d6 commit 18af867

File tree

1 file changed

+5
-2
lines changed
  • features/storage/TESTS/filesystem/general_filesystem

1 file changed

+5
-2
lines changed

features/storage/TESTS/filesystem/general_filesystem/main.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ static const size_t test_files = 2;
4444

4545
FILE *fd[test_files];
4646

47-
BlockDevice *bd = BlockDevice::get_default_instance();
48-
FileSystem *fs = FileSystem::get_default_instance();
47+
BlockDevice *bd;
48+
FileSystem *fs;
4949
const char *bd_type;
5050

5151
/*----------------help functions------------------*/
@@ -76,6 +76,9 @@ static void deinit()
7676
//init the blockdevice and reformat the filesystem
7777
static void bd_init_fs_reformat()
7878
{
79+
bd = BlockDevice::get_default_instance();
80+
fs = FileSystem::get_default_instance();
81+
7982
bd_type = bd->get_type();
8083
init();
8184
}

0 commit comments

Comments
 (0)