usb_device-msd test: disable host side unmount on windows machines

pull/10767/head
Maciej Bocianski 2019-06-17 14:51:18 +02:00
parent f6d6863c1f
commit 4378c141df
2 changed files with 41 additions and 9 deletions

View File

@ -127,7 +127,17 @@ class PyusbMSDTest(BaseHostTest):
else:
self.report_error("unmount")
def _callback_os_type(self, key, value, timestamp):
system_name = platform.system()
if system_name == "Windows":
self.send_kv("os_type", 1)
elif system_name == "Linux":
self.send_kv("os_type", 2)
elif system_name == "Darwin":
self.send_kv("os_type", 3)
def setup(self):
self.register_callback("get_os_type", self._callback_os_type)
self.register_callback("get_serial_number", self._callback_device_ready)
self.register_callback('check_if_mounted', self._callback_check_if_mounted)
self.register_callback('check_if_not_mounted', self._callback_check_if_not_mounted)

View File

@ -33,6 +33,17 @@
#error [NOT_SUPPORTED] USB Device not supported for this target
#endif
#define OS_WINDOWS 1
#define OS_LINUX 2
#define OS_MAC 3
// Host side unmount was disabled for windows machines.
// PowerShell execution policies/restrictions cause that
// on some windows machines unmount is failing
// To re-enable it comment out below line.
#define DISABLE_HOST_SIDE_UMOUNT
#ifdef MIN
#undef MIN
#endif
@ -313,19 +324,30 @@ void mount_unmount_test(BlockDevice *bd, FileSystem *fs)
uint64_t ret_size = atoll(_key);
TEST_ASSERT_EQUAL_UINT64(get_fs_mount_size(fs), ret_size);
// unmount msd device on host side
greentea_send_kv("unmount", 0);
#ifdef DISABLE_HOST_SIDE_UMOUNT
greentea_send_kv("get_os_type", 0);
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value));
TEST_ASSERT_EQUAL_STRING_LOOP("passed", _key, i);
int32_t os_type = atoi(_key);
if (os_type != OS_WINDOWS) {
#endif
// unmount msd device on host side
greentea_send_kv("unmount", 0);
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value));
TEST_ASSERT_EQUAL_STRING_LOOP("passed", _key, i);
// wait for unmount event (set 10s timeout)
media_remove_event.wait(10000);
if (!usb.media_removed()) {
TEST_ASSERT_EQUAL_LOOP(true, usb.media_removed(), i);
// wait for unmount event (set 10s timeout)
media_remove_event.wait(10000);
if (!usb.media_removed()) {
TEST_ASSERT_EQUAL_LOOP(true, usb.media_removed(), i);
}
#ifdef DISABLE_HOST_SIDE_UMOUNT
// unmount since media_removed doesn't disconnects device side
usb.disconnect();
}
// unmount since media_removed doesn't disconnects device side
#else
// unmount
usb.disconnect();
#endif
// check if device is detached on host side
greentea_send_kv("check_if_not_mounted", 0);
greentea_parse_kv(_key, _value, sizeof(_key), sizeof(_value));