Tests: USB: Fix USB reconnect tests for Win hosts

pull/9768/head
Filip Jagodzinski 2018-08-10 15:30:46 +02:00 committed by Russ Butler
parent 7a4b36c37f
commit 07ffcb4269
1 changed files with 8 additions and 0 deletions

View File

@ -43,6 +43,10 @@
#define SERIAL_LOOPBACK_REPS 100
#define USB_RECONNECT_DELAY_MS 200
// Additional delay necessary for Windows hosts
// to handle the reconnect operation correctly.
#define USB_DISCONNECT_DELAY_MS 1
using utest::v1::Case;
using utest::v1::Specification;
using utest::v1::Harness;
@ -92,6 +96,7 @@ void test_cdc_usb_reconnect()
TEST_ASSERT_TRUE(usb_cdc.configured());
TEST_ASSERT_TRUE(usb_cdc.ready());
wait_ms(USB_DISCONNECT_DELAY_MS);
// Disconnect the USB device.
usb_cdc.disconnect();
TEST_ASSERT_FALSE(usb_cdc.configured());
@ -116,6 +121,7 @@ void test_cdc_usb_reconnect()
TEST_ASSERT_TRUE(usb_cdc.configured());
TEST_ASSERT_TRUE(usb_cdc.ready());
wait_ms(USB_DISCONNECT_DELAY_MS);
// Disconnect the USB device again.
usb_cdc.disconnect();
TEST_ASSERT_FALSE(usb_cdc.configured());
@ -345,6 +351,7 @@ void test_serial_usb_reconnect()
TEST_ASSERT_EQUAL_INT(0, usb_serial.readable());
// Disconnect the USB device.
wait_ms(USB_DISCONNECT_DELAY_MS);
usb_serial.disconnect();
TEST_ASSERT_FALSE(usb_serial.configured());
TEST_ASSERT_FALSE(usb_serial.connected());
@ -374,6 +381,7 @@ void test_serial_usb_reconnect()
TEST_ASSERT_EQUAL_INT(0, usb_serial.readable());
// Disconnect the USB device again.
wait_ms(USB_DISCONNECT_DELAY_MS);
usb_serial.disconnect();
TEST_ASSERT_FALSE(usb_serial.configured());
TEST_ASSERT_FALSE(usb_serial.connected());