From 2b585efd936f0dd5219e671b25d90434aee01190 Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Tue, 30 May 2023 14:32:37 +0100 Subject: [PATCH] Add test_bulk_rx_basic_short --- tests/test_bulk_rx_basic_short.py | 34 ++++++++++++++++++++++ tests/test_bulk_rx_basic_short/Makefile | 3 ++ tests/test_bulk_rx_basic_short/src/test.xc | 33 +++++++++++++++++++++ 3 files changed, 70 insertions(+) create mode 100644 tests/test_bulk_rx_basic_short.py create mode 100644 tests/test_bulk_rx_basic_short/Makefile create mode 100644 tests/test_bulk_rx_basic_short/src/test.xc diff --git a/tests/test_bulk_rx_basic_short.py b/tests/test_bulk_rx_basic_short.py new file mode 100644 index 00000000..79e79309 --- /dev/null +++ b/tests/test_bulk_rx_basic_short.py @@ -0,0 +1,34 @@ +# Copyright 2016-2023 XMOS LIMITED. +# This Software is subject to the terms of the XMOS Public Licence: Version 1. +import pytest + +from conftest import PARAMS, test_RunUsbSession # noqa F401 +from usb_session import UsbSession +from usb_transaction import UsbTransaction + + +@pytest.fixture +def test_session(ep, address, bus_speed): + + start_length = 0 + end_length = 11 + interEventDelay = 100 + + session = UsbSession( + bus_speed=bus_speed, run_enumeration=False, device_address=address + ) + + for pktLength in range(start_length, end_length): + session.add_event( + UsbTransaction( + session, + deviceAddress=address, + endpointNumber=ep, + endpointType="BULK", + transType="OUT", + dataLength=pktLength, + interEventDelay=interEventDelay, + ) + ) + + return session diff --git a/tests/test_bulk_rx_basic_short/Makefile b/tests/test_bulk_rx_basic_short/Makefile new file mode 100644 index 00000000..a2c9ee98 --- /dev/null +++ b/tests/test_bulk_rx_basic_short/Makefile @@ -0,0 +1,3 @@ +TEST_FLAGS = -DXUD_BYPASS_RESET=1 + +include ../test_makefile.mak diff --git a/tests/test_bulk_rx_basic_short/src/test.xc b/tests/test_bulk_rx_basic_short/src/test.xc new file mode 100644 index 00000000..710ba185 --- /dev/null +++ b/tests/test_bulk_rx_basic_short/src/test.xc @@ -0,0 +1,33 @@ +// Copyright 2016-2023 XMOS LIMITED. +// This Software is subject to the terms of the XMOS Public Licence: Version 1. + +#define EP_COUNT_OUT (6) +#define EP_COUNT_IN (6) + +#ifndef PKT_LENGTH_START +#define PKT_LENGTH_START (0) +#endif + +#ifndef PKT_LENGTH_END +#define PKT_LENGTH_END (10) +#endif + +#include "xud_shared.h" + +XUD_EpType epTypeTableOut[EP_COUNT_OUT] = {XUD_EPTYPE_CTL, XUD_EPTYPE_BUL, XUD_EPTYPE_BUL, XUD_EPTYPE_BUL, XUD_EPTYPE_BUL, XUD_EPTYPE_BUL}; +XUD_EpType epTypeTableIn[EP_COUNT_IN] = {XUD_EPTYPE_CTL, XUD_EPTYPE_BUL, XUD_EPTYPE_BUL, XUD_EPTYPE_BUL, XUD_EPTYPE_BUL, XUD_EPTYPE_BUL}; + +unsigned test_func(chanend c_ep_out[EP_COUNT_OUT], chanend c_ep_in[EP_COUNT_IN]) +{ + unsigned fail = TestEp_Rx(c_ep_out[TEST_EP_NUM], TEST_EP_NUM, PKT_LENGTH_START, PKT_LENGTH_END); + + /* Give some time for XUD to respond before we shutdown */ + timer t; + unsigned time; + t when timerafter(time+1000000) :> void; + + return fail; +} + +#include "test_main.xc" +