Skip to content

Commit ef51230

Browse files
jfischer-nonashif
authored andcommitted
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: Johann Fischer <[email protected]>
1 parent 155ef4b commit ef51230

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

tests/drivers/udc/prj.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ CONFIG_LOG=y
55
CONFIG_ZTEST=y
66

77
CONFIG_UDC_DRIVER=y
8-
CONFIG_UDC_BUF_COUNT=32
9-
CONFIG_UDC_BUF_POOL_SIZE=8192
8+
CONFIG_UDC_BUF_COUNT=16
9+
CONFIG_UDC_BUF_POOL_SIZE=16384
1010
CONFIG_UDC_DRIVER_LOG_LEVEL_INF=y

tests/drivers/udc/src/main.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,10 @@ static void test_udc_ep_halt(const struct device *dev,
212212
struct usb_ep_descriptor *ed)
213213
{
214214
/* Possible return values 0, -ENODEV, -ENOTSUP, -EPERM. */
215-
int err1, err2, err3;
215+
int err1, err2;
216216

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

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

228227
zassert_equal(err2, -ENODEV, "Not failed to set halt");
229-
zassert_equal(err3, 0, "Failed to set halt");
230228
} else {
231229
zassert_equal(err1, -EPERM, "Not failed to set halt");
232230
zassert_equal(err2, -EPERM, "Not failed to set halt");
233-
zassert_equal(err3, -EPERM, "Not failed to set halt");
234231
}
235232

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

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

247243
zassert_equal(err2, -ENODEV, "Not failed to clear halt");
248-
zassert_equal(err3, 0, "Failed to clear halt");
249244
} else {
250245
zassert_equal(err1, -EPERM, "Not failed to clear halt");
251246
zassert_equal(err2, -EPERM, "Not failed to clear halt");
252-
zassert_equal(err3, -EPERM, "Not failed to clear halt");
253247
}
254248
}
255249

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

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

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

0 commit comments

Comments
 (0)