free(data);
}
-#define test_l2cap(name, data, setup, func) \
+#define test_l2cap_bredr(name, data, setup, func) \
do { \
struct test_data *user; \
user = malloc(sizeof(struct test_data)); \
if (!user) \
break; \
- user->hciemu_type = HCIEMU_TYPE_BREDRLE; \
+ user->hciemu_type = HCIEMU_TYPE_BREDR; \
+ user->io_id = 0; \
+ user->test_data = data; \
+ tester_add_full(name, data, \
+ test_pre_setup, setup, func, NULL, \
+ test_post_teardown, 2, user, test_data_free); \
+ } while (0)
+
+#define test_l2cap_le(name, data, setup, func) \
+ do { \
+ struct test_data *user; \
+ user = malloc(sizeof(struct test_data)); \
+ if (!user) \
+ break; \
+ user->hciemu_type = HCIEMU_TYPE_LE; \
user->io_id = 0; \
user->test_data = data; \
tester_add_full(name, data, \
const void *param, uint8_t len,
void *user_data)
{
- if (opcode != BT_HCI_CMD_WRITE_SCAN_ENABLE)
+ switch (opcode) {
+ case BT_HCI_CMD_WRITE_SCAN_ENABLE:
+ case BT_HCI_CMD_LE_SET_ADV_ENABLE:
+ break;
+ default:
return;
+ }
tester_print("Client set connectable status 0x%02x", status);
bthost = hciemu_client_get_host(data->hciemu);
bthost_set_cmd_complete_cb(bthost, client_connectable_complete, data);
- bthost_write_scan_enable(bthost, 0x03);
+ if (data->hciemu_type == HCIEMU_TYPE_LE)
+ bthost_set_adv_enable(bthost, 0x01);
+ else
+ bthost_write_scan_enable(bthost, 0x03);
}
static void setup_powered(const void *test_data)
tester_print("Powering on controller");
- mgmt_send(data->mgmt, MGMT_OP_SET_CONNECTABLE, data->mgmt_index,
- sizeof(param), param,
- NULL, NULL, NULL);
-
- mgmt_send(data->mgmt, MGMT_OP_SET_SSP, data->mgmt_index,
+ if (data->hciemu_type == HCIEMU_TYPE_BREDR) {
+ mgmt_send(data->mgmt, MGMT_OP_SET_CONNECTABLE, data->mgmt_index,
+ sizeof(param), param,
+ NULL, NULL, NULL);
+ mgmt_send(data->mgmt, MGMT_OP_SET_SSP, data->mgmt_index,
sizeof(param), param, NULL, NULL, NULL);
-
- mgmt_send(data->mgmt, MGMT_OP_SET_LE, data->mgmt_index,
+ } else {
+ mgmt_send(data->mgmt, MGMT_OP_SET_LE, data->mgmt_index,
sizeof(param), param, NULL, NULL, NULL);
+ }
mgmt_send(data->mgmt, MGMT_OP_SET_POWERED, data->mgmt_index,
sizeof(param), param,
addr.l2_family = AF_BLUETOOTH;
addr.l2_psm = htobs(psm);
bacpy(&addr.l2_bdaddr, (void *) master_bdaddr);
+ if (data->hciemu_type == HCIEMU_TYPE_LE)
+ addr.l2_bdaddr_type = BDADDR_LE_PUBLIC;
+ else
+ addr.l2_bdaddr_type = BDADDR_BREDR;
if (bind(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
err = -errno;
addr.l2_family = AF_BLUETOOTH;
bacpy(&addr.l2_bdaddr, (void *) client_bdaddr);
addr.l2_psm = htobs(psm);
+ if (data->hciemu_type == HCIEMU_TYPE_LE)
+ addr.l2_bdaddr_type = BDADDR_LE_PUBLIC;
+ else
+ addr.l2_bdaddr_type = BDADDR_BREDR;
err = connect(sk, (struct sockaddr *) &addr, sizeof(addr));
if (err < 0 && !(errno == EAGAIN || errno == EINPROGRESS)) {
return 0;
}
-static void test_bredr_connect(const void *test_data)
+static void test_connect(const void *test_data)
{
struct test_data *data = tester_get_data();
const struct l2cap_client_data *l2data = data->test_data;
{
tester_init(&argc, &argv);
- test_l2cap("Basic L2CAP Socket - Success", NULL, setup_powered,
+ test_l2cap_bredr("Basic L2CAP Socket - Success", NULL, setup_powered,
test_basic);
- test_l2cap("L2CAP BR/EDR Client - Success",
+ test_l2cap_bredr("L2CAP BR/EDR Client - Success",
&client_connect_success_test,
- setup_powered, test_bredr_connect);
- test_l2cap("L2CAP BR/EDR Client - Invalid PSM",
+ setup_powered, test_connect);
+ test_l2cap_bredr("L2CAP BR/EDR Client - Invalid PSM",
&client_connect_nval_psm_test,
- setup_powered, test_bredr_connect);
+ setup_powered, test_connect);
- test_l2cap("L2CAP BR/EDR Server - Success", &l2cap_server_success_test,
+ test_l2cap_bredr("L2CAP BR/EDR Server - Success",
+ &l2cap_server_success_test,
setup_powered, test_bredr_server);
- test_l2cap("L2CAP BR/EDR Server - Invalid PSM",
+ test_l2cap_bredr("L2CAP BR/EDR Server - Invalid PSM",
&l2cap_server_nval_psm_test,
setup_powered, test_bredr_server);
- test_l2cap("L2CAP BR/EDR Server - Invalid PDU",
+ test_l2cap_bredr("L2CAP BR/EDR Server - Invalid PDU",
&l2cap_server_nval_pdu_test1, setup_powered,
test_bredr_server);
- test_l2cap("L2CAP BR/EDR Server - Invalid Disconnect CID",
+ test_l2cap_bredr("L2CAP BR/EDR Server - Invalid Disconnect CID",
&l2cap_server_nval_cid_test1, setup_powered,
test_bredr_server);
- test_l2cap("L2CAP BR/EDR Server - Invalid Config CID",
+ test_l2cap_bredr("L2CAP BR/EDR Server - Invalid Config CID",
&l2cap_server_nval_cid_test2, setup_powered,
test_bredr_server);