mgmt-tester: Add test for Limited/Device Privacy
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Mon, 1 Nov 2021 22:24:34 +0000 (15:24 -0700)
committerAyush Garg <ayush.garg@samsung.com>
Fri, 11 Mar 2022 13:38:37 +0000 (19:08 +0530)
This adds a test for Limited/Device Privacy (0x02):

@ MGMT Command: Set Privacy (0x002f) plen 17
        Privacy: Limited (0x02)
        Key: 01020304050607080102030405060708
@ MGMT Event: Command Complete (0x0001) plen 7
      Set Privacy (0x002f) plen 4
        Status: Success (0x00)
        Current settings: 0x00002080
          BR/EDR
          Privacy
@ MGMT Event: New Settings (0x0006) plen 4
        Current settings: 0x00002080
          BR/EDR
          Privacy

Signed-off-by: Anuj Jain <anuj01.jain@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
tools/mgmt-tester.c

index 2071682..e9fcb26 100755 (executable)
@@ -4136,15 +4136,29 @@ static const struct generic_data load_irks_not_supported_test = {
        .expect_status = MGMT_STATUS_NOT_SUPPORTED,
 };
 
-static const char set_privacy_valid_param[] = { 0x01,
+static const char set_privacy_1_valid_param[] = { 0x01,
                        0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
                        0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 };
 static const char set_privacy_settings_param[] = { 0x80, 0x20, 0x00, 0x00 };
 
-static const struct generic_data set_privacy_success_test = {
+static const struct generic_data set_privacy_success_1_test = {
        .send_opcode = MGMT_OP_SET_PRIVACY,
-       .send_param = set_privacy_valid_param,
-       .send_len = sizeof(set_privacy_valid_param),
+       .send_param = set_privacy_1_valid_param,
+       .send_len = sizeof(set_privacy_1_valid_param),
+       .expect_status = MGMT_STATUS_SUCCESS,
+       .expect_param = set_privacy_settings_param,
+       .expect_len = sizeof(set_privacy_settings_param),
+       .expect_settings_set = MGMT_SETTING_PRIVACY,
+};
+
+static const char set_privacy_2_valid_param[] = { 0x02,
+                       0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+                       0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 };
+
+static const struct generic_data set_privacy_success_2_test = {
+       .send_opcode = MGMT_OP_SET_PRIVACY,
+       .send_param = set_privacy_2_valid_param,
+       .send_len = sizeof(set_privacy_2_valid_param),
        .expect_status = MGMT_STATUS_SUCCESS,
        .expect_param = set_privacy_settings_param,
        .expect_len = sizeof(set_privacy_settings_param),
@@ -4154,8 +4168,8 @@ static const struct generic_data set_privacy_success_test = {
 static const struct generic_data set_privacy_powered_test = {
        .setup_settings = settings_powered,
        .send_opcode = MGMT_OP_SET_PRIVACY,
-       .send_param = set_privacy_valid_param,
-       .send_len = sizeof(set_privacy_valid_param),
+       .send_param = set_privacy_1_valid_param,
+       .send_len = sizeof(set_privacy_1_valid_param),
        .expect_status = MGMT_STATUS_REJECTED,
 };
 
@@ -13063,8 +13077,11 @@ int main(int argc, char *argv[])
                                &load_irks_not_supported_test,
                                NULL, test_command_generic);
 
-       test_bredrle("Set Privacy - Success",
-                               &set_privacy_success_test,
+       test_bredrle("Set Privacy - Success 1",
+                               &set_privacy_success_1_test,
+                               NULL, test_command_generic);
+       test_bredrle("Set Privacy - Success 2 (Device Mode)",
+                               &set_privacy_success_2_test,
                                NULL, test_command_generic);
        test_bredrle("Set Privacy - Rejected",
                                &set_privacy_powered_test,