Commit ef512305 authored by Johann Fischer's avatar Johann Fischer Committed by Anas Nashif
Browse files

tests: drivers: udc: updates to pass testing on supported platforms

Do not halt control endpoint, control endpoint may not be enabled when
there no host is connected. Yield after buffer is queued to allow the
driver to work.

Tweak pool size and number of buffers to pass the test with high-speed
drivers.

Signed-off-by: default avatarJohann Fischer <johann.fischer@nordicsemi.no>
parent 155ef4bd
Loading
Loading
Loading
Loading
+2 −2
Changes for tests/drivers/udc/prj.conf: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -5,6 +5,6 @@ CONFIG_LOG=y
CONFIG_ZTEST=y

CONFIG_UDC_DRIVER=y
CONFIG_UDC_BUF_COUNT=32
CONFIG_UDC_BUF_POOL_SIZE=8192
CONFIG_UDC_BUF_COUNT=16
CONFIG_UDC_BUF_POOL_SIZE=16384
CONFIG_UDC_DRIVER_LOG_LEVEL_INF=y
+3 −8
Changes for tests/drivers/udc/src/main.c: 3 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -212,11 +212,10 @@ static void test_udc_ep_halt(const struct device *dev,
			     struct usb_ep_descriptor *ed)
{
	/* Possible return values 0, -ENODEV, -ENOTSUP, -EPERM. */
	int err1, err2, err3;
	int err1, err2;

	err1 = udc_ep_set_halt(dev, ed->bEndpointAddress);
	err2 = udc_ep_set_halt(dev, FALSE_EP_ADDR);
	err3 = udc_ep_set_halt(dev, USB_CONTROL_EP_OUT);

	if (udc_is_enabled(dev)) {
		if (ed->bmAttributes == USB_EP_TYPE_ISO) {
@@ -226,16 +225,13 @@ static void test_udc_ep_halt(const struct device *dev,
		}

		zassert_equal(err2, -ENODEV, "Not failed to set halt");
		zassert_equal(err3, 0, "Failed to set halt");
	} else {
		zassert_equal(err1, -EPERM, "Not failed to set halt");
		zassert_equal(err2, -EPERM, "Not failed to set halt");
		zassert_equal(err3, -EPERM, "Not failed to set halt");
	}

	err1 = udc_ep_clear_halt(dev, ed->bEndpointAddress);
	err2 = udc_ep_clear_halt(dev, FALSE_EP_ADDR);
	err3 = udc_ep_clear_halt(dev, USB_CONTROL_EP_OUT);

	if (udc_is_enabled(dev)) {
		if (ed->bmAttributes == USB_EP_TYPE_ISO) {
@@ -245,11 +241,9 @@ static void test_udc_ep_halt(const struct device *dev,
		}

		zassert_equal(err2, -ENODEV, "Not failed to clear halt");
		zassert_equal(err3, 0, "Failed to clear halt");
	} else {
		zassert_equal(err1, -EPERM, "Not failed to clear halt");
		zassert_equal(err2, -EPERM, "Not failed to clear halt");
		zassert_equal(err3, -EPERM, "Not failed to clear halt");
	}
}

@@ -332,7 +326,7 @@ static void test_udc_ep_api(const struct device *dev,
		zassert_ok(err, "Failed to enable endpoint");

		/* It needs a little reserve for memory management overhead. */
		for (int n = 0; n < (CONFIG_UDC_BUF_COUNT - 2); n++) {
		for (int n = 0; n < (CONFIG_UDC_BUF_COUNT - 4); n++) {
			buf = udc_ep_buf_alloc(dev, ed->bEndpointAddress,
					       ed->wMaxPacketSize);
			zassert_not_null(buf,
@@ -342,6 +336,7 @@ static void test_udc_ep_api(const struct device *dev,
			udc_ep_buf_set_zlp(buf);
			err = udc_ep_enqueue(dev, buf);
			zassert_ok(err, "Failed to queue request");
			k_yield();
		}

		err = udc_ep_disable(dev, ed->bEndpointAddress);