From 658961838b4242ea7afcfe9fbdd5f107cadc84fb Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Sun, 29 Mar 2015 15:18:27 -0700 Subject: [PATCH] tools: Add basic test cases for reading local out-of-band data --- doc/test-coverage.txt | 4 +-- tools/mgmt-tester.c | 57 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/doc/test-coverage.txt b/doc/test-coverage.txt index fc51bb802..c663697e2 100644 --- a/doc/test-coverage.txt +++ b/doc/test-coverage.txt @@ -40,7 +40,7 @@ Automated end-to-end testing Application Count Description ------------------------------------------- -mgmt-tester 287 Kernel management interface testing +mgmt-tester 291 Kernel management interface testing l2cap-tester 27 Kernel L2CAP implementation testing rfcomm-tester 9 Kernel RFCOMM implementation testing smp-tester 5 Kernel SMP implementation testing @@ -48,7 +48,7 @@ sco-tester 8 Kernel SCO implementation testing gap-tester 1 Daemon D-Bus API testing hci-tester 14 Controller hardware testing ----- - 351 + 355 Android end-to-end testing diff --git a/tools/mgmt-tester.c b/tools/mgmt-tester.c index a5bb13155..98dce4e95 100644 --- a/tools/mgmt-tester.c +++ b/tools/mgmt-tester.c @@ -319,6 +319,25 @@ static void test_condition_complete(struct test_data *data) test_post_teardown, 2, user, free); \ } while (0) +#define test_bredr20(name, data, setup, func) \ + do { \ + struct test_data *user; \ + user = malloc(sizeof(struct test_data)); \ + if (!user) \ + break; \ + user->hciemu_type = HCIEMU_TYPE_LEGACY; \ + user->test_setup = setup; \ + user->test_data = data; \ + user->expected_version = 0x04; \ + user->expected_manufacturer = 0x003f; \ + user->expected_supported_settings = 0x000010bf; \ + user->initial_settings = 0x00000080; \ + user->unmet_conditions = 0; \ + tester_add_full(name, data, \ + test_pre_setup, test_setup, func, NULL, \ + test_post_teardown, 2, user, free); \ + } while (0) + #define test_bredr(name, data, setup, func) \ do { \ struct test_data *user; \ @@ -4429,6 +4448,30 @@ static const struct generic_data remove_advertising_success_2 = { .expect_hci_len = sizeof(set_adv_off_param), }; +static const struct generic_data read_local_oob_not_powered_test = { + .send_opcode = MGMT_OP_READ_LOCAL_OOB_DATA, + .expect_status = MGMT_STATUS_NOT_POWERED, +}; + +static const struct generic_data read_local_oob_invalid_param_test = { + .send_opcode = MGMT_OP_READ_LOCAL_OOB_DATA, + .send_param = dummy_data, + .send_len = sizeof(dummy_data), + .expect_status = MGMT_STATUS_INVALID_PARAMS, +}; + +static const struct generic_data read_local_oob_invalid_index_test = { + .send_index_none = true, + .send_opcode = MGMT_OP_READ_LOCAL_OOB_DATA, + .expect_status = MGMT_STATUS_INVALID_INDEX, +}; + +static const struct generic_data read_local_oob_legacy_pairing_test = { + .setup_settings = settings_powered, + .send_opcode = MGMT_OP_READ_LOCAL_OOB_DATA, + .expect_status = MGMT_STATUS_NOT_SUPPORTED, +}; + static void client_cmd_complete(uint16_t opcode, uint8_t status, const void *param, uint8_t len, void *user_data) @@ -6318,6 +6361,7 @@ int main(int argc, char *argv[]) test_bredrle("Read Advertising Features - Invalid index", &read_adv_features_invalid_index_test, NULL, test_command_generic); + test_bredrle("Add Advertising - Failure: LE off", &add_advertising_fail_1, NULL, test_command_generic); @@ -6428,5 +6472,18 @@ int main(int argc, char *argv[]) setup_add_advertising, test_command_generic); + test_bredrle("Read Local OOB Data - Not powered", + &read_local_oob_not_powered_test, + NULL, test_command_generic); + test_bredrle("Read Local OOB Data - Invalid parameters", + &read_local_oob_invalid_param_test, + NULL, test_command_generic); + test_bredrle("Read Local OOB Data - Invalid index", + &read_local_oob_invalid_index_test, + NULL, test_command_generic); + test_bredr20("Read Local OOB Data - Legacy pairing", + &read_local_oob_legacy_pairing_test, + NULL, test_command_generic); + return tester_run(); } -- 2.47.3