mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2025-01-21 03:43:50 +08:00
tools: Use connectable and powered setup stages for discoverable tests
This commit is contained in:
parent
b6b65b9b19
commit
6186d0a8ca
@ -478,6 +478,7 @@ static const char set_discoverable_on_param[] = { 0x01, 0x00, 0x00 };
|
|||||||
static const char set_discoverable_timeout_param[] = { 0x01, 0x0a, 0x00 };
|
static const char set_discoverable_timeout_param[] = { 0x01, 0x0a, 0x00 };
|
||||||
static const char set_discoverable_invalid_param[] = { 0x02, 0x00, 0x00 };
|
static const char set_discoverable_invalid_param[] = { 0x02, 0x00, 0x00 };
|
||||||
static const char set_discoverable_garbage_param[] = { 0x01, 0x00, 0x00, 0x00 };
|
static const char set_discoverable_garbage_param[] = { 0x01, 0x00, 0x00, 0x00 };
|
||||||
|
static const char set_discoverable_settings_param[] = { 0x8b, 0x00, 0x00, 0x00 };
|
||||||
|
|
||||||
static const struct generic_data set_discoverable_on_invalid_param_test_1 = {
|
static const struct generic_data set_discoverable_on_invalid_param_test_1 = {
|
||||||
.send_opcode = MGMT_OP_SET_DISCOVERABLE,
|
.send_opcode = MGMT_OP_SET_DISCOVERABLE,
|
||||||
@ -526,6 +527,16 @@ static const struct generic_data set_discoverable_on_rejected_test_2 = {
|
|||||||
.expect_status = MGMT_STATUS_REJECTED,
|
.expect_status = MGMT_STATUS_REJECTED,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static const struct generic_data set_discoverable_on_success_test = {
|
||||||
|
.send_opcode = MGMT_OP_SET_DISCOVERABLE,
|
||||||
|
.send_param = set_discoverable_on_param,
|
||||||
|
.send_len = sizeof(set_discoverable_on_param),
|
||||||
|
.expect_status = MGMT_STATUS_SUCCESS,
|
||||||
|
.expect_param = set_discoverable_settings_param,
|
||||||
|
.expect_len = sizeof(set_discoverable_settings_param),
|
||||||
|
.expect_settings_set = MGMT_SETTING_DISCOVERABLE,
|
||||||
|
};
|
||||||
|
|
||||||
static void setup_powered_callback(uint8_t status, uint16_t length,
|
static void setup_powered_callback(uint8_t status, uint16_t length,
|
||||||
const void *param, void *user_data)
|
const void *param, void *user_data)
|
||||||
{
|
{
|
||||||
@ -539,6 +550,22 @@ static void setup_powered_callback(uint8_t status, uint16_t length,
|
|||||||
tester_setup_complete();
|
tester_setup_complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void setup_powered_connectable(const void *test_data)
|
||||||
|
{
|
||||||
|
struct test_data *data = tester_get_data();
|
||||||
|
unsigned char param[] = { 0x01 };
|
||||||
|
|
||||||
|
tester_print("Powering on connectable 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_POWERED, data->mgmt_index,
|
||||||
|
sizeof(param), param,
|
||||||
|
setup_powered_callback, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static void setup_powered(const void *test_data)
|
static void setup_powered(const void *test_data)
|
||||||
{
|
{
|
||||||
struct test_data *data = tester_get_data();
|
struct test_data *data = tester_get_data();
|
||||||
@ -551,6 +578,31 @@ static void setup_powered(const void *test_data)
|
|||||||
setup_powered_callback, NULL, NULL);
|
setup_powered_callback, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void setup_connectable_callback(uint8_t status, uint16_t length,
|
||||||
|
const void *param, void *user_data)
|
||||||
|
{
|
||||||
|
if (status != MGMT_STATUS_SUCCESS) {
|
||||||
|
tester_setup_failed();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
tester_print("Controller connectable on");
|
||||||
|
|
||||||
|
tester_setup_complete();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void setup_connectable(const void *test_data)
|
||||||
|
{
|
||||||
|
struct test_data *data = tester_get_data();
|
||||||
|
unsigned char param[] = { 0x01 };
|
||||||
|
|
||||||
|
tester_print("Setting controller connectable");
|
||||||
|
|
||||||
|
mgmt_send(data->mgmt, MGMT_OP_SET_CONNECTABLE, data->mgmt_index,
|
||||||
|
sizeof(param), param,
|
||||||
|
setup_connectable_callback, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static void command_generic_new_settings(uint16_t index, uint16_t length,
|
static void command_generic_new_settings(uint16_t index, uint16_t length,
|
||||||
const void *param, void *user_data)
|
const void *param, void *user_data)
|
||||||
{
|
{
|
||||||
@ -743,14 +795,23 @@ int main(int argc, char *argv[])
|
|||||||
&set_discoverable_on_not_powered_test_1,
|
&set_discoverable_on_not_powered_test_1,
|
||||||
NULL, test_command_generic);
|
NULL, test_command_generic);
|
||||||
test_bredr("Set discoverable on - Not powered 2",
|
test_bredr("Set discoverable on - Not powered 2",
|
||||||
&set_discoverable_on_not_powered_test_1,
|
&set_discoverable_on_not_powered_test_2,
|
||||||
NULL, test_command_generic);
|
NULL, test_command_generic);
|
||||||
|
test_bredr("Set discoverable on - Not powered 3",
|
||||||
|
&set_discoverable_on_not_powered_test_2,
|
||||||
|
setup_connectable, test_command_generic);
|
||||||
test_bredr("Set discoverable on - Rejected 1",
|
test_bredr("Set discoverable on - Rejected 1",
|
||||||
&set_discoverable_on_rejected_test_1,
|
&set_discoverable_on_rejected_test_1,
|
||||||
setup_powered, test_command_generic);
|
setup_powered, test_command_generic);
|
||||||
test_bredr("Set discoverable on - Rejected 2",
|
test_bredr("Set discoverable on - Rejected 2",
|
||||||
&set_discoverable_on_rejected_test_2,
|
&set_discoverable_on_rejected_test_2,
|
||||||
setup_powered, test_command_generic);
|
setup_powered, test_command_generic);
|
||||||
|
test_bredr("Set discoverable on - Success 1",
|
||||||
|
&set_discoverable_on_success_test,
|
||||||
|
setup_connectable, test_command_generic);
|
||||||
|
test_bredr("Set discoverable on - Success 2",
|
||||||
|
&set_discoverable_on_success_test,
|
||||||
|
setup_powered_connectable, test_command_generic);
|
||||||
|
|
||||||
return tester_run();
|
return tester_run();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user