summaryrefslogtreecommitdiff
path: root/android/ipc-tester.c
diff options
context:
space:
mode:
authorJakub Tyszkowski <jakub.tyszkowski@tieto.com>2014-01-22 09:25:20 +0100
committerSzymon Janc <szymon.janc@gmail.com>2014-01-23 23:42:30 +0100
commitaa6d67930f96371ed4243da913dbf087dbc30a22 (patch)
tree786be88d74efa300100235c1815ed9abc9d1d35c /android/ipc-tester.c
parent7620fee1e9f267d338d7fe559e440d19a91df633 (diff)
downloadbluez-aa6d67930f96371ed4243da913dbf087dbc30a22.tar.gz
android/ipc-tester: Add case for HIDHOST Send Data
This adds test for verifying data length inside hal_cmd_hidhost_send_data struct.
Diffstat (limited to 'android/ipc-tester.c')
-rw-r--r--android/ipc-tester.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/android/ipc-tester.c b/android/ipc-tester.c
index ca4d9b988..b161049c4 100644
--- a/android/ipc-tester.c
+++ b/android/ipc-tester.c
@@ -720,6 +720,41 @@ static struct hidhost_set_report_data hidhost_set_report_data_unders = {
.buf = set_rep_data,
};
+struct hidhost_send_data_data {
+ struct hal_hdr hdr;
+ struct hal_cmd_hidhost_send_data hiddata;
+
+ /* data placeholder for hal_cmd_hidhost_send_data.data[0] field */
+ uint8_t buf[BLUEZ_HAL_MTU - sizeof(struct hal_hdr) -
+ sizeof(struct hal_cmd_hidhost_send_data)];
+} __attribute__((packed));
+
+#define send_data_data "1234567890"
+
+static struct hidhost_send_data_data hidhost_send_data_overs = {
+ .hdr.service_id = HAL_SERVICE_ID_HIDHOST,
+ .hdr.opcode = HAL_OP_HIDHOST_SEND_DATA,
+ .hdr.len = sizeof(struct hal_cmd_hidhost_send_data) +
+ sizeof(send_data_data),
+
+ /* declare wrong descriptor length */
+ .hiddata.len = sizeof(send_data_data) + 1,
+ /* init .hiddata.data[0] */
+ .buf = send_data_data,
+};
+
+static struct hidhost_send_data_data hidhost_send_data_unders = {
+ .hdr.service_id = HAL_SERVICE_ID_HIDHOST,
+ .hdr.opcode = HAL_OP_HIDHOST_SEND_DATA,
+ .hdr.len = sizeof(struct hal_cmd_hidhost_send_data) +
+ sizeof(send_data_data),
+
+ /* declare wrong descriptor length */
+ .hiddata.len = sizeof(send_data_data) - 1,
+ /* init .hiddata.data[0] */
+ .buf = send_data_data,
+};
+
int main(int argc, char *argv[])
{
snprintf(exec_dir, sizeof(exec_dir), "%s", dirname(argv[0]));
@@ -1053,6 +1088,20 @@ int main(int argc, char *argv[])
HAL_OP_HIDHOST_SEND_DATA,
sizeof(struct hal_cmd_hidhost_send_data), -1,
HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+ test_generic("Data size HIDHOST Send Vardata+",
+ ipc_send_tc, setup, teardown,
+ &hidhost_send_data_overs,
+ (sizeof(struct hal_hdr) +
+ sizeof(struct hal_cmd_hidhost_send_data) +
+ sizeof(send_data_data)),
+ HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+ test_generic("Data size HIDHOST Send Vardata-",
+ ipc_send_tc, setup, teardown,
+ &hidhost_send_data_unders,
+ (sizeof(struct hal_hdr) +
+ sizeof(struct hal_cmd_hidhost_send_data) +
+ sizeof(send_data_data)),
+ HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
return tester_run();
}