Check that the PDUs that we expect to receive when registering for events have been delivered. --- unit/test-gattrib.c | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/unit/test-gattrib.c b/unit/test-gattrib.c index 473112c..326478d 100644 --- a/unit/test-gattrib.c +++ b/unit/test-gattrib.c @@ -404,7 +404,7 @@ static void notify_canary_expect(const guint8 *pdu, guint16 len, gpointer data) static void test_register(struct context *cxt, gconstpointer user_data) { guint reg_id; - gboolean success; + gboolean canceled; struct test_pdu pdus[] = { /* Unmatched by any (GATTRIB_ALL_EVENTS) */ PDU_MTU_RESP, @@ -434,6 +434,7 @@ static void test_register(struct context *cxt, gconstpointer user_data) { }, }; struct test_pdu followed_ind_pdus[] = { PDU_IND_DATA, { } }; + struct test_pdu *current_pdu; /* * Without registering anything, should be able to ignore everything but @@ -446,7 +447,12 @@ static void test_register(struct context *cxt, gconstpointer user_data) send_test_pdus(cxt, pdus); - g_attrib_unregister(cxt->att, reg_id); + canceled = g_attrib_unregister(cxt->att, reg_id); + + g_assert(canceled); + + for (current_pdu = pdus; current_pdu->valid; current_pdu++) + g_assert(current_pdu->received); if (g_test_verbose()) g_print("ALL_REQS, ALL_HANDLES\r\n"); @@ -457,7 +463,12 @@ static void test_register(struct context *cxt, gconstpointer user_data) send_test_pdus(cxt, pdus); - g_attrib_unregister(cxt->att, reg_id); + canceled = g_attrib_unregister(cxt->att, reg_id); + + g_assert(canceled); + + for (current_pdu = req_pdus; current_pdu->valid; current_pdu++) + g_assert(current_pdu->received); if (g_test_verbose()) g_print("IND, ALL_HANDLES\r\n"); @@ -468,7 +479,12 @@ static void test_register(struct context *cxt, gconstpointer user_data) send_test_pdus(cxt, pdus); - g_attrib_unregister(cxt->att, reg_id); + canceled = g_attrib_unregister(cxt->att, reg_id); + + g_assert(canceled); + + for (current_pdu = all_ind_pdus; current_pdu->valid; current_pdu++) + g_assert(current_pdu->received); if (g_test_verbose()) g_print("IND, 0x0014\r\n"); @@ -479,11 +495,16 @@ static void test_register(struct context *cxt, gconstpointer user_data) send_test_pdus(cxt, pdus); - g_attrib_unregister(cxt->att, reg_id); + canceled = g_attrib_unregister(cxt->att, reg_id); + + g_assert(canceled); - success = g_attrib_unregister(cxt->att, reg_id); + for (current_pdu = followed_ind_pdus; current_pdu->valid; current_pdu++) + g_assert(current_pdu->received); - g_assert(!success); + canceled = g_attrib_unregister(cxt->att, reg_id); + + g_assert(!canceled); } static void test_buffers(struct context *cxt, gconstpointer unused) -- 2.1.0.rc2.206.gedb03e5 -- To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html