From 100d8dffa75fbef435535ad2e8bf3402d6edde2a Mon Sep 17 00:00:00 2001 From: Wootak Jung Date: Thu, 30 Jul 2020 09:33:59 +0900 Subject: [PATCH] Add offset handling logic in bt_unit_test Change-Id: I88edf5f20da7123040f783892da25f9e74b7df26 Signed-off-by: Wootak Jung --- tests/test/bt_unit_test.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/test/bt_unit_test.c b/tests/test/bt_unit_test.c index 0331d63..26608f7 100644 --- a/tests/test/bt_unit_test.c +++ b/tests/test/bt_unit_test.c @@ -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: -- 2.7.4