Index: uspace/drv/bus/usb/usbdiag/Makefile
===================================================================
--- uspace/drv/bus/usb/usbdiag/Makefile	(revision 15f80796072dd77d9218eb941f07bf74668724cc)
+++ uspace/drv/bus/usb/usbdiag/Makefile	(revision fd312d505127e9d7f9046c8ee961d3cb5c51249c)
@@ -35,4 +35,5 @@
 SOURCES = \
 	device.c \
+	tests.c \
 	main.c \
 
Index: uspace/drv/bus/usb/usbdiag/device.c
===================================================================
--- uspace/drv/bus/usb/usbdiag/device.c	(revision 15f80796072dd77d9218eb941f07bf74668724cc)
+++ uspace/drv/bus/usb/usbdiag/device.c	(revision fd312d505127e9d7f9046c8ee961d3cb5c51249c)
@@ -41,51 +41,26 @@
 
 #include "device.h"
+#include "tests.h"
 
 #define NAME "usbdiag"
 
-
-static int some_test(ddf_fun_t *fun, int x, int *y)
-{
-	int rc = EOK;
-	usb_diag_dev_t *dev = ddf_fun_to_usb_diag_dev(fun);
-
-	const size_t size = min(dev->bulk_in->desc.max_packet_size, dev->bulk_out->desc.max_packet_size);
-	char *buffer = (char *) malloc(size);
-	memset(buffer, 42, sizeof(buffer));
-
-	// Write buffer to device.
-	if ((rc = usb_pipe_write(dev->bulk_out, buffer, size))) {
-		usb_log_error("Bulk OUT write failed. %s\n", str_error(rc));
+#define TRANSLATE_FUNC_NAME(fun) translate_##fun
+#define TRANSLATE_FUNC(fun) \
+	static int TRANSLATE_FUNC_NAME(fun)(ddf_fun_t *f, int cycles, size_t size)\
+	{\
+		usb_diag_dev_t *dev = ddf_fun_to_usb_diag_dev(f);\
+		return fun(dev, cycles, size);\
 	}
 
-	// Read device's response.
-	size_t remaining = size;
-	size_t transferred;
-	while (remaining > 0) {
-		if ((rc = usb_pipe_read(dev->bulk_in, buffer + size - remaining, remaining, &transferred))) {
-			usb_log_error("Bulk IN read failed. %s\n", str_error(rc));
-			break;
-		}
-
-		if (transferred > remaining) {
-			usb_log_error("Bulk IN read more than expected.\n");
-			rc = EINVAL;
-			break;
-		}
-
-		remaining -= transferred;
-	}
-
-	// TODO: Check output?
-
-	free(buffer);
-
-	*y = x + 42;
-	return rc;
-}
+TRANSLATE_FUNC(usb_diag_stress_bulk_out)
+TRANSLATE_FUNC(usb_diag_stress_bulk_in)
 
 static usbdiag_iface_t diag_interface = {
-	.test = some_test,
+	.stress_bulk_out = TRANSLATE_FUNC_NAME(usb_diag_stress_bulk_out),
+	.stress_bulk_in = TRANSLATE_FUNC_NAME(usb_diag_stress_bulk_in)
 };
+
+#undef TRANSLATE_FUNC_NAME
+#undef TRANSLATE_FUNC
 
 static ddf_dev_ops_t diag_ops = {
@@ -105,15 +80,22 @@
 	dev->fun = fun;
 
-	usb_endpoint_mapping_t *epm_out = usb_device_get_mapped_ep(dev->usb_dev, USB_DIAG_EP_BULK_OUT);
-	usb_endpoint_mapping_t *epm_in = usb_device_get_mapped_ep(dev->usb_dev, USB_DIAG_EP_BULK_IN);
+#define _MAP_EP(target, ep_no) do {\
+	usb_endpoint_mapping_t *epm = usb_device_get_mapped_ep(dev->usb_dev, USB_DIAG_EP_##ep_no);\
+	if (!epm || !epm->present) {\
+		usb_log_error("Failed to map endpoint: " #ep_no ".\n");\
+		rc = ENOENT;\
+		goto err_fun;\
+	}\
+	target = &epm->pipe;\
+	} while (0);
 
-	if (!epm_in || !epm_out || !epm_in->present || !epm_out->present) {
-		usb_log_error("Required EPs were not mapped.\n");
-		rc = ENOENT;
-		goto err_fun;
-	}
+	_MAP_EP(dev->intr_in, INTR_IN);
+	_MAP_EP(dev->intr_out, INTR_OUT);
+	_MAP_EP(dev->bulk_in, BULK_IN);
+	_MAP_EP(dev->bulk_out, BULK_OUT);
+	_MAP_EP(dev->isoch_in, ISOCH_IN);
+	_MAP_EP(dev->isoch_out, ISOCH_OUT);
 
-	dev->bulk_out = &epm_out->pipe;
-	dev->bulk_in = &epm_in->pipe;
+#undef _MAP_EP
 
 	return EOK;
Index: uspace/drv/bus/usb/usbdiag/device.h
===================================================================
--- uspace/drv/bus/usb/usbdiag/device.h	(revision 15f80796072dd77d9218eb941f07bf74668724cc)
+++ uspace/drv/bus/usb/usbdiag/device.h	(revision fd312d505127e9d7f9046c8ee961d3cb5c51249c)
@@ -52,6 +52,10 @@
 	usb_device_t *usb_dev;
 	ddf_fun_t *fun;
+	usb_pipe_t *intr_in;
+	usb_pipe_t *intr_out;
 	usb_pipe_t *bulk_in;
 	usb_pipe_t *bulk_out;
+	usb_pipe_t *isoch_in;
+	usb_pipe_t *isoch_out;
 } usb_diag_dev_t;
 
Index: uspace/drv/bus/usb/usbdiag/tests.c
===================================================================
--- uspace/drv/bus/usb/usbdiag/tests.c	(revision fd312d505127e9d7f9046c8ee961d3cb5c51249c)
+++ uspace/drv/bus/usb/usbdiag/tests.c	(revision fd312d505127e9d7f9046c8ee961d3cb5c51249c)
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) 2017 Petr Manek
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup drvusbdiag
+ * @{
+ */
+/**
+ * @file
+ * Code for executing diagnostic tests.
+ */
+#include <errno.h>
+#include <str_error.h>
+#include <usb/debug.h>
+#include "tests.h"
+
+#define NAME "usbdiag"
+
+
+int usb_diag_stress_bulk_out(usb_diag_dev_t *dev, int cycles, size_t size)
+{
+	if (!dev)
+		return EBADMEM;
+
+	char *buffer = (char *) malloc(size);
+	if (!buffer)
+		return ENOMEM;
+
+	memset(buffer, 42, size);
+
+	// TODO: Are we sure that no other test is running on this endpoint?
+
+	usb_log_info("Performing bulk out stress test on device %s.", ddf_fun_get_name(dev->fun));
+	int rc = EOK;
+	for (int i = 0; i < cycles; ++i) {
+		// Write buffer to device.
+		if ((rc = usb_pipe_write(dev->bulk_out, buffer, size))) {
+			usb_log_error("Bulk OUT write failed. %s\n", str_error(rc));
+			break;
+		}
+	}
+
+	free(buffer);
+	return rc;
+}
+
+int usb_diag_stress_bulk_in(usb_diag_dev_t *dev, int cycles, size_t size)
+{
+	if (!dev)
+		return EBADMEM;
+
+	char *buffer = (char *) malloc(size);
+	if (!buffer)
+		return ENOMEM;
+
+	// TODO: Are we sure that no other test is running on this endpoint?
+
+	usb_log_info("Performing bulk in stress test on device %s.", ddf_fun_get_name(dev->fun));
+	int rc = EOK;
+	for (int i = 0; i < cycles; ++i) {
+		// Read device's response.
+		size_t remaining = size;
+		size_t transferred;
+
+		while (remaining > 0) {
+			if ((rc = usb_pipe_read(dev->bulk_in, buffer + size - remaining, remaining, &transferred))) {
+				usb_log_error("Bulk IN read failed. %s\n", str_error(rc));
+				break;
+			}
+
+			if (transferred > remaining) {
+				usb_log_error("Bulk IN read more than expected.\n");
+				rc = EINVAL;
+				break;
+			}
+
+			remaining -= transferred;
+		}
+	}
+
+	free(buffer);
+	return rc;
+}
+
+/**
+ * @}
+ */
Index: uspace/drv/bus/usb/usbdiag/tests.h
===================================================================
--- uspace/drv/bus/usb/usbdiag/tests.h	(revision fd312d505127e9d7f9046c8ee961d3cb5c51249c)
+++ uspace/drv/bus/usb/usbdiag/tests.h	(revision fd312d505127e9d7f9046c8ee961d3cb5c51249c)
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2017 Petr Manek
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup drvusbdiag
+ * @{
+ */
+/** @file
+ * USB diagnostic tests.
+ */
+
+#ifndef USB_DIAG_TESTS_H_
+#define USB_DIAG_TESTS_H_
+
+#include "device.h"
+
+int usb_diag_stress_bulk_out(usb_diag_dev_t *, int, size_t);
+int usb_diag_stress_bulk_in(usb_diag_dev_t *, int, size_t);
+
+#endif /* USB_DIAG_TESTS_H_ */
+
+/**
+ * @}
+ */
