mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-12-12 13:34:41 +08:00
tools: Fix tests for discoverable management commands
This commit is contained in:
parent
321e8db58c
commit
b6b65b9b19
@ -479,20 +479,6 @@ 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_garbage_param[] = { 0x01, 0x00, 0x00, 0x00 };
|
||||
|
||||
static const struct generic_data set_discoverable_on_rejected_test = {
|
||||
.send_opcode = MGMT_OP_SET_DISCOVERABLE,
|
||||
.send_param = set_discoverable_on_param,
|
||||
.send_len = sizeof(set_discoverable_on_param),
|
||||
.expect_status = MGMT_STATUS_REJECTED,
|
||||
};
|
||||
|
||||
static const struct generic_data set_discoverable_on_not_powered_test = {
|
||||
.send_opcode = MGMT_OP_SET_DISCOVERABLE,
|
||||
.send_param = set_discoverable_timeout_param,
|
||||
.send_len = sizeof(set_discoverable_timeout_param),
|
||||
.expect_status = MGMT_STATUS_NOT_POWERED,
|
||||
};
|
||||
|
||||
static const struct generic_data set_discoverable_on_invalid_param_test_1 = {
|
||||
.send_opcode = MGMT_OP_SET_DISCOVERABLE,
|
||||
.expect_status = MGMT_STATUS_INVALID_PARAMS,
|
||||
@ -512,6 +498,59 @@ static const struct generic_data set_discoverable_on_invalid_param_test_3 = {
|
||||
.expect_status = MGMT_STATUS_INVALID_PARAMS,
|
||||
};
|
||||
|
||||
static const struct generic_data set_discoverable_on_not_powered_test_1 = {
|
||||
.send_opcode = MGMT_OP_SET_DISCOVERABLE,
|
||||
.send_param = set_discoverable_on_param,
|
||||
.send_len = sizeof(set_discoverable_on_param),
|
||||
.expect_status = MGMT_STATUS_NOT_POWERED,
|
||||
};
|
||||
|
||||
static const struct generic_data set_discoverable_on_not_powered_test_2 = {
|
||||
.send_opcode = MGMT_OP_SET_DISCOVERABLE,
|
||||
.send_param = set_discoverable_timeout_param,
|
||||
.send_len = sizeof(set_discoverable_timeout_param),
|
||||
.expect_status = MGMT_STATUS_NOT_POWERED,
|
||||
};
|
||||
|
||||
static const struct generic_data set_discoverable_on_rejected_test_1 = {
|
||||
.send_opcode = MGMT_OP_SET_DISCOVERABLE,
|
||||
.send_param = set_discoverable_on_param,
|
||||
.send_len = sizeof(set_discoverable_on_param),
|
||||
.expect_status = MGMT_STATUS_REJECTED,
|
||||
};
|
||||
|
||||
static const struct generic_data set_discoverable_on_rejected_test_2 = {
|
||||
.send_opcode = MGMT_OP_SET_DISCOVERABLE,
|
||||
.send_param = set_discoverable_timeout_param,
|
||||
.send_len = sizeof(set_discoverable_timeout_param),
|
||||
.expect_status = MGMT_STATUS_REJECTED,
|
||||
};
|
||||
|
||||
static void setup_powered_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 powered on");
|
||||
|
||||
tester_setup_complete();
|
||||
}
|
||||
|
||||
static void setup_powered(const void *test_data)
|
||||
{
|
||||
struct test_data *data = tester_get_data();
|
||||
unsigned char param[] = { 0x01 };
|
||||
|
||||
tester_print("Powering on controller");
|
||||
|
||||
mgmt_send(data->mgmt, MGMT_OP_SET_POWERED, data->mgmt_index,
|
||||
sizeof(param), param,
|
||||
setup_powered_callback, NULL, NULL);
|
||||
}
|
||||
|
||||
static void command_generic_new_settings(uint16_t index, uint16_t length,
|
||||
const void *param, void *user_data)
|
||||
{
|
||||
@ -691,12 +730,6 @@ int main(int argc, char *argv[])
|
||||
&set_pairable_on_invalid_index_test,
|
||||
NULL, test_command_generic);
|
||||
|
||||
test_bredr("Set discoverable on - Rejected",
|
||||
&set_discoverable_on_rejected_test,
|
||||
NULL, test_command_generic);
|
||||
test_bredr("Set discoverable on - Not powered",
|
||||
&set_discoverable_on_not_powered_test,
|
||||
NULL, test_command_generic);
|
||||
test_bredr("Set discoverable on - Invalid parameters 1",
|
||||
&set_discoverable_on_invalid_param_test_1,
|
||||
NULL, test_command_generic);
|
||||
@ -706,6 +739,18 @@ int main(int argc, char *argv[])
|
||||
test_bredr("Set discoverable on - Invalid parameters 3",
|
||||
&set_discoverable_on_invalid_param_test_3,
|
||||
NULL, test_command_generic);
|
||||
test_bredr("Set discoverable on - Not powered 1",
|
||||
&set_discoverable_on_not_powered_test_1,
|
||||
NULL, test_command_generic);
|
||||
test_bredr("Set discoverable on - Not powered 2",
|
||||
&set_discoverable_on_not_powered_test_1,
|
||||
NULL, test_command_generic);
|
||||
test_bredr("Set discoverable on - Rejected 1",
|
||||
&set_discoverable_on_rejected_test_1,
|
||||
setup_powered, test_command_generic);
|
||||
test_bredr("Set discoverable on - Rejected 2",
|
||||
&set_discoverable_on_rejected_test_2,
|
||||
setup_powered, test_command_generic);
|
||||
|
||||
return tester_run();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user