tizen 2.3.1 release
[framework/connectivity/bluez.git] / android / ipc-tester.c
1 /*
2  *
3  *  BlueZ - Bluetooth protocol stack for Linux
4  *
5  *  Copyright (C) 2013-2014  Intel Corporation. All rights reserved.
6  *
7  *
8  *  This library is free software; you can redistribute it and/or
9  *  modify it under the terms of the GNU Lesser General Public
10  *  License as published by the Free Software Foundation; either
11  *  version 2.1 of the License, or (at your option) any later version.
12  *
13  *  This library is distributed in the hope that it will be useful,
14  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  *  Lesser General Public License for more details.
17  *
18  *  You should have received a copy of the GNU Lesser General Public
19  *  License along with this library; if not, write to the Free Software
20  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21  *
22  */
23
24 #ifdef HAVE_CONFIG_H
25 #include <config.h>
26 #endif
27
28 #include <stdlib.h>
29 #include <unistd.h>
30 #include <errno.h>
31 #include <poll.h>
32
33 #include <sys/socket.h>
34 #include <sys/types.h>
35 #include <sys/wait.h>
36 #include <sys/un.h>
37 #include <libgen.h>
38 #include <glib.h>
39
40 #include "lib/bluetooth.h"
41 #include "lib/mgmt.h"
42
43 #include "src/shared/tester.h"
44 #include "src/shared/mgmt.h"
45 #include "emulator/hciemu.h"
46
47 #include "hal-msg.h"
48 #include "ipc-common.h"
49
50 #include <cutils/properties.h>
51
52 #define WAIT_FOR_SIGNAL_TIME 2 /* in seconds */
53 #define EMULATOR_SIGNAL "emulator_started"
54
55 struct test_data {
56         struct mgmt *mgmt;
57         uint16_t mgmt_index;
58         struct hciemu *hciemu;
59         enum hciemu_type hciemu_type;
60         pid_t bluetoothd_pid;
61         bool setup_done;
62 };
63
64 struct ipc_data {
65         void *buffer;
66         size_t len;
67 };
68
69 struct generic_data {
70         struct ipc_data ipc_data;
71
72         unsigned int num_services;
73         int init_services[];
74 };
75
76 struct regmod_msg {
77         struct ipc_hdr header;
78         struct hal_cmd_register_module cmd;
79 } __attribute__((packed));
80
81 #define CONNECT_TIMEOUT (5 * 1000)
82 #define SERVICE_NAME "bluetoothd"
83
84 static char exec_dir[PATH_MAX];
85
86 static int cmd_sk = -1;
87 static int notif_sk = -1;
88
89 static void read_info_callback(uint8_t status, uint16_t length,
90                                         const void *param, void *user_data)
91 {
92         struct test_data *data = tester_get_data();
93         const struct mgmt_rp_read_info *rp = param;
94         char addr[18];
95         uint16_t manufacturer;
96         uint32_t supported_settings, current_settings;
97
98         tester_print("Read Info callback");
99         tester_print("  Status: 0x%02x", status);
100
101         if (status || !param) {
102                 tester_pre_setup_failed();
103                 return;
104         }
105
106         ba2str(&rp->bdaddr, addr);
107         manufacturer = btohs(rp->manufacturer);
108         supported_settings = btohl(rp->supported_settings);
109         current_settings = btohl(rp->current_settings);
110
111         tester_print("  Address: %s", addr);
112         tester_print("  Version: 0x%02x", rp->version);
113         tester_print("  Manufacturer: 0x%04x", manufacturer);
114         tester_print("  Supported settings: 0x%08x", supported_settings);
115         tester_print("  Current settings: 0x%08x", current_settings);
116         tester_print("  Class: 0x%02x%02x%02x",
117                         rp->dev_class[2], rp->dev_class[1], rp->dev_class[0]);
118         tester_print("  Name: %s", rp->name);
119         tester_print("  Short name: %s", rp->short_name);
120
121         if (strcmp(hciemu_get_address(data->hciemu), addr)) {
122                 tester_pre_setup_failed();
123                 return;
124         }
125
126         tester_pre_setup_complete();
127 }
128
129 static void index_added_callback(uint16_t index, uint16_t length,
130                                         const void *param, void *user_data)
131 {
132         struct test_data *data = tester_get_data();
133
134         tester_print("Index Added callback");
135         tester_print("  Index: 0x%04x", index);
136
137         data->mgmt_index = index;
138
139         mgmt_send(data->mgmt, MGMT_OP_READ_INFO, data->mgmt_index, 0, NULL,
140                                         read_info_callback, NULL, NULL);
141 }
142
143 static void index_removed_callback(uint16_t index, uint16_t length,
144                                         const void *param, void *user_data)
145 {
146         struct test_data *data = tester_get_data();
147
148         tester_print("Index Removed callback");
149         tester_print("  Index: 0x%04x", index);
150
151         if (index != data->mgmt_index)
152                 return;
153
154         mgmt_unregister_index(data->mgmt, data->mgmt_index);
155
156         mgmt_unref(data->mgmt);
157         data->mgmt = NULL;
158
159         tester_post_teardown_complete();
160 }
161
162 static void read_index_list_callback(uint8_t status, uint16_t length,
163                                         const void *param, void *user_data)
164 {
165         struct test_data *data = tester_get_data();
166
167         tester_print("Read Index List callback");
168         tester_print("  Status: 0x%02x", status);
169
170         if (status || !param) {
171                 tester_pre_setup_failed();
172                 return;
173         }
174
175         mgmt_register(data->mgmt, MGMT_EV_INDEX_ADDED, MGMT_INDEX_NONE,
176                                         index_added_callback, NULL, NULL);
177
178         mgmt_register(data->mgmt, MGMT_EV_INDEX_REMOVED, MGMT_INDEX_NONE,
179                                         index_removed_callback, NULL, NULL);
180
181         data->hciemu = hciemu_new(data->hciemu_type);
182         if (!data->hciemu) {
183                 tester_warn("Failed to setup HCI emulation");
184                 tester_pre_setup_failed();
185                 return;
186         }
187
188         tester_print("New hciemu instance created");
189 }
190
191 static void test_pre_setup(const void *data)
192 {
193         struct test_data *test_data = tester_get_data();
194
195         if (!tester_use_debug())
196                 fclose(stderr);
197
198         test_data->mgmt = mgmt_new_default();
199         if (!test_data->mgmt) {
200                 tester_warn("Failed to setup management interface");
201                 tester_pre_setup_failed();
202                 return;
203         }
204
205         mgmt_send(test_data->mgmt, MGMT_OP_READ_INDEX_LIST, MGMT_INDEX_NONE, 0,
206                                 NULL, read_index_list_callback, NULL, NULL);
207 }
208
209 static void test_post_teardown(const void *data)
210 {
211         struct test_data *test_data = tester_get_data();
212
213         if (test_data->hciemu) {
214                 hciemu_unref(test_data->hciemu);
215                 test_data->hciemu = NULL;
216         }
217 }
218
219 static void bluetoothd_start(int hci_index)
220 {
221         char prg_name[PATH_MAX];
222         char index[8];
223         char *prg_argv[4];
224
225         snprintf(prg_name, sizeof(prg_name), "%s/%s", exec_dir, "bluetoothd");
226         snprintf(index, sizeof(index), "%d", hci_index);
227
228         prg_argv[0] = prg_name;
229         prg_argv[1] = "-i";
230         prg_argv[2] = index;
231         prg_argv[3] = NULL;
232
233         if (!tester_use_debug())
234                 fclose(stderr);
235
236         execve(prg_argv[0], prg_argv, NULL);
237 }
238
239 static void emulator(int pipe, int hci_index)
240 {
241         static const char SYSTEM_SOCKET_PATH[] = "\0android_system";
242         char buf[1024];
243         struct sockaddr_un addr;
244         struct timeval tv;
245         int fd;
246         ssize_t len;
247
248         fd = socket(PF_LOCAL, SOCK_DGRAM | SOCK_CLOEXEC, 0);
249         if (fd < 0)
250                 goto failed;
251
252         tv.tv_sec = WAIT_FOR_SIGNAL_TIME;
253         tv.tv_usec = 0;
254         setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(tv));
255
256         memset(&addr, 0, sizeof(addr));
257         addr.sun_family = AF_UNIX;
258         memcpy(addr.sun_path, SYSTEM_SOCKET_PATH, sizeof(SYSTEM_SOCKET_PATH));
259
260         if (bind(fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
261                 perror("Failed to bind system socket");
262                 goto failed;
263         }
264
265         len = write(pipe, EMULATOR_SIGNAL, sizeof(EMULATOR_SIGNAL));
266
267         if (len != sizeof(EMULATOR_SIGNAL))
268                 goto failed;
269
270         memset(buf, 0, sizeof(buf));
271
272         len = read(fd, buf, sizeof(buf));
273         if (len <= 0 || strcmp(buf, "ctl.start=bluetoothd"))
274                 goto failed;
275
276         close(pipe);
277         close(fd);
278         return bluetoothd_start(hci_index);
279
280 failed:
281         close(pipe);
282         if (fd >= 0)
283                 close(fd);
284 }
285
286 static int accept_connection(int sk)
287 {
288         int err;
289         struct pollfd pfd;
290         int new_sk;
291
292         memset(&pfd, 0 , sizeof(pfd));
293         pfd.fd = sk;
294         pfd.events = POLLIN;
295
296         err = poll(&pfd, 1, CONNECT_TIMEOUT);
297         if (err < 0) {
298                 err = errno;
299                 tester_warn("Failed to poll: %d (%s)", err, strerror(err));
300                 return -errno;
301         }
302
303         if (err == 0) {
304                 tester_warn("bluetoothd connect timeout");
305                 return -errno;
306         }
307
308         new_sk = accept(sk, NULL, NULL);
309         if (new_sk < 0) {
310                 err = errno;
311                 tester_warn("Failed to accept socket: %d (%s)",
312                                                         err, strerror(err));
313                 return -errno;
314         }
315
316         return new_sk;
317 }
318
319 static bool init_ipc(void)
320 {
321         struct sockaddr_un addr;
322
323         int sk;
324         int err;
325
326         sk = socket(AF_LOCAL, SOCK_SEQPACKET, 0);
327         if (sk < 0) {
328                 err = errno;
329                 tester_warn("Failed to create socket: %d (%s)", err,
330                                                         strerror(err));
331                 return false;
332         }
333
334         memset(&addr, 0, sizeof(addr));
335         addr.sun_family = AF_UNIX;
336
337         memcpy(addr.sun_path, BLUEZ_HAL_SK_PATH, sizeof(BLUEZ_HAL_SK_PATH));
338
339         if (bind(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
340                 err = errno;
341                 tester_warn("Failed to bind socket: %d (%s)", err,
342                                                                 strerror(err));
343                 close(sk);
344                 return false;
345         }
346
347         if (listen(sk, 2) < 0) {
348                 err = errno;
349                 tester_warn("Failed to listen on socket: %d (%s)", err,
350                                                                 strerror(err));
351                 close(sk);
352                 return false;
353         }
354
355         /* Start Android Bluetooth daemon service */
356         if (property_set("ctl.start", SERVICE_NAME) < 0) {
357                 tester_warn("Failed to start service %s", SERVICE_NAME);
358                 close(sk);
359                 return false;
360         }
361
362         cmd_sk = accept_connection(sk);
363         if (cmd_sk < 0) {
364                 close(sk);
365                 return false;
366         }
367
368         notif_sk = accept_connection(sk);
369         if (notif_sk < 0) {
370                 close(sk);
371                 close(cmd_sk);
372                 cmd_sk = -1;
373                 return false;
374         }
375
376         tester_print("bluetoothd connected");
377
378         close(sk);
379
380         return true;
381 }
382
383 static void cleanup_ipc(void)
384 {
385         if (cmd_sk < 0)
386                 return;
387
388         close(cmd_sk);
389         cmd_sk = -1;
390 }
391
392 static gboolean check_for_daemon(gpointer user_data)
393 {
394         int status;
395         struct test_data *data = user_data;
396
397         if ((waitpid(data->bluetoothd_pid, &status, WNOHANG))
398                                                         != data->bluetoothd_pid)
399                 return true;
400
401         if (data->setup_done) {
402                 if (WIFEXITED(status) &&
403                                 (WEXITSTATUS(status) == EXIT_SUCCESS)) {
404                         tester_test_passed();
405                         return false;
406                 }
407                 tester_test_failed();
408         } else {
409                 tester_setup_failed();
410                 test_post_teardown(data);
411         }
412
413         tester_warn("Unexpected Daemon shutdown with status %d", status);
414         return false;
415 }
416
417 static bool setup_module(int service_id)
418 {
419         struct ipc_hdr response;
420         struct ipc_hdr expected_response;
421
422         struct regmod_msg btmodule_msg = {
423                 .header = {
424                         .service_id = HAL_SERVICE_ID_CORE,
425                         .opcode = HAL_OP_REGISTER_MODULE,
426                         .len = sizeof(struct hal_cmd_register_module),
427                         },
428                 .cmd = {
429                         .service_id = service_id,
430                         .mode = HAL_MODE_DEFAULT,
431                         .max_clients = 1,
432                         },
433         };
434
435         if (write(cmd_sk, &btmodule_msg, sizeof(btmodule_msg)) < 0)
436                 goto fail;
437
438         if (read(cmd_sk, &response, sizeof(response)) < 0)
439                 goto fail;
440
441         expected_response = btmodule_msg.header;
442         expected_response.len = 0;
443
444         if (memcmp(&response, &expected_response, sizeof(response)) == 0)
445                 return true;
446
447 fail:
448         tester_warn("Module registration failed.");
449         return false;
450 }
451
452 static void setup(const void *data)
453 {
454         const struct generic_data *generic_data = data;
455         struct test_data *test_data = tester_get_data();
456         int signal_fd[2];
457         char buf[1024];
458         pid_t pid;
459         int len;
460         unsigned int i;
461
462         if (pipe(signal_fd))
463                 goto failed;
464
465         pid = fork();
466
467         if (pid < 0) {
468                 close(signal_fd[0]);
469                 close(signal_fd[1]);
470                 goto failed;
471         }
472
473         if (pid == 0) {
474                 if (!tester_use_debug())
475                         fclose(stderr);
476
477                 close(signal_fd[0]);
478                 emulator(signal_fd[1], test_data->mgmt_index);
479                 exit(0);
480         }
481
482         close(signal_fd[1]);
483         test_data->bluetoothd_pid = pid;
484
485         len = read(signal_fd[0], buf, sizeof(buf));
486         if (len <= 0 || (strcmp(buf, EMULATOR_SIGNAL))) {
487                 close(signal_fd[0]);
488                 goto failed;
489         }
490
491         g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, check_for_daemon, test_data,
492                                                                         NULL);
493
494         if (!init_ipc()) {
495                 tester_warn("Cannot initialize IPC mechanism!");
496                 goto failed;
497         }
498         tester_print("Will init %d services.", generic_data->num_services);
499
500         for (i = 0; i < generic_data->num_services; i++)
501                 if (!setup_module(generic_data->init_services[i])) {
502                         cleanup_ipc();
503                         goto failed;
504                 }
505
506         test_data->setup_done = true;
507
508         tester_setup_complete();
509         return;
510
511 failed:
512         g_idle_remove_by_data(test_data);
513         tester_setup_failed();
514         test_post_teardown(data);
515 }
516
517 static void teardown(const void *data)
518 {
519         struct test_data *test_data = tester_get_data();
520
521         g_idle_remove_by_data(test_data);
522         cleanup_ipc();
523
524         if (test_data->bluetoothd_pid)
525                 waitpid(test_data->bluetoothd_pid, NULL, 0);
526
527         tester_teardown_complete();
528 }
529
530 static void ipc_send_tc(const void *data)
531 {
532         const struct generic_data *generic_data = data;
533         const struct ipc_data *ipc_data = &generic_data->ipc_data;
534
535         if (ipc_data->len) {
536                 if (write(cmd_sk, ipc_data->buffer, ipc_data->len) < 0)
537                         tester_test_failed();
538         }
539 }
540
541 #define service_data(args...) { args }
542
543 #define gen_data(writelen, writebuf, servicelist...) \
544         {                                                               \
545                 .ipc_data = {                                           \
546                         .buffer = writebuf,                             \
547                         .len = writelen,                                \
548                 },                                                      \
549                 .init_services = service_data(servicelist),             \
550                 .num_services = sizeof((const int[])                    \
551                                         service_data(servicelist)) /    \
552                                         sizeof(int),                    \
553         }
554
555 #define test_generic(name, test, setup, teardown, buffer, writelen, \
556                                                         services...) \
557         do {                                                            \
558                 struct test_data *user;                                 \
559                 static const struct generic_data data =                 \
560                                 gen_data(writelen, buffer, services);   \
561                 user = g_malloc0(sizeof(struct test_data));             \
562                 if (!user)                                              \
563                         break;                                          \
564                 user->hciemu_type = HCIEMU_TYPE_BREDRLE;                \
565                 tester_add_full(name, &data, test_pre_setup, setup,     \
566                                 test, teardown, test_post_teardown,     \
567                                 3, user, g_free);                       \
568         } while (0)
569
570 #define test_opcode_valid(_name, _service, _opcode, _len, _servicelist...) \
571         do {                                                            \
572                 static struct ipc_hdr hdr = {                           \
573                         .service_id = _service,                         \
574                         .opcode = _opcode,                              \
575                         .len = _len,                                    \
576                 };                                                      \
577                                                                         \
578                 test_generic("Opcode out of range: "_name,              \
579                                 ipc_send_tc, setup, teardown,           \
580                                 &hdr,                                   \
581                                 sizeof(hdr),                            \
582                                 _servicelist);                          \
583         } while (0)
584
585 struct vardata {
586         struct ipc_hdr hdr;
587         uint8_t buf[IPC_MTU];
588 } __attribute__((packed));
589
590 #define test_datasize_valid(_name, _service, _opcode, _hlen, _addatasize, \
591                                                         _servicelist...) \
592         do {                                                            \
593                 static struct vardata vdata = {                         \
594                         .hdr.service_id = _service,                     \
595                         .hdr.opcode = _opcode,                          \
596                         .hdr.len = (_hlen) + (_addatasize),             \
597                         .buf = {},                                      \
598                 };                                                      \
599                 test_generic("Data size "_name,                         \
600                                 ipc_send_tc, setup, teardown,           \
601                                 &vdata,                                 \
602                                 sizeof(vdata.hdr) + (_hlen) + (_addatasize),\
603                                 _servicelist);                          \
604         } while (0)
605
606 static struct regmod_msg register_bt_msg = {
607         .header = {
608                 .service_id = HAL_SERVICE_ID_CORE,
609                 .opcode = HAL_OP_REGISTER_MODULE,
610                 .len = sizeof(struct hal_cmd_register_module),
611                 },
612         .cmd = {
613                 .service_id = HAL_SERVICE_ID_BLUETOOTH,
614                 },
615 };
616
617 static struct regmod_msg register_bt_malformed_size_msg = {
618         .header = {
619                 .service_id = HAL_SERVICE_ID_CORE,
620                 .opcode = HAL_OP_REGISTER_MODULE,
621                 /* wrong payload size declared */
622                 .len = sizeof(struct hal_cmd_register_module) - 1,
623                 },
624         .cmd = {
625                 .service_id = HAL_SERVICE_ID_CORE,
626                 },
627 };
628
629 struct malformed_data3_struct {
630         struct regmod_msg valid_msg;
631         int redundant_data;
632 }  __attribute__((packed));
633
634 static struct malformed_data3_struct malformed_data3_msg = {
635         /* valid register service message */
636         .valid_msg = {
637                 .header = {
638                         .service_id = HAL_SERVICE_ID_CORE,
639                         .opcode = HAL_OP_REGISTER_MODULE,
640                         .len = sizeof(struct hal_cmd_register_module),
641                         },
642                 .cmd = {
643                         .service_id = HAL_SERVICE_ID_CORE,
644                         },
645         },
646         /* plus redundant data */
647         . redundant_data = 666,
648 };
649
650 static struct ipc_hdr enable_unknown_service_hdr = {
651         .service_id = HAL_SERVICE_ID_MAX + 1,
652         .opcode = HAL_OP_REGISTER_MODULE,
653         .len = 0,
654 };
655
656 static struct ipc_hdr enable_bt_service_hdr = {
657         .service_id = HAL_SERVICE_ID_BLUETOOTH,
658         .opcode = HAL_OP_ENABLE,
659         .len = 0,
660 };
661
662 struct bt_set_adapter_prop_data {
663         struct ipc_hdr hdr;
664         struct hal_cmd_set_adapter_prop prop;
665
666         /* data placeholder for hal_cmd_set_adapter_prop.val[0] */
667         uint8_t buf[IPC_MTU - sizeof(struct ipc_hdr) -
668                                 sizeof(struct hal_cmd_set_adapter_prop)];
669 } __attribute__((packed));
670
671 #define set_name "new name"
672
673 static struct bt_set_adapter_prop_data bt_set_adapter_prop_data_overs = {
674         .hdr.service_id = HAL_SERVICE_ID_BLUETOOTH,
675         .hdr.opcode = HAL_OP_SET_ADAPTER_PROP,
676         .hdr.len = sizeof(struct hal_cmd_set_adapter_prop) + sizeof(set_name),
677
678         .prop.type = HAL_PROP_ADAPTER_NAME,
679         /* declare wrong descriptor length */
680         .prop.len = sizeof(set_name) + 1,
681         /* init prop.val[0] */
682         .buf = set_name,
683 };
684
685 static struct bt_set_adapter_prop_data bt_set_adapter_prop_data_unders = {
686         .hdr.service_id = HAL_SERVICE_ID_BLUETOOTH,
687         .hdr.opcode = HAL_OP_SET_ADAPTER_PROP,
688         .hdr.len = sizeof(struct hal_cmd_set_adapter_prop) + sizeof(set_name),
689
690         .prop.type = HAL_PROP_ADAPTER_NAME,
691         /* declare wrong descriptor length */
692         .prop.len = sizeof(set_name) - 1,
693         /* init prop.val[0] */
694         .buf = set_name,
695 };
696
697 struct bt_set_remote_prop_data {
698         struct ipc_hdr hdr;
699         struct hal_cmd_set_remote_device_prop prop;
700
701         /* data placeholder for hal_cmd_set_remote_device_prop.val[0] */
702         uint8_t buf[IPC_MTU - sizeof(struct ipc_hdr) -
703                                 sizeof(struct hal_cmd_set_remote_device_prop)];
704 } __attribute__((packed));
705
706 static struct bt_set_remote_prop_data bt_set_remote_prop_data_overs = {
707         .hdr.service_id = HAL_SERVICE_ID_BLUETOOTH,
708         .hdr.opcode = HAL_OP_SET_REMOTE_DEVICE_PROP,
709         .hdr.len = sizeof(struct hal_cmd_set_remote_device_prop) +
710                                                         sizeof(set_name),
711
712         .prop.bdaddr = {},
713         .prop.type = HAL_PROP_DEVICE_NAME,
714         /* declare wrong descriptor length */
715         .prop.len = sizeof(set_name) + 1,
716         .buf = set_name,
717 };
718
719 static struct bt_set_remote_prop_data bt_set_remote_prop_data_unders = {
720         .hdr.service_id = HAL_SERVICE_ID_BLUETOOTH,
721         .hdr.opcode = HAL_OP_SET_REMOTE_DEVICE_PROP,
722         .hdr.len = sizeof(struct hal_cmd_set_remote_device_prop) +
723                                                 sizeof(set_name),
724
725         .prop.bdaddr = {},
726         .prop.type = HAL_PROP_DEVICE_NAME,
727         /* declare wrong descriptor length */
728         .prop.len = sizeof(set_name) - 1,
729         .buf = set_name,
730 };
731
732 struct hidhost_set_info_data {
733         struct ipc_hdr hdr;
734         struct hal_cmd_hidhost_set_info info;
735
736         /* data placeholder for hal_cmd_hidhost_set_info.descr[0] field */
737         uint8_t buf[IPC_MTU - sizeof(struct ipc_hdr) -
738                                 sizeof(struct hal_cmd_hidhost_set_info)];
739 } __attribute__((packed));
740
741 #define set_info_data "some descriptor"
742
743 static struct hidhost_set_info_data hidhost_set_info_data_overs = {
744         .hdr.service_id = HAL_SERVICE_ID_HIDHOST,
745         .hdr.opcode = HAL_OP_HIDHOST_SET_INFO,
746         .hdr.len = sizeof(struct hal_cmd_hidhost_set_info) +
747                                                         sizeof(set_info_data),
748
749         /* declare wrong descriptor length */
750         .info.descr_len = sizeof(set_info_data) + 1,
751         /* init .info.descr[0] */
752         .buf = set_info_data,
753 };
754
755 static struct hidhost_set_info_data hidhost_set_info_data_unders = {
756         .hdr.service_id = HAL_SERVICE_ID_HIDHOST,
757         .hdr.opcode = HAL_OP_HIDHOST_SET_INFO,
758         .hdr.len = sizeof(struct hal_cmd_hidhost_set_info) +
759                                                         sizeof(set_info_data),
760
761         /* declare wrong descriptor length */
762         .info.descr_len = sizeof(set_info_data) - 1,
763         /* init .info.descr[0] */
764         .buf = set_info_data,
765 };
766
767 struct hidhost_set_report_data {
768         struct ipc_hdr hdr;
769         struct hal_cmd_hidhost_set_report report;
770
771         /* data placeholder for hal_cmd_hidhost_set_report.data[0] field */
772         uint8_t buf[IPC_MTU - sizeof(struct ipc_hdr) -
773                                 sizeof(struct hal_cmd_hidhost_set_report)];
774 } __attribute__((packed));
775
776 #define set_rep_data "1234567890"
777
778 static struct hidhost_set_report_data hidhost_set_report_data_overs = {
779         .hdr.service_id = HAL_SERVICE_ID_HIDHOST,
780         .hdr.opcode = HAL_OP_HIDHOST_SET_REPORT,
781         .hdr.len = sizeof(struct hal_cmd_hidhost_set_report) +
782                                                         sizeof(set_rep_data),
783
784         /* declare wrong descriptor length */
785         .report.len = sizeof(set_rep_data) + 1,
786         /* init report.data[0] */
787         .buf = set_rep_data,
788 };
789
790 static struct hidhost_set_report_data hidhost_set_report_data_unders = {
791         .hdr.service_id = HAL_SERVICE_ID_HIDHOST,
792         .hdr.opcode = HAL_OP_HIDHOST_SET_REPORT,
793         .hdr.len = sizeof(struct hal_cmd_hidhost_set_report) +
794                                                         sizeof(set_rep_data),
795
796         /* declare wrong descriptor length */
797         .report.len = sizeof(set_rep_data) - 1,
798         /* init report.data[0] */
799         .buf = set_rep_data,
800 };
801
802 struct hidhost_send_data_data {
803         struct ipc_hdr hdr;
804         struct hal_cmd_hidhost_send_data hiddata;
805
806         /* data placeholder for hal_cmd_hidhost_send_data.data[0] field */
807         uint8_t buf[IPC_MTU - sizeof(struct ipc_hdr) -
808                                 sizeof(struct hal_cmd_hidhost_send_data)];
809 } __attribute__((packed));
810
811 #define send_data_data "1234567890"
812
813 static struct hidhost_send_data_data hidhost_send_data_overs = {
814         .hdr.service_id = HAL_SERVICE_ID_HIDHOST,
815         .hdr.opcode = HAL_OP_HIDHOST_SEND_DATA,
816         .hdr.len = sizeof(struct hal_cmd_hidhost_send_data) +
817                                                         sizeof(send_data_data),
818
819         /* declare wrong descriptor length */
820         .hiddata.len = sizeof(send_data_data) + 1,
821         /* init .hiddata.data[0] */
822         .buf = send_data_data,
823 };
824
825 static struct hidhost_send_data_data hidhost_send_data_unders = {
826         .hdr.service_id = HAL_SERVICE_ID_HIDHOST,
827         .hdr.opcode = HAL_OP_HIDHOST_SEND_DATA,
828         .hdr.len = sizeof(struct hal_cmd_hidhost_send_data) +
829                                                         sizeof(send_data_data),
830
831         /* declare wrong descriptor length */
832         .hiddata.len = sizeof(send_data_data) - 1,
833         /* init .hiddata.data[0] */
834         .buf = send_data_data,
835 };
836
837 #define hfp_number "#1234567890"
838
839 struct hfp_dial_data {
840         struct ipc_hdr hdr;
841         struct hal_cmd_hf_client_dial data;
842
843         uint8_t buf[IPC_MTU - sizeof(struct ipc_hdr) -
844                                 sizeof(struct hal_cmd_hf_client_dial)];
845 } __attribute__((packed));
846
847 static struct hfp_dial_data hfp_dial_overs = {
848         .hdr.service_id = HAL_SERVICE_ID_HANDSFREE_CLIENT,
849         .hdr.opcode = HAL_OP_HF_CLIENT_DIAL,
850         .hdr.len = sizeof(struct hal_cmd_hf_client_dial) + sizeof(hfp_number),
851
852         .data.number_len = sizeof(hfp_number) + 1,
853         .buf = hfp_number,
854 };
855
856 static struct hfp_dial_data hfp_dial_unders = {
857         .hdr.service_id = HAL_SERVICE_ID_HANDSFREE_CLIENT,
858         .hdr.opcode = HAL_OP_HF_CLIENT_DIAL,
859         .hdr.len = sizeof(struct hal_cmd_hf_client_dial) + sizeof(hfp_number),
860
861         .data.number_len = sizeof(hfp_number) - 1,
862         .buf = hfp_number,
863 };
864
865 int main(int argc, char *argv[])
866 {
867         snprintf(exec_dir, sizeof(exec_dir), "%s", dirname(argv[0]));
868
869         tester_init(&argc, &argv);
870
871         /* check general IPC errors */
872         test_generic("Too small data",
873                                 ipc_send_tc, setup, teardown,
874                                 &register_bt_msg, 1);
875
876         test_generic("Malformed data (wrong payload declared)",
877                                 ipc_send_tc, setup, teardown,
878                                 &register_bt_malformed_size_msg,
879                                 sizeof(register_bt_malformed_size_msg),
880                                 HAL_SERVICE_ID_BLUETOOTH);
881
882         test_generic("Malformed data2 (undersized msg)",
883                                 ipc_send_tc, setup, teardown,
884                                 &register_bt_msg,
885                                 sizeof(register_bt_msg) - 1,
886                                 HAL_SERVICE_ID_BLUETOOTH);
887
888         test_generic("Malformed data3 (oversized msg)",
889                                 ipc_send_tc, setup, teardown,
890                                 &malformed_data3_msg,
891                                 sizeof(malformed_data3_msg),
892                                 HAL_SERVICE_ID_BLUETOOTH);
893
894         test_generic("Invalid service",
895                                 ipc_send_tc, setup, teardown,
896                                 &enable_unknown_service_hdr,
897                                 sizeof(enable_unknown_service_hdr),
898                                 HAL_SERVICE_ID_BLUETOOTH);
899
900         test_generic("Enable unregistered service",
901                                 ipc_send_tc, setup, teardown,
902                                 &enable_bt_service_hdr,
903                                 sizeof(enable_bt_service_hdr));
904
905         /* check service handler's max opcode value */
906         test_opcode_valid("CORE", HAL_SERVICE_ID_CORE, 0x03, 0);
907
908         test_opcode_valid("BLUETOOTH", HAL_SERVICE_ID_BLUETOOTH, 0x15, 0,
909                         HAL_SERVICE_ID_BLUETOOTH);
910
911         test_opcode_valid("SOCK", HAL_SERVICE_ID_SOCKET, 0x03, 0,
912                         HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_SOCKET);
913
914         test_opcode_valid("HIDHOST", HAL_SERVICE_ID_HIDHOST, 0x10, 0,
915                         HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
916
917         test_opcode_valid("PAN", HAL_SERVICE_ID_PAN, 0x05, 0,
918                         HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_PAN);
919
920         test_opcode_valid("HANDSFREE", HAL_SERVICE_ID_HANDSFREE, 0x10, 0,
921                                                 HAL_SERVICE_ID_BLUETOOTH,
922                                                 HAL_SERVICE_ID_HANDSFREE);
923
924         test_opcode_valid("A2DP", HAL_SERVICE_ID_A2DP, 0x03, 0,
925                         HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_A2DP);
926
927         test_opcode_valid("HEALTH", HAL_SERVICE_ID_HEALTH, 0x06, 0,
928                                                 HAL_SERVICE_ID_BLUETOOTH,
929                                                 HAL_SERVICE_ID_HEALTH);
930
931         test_opcode_valid("AVRCP", HAL_SERVICE_ID_AVRCP, 0x0b, 0,
932                                 HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_AVRCP);
933
934         test_opcode_valid("GATT", HAL_SERVICE_ID_GATT, 0x24, 0,
935                                 HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_GATT);
936
937         test_opcode_valid("HF_CLIENT", HAL_SERVICE_ID_HANDSFREE_CLIENT, 0x10, 0,
938                         HAL_SERVICE_ID_BLUETOOTH,
939                         HAL_SERVICE_ID_HANDSFREE_CLIENT);
940
941         test_opcode_valid("MAP_CLIENT", HAL_SERVICE_ID_MAP_CLIENT, 0x01, 0,
942                                                 HAL_SERVICE_ID_BLUETOOTH,
943                                                 HAL_SERVICE_ID_MAP_CLIENT);
944
945         /* check for valid data size */
946         test_datasize_valid("CORE Register+", HAL_SERVICE_ID_CORE,
947                         HAL_OP_REGISTER_MODULE,
948                         sizeof(struct hal_cmd_register_module), 1);
949         test_datasize_valid("CORE Register-", HAL_SERVICE_ID_CORE,
950                         HAL_OP_REGISTER_MODULE,
951                         sizeof(struct hal_cmd_register_module), -1);
952         test_datasize_valid("CORE Unregister+", HAL_SERVICE_ID_CORE,
953                         HAL_OP_UNREGISTER_MODULE,
954                         sizeof(struct hal_cmd_unregister_module), 1);
955         test_datasize_valid("CORE Unregister-", HAL_SERVICE_ID_CORE,
956                         HAL_OP_UNREGISTER_MODULE,
957                         sizeof(struct hal_cmd_unregister_module), -1);
958
959         /* check for valid data size for BLUETOOTH */
960         test_datasize_valid("BT Enable+", HAL_SERVICE_ID_BLUETOOTH,
961                         HAL_OP_ENABLE,
962                         0, 1,
963                         HAL_SERVICE_ID_BLUETOOTH);
964         test_datasize_valid("BT Disable+", HAL_SERVICE_ID_BLUETOOTH,
965                         HAL_OP_DISABLE,
966                         0, 1,
967                         HAL_SERVICE_ID_BLUETOOTH);
968         test_datasize_valid("BT Get Adapter Props+", HAL_SERVICE_ID_BLUETOOTH,
969                         HAL_OP_GET_ADAPTER_PROPS,
970                         0, 1,
971                         HAL_SERVICE_ID_BLUETOOTH);
972         test_datasize_valid("BT Get Adapter Prop+", HAL_SERVICE_ID_BLUETOOTH,
973                         HAL_OP_GET_ADAPTER_PROP,
974                         sizeof(struct hal_cmd_get_adapter_prop), 1,
975                         HAL_SERVICE_ID_BLUETOOTH);
976         test_datasize_valid("BT Get Adapter Prop-", HAL_SERVICE_ID_BLUETOOTH,
977                         HAL_OP_GET_ADAPTER_PROP,
978                         sizeof(struct hal_cmd_get_adapter_prop), -1,
979                         HAL_SERVICE_ID_BLUETOOTH);
980         test_datasize_valid("BT Set Adapter Prop+", HAL_SERVICE_ID_BLUETOOTH,
981                         HAL_OP_SET_ADAPTER_PROP,
982                         sizeof(struct hal_cmd_set_adapter_prop), 1,
983                         HAL_SERVICE_ID_BLUETOOTH);
984         test_datasize_valid("BT Set Adapter Prop-", HAL_SERVICE_ID_BLUETOOTH,
985                         HAL_OP_SET_ADAPTER_PROP,
986                         sizeof(struct hal_cmd_set_adapter_prop), -1,
987                         HAL_SERVICE_ID_BLUETOOTH);
988         test_generic("Data size BT Set Adapter Prop Vardata+",
989                         ipc_send_tc, setup, teardown,
990                         &bt_set_adapter_prop_data_overs,
991                         (sizeof(struct ipc_hdr) +
992                                 sizeof(struct hal_cmd_set_adapter_prop) +
993                                 sizeof(set_name)),
994                         HAL_SERVICE_ID_BLUETOOTH);
995         test_generic("Data size BT Set Adapter Prop Vardata+",
996                         ipc_send_tc, setup, teardown,
997                         &bt_set_adapter_prop_data_unders,
998                         (sizeof(struct ipc_hdr) +
999                                 sizeof(struct hal_cmd_set_adapter_prop) +
1000                                 sizeof(set_name)),
1001                         HAL_SERVICE_ID_BLUETOOTH);
1002         test_datasize_valid("BT Get Remote Props+", HAL_SERVICE_ID_BLUETOOTH,
1003                         HAL_OP_GET_REMOTE_DEVICE_PROPS,
1004                         sizeof(struct hal_cmd_get_remote_device_props), 1,
1005                         HAL_SERVICE_ID_BLUETOOTH);
1006         test_datasize_valid("BT Get Remote Props-", HAL_SERVICE_ID_BLUETOOTH,
1007                         HAL_OP_GET_REMOTE_DEVICE_PROPS,
1008                         sizeof(struct hal_cmd_get_remote_device_props), -1,
1009                         HAL_SERVICE_ID_BLUETOOTH);
1010         test_datasize_valid("BT Get Remote Prop+", HAL_SERVICE_ID_BLUETOOTH,
1011                         HAL_OP_GET_REMOTE_DEVICE_PROP,
1012                         sizeof(struct hal_cmd_get_remote_device_prop), 1,
1013                         HAL_SERVICE_ID_BLUETOOTH);
1014         test_datasize_valid("BT Get Remote Prop-", HAL_SERVICE_ID_BLUETOOTH,
1015                         HAL_OP_GET_REMOTE_DEVICE_PROP,
1016                         sizeof(struct hal_cmd_get_remote_device_prop), -1,
1017                         HAL_SERVICE_ID_BLUETOOTH);
1018         test_datasize_valid("BT Set Remote Prop+", HAL_SERVICE_ID_BLUETOOTH,
1019                         HAL_OP_SET_REMOTE_DEVICE_PROP,
1020                         sizeof(struct hal_cmd_set_remote_device_prop), 1,
1021                         HAL_SERVICE_ID_BLUETOOTH);
1022         test_datasize_valid("BT Set Remote Prop-", HAL_SERVICE_ID_BLUETOOTH,
1023                         HAL_OP_SET_REMOTE_DEVICE_PROP,
1024                         sizeof(struct hal_cmd_set_remote_device_prop), -1,
1025                         HAL_SERVICE_ID_BLUETOOTH);
1026         test_generic("Data size BT Set Remote Prop Vardata+",
1027                         ipc_send_tc, setup, teardown,
1028                         &bt_set_remote_prop_data_overs,
1029                         (sizeof(struct ipc_hdr) +
1030                                 sizeof(struct hal_cmd_set_remote_device_prop) +
1031                                 sizeof(set_name)),
1032                         HAL_SERVICE_ID_BLUETOOTH);
1033         test_generic("Data size BT Set Remote Prop Vardata-",
1034                         ipc_send_tc, setup, teardown,
1035                         &bt_set_remote_prop_data_unders,
1036                         (sizeof(struct ipc_hdr) +
1037                                 sizeof(struct hal_cmd_set_remote_device_prop) +
1038                                 sizeof(set_name)),
1039                         HAL_SERVICE_ID_BLUETOOTH);
1040         test_datasize_valid("BT Get Remote SV Rec+", HAL_SERVICE_ID_BLUETOOTH,
1041                         HAL_OP_GET_REMOTE_SERVICE_REC,
1042                         sizeof(struct hal_cmd_get_remote_service_rec), 1,
1043                         HAL_SERVICE_ID_BLUETOOTH);
1044         test_datasize_valid("BT Get Remote SV Rec-", HAL_SERVICE_ID_BLUETOOTH,
1045                         HAL_OP_GET_REMOTE_SERVICE_REC,
1046                         sizeof(struct hal_cmd_get_remote_service_rec), -1,
1047                         HAL_SERVICE_ID_BLUETOOTH);
1048         test_datasize_valid("BT Get Remote Services+", HAL_SERVICE_ID_BLUETOOTH,
1049                         HAL_OP_GET_REMOTE_SERVICES,
1050                         sizeof(struct hal_cmd_get_remote_services), 1,
1051                         HAL_SERVICE_ID_BLUETOOTH);
1052         test_datasize_valid("BT Get Remote Services-", HAL_SERVICE_ID_BLUETOOTH,
1053                         HAL_OP_GET_REMOTE_SERVICES,
1054                         sizeof(struct hal_cmd_get_remote_services), -1,
1055                         HAL_SERVICE_ID_BLUETOOTH);
1056         test_datasize_valid("BT Start Discovery+", HAL_SERVICE_ID_BLUETOOTH,
1057                         HAL_OP_START_DISCOVERY,
1058                         0, 1,
1059                         HAL_SERVICE_ID_BLUETOOTH);
1060         test_datasize_valid("BT Cancel Discovery+", HAL_SERVICE_ID_BLUETOOTH,
1061                         HAL_OP_CANCEL_DISCOVERY,
1062                         0, 1,
1063                         HAL_SERVICE_ID_BLUETOOTH);
1064         test_datasize_valid("BT Create Bond+", HAL_SERVICE_ID_BLUETOOTH,
1065                         HAL_OP_CREATE_BOND,
1066                         sizeof(struct hal_cmd_create_bond), 1,
1067                         HAL_SERVICE_ID_BLUETOOTH);
1068         test_datasize_valid("BT Create Bond-", HAL_SERVICE_ID_BLUETOOTH,
1069                         HAL_OP_CREATE_BOND,
1070                         sizeof(struct hal_cmd_create_bond), -1,
1071                         HAL_SERVICE_ID_BLUETOOTH);
1072         test_datasize_valid("BT Remove Bond+", HAL_SERVICE_ID_BLUETOOTH,
1073                         HAL_OP_REMOVE_BOND,
1074                         sizeof(struct hal_cmd_remove_bond), 1,
1075                         HAL_SERVICE_ID_BLUETOOTH);
1076         test_datasize_valid("BT Remove Bond-", HAL_SERVICE_ID_BLUETOOTH,
1077                         HAL_OP_REMOVE_BOND,
1078                         sizeof(struct hal_cmd_remove_bond), -1,
1079                         HAL_SERVICE_ID_BLUETOOTH);
1080         test_datasize_valid("BT Cancel Bond+", HAL_SERVICE_ID_BLUETOOTH,
1081                         HAL_OP_CANCEL_BOND,
1082                         sizeof(struct hal_cmd_cancel_bond), 1,
1083                         HAL_SERVICE_ID_BLUETOOTH);
1084         test_datasize_valid("BT Cancel Bond-", HAL_SERVICE_ID_BLUETOOTH,
1085                         HAL_OP_CANCEL_BOND,
1086                         sizeof(struct hal_cmd_cancel_bond), -1,
1087                         HAL_SERVICE_ID_BLUETOOTH);
1088         test_datasize_valid("BT Pin Reply+", HAL_SERVICE_ID_BLUETOOTH,
1089                         HAL_OP_PIN_REPLY,
1090                         sizeof(struct hal_cmd_pin_reply), 1,
1091                         HAL_SERVICE_ID_BLUETOOTH);
1092         test_datasize_valid("BT Pin Reply-", HAL_SERVICE_ID_BLUETOOTH,
1093                         HAL_OP_PIN_REPLY,
1094                         sizeof(struct hal_cmd_pin_reply), -1,
1095                         HAL_SERVICE_ID_BLUETOOTH);
1096         test_datasize_valid("BT SSP Reply+", HAL_SERVICE_ID_BLUETOOTH,
1097                         HAL_OP_SSP_REPLY,
1098                         sizeof(struct hal_cmd_ssp_reply), 1,
1099                         HAL_SERVICE_ID_BLUETOOTH);
1100         test_datasize_valid("BT SSP Reply-", HAL_SERVICE_ID_BLUETOOTH,
1101                         HAL_OP_SSP_REPLY,
1102                         sizeof(struct hal_cmd_ssp_reply), -1,
1103                         HAL_SERVICE_ID_BLUETOOTH);
1104         test_datasize_valid("BT DUT Mode Conf+", HAL_SERVICE_ID_BLUETOOTH,
1105                         HAL_OP_DUT_MODE_CONF,
1106                         sizeof(struct hal_cmd_dut_mode_conf), 1,
1107                         HAL_SERVICE_ID_BLUETOOTH);
1108         test_datasize_valid("BT DUT Mode Conf-", HAL_SERVICE_ID_BLUETOOTH,
1109                         HAL_OP_DUT_MODE_CONF,
1110                         sizeof(struct hal_cmd_dut_mode_conf), -1,
1111                         HAL_SERVICE_ID_BLUETOOTH);
1112         test_datasize_valid("BT DUT Mode Send+", HAL_SERVICE_ID_BLUETOOTH,
1113                         HAL_OP_DUT_MODE_SEND,
1114                         sizeof(struct hal_cmd_dut_mode_send), 1,
1115                         HAL_SERVICE_ID_BLUETOOTH);
1116         test_datasize_valid("BT DUT Mode Send-", HAL_SERVICE_ID_BLUETOOTH,
1117                         HAL_OP_DUT_MODE_SEND,
1118                         sizeof(struct hal_cmd_dut_mode_send), -1,
1119                         HAL_SERVICE_ID_BLUETOOTH);
1120         test_datasize_valid("BT LE Test+", HAL_SERVICE_ID_BLUETOOTH,
1121                         HAL_OP_LE_TEST_MODE,
1122                         sizeof(struct hal_cmd_le_test_mode), 1,
1123                         HAL_SERVICE_ID_BLUETOOTH);
1124         test_datasize_valid("BT LE Test-", HAL_SERVICE_ID_BLUETOOTH,
1125                         HAL_OP_LE_TEST_MODE,
1126                         sizeof(struct hal_cmd_le_test_mode), -1,
1127                         HAL_SERVICE_ID_BLUETOOTH);
1128
1129         /* check for valid data size for SOCK */
1130         test_datasize_valid("SOCKET Listen+", HAL_SERVICE_ID_SOCKET,
1131                         HAL_OP_SOCKET_LISTEN,
1132                         sizeof(struct hal_cmd_socket_listen), 1,
1133                         HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_SOCKET);
1134         test_datasize_valid("SOCKET Listen-", HAL_SERVICE_ID_SOCKET,
1135                         HAL_OP_SOCKET_LISTEN,
1136                         sizeof(struct hal_cmd_socket_listen), -1,
1137                         HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_SOCKET);
1138         test_datasize_valid("SOCKET Connect+", HAL_SERVICE_ID_SOCKET,
1139                         HAL_OP_SOCKET_CONNECT,
1140                         sizeof(struct hal_cmd_socket_connect), 1,
1141                         HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_SOCKET);
1142         test_datasize_valid("SOCKET Connect-", HAL_SERVICE_ID_SOCKET,
1143                         HAL_OP_SOCKET_CONNECT,
1144                         sizeof(struct hal_cmd_socket_connect), -1,
1145                         HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_SOCKET);
1146
1147         /* check for valid data size for HID Host */
1148         test_datasize_valid("HIDHOST Connect+", HAL_SERVICE_ID_HIDHOST,
1149                         HAL_OP_HIDHOST_CONNECT,
1150                         sizeof(struct hal_cmd_hidhost_connect), 1,
1151                         HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
1152         test_datasize_valid("HIDHOST Connect-", HAL_SERVICE_ID_HIDHOST,
1153                         HAL_OP_HIDHOST_CONNECT,
1154                         sizeof(struct hal_cmd_hidhost_connect), -1,
1155                         HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
1156         test_datasize_valid("HIDHOST Disconnect+", HAL_SERVICE_ID_HIDHOST,
1157                         HAL_OP_HIDHOST_DISCONNECT,
1158                         sizeof(struct hal_cmd_hidhost_disconnect), 1,
1159                         HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
1160         test_datasize_valid("HIDHOST Disconnect-", HAL_SERVICE_ID_HIDHOST,
1161                         HAL_OP_HIDHOST_DISCONNECT,
1162                         sizeof(struct hal_cmd_hidhost_disconnect), -1,
1163                         HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
1164         test_datasize_valid("HIDHOST Virt. Unplug+", HAL_SERVICE_ID_HIDHOST,
1165                         HAL_OP_HIDHOST_VIRTUAL_UNPLUG,
1166                         sizeof(struct hal_cmd_hidhost_virtual_unplug), 1,
1167                         HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
1168         test_datasize_valid("HIDHOST Virt. Unplug-", HAL_SERVICE_ID_HIDHOST,
1169                         HAL_OP_HIDHOST_VIRTUAL_UNPLUG,
1170                         sizeof(struct hal_cmd_hidhost_virtual_unplug), -1,
1171                         HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
1172         test_datasize_valid("HIDHOST Set Info+", HAL_SERVICE_ID_HIDHOST,
1173                         HAL_OP_HIDHOST_SET_INFO,
1174                         sizeof(struct hal_cmd_hidhost_set_info), 1,
1175                         HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
1176         test_datasize_valid("HIDHOST Set Info-", HAL_SERVICE_ID_HIDHOST,
1177                         HAL_OP_HIDHOST_SET_INFO,
1178                         sizeof(struct hal_cmd_hidhost_set_info), -1,
1179                         HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
1180         test_generic("Data size HIDHOST Set Info Vardata+",
1181                         ipc_send_tc, setup, teardown,
1182                         &hidhost_set_info_data_overs,
1183                         (sizeof(struct ipc_hdr) +
1184                                 sizeof(struct hal_cmd_hidhost_set_info) +
1185                                 sizeof(set_info_data)),
1186                         HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
1187         test_generic("Data size HIDHOST Set Info Vardata-",
1188                         ipc_send_tc, setup, teardown,
1189                         &hidhost_set_info_data_unders,
1190                         (sizeof(struct ipc_hdr) +
1191                                 sizeof(struct hal_cmd_hidhost_set_info) +
1192                                 sizeof(set_info_data)),
1193                         HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
1194         test_datasize_valid("HIDHOST Get Protocol+", HAL_SERVICE_ID_HIDHOST,
1195                         HAL_OP_HIDHOST_GET_PROTOCOL,
1196                         sizeof(struct hal_cmd_hidhost_get_protocol), 1,
1197                         HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
1198         test_datasize_valid("HIDHOST Get Protocol-", HAL_SERVICE_ID_HIDHOST,
1199                         HAL_OP_HIDHOST_GET_PROTOCOL,
1200                         sizeof(struct hal_cmd_hidhost_get_protocol), -1,
1201                         HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
1202         test_datasize_valid("HIDHOST Set Protocol+", HAL_SERVICE_ID_HIDHOST,
1203                         HAL_OP_HIDHOST_SET_PROTOCOL,
1204                         sizeof(struct hal_cmd_hidhost_set_protocol), 1,
1205                         HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
1206         test_datasize_valid("HIDHOST Set Protocol-", HAL_SERVICE_ID_HIDHOST,
1207                         HAL_OP_HIDHOST_SET_PROTOCOL,
1208                         sizeof(struct hal_cmd_hidhost_set_protocol), -1,
1209                         HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
1210         test_datasize_valid("HIDHOST Get Report+", HAL_SERVICE_ID_HIDHOST,
1211                         HAL_OP_HIDHOST_GET_REPORT,
1212                         sizeof(struct hal_cmd_hidhost_get_report), 1,
1213                         HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
1214         test_datasize_valid("HIDHOST Get Report-", HAL_SERVICE_ID_HIDHOST,
1215                         HAL_OP_HIDHOST_GET_REPORT,
1216                         sizeof(struct hal_cmd_hidhost_get_report), -1,
1217                         HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
1218         test_datasize_valid("HIDHOST Set Report+", HAL_SERVICE_ID_HIDHOST,
1219                         HAL_OP_HIDHOST_SET_REPORT,
1220                         sizeof(struct hal_cmd_hidhost_set_report), 1,
1221                         HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
1222         test_datasize_valid("HIDHOST Set Report-", HAL_SERVICE_ID_HIDHOST,
1223                         HAL_OP_HIDHOST_SET_REPORT,
1224                         sizeof(struct hal_cmd_hidhost_set_report), -1,
1225                         HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
1226         test_generic("Data size HIDHOST Set Report Vardata+",
1227                         ipc_send_tc, setup, teardown,
1228                         &hidhost_set_report_data_overs,
1229                         (sizeof(struct ipc_hdr) +
1230                                 sizeof(struct hal_cmd_hidhost_set_report) +
1231                                 sizeof(set_rep_data)),
1232                         HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
1233         test_generic("Data size HIDHOST Set Report Vardata-",
1234                         ipc_send_tc, setup, teardown,
1235                         &hidhost_set_report_data_unders,
1236                         (sizeof(struct ipc_hdr) +
1237                                 sizeof(struct hal_cmd_hidhost_set_report) +
1238                                 sizeof(set_rep_data)),
1239                         HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
1240         test_datasize_valid("HIDHOST Send Data+", HAL_SERVICE_ID_HIDHOST,
1241                         HAL_OP_HIDHOST_SEND_DATA,
1242                         sizeof(struct hal_cmd_hidhost_send_data), 1,
1243                         HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
1244         test_datasize_valid("HIDHOST Send Data-", HAL_SERVICE_ID_HIDHOST,
1245                         HAL_OP_HIDHOST_SEND_DATA,
1246                         sizeof(struct hal_cmd_hidhost_send_data), -1,
1247                         HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
1248         test_generic("Data size HIDHOST Send Vardata+",
1249                         ipc_send_tc, setup, teardown,
1250                         &hidhost_send_data_overs,
1251                         (sizeof(struct ipc_hdr) +
1252                                 sizeof(struct hal_cmd_hidhost_send_data) +
1253                                 sizeof(send_data_data)),
1254                         HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
1255         test_generic("Data size HIDHOST Send Vardata-",
1256                         ipc_send_tc, setup, teardown,
1257                         &hidhost_send_data_unders,
1258                         (sizeof(struct ipc_hdr) +
1259                                 sizeof(struct hal_cmd_hidhost_send_data) +
1260                                 sizeof(send_data_data)),
1261                         HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
1262
1263         /* check for valid data size for PAN */
1264         test_datasize_valid("PAN Enable+", HAL_SERVICE_ID_PAN,
1265                         HAL_OP_PAN_ENABLE,
1266                         sizeof(struct hal_cmd_pan_enable), 1,
1267                         HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_PAN);
1268         test_datasize_valid("PAN Enable-", HAL_SERVICE_ID_PAN,
1269                         HAL_OP_PAN_ENABLE,
1270                         sizeof(struct hal_cmd_pan_enable), -1,
1271                         HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_PAN);
1272         test_datasize_valid("PAN Get Role+", HAL_SERVICE_ID_PAN,
1273                         HAL_OP_PAN_GET_ROLE,
1274                         0, 1,
1275                         HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_PAN);
1276         test_datasize_valid("PAN Connect+", HAL_SERVICE_ID_PAN,
1277                         HAL_OP_PAN_CONNECT,
1278                         sizeof(struct hal_cmd_pan_connect), 1,
1279                         HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_PAN);
1280         test_datasize_valid("PAN Connect-", HAL_SERVICE_ID_PAN,
1281                         HAL_OP_PAN_CONNECT,
1282                         sizeof(struct hal_cmd_pan_connect), -1,
1283                         HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_PAN);
1284         test_datasize_valid("PAN Disconnect+", HAL_SERVICE_ID_PAN,
1285                         HAL_OP_PAN_DISCONNECT,
1286                         sizeof(struct hal_cmd_pan_disconnect), 1,
1287                         HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_PAN);
1288         test_datasize_valid("PAN Disconnect-", HAL_SERVICE_ID_PAN,
1289                         HAL_OP_PAN_DISCONNECT,
1290                         sizeof(struct hal_cmd_pan_disconnect), -1,
1291                         HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_PAN);
1292
1293         /* check for valid data size for A2DP */
1294         test_datasize_valid("A2DP Connect+", HAL_SERVICE_ID_A2DP,
1295                         HAL_OP_A2DP_CONNECT,
1296                         sizeof(struct hal_cmd_a2dp_connect), 1,
1297                         HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_A2DP);
1298         test_datasize_valid("A2DP Connect-", HAL_SERVICE_ID_A2DP,
1299                         HAL_OP_A2DP_CONNECT,
1300                         sizeof(struct hal_cmd_a2dp_connect), -1,
1301                         HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_A2DP);
1302         test_datasize_valid("A2DP Disconnect+", HAL_SERVICE_ID_A2DP,
1303                         HAL_OP_A2DP_DISCONNECT,
1304                         sizeof(struct hal_cmd_a2dp_disconnect), 1,
1305                         HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_A2DP);
1306         test_datasize_valid("A2DP Disconnect-", HAL_SERVICE_ID_A2DP,
1307                         HAL_OP_A2DP_DISCONNECT,
1308                         sizeof(struct hal_cmd_a2dp_disconnect), -1,
1309                         HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_A2DP);
1310
1311         /* Check for valid data size for Handsfree Client */
1312         test_datasize_valid("HF_CLIENT Connect+",
1313                         HAL_SERVICE_ID_HANDSFREE_CLIENT,
1314                         HAL_OP_HF_CLIENT_CONNECT,
1315                         sizeof(struct hal_cmd_hf_client_connect), 1,
1316                         HAL_SERVICE_ID_BLUETOOTH,
1317                         HAL_SERVICE_ID_HANDSFREE_CLIENT);
1318         test_datasize_valid("HF_CLIENT Connect-",
1319                         HAL_SERVICE_ID_HANDSFREE_CLIENT,
1320                         HAL_OP_HF_CLIENT_CONNECT,
1321                         sizeof(struct hal_cmd_hf_client_connect), -1,
1322                         HAL_SERVICE_ID_BLUETOOTH,
1323                         HAL_SERVICE_ID_HANDSFREE_CLIENT);
1324         test_datasize_valid("HF_CLIENT Disconnect+",
1325                         HAL_SERVICE_ID_HANDSFREE_CLIENT,
1326                         HAL_OP_HF_CLIENT_DISCONNECT,
1327                         sizeof(struct hal_cmd_hf_client_disconnect), 1,
1328                         HAL_SERVICE_ID_BLUETOOTH,
1329                         HAL_SERVICE_ID_HANDSFREE_CLIENT);
1330         test_datasize_valid("HF_CLIENT Disconnect-",
1331                         HAL_SERVICE_ID_HANDSFREE_CLIENT,
1332                         HAL_OP_HF_CLIENT_DISCONNECT,
1333                         sizeof(struct hal_cmd_hf_client_disconnect), -1,
1334                         HAL_SERVICE_ID_BLUETOOTH,
1335                         HAL_SERVICE_ID_HANDSFREE_CLIENT);
1336         test_datasize_valid("HF_CLIENT Connect Audio+",
1337                         HAL_SERVICE_ID_HANDSFREE_CLIENT,
1338                         HAL_OP_HF_CLIENT_CONNECT_AUDIO,
1339                         sizeof(struct hal_cmd_hf_client_connect_audio), 1,
1340                         HAL_SERVICE_ID_BLUETOOTH,
1341                         HAL_SERVICE_ID_HANDSFREE_CLIENT);
1342         test_datasize_valid("HF_CLIENT Connect Audio-",
1343                         HAL_SERVICE_ID_HANDSFREE_CLIENT,
1344                         HAL_OP_HF_CLIENT_CONNECT_AUDIO,
1345                         sizeof(struct hal_cmd_hf_client_connect_audio), -1,
1346                         HAL_SERVICE_ID_BLUETOOTH,
1347                         HAL_SERVICE_ID_HANDSFREE_CLIENT);
1348         test_datasize_valid("HF_CLIENT Disconnect Audio+",
1349                         HAL_SERVICE_ID_HANDSFREE_CLIENT,
1350                         HAL_OP_HF_CLIENT_DISCONNECT_AUDIO,
1351                         sizeof(struct hal_cmd_hf_client_disconnect_audio), 1,
1352                         HAL_SERVICE_ID_BLUETOOTH,
1353                         HAL_SERVICE_ID_HANDSFREE_CLIENT);
1354         test_datasize_valid("HF_CLIENT Disconnect Audio-",
1355                         HAL_SERVICE_ID_HANDSFREE_CLIENT,
1356                         HAL_OP_HF_CLIENT_DISCONNECT_AUDIO,
1357                         sizeof(struct hal_cmd_hf_client_disconnect_audio), -1,
1358                         HAL_SERVICE_ID_BLUETOOTH,
1359                         HAL_SERVICE_ID_HANDSFREE_CLIENT);
1360         test_datasize_valid("HF_CLIENT Start VR+",
1361                         HAL_SERVICE_ID_HANDSFREE_CLIENT,
1362                         HAL_OP_HF_CLIENT_START_VR,
1363                         0, 1,
1364                         HAL_SERVICE_ID_BLUETOOTH,
1365                         HAL_SERVICE_ID_HANDSFREE_CLIENT);
1366         test_datasize_valid("HF_CLIENT Start VR-",
1367                         HAL_SERVICE_ID_HANDSFREE_CLIENT,
1368                         HAL_OP_HF_CLIENT_START_VR,
1369                         0, -1,
1370                         HAL_SERVICE_ID_BLUETOOTH,
1371                         HAL_SERVICE_ID_HANDSFREE_CLIENT);
1372         test_datasize_valid("HF_CLIENT Stop VR+",
1373                         HAL_SERVICE_ID_HANDSFREE_CLIENT,
1374                         HAL_OP_HF_CLIENT_STOP_VR,
1375                         0, 1,
1376                         HAL_SERVICE_ID_BLUETOOTH,
1377                         HAL_SERVICE_ID_HANDSFREE_CLIENT);
1378         test_datasize_valid("HF_CLIENT Stop VR-",
1379                         HAL_SERVICE_ID_HANDSFREE_CLIENT,
1380                         HAL_OP_HF_CLIENT_STOP_VR,
1381                         0, -1,
1382                         HAL_SERVICE_ID_BLUETOOTH,
1383                         HAL_SERVICE_ID_HANDSFREE_CLIENT);
1384         test_datasize_valid("HF_CLIENT Vol Contr.+",
1385                         HAL_SERVICE_ID_HANDSFREE_CLIENT,
1386                         HAL_OP_HF_CLIENT_VOLUME_CONTROL,
1387                         sizeof(struct hal_cmd_hf_client_volume_control), 1,
1388                         HAL_SERVICE_ID_BLUETOOTH,
1389                         HAL_SERVICE_ID_HANDSFREE_CLIENT);
1390         test_datasize_valid("HF_CLIENT Vol Contr.-",
1391                         HAL_SERVICE_ID_HANDSFREE_CLIENT,
1392                         HAL_OP_HF_CLIENT_VOLUME_CONTROL,
1393                         sizeof(struct hal_cmd_hf_client_volume_control), -1,
1394                         HAL_SERVICE_ID_BLUETOOTH,
1395                         HAL_SERVICE_ID_HANDSFREE_CLIENT);
1396         test_generic("Data size HF_CLIENT Dial Vardata+",
1397                         ipc_send_tc, setup, teardown,
1398                         &hfp_dial_overs,
1399                         (sizeof(struct ipc_hdr) +
1400                                 sizeof(struct hal_cmd_hf_client_dial) +
1401                                 sizeof(hfp_number)),
1402                         HAL_SERVICE_ID_BLUETOOTH,
1403                         HAL_SERVICE_ID_HANDSFREE_CLIENT);
1404         test_generic("Data size HF_CLIENT Dial Vardata-",
1405                         ipc_send_tc, setup, teardown,
1406                         &hfp_dial_unders,
1407                         (sizeof(struct ipc_hdr) +
1408                                 sizeof(struct hal_cmd_hf_client_dial) +
1409                                 sizeof(hfp_number)),
1410                         HAL_SERVICE_ID_BLUETOOTH,
1411                         HAL_SERVICE_ID_HANDSFREE_CLIENT);
1412         test_datasize_valid("HF_CLIENT Dial Memory+",
1413                         HAL_SERVICE_ID_HANDSFREE_CLIENT,
1414                         HAL_OP_HF_CLIENT_DIAL_MEMORY,
1415                         sizeof(struct hal_cmd_hf_client_dial_memory), 1,
1416                         HAL_SERVICE_ID_BLUETOOTH,
1417                         HAL_SERVICE_ID_HANDSFREE_CLIENT);
1418         test_datasize_valid("HF_CLIENT Dial Memory-",
1419                         HAL_SERVICE_ID_HANDSFREE_CLIENT,
1420                         HAL_OP_HF_CLIENT_DIAL_MEMORY,
1421                         sizeof(struct hal_cmd_hf_client_dial_memory), -1,
1422                         HAL_SERVICE_ID_BLUETOOTH,
1423                         HAL_SERVICE_ID_HANDSFREE_CLIENT);
1424         test_datasize_valid("HF_CLIENT Call Action+",
1425                         HAL_SERVICE_ID_HANDSFREE_CLIENT,
1426                         HAL_OP_HF_CLIENT_CALL_ACTION,
1427                         sizeof(struct hal_cmd_hf_client_call_action), 1,
1428                         HAL_SERVICE_ID_BLUETOOTH,
1429                         HAL_SERVICE_ID_HANDSFREE_CLIENT);
1430         test_datasize_valid("HF_CLIENT Call Action-",
1431                         HAL_SERVICE_ID_HANDSFREE_CLIENT,
1432                         HAL_OP_HF_CLIENT_CALL_ACTION,
1433                         sizeof(struct hal_cmd_hf_client_call_action), -1,
1434                         HAL_SERVICE_ID_BLUETOOTH,
1435                         HAL_SERVICE_ID_HANDSFREE_CLIENT);
1436         test_datasize_valid("HF_CLIENT Query Current Calls+",
1437                         HAL_SERVICE_ID_BLUETOOTH,
1438                         HAL_OP_HF_CLIENT_QUERY_CURRENT_CALLS,
1439                         0, 1,
1440                         HAL_SERVICE_ID_BLUETOOTH,
1441                         HAL_SERVICE_ID_HANDSFREE_CLIENT);
1442         test_datasize_valid("HF_CLIENT Query Current Calls-",
1443                         HAL_SERVICE_ID_HANDSFREE_CLIENT,
1444                         HAL_OP_HF_CLIENT_QUERY_CURRENT_CALLS,
1445                         0, -1,
1446                         HAL_SERVICE_ID_BLUETOOTH,
1447                         HAL_SERVICE_ID_HANDSFREE_CLIENT);
1448         test_datasize_valid("HF_CLIENT Query Operator Name+",
1449                         HAL_SERVICE_ID_HANDSFREE_CLIENT,
1450                         HAL_OP_HF_CLIENT_QUERY_OPERATOR_NAME,
1451                         0, 1,
1452                         HAL_SERVICE_ID_BLUETOOTH,
1453                         HAL_SERVICE_ID_HANDSFREE_CLIENT);
1454         test_datasize_valid("HF_CLIENT Query Operator Name-",
1455                         HAL_SERVICE_ID_HANDSFREE_CLIENT,
1456                         HAL_OP_HF_CLIENT_QUERY_OPERATOR_NAME,
1457                         0, -1,
1458                         HAL_SERVICE_ID_BLUETOOTH,
1459                         HAL_SERVICE_ID_HANDSFREE_CLIENT);
1460         test_datasize_valid("HF_CLIENT Retrieve Subscrb. Info+",
1461                         HAL_SERVICE_ID_HANDSFREE_CLIENT,
1462                         HAL_OP_HF_CLIENT_RETRIEVE_SUBSCR_INFO,
1463                         0, 1,
1464                         HAL_SERVICE_ID_BLUETOOTH,
1465                         HAL_SERVICE_ID_HANDSFREE_CLIENT);
1466         test_datasize_valid("HF_CLIENT Retrieve Subscrb. Info-",
1467                         HAL_SERVICE_ID_HANDSFREE_CLIENT,
1468                         HAL_OP_HF_CLIENT_RETRIEVE_SUBSCR_INFO,
1469                         0, -1,
1470                         HAL_SERVICE_ID_BLUETOOTH,
1471                         HAL_SERVICE_ID_HANDSFREE_CLIENT);
1472         test_datasize_valid("HF_CLIENT Send DTMF+",
1473                         HAL_SERVICE_ID_HANDSFREE_CLIENT,
1474                         HAL_OP_HF_CLIENT_SEND_DTMF,
1475                         sizeof(struct hal_cmd_hf_client_send_dtmf), 1,
1476                         HAL_SERVICE_ID_BLUETOOTH,
1477                         HAL_SERVICE_ID_HANDSFREE_CLIENT);
1478         test_datasize_valid("HF_CLIENT Send DTMF-",
1479                         HAL_SERVICE_ID_HANDSFREE_CLIENT,
1480                         HAL_OP_HF_CLIENT_SEND_DTMF,
1481                         sizeof(struct hal_cmd_hf_client_send_dtmf), -1,
1482                         HAL_SERVICE_ID_BLUETOOTH,
1483                         HAL_SERVICE_ID_HANDSFREE_CLIENT);
1484         test_datasize_valid("HF_CLIENT Get Last Voice Tag+",
1485                         HAL_SERVICE_ID_HANDSFREE_CLIENT,
1486                         HAL_OP_HF_CLIENT_GET_LAST_VOICE_TAG_NUM,
1487                         0, 1,
1488                         HAL_SERVICE_ID_BLUETOOTH,
1489                         HAL_SERVICE_ID_HANDSFREE_CLIENT);
1490         test_datasize_valid("HF_CLIENT Get Last Voice Tag-",
1491                         HAL_SERVICE_ID_HANDSFREE_CLIENT,
1492                         HAL_OP_HF_CLIENT_GET_LAST_VOICE_TAG_NUM,
1493                         0, -1,
1494                         HAL_SERVICE_ID_BLUETOOTH,
1495                         HAL_SERVICE_ID_HANDSFREE_CLIENT);
1496
1497         /* check for valid data size for MAP CLIENT */
1498         test_datasize_valid("MAP CLIENT Get instances+",
1499                                 HAL_SERVICE_ID_MAP_CLIENT,
1500                                 HAL_OP_MAP_CLIENT_GET_INSTANCES,
1501                                 sizeof(struct hal_cmd_map_client_get_instances),
1502                                 1, HAL_SERVICE_ID_BLUETOOTH,
1503                                 HAL_SERVICE_ID_MAP_CLIENT);
1504         test_datasize_valid("MAP CLIENT Get instances-",
1505                                 HAL_SERVICE_ID_MAP_CLIENT,
1506                                 HAL_OP_MAP_CLIENT_GET_INSTANCES,
1507                                 sizeof(struct hal_cmd_map_client_get_instances),
1508                                 -1, HAL_SERVICE_ID_BLUETOOTH,
1509                                 HAL_SERVICE_ID_MAP_CLIENT);
1510
1511         return tester_run();
1512 }