|
33 | 33 | #error [NOT_SUPPORTED] USB Device not supported for this target |
34 | 34 | #endif |
35 | 35 |
|
| 36 | + |
| 37 | +#define OS_WINDOWS 1 |
| 38 | +#define OS_LINUX 2 |
| 39 | +#define OS_MAC 3 |
| 40 | + |
| 41 | +// Host side unmount was disabled for windows machines. |
| 42 | +// PowerShell execution policies/restrictions cause that |
| 43 | +// on some windows machines unmount is failing |
| 44 | +// To re-enable it comment out below line. |
| 45 | +#define DISABLE_HOST_SIDE_UMOUNT |
| 46 | + |
36 | 47 | #ifdef MIN |
37 | 48 | #undef MIN |
38 | 49 | #endif |
@@ -250,13 +261,10 @@ void msd_process(USBMSD *msd) |
250 | 261 | */ |
251 | 262 | void storage_init() |
252 | 263 | { |
253 | | - if (mbed_heap_size >= MIN_HEAP_SIZE) { |
254 | | - FATFileSystem::format(get_heap_block_device()); |
255 | | - bool result = prepare_storage(get_heap_block_device(), &heap_fs); |
256 | | - TEST_ASSERT_MESSAGE(result, "heap storage initialisation failed"); |
257 | | - } else { |
258 | | - utest_printf("Not enough heap memory for HeapBlockDevice creation. Heap block device init skipped!!!\n"); |
259 | | - } |
| 264 | + TEST_ASSERT_MESSAGE(mbed_heap_size >= MIN_HEAP_SIZE, "Not enough heap memory for HeapBlockDevice creation"); |
| 265 | + FATFileSystem::format(get_heap_block_device()); |
| 266 | + bool result = prepare_storage(get_heap_block_device(), &heap_fs); |
| 267 | + TEST_ASSERT_MESSAGE(result, "heap storage initialisation failed"); |
260 | 268 | } |
261 | 269 |
|
262 | 270 | /** Test mass storage device mount and unmount |
@@ -316,19 +324,31 @@ void mount_unmount_test(BlockDevice *bd, FileSystem *fs) |
316 | 324 | uint64_t ret_size = atoll(_key); |
317 | 325 | TEST_ASSERT_EQUAL_UINT64(get_fs_mount_size(fs), ret_size); |
318 | 326 |
|
319 | | - // unmount msd device on host side |
320 | | - greentea_send_kv("unmount", 0); |
| 327 | +#ifdef DISABLE_HOST_SIDE_UMOUNT |
| 328 | + greentea_send_kv("get_os_type", 0); |
321 | 329 | greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value)); |
322 | | - TEST_ASSERT_EQUAL_STRING_LOOP("passed", _key, i); |
323 | | - |
324 | | - // wait for unmount event (set 10s timeout) |
325 | | - media_remove_event.wait(10000); |
326 | | - if (!usb.media_removed()) { |
327 | | - TEST_ASSERT_EQUAL_LOOP(true, usb.media_removed(), i); |
| 330 | + int32_t os_type = atoi(_value); |
| 331 | + if (os_type != OS_WINDOWS) { |
| 332 | +#endif |
| 333 | + // unmount msd device on host side |
| 334 | + greentea_send_kv("unmount", 0); |
| 335 | + greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value)); |
| 336 | + TEST_ASSERT_EQUAL_STRING_LOOP("passed", _key, i); |
| 337 | + |
| 338 | + // wait for unmount event (set 10s timeout) |
| 339 | + media_remove_event.wait(10000); |
| 340 | + if (!usb.media_removed()) { |
| 341 | + TEST_ASSERT_EQUAL_LOOP(true, usb.media_removed(), i); |
| 342 | + } |
| 343 | + |
| 344 | + // unmount since media_removed doesn't disconnects device side |
| 345 | + usb.disconnect(); |
| 346 | +#ifdef DISABLE_HOST_SIDE_UMOUNT |
| 347 | + } else { |
| 348 | + // unmount |
| 349 | + usb.disconnect(); |
328 | 350 | } |
329 | | - // unmount since media_removed doesn't disconnects device side |
330 | | - usb.disconnect(); |
331 | | - |
| 351 | +#endif |
332 | 352 | // check if device is detached on host side |
333 | 353 | greentea_send_kv("check_if_not_mounted", 0); |
334 | 354 | greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value)); |
@@ -428,19 +448,13 @@ void mount_unmount_and_data_test(BlockDevice *bd, FileSystem *fs) |
428 | 448 |
|
429 | 449 | void heap_block_device_mount_unmount_test() |
430 | 450 | { |
431 | | - if (mbed_heap_size < MIN_HEAP_SIZE) { |
432 | | - TEST_SKIP_MESSAGE("Not enough heap memory for HeapBlockDevice creation"); |
433 | | - return; |
434 | | - } |
| 451 | + TEST_ASSERT_MESSAGE(mbed_heap_size >= MIN_HEAP_SIZE, "Not enough heap memory for HeapBlockDevice creation"); |
435 | 452 | mount_unmount_test<3>(get_heap_block_device(), &heap_fs); |
436 | 453 | } |
437 | 454 |
|
438 | 455 | void heap_block_device_mount_unmount_and_data_test() |
439 | 456 | { |
440 | | - if (mbed_heap_size < MIN_HEAP_SIZE) { |
441 | | - TEST_SKIP_MESSAGE("Not enough heap memory for HeapBlockDevice creation"); |
442 | | - return; |
443 | | - } |
| 457 | + TEST_ASSERT_MESSAGE(mbed_heap_size >= MIN_HEAP_SIZE, "Not enough heap memory for HeapBlockDevice creation"); |
444 | 458 | mount_unmount_and_data_test(get_heap_block_device(), &heap_fs); |
445 | 459 | } |
446 | 460 |
|
|
0 commit comments