Add offset handling logic in bt_unit_test 90/239790/1
authorWootak Jung <wootak.jung@samsung.com>
Thu, 30 Jul 2020 00:33:59 +0000 (09:33 +0900)
committerWootak Jung <wootak.jung@samsung.com>
Thu, 30 Jul 2020 00:33:59 +0000 (09:33 +0900)
Change-Id: I88edf5f20da7123040f783892da25f9e74b7df26
Signed-off-by: Wootak Jung <wootak.jung@samsung.com>
tests/test/bt_unit_test.c

index 0331d63..26608f7 100644 (file)
@@ -1886,8 +1886,14 @@ void __bt_gatt_server_read_value_requested_cb(
        bt_gatt_server_h server, bt_gatt_h gatt_handle,
        int offset, void *user_data)
 {
-       char char_value_1[3] = {0, 1, 2};
+       char *value = "A very long test value, can be long than MTU";
        int resp_status = BT_ATT_ERROR_NONE;
+       char *new_value = NULL;
+
+       new_value = g_malloc0(strlen(value) + 1);
+       strncpy(new_value, &value[offset], strlen(value) - offset);
+       new_value[strlen(value) - offset] = '\0';
+       TC_PRT("new_value: %s(len: %d)\n", new_value, strlen(new_value));
 
        __print_gatt_handler(gatt_handle);
        TC_PRT("[%s] req_id %d, offset %d", remote_address, request_id, offset);
@@ -1896,7 +1902,8 @@ void __bt_gatt_server_read_value_requested_cb(
        /* Get the attribute new values here */
        bt_gatt_server_send_response(request_id,
                BLUETOOTH_GATT_ATT_REQUEST_TYPE_READ, offset,
-               resp_status, char_value_1, 3 - offset);
+               resp_status, new_value, strlen(new_value));
+       g_free(new_value);
 }
 
 void __bt_gatt_server_notification_state_change_cb(bool notify,
@@ -3864,6 +3871,11 @@ int test_set_params(int test_id, char *param)
                        }
                        break;
                }
+               case BT_UNIT_TEST_FUNCTION_GATT_CLIENT_REQUEST_ATT_MTU:
+                       param_count = 1;
+                       param_type = BT_UNIT_TEST_PARAM_TYPE_INT;
+                       TC_PRT("Input param(%d) type:%s", param_index + 1, param_type);
+                       break;
                case BT_UNIT_TEST_FUNCTION_ANCS_POSITIVE_ACTION:
                case BT_UNIT_TEST_FUNCTION_ANCS_NEGATIVE_ACTION:
                case BT_UNIT_TEST_FUNCTION_ANCS_GET_NOTI_ATTR: