[openib-general] [PATCH] new test code for ib_cm_listen
Sean Hefty
mshefty at ichips.intel.com
Fri Dec 17 17:27:30 PST 2004
This patch adds basic test code for ib_cm_listen. It tests listen insertions,
removal, duplicate insertions, component mask usage, and all error handling cases.
- Sean
Index: util/cmpost/cmpost.c
===================================================================
--- util/cmpost/cmpost.c (revision 1352)
+++ util/cmpost/cmpost.c (working copy)
@@ -55,14 +55,69 @@
struct ib_cm_id *conn_cm_id;
};
+/* Last test number used: 8 */
+#define VERIFY_RESULT(test, result, value) \
+ printk("cmpost test %d : ", test); \
+ if (result == value) { \
+ printk("passed\n"); \
+ } else { \
+ printk("FAILED! result = %d\n", result); \
+ return result; \
+ }
+
void cm_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event)
{
}
+static int test_listen()
+{
+ struct ib_cm_id * listen_ids[3];
+ int i, ret;
+
+ for (i = 0; i < 3; i++) {
+ listen_ids[i] = ib_create_cm_id(cm_handler, NULL);
+ if (IS_ERR(listen_ids[i]))
+ return PTR_ERR(listen_ids[i]);
+ }
+
+ ret = ib_cm_listen(listen_ids[0], 0x1000, 0);
+ VERIFY_RESULT(1, ret, 0);
+ ret = ib_cm_listen(listen_ids[0], 0x1000, 0);
+ VERIFY_RESULT(2, ret, -EINVAL);
+
+ ret = ib_cm_listen(listen_ids[1], 0x1001, 0);
+ VERIFY_RESULT(3, ret, 0);
+ ret = ib_cm_listen(listen_ids[2], 0x1000, 0);
+ VERIFY_RESULT(4, ret, -EBUSY);
+ ret = ib_cm_listen(listen_ids[2], 0x1001, 0xF00F);
+ VERIFY_RESULT(5, ret, -EBUSY);
+ ret = ib_cm_listen(listen_ids[2], 0x1100, 0x1100);
+ VERIFY_RESULT(6, ret, 0);
+
+ ib_destroy_cm_id(listen_ids[0]);
+ listen_ids[0] = ib_create_cm_id(cm_handler, NULL);
+ if (IS_ERR(listen_ids[0]))
+ return PTR_ERR(listen_ids[0]);
+ ret = ib_cm_listen(listen_ids[0], 0x1011, 0);
+ VERIFY_RESULT(7, ret, 0);
+ ib_destroy_cm_id(listen_ids[0]);
+ listen_ids[0] = ib_create_cm_id(cm_handler, NULL);
+ if (IS_ERR(listen_ids[0]))
+ return PTR_ERR(listen_ids[0]);
+ ret = ib_cm_listen(listen_ids[0], 0x1000, 0);
+ VERIFY_RESULT(8, ret, 0);
+
+ for (i = 0; i < 3; i++) {
+ if (listen_ids[i] && !IS_ERR(listen_ids[i]))
+ ib_destroy_cm_id(listen_ids[i]);
+ }
+ return 0;
+}
+
static void cmpost_add_one(struct ib_device *device)
{
struct cmpost_port *port;
- int i;
+ int i, ret;
port = kmalloc(sizeof *port * device->phys_port_cnt, GFP_KERNEL);
if (!port)
@@ -73,6 +128,11 @@
port[i].conn_cm_id = ib_create_cm_id(cm_handler, &port[i]);
}
+ ret = test_listen();
+ if (ret) {
+ printk("FAILURE: test_listen failed: %d\n", ret);
+ goto out;
+ }
out:
ib_set_client_data(device, &cmpost_client, port);
}
More information about the general
mailing list