Skip to content

Commit 4378c14

Browse files
usb_device-msd test: disable host side unmount on windows machines
1 parent f6d6863 commit 4378c14

File tree

2 files changed

+42
-10
lines changed

2 files changed

+42
-10
lines changed

TESTS/host_tests/pyusb_msd.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,17 @@ def _callback_unmount(self, key, value, timestamp):
127127
else:
128128
self.report_error("unmount")
129129

130+
def _callback_os_type(self, key, value, timestamp):
131+
system_name = platform.system()
132+
if system_name == "Windows":
133+
self.send_kv("os_type", 1)
134+
elif system_name == "Linux":
135+
self.send_kv("os_type", 2)
136+
elif system_name == "Darwin":
137+
self.send_kv("os_type", 3)
138+
130139
def setup(self):
140+
self.register_callback("get_os_type", self._callback_os_type)
131141
self.register_callback("get_serial_number", self._callback_device_ready)
132142
self.register_callback('check_if_mounted', self._callback_check_if_mounted)
133143
self.register_callback('check_if_not_mounted', self._callback_check_if_not_mounted)

TESTS/usb_device/msd/main.cpp

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,17 @@
3333
#error [NOT_SUPPORTED] USB Device not supported for this target
3434
#endif
3535

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+
3647
#ifdef MIN
3748
#undef MIN
3849
#endif
@@ -313,19 +324,30 @@ void mount_unmount_test(BlockDevice *bd, FileSystem *fs)
313324
uint64_t ret_size = atoll(_key);
314325
TEST_ASSERT_EQUAL_UINT64(get_fs_mount_size(fs), ret_size);
315326

316-
// unmount msd device on host side
317-
greentea_send_kv("unmount", 0);
327+
#ifdef DISABLE_HOST_SIDE_UMOUNT
328+
greentea_send_kv("get_os_type", 0);
318329
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value));
319-
TEST_ASSERT_EQUAL_STRING_LOOP("passed", _key, i);
320-
321-
// wait for unmount event (set 10s timeout)
322-
media_remove_event.wait(10000);
323-
if (!usb.media_removed()) {
324-
TEST_ASSERT_EQUAL_LOOP(true, usb.media_removed(), i);
330+
int32_t os_type = atoi(_key);
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+
#ifdef DISABLE_HOST_SIDE_UMOUNT
344+
// unmount since media_removed doesn't disconnects device side
345+
usb.disconnect();
325346
}
326-
// unmount since media_removed doesn't disconnects device side
347+
#else
348+
// unmount
327349
usb.disconnect();
328-
350+
#endif
329351
// check if device is detached on host side
330352
greentea_send_kv("check_if_not_mounted", 0);
331353
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value));

0 commit comments

Comments
 (0)