diff --git a/tools/smp-tester.c b/tools/smp-tester.c
index f638132..a8f6a18 100644
--- a/tools/smp-tester.c
+++ b/tools/smp-tester.c
uint8_t preq[7];
uint8_t prsp[7];
uint8_t ltk[16];
+ int unmet_conditions;
};
struct smp_req_rsp {
free(data);
}
+static void test_add_condition(struct test_data *data)
+{
+ data->unmet_conditions++;
+
+ tester_print("Test condition added, total %d", data->unmet_conditions);
+}
+
+static void test_condition_complete(struct test_data *data)
+{
+ data->unmet_conditions--;
+
+ tester_print("Test condition complete, %d left",
+ data->unmet_conditions);
+
+ if (data->unmet_conditions > 0)
+ return;
+
+ tester_test_passed();
+}
+
#define test_smp(name, data, setup, func) \
do { \
struct test_data *user; \
tester_print("Received SMP opcode 0x%02x", opcode);
if (test_data->counter >= smp->req_count) {
- tester_test_passed();
+ test_condition_complete(test_data);
return;
}
next:
if (smp->req_count == test_data->counter) {
- tester_test_passed();
+ test_condition_complete(test_data);
return;
}
req->send_len);
if (!req->expect)
- tester_test_passed();
+ test_condition_complete(test_data);
return;
pdu = get_pdu(req->send);
bthost_send_cid(bthost, handle, SMP_CID, pdu, req->send_len);
+
+ if (!req->expect)
+ test_condition_complete(data);
}
static void init_bdaddr(struct test_data *data)
bthost = hciemu_client_get_host(data->hciemu);
bthost_set_connect_cb(bthost, smp_new_conn, data);
+ test_add_condition(data);
memcpy(&cp.addr.bdaddr, data->ra, sizeof(data->ra));
cp.addr.type = BDADDR_LE_PUBLIC;
bthost = hciemu_client_get_host(data->hciemu);
bthost_set_connect_cb(bthost, smp_new_conn, data);
+ test_add_condition(data);
bthost_hci_connect(bthost, data->ra, BDADDR_LE_PUBLIC);
}