From 4378c141dfde57a82fbeac3338f495b7bcfebef8 Mon Sep 17 00:00:00 2001 From: Maciej Bocianski Date: Mon, 17 Jun 2019 14:51:18 +0200 Subject: [PATCH] usb_device-msd test: disable host side unmount on windows machines --- TESTS/host_tests/pyusb_msd.py | 10 +++++++++ TESTS/usb_device/msd/main.cpp | 40 +++++++++++++++++++++++++++-------- 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/TESTS/host_tests/pyusb_msd.py b/TESTS/host_tests/pyusb_msd.py index 2b72a3f7ee..4ab7529657 100644 --- a/TESTS/host_tests/pyusb_msd.py +++ b/TESTS/host_tests/pyusb_msd.py @@ -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) diff --git a/TESTS/usb_device/msd/main.cpp b/TESTS/usb_device/msd/main.cpp index 10ce6c6a56..c59a686f03 100644 --- a/TESTS/usb_device/msd/main.cpp +++ b/TESTS/usb_device/msd/main.cpp @@ -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));