mirror of https://github.com/ARMmbed/mbed-os.git
Tests: USB: Increas the size of RX CDC test data
This ensures the flow control is tested.pull/9768/head
parent
53f7cd5561
commit
31fe3ee11e
|
|
@ -323,9 +323,10 @@ class USBSerialTest(mbed_host_tests.BaseHostTest):
|
||||||
|
|
||||||
def cb_send_bytes_multiple(self, key, value, timestamp):
|
def cb_send_bytes_multiple(self, key, value, timestamp):
|
||||||
"""Open the serial and send a sequence of one byte values."""
|
"""Open the serial and send a sequence of one byte values."""
|
||||||
|
chunk_size = RX_BUFF_SIZE * int(value)
|
||||||
self.start_bg_task(
|
self.start_bg_task(
|
||||||
target=self.send_data_sequence,
|
target=self.send_data_sequence,
|
||||||
args=(RX_BUFF_SIZE, ))
|
args=(chunk_size, ))
|
||||||
|
|
||||||
def cb_loopback(self, key, value, timestamp):
|
def cb_loopback(self, key, value, timestamp):
|
||||||
"""Open the serial and send a sequence of multibyte values."""
|
"""Open the serial and send a sequence of multibyte values."""
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,13 @@
|
||||||
|
|
||||||
#define TX_BUFF_SIZE 32
|
#define TX_BUFF_SIZE 32
|
||||||
#define RX_BUFF_SIZE 32
|
#define RX_BUFF_SIZE 32
|
||||||
|
|
||||||
|
// The size of every data chunk the host sends (for each value from a
|
||||||
|
// known sequence) during 'CDC RX multiple' test cases is
|
||||||
|
// HOST_RX_BUFF_SIZE_RATIO times the size of RX_BUFF_SIZE input buffer.
|
||||||
|
// This way the device has to correctly handle data bigger that its buffer.
|
||||||
|
#define HOST_RX_BUFF_SIZE_RATIO 64
|
||||||
|
|
||||||
#define CDC_LOOPBACK_REPS 1200
|
#define CDC_LOOPBACK_REPS 1200
|
||||||
#define SERIAL_LOOPBACK_REPS 100
|
#define SERIAL_LOOPBACK_REPS 100
|
||||||
#define USB_RECONNECT_DELAY_MS 1
|
#define USB_RECONNECT_DELAY_MS 1
|
||||||
|
|
@ -398,20 +405,24 @@ void test_cdc_rx_multiple_bytes()
|
||||||
{
|
{
|
||||||
TestUSBCDC usb_cdc(USB_CDC_VID, USB_CDC_PID, 1, usb_dev_sn);
|
TestUSBCDC usb_cdc(USB_CDC_VID, USB_CDC_PID, 1, usb_dev_sn);
|
||||||
usb_cdc.connect();
|
usb_cdc.connect();
|
||||||
greentea_send_kv(MSG_KEY_SEND_BYTES_MULTIPLE, MSG_VALUE_DUMMY);
|
greentea_send_kv(MSG_KEY_SEND_BYTES_MULTIPLE, HOST_RX_BUFF_SIZE_RATIO);
|
||||||
usb_cdc.wait_ready();
|
usb_cdc.wait_ready();
|
||||||
uint8_t buff[RX_BUFF_SIZE] = { 0 };
|
uint8_t buff[RX_BUFF_SIZE] = { 0 };
|
||||||
uint8_t expected_buff[RX_BUFF_SIZE] = { 0 };
|
uint8_t expected_buff[RX_BUFF_SIZE] = { 0 };
|
||||||
for (int expected = 0xff; expected >= 0; expected--) {
|
for (int expected = 0xff; expected >= 0; expected--) {
|
||||||
|
for (int chunk = 0; chunk < HOST_RX_BUFF_SIZE_RATIO; chunk++) {
|
||||||
memset(expected_buff, expected, RX_BUFF_SIZE);
|
memset(expected_buff, expected, RX_BUFF_SIZE);
|
||||||
TEST_ASSERT(usb_cdc.receive(buff, RX_BUFF_SIZE, NULL));
|
TEST_ASSERT(usb_cdc.receive(buff, RX_BUFF_SIZE, NULL));
|
||||||
TEST_ASSERT_EQUAL_UINT8_ARRAY(expected_buff, buff, RX_BUFF_SIZE);
|
TEST_ASSERT_EQUAL_UINT8_ARRAY(expected_buff, buff, RX_BUFF_SIZE);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
for (int expected = 0; expected <= 0xff; expected++) {
|
for (int expected = 0; expected <= 0xff; expected++) {
|
||||||
|
for (int chunk = 0; chunk < HOST_RX_BUFF_SIZE_RATIO; chunk++) {
|
||||||
memset(expected_buff, expected, RX_BUFF_SIZE);
|
memset(expected_buff, expected, RX_BUFF_SIZE);
|
||||||
TEST_ASSERT(usb_cdc.receive(buff, RX_BUFF_SIZE, NULL));
|
TEST_ASSERT(usb_cdc.receive(buff, RX_BUFF_SIZE, NULL));
|
||||||
TEST_ASSERT_EQUAL_UINT8_ARRAY(expected_buff, buff, RX_BUFF_SIZE);
|
TEST_ASSERT_EQUAL_UINT8_ARRAY(expected_buff, buff, RX_BUFF_SIZE);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Wait for the host to close its port.
|
// Wait for the host to close its port.
|
||||||
while (usb_cdc.ready()) {
|
while (usb_cdc.ready()) {
|
||||||
wait_ms(1);
|
wait_ms(1);
|
||||||
|
|
@ -430,7 +441,7 @@ void test_cdc_rx_multiple_bytes_concurrent()
|
||||||
{
|
{
|
||||||
TestUSBCDC usb_cdc(USB_CDC_VID, USB_CDC_PID, 1, usb_dev_sn);
|
TestUSBCDC usb_cdc(USB_CDC_VID, USB_CDC_PID, 1, usb_dev_sn);
|
||||||
usb_cdc.connect();
|
usb_cdc.connect();
|
||||||
greentea_send_kv(MSG_KEY_SEND_BYTES_MULTIPLE, MSG_VALUE_DUMMY);
|
greentea_send_kv(MSG_KEY_SEND_BYTES_MULTIPLE, HOST_RX_BUFF_SIZE_RATIO);
|
||||||
usb_cdc.wait_ready();
|
usb_cdc.wait_ready();
|
||||||
wait_ms(TX_DELAY_MS);
|
wait_ms(TX_DELAY_MS);
|
||||||
Thread tx_thread;
|
Thread tx_thread;
|
||||||
|
|
@ -439,15 +450,19 @@ void test_cdc_rx_multiple_bytes_concurrent()
|
||||||
uint8_t buff[RX_BUFF_SIZE] = { 0 };
|
uint8_t buff[RX_BUFF_SIZE] = { 0 };
|
||||||
uint8_t expected_buff[RX_BUFF_SIZE] = { 0 };
|
uint8_t expected_buff[RX_BUFF_SIZE] = { 0 };
|
||||||
for (int expected = 0xff; expected >= 0; expected--) {
|
for (int expected = 0xff; expected >= 0; expected--) {
|
||||||
|
for (int chunk = 0; chunk < HOST_RX_BUFF_SIZE_RATIO; chunk++) {
|
||||||
memset(expected_buff, expected, RX_BUFF_SIZE);
|
memset(expected_buff, expected, RX_BUFF_SIZE);
|
||||||
TEST_ASSERT(usb_cdc.receive(buff, RX_BUFF_SIZE, NULL));
|
TEST_ASSERT(usb_cdc.receive(buff, RX_BUFF_SIZE, NULL));
|
||||||
TEST_ASSERT_EQUAL_UINT8_ARRAY(expected_buff, buff, RX_BUFF_SIZE);
|
TEST_ASSERT_EQUAL_UINT8_ARRAY(expected_buff, buff, RX_BUFF_SIZE);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
for (int expected = 0; expected <= 0xff; expected++) {
|
for (int expected = 0; expected <= 0xff; expected++) {
|
||||||
|
for (int chunk = 0; chunk < HOST_RX_BUFF_SIZE_RATIO; chunk++) {
|
||||||
memset(expected_buff, expected, RX_BUFF_SIZE);
|
memset(expected_buff, expected, RX_BUFF_SIZE);
|
||||||
TEST_ASSERT(usb_cdc.receive(buff, RX_BUFF_SIZE, NULL));
|
TEST_ASSERT(usb_cdc.receive(buff, RX_BUFF_SIZE, NULL));
|
||||||
TEST_ASSERT_EQUAL_UINT8_ARRAY(expected_buff, buff, RX_BUFF_SIZE);
|
TEST_ASSERT_EQUAL_UINT8_ARRAY(expected_buff, buff, RX_BUFF_SIZE);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
event_flags.clear(EF_SEND);
|
event_flags.clear(EF_SEND);
|
||||||
tx_thread.join();
|
tx_thread.join();
|
||||||
// Wait for the host to close its port.
|
// Wait for the host to close its port.
|
||||||
|
|
@ -738,7 +753,7 @@ void test_serial_line_coding_change()
|
||||||
|
|
||||||
utest::v1::status_t testsuite_setup(const size_t number_of_cases)
|
utest::v1::status_t testsuite_setup(const size_t number_of_cases)
|
||||||
{
|
{
|
||||||
GREENTEA_SETUP(35, "usb_device_serial");
|
GREENTEA_SETUP(45, "usb_device_serial");
|
||||||
srand((unsigned) ticker_read_us(get_us_ticker_data()));
|
srand((unsigned) ticker_read_us(get_us_ticker_data()));
|
||||||
|
|
||||||
utest::v1::status_t status = utest::v1::greentea_test_setup_handler(number_of_cases);
|
utest::v1::status_t status = utest::v1::greentea_test_setup_handler(number_of_cases);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue