3 * BlueZ - Bluetooth protocol stack for Linux
5 * Copyright (C) 2013-2014 Intel Corporation. All rights reserved.
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.
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.
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
33 #include <sys/socket.h>
34 #include <sys/types.h>
40 #include "lib/bluetooth.h"
43 #include "src/shared/tester.h"
44 #include "src/shared/mgmt.h"
45 #include "emulator/hciemu.h"
48 #include "ipc-common.h"
50 #include <cutils/properties.h>
52 #define WAIT_FOR_SIGNAL_TIME 2 /* in seconds */
53 #define EMULATOR_SIGNAL "emulator_started"
58 struct hciemu *hciemu;
59 enum hciemu_type hciemu_type;
70 struct ipc_data ipc_data;
72 unsigned int num_services;
77 struct ipc_hdr header;
78 struct hal_cmd_register_module cmd;
79 } __attribute__((packed));
81 #define CONNECT_TIMEOUT (5 * 1000)
82 #define SERVICE_NAME "bluetoothd"
84 static char exec_dir[PATH_MAX];
86 static int cmd_sk = -1;
87 static int notif_sk = -1;
89 static void read_info_callback(uint8_t status, uint16_t length,
90 const void *param, void *user_data)
92 struct test_data *data = tester_get_data();
93 const struct mgmt_rp_read_info *rp = param;
95 uint16_t manufacturer;
96 uint32_t supported_settings, current_settings;
98 tester_print("Read Info callback");
99 tester_print(" Status: 0x%02x", status);
101 if (status || !param) {
102 tester_pre_setup_failed();
106 ba2str(&rp->bdaddr, addr);
107 manufacturer = btohs(rp->manufacturer);
108 supported_settings = btohl(rp->supported_settings);
109 current_settings = btohl(rp->current_settings);
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);
121 if (strcmp(hciemu_get_address(data->hciemu), addr)) {
122 tester_pre_setup_failed();
126 tester_pre_setup_complete();
129 static void index_added_callback(uint16_t index, uint16_t length,
130 const void *param, void *user_data)
132 struct test_data *data = tester_get_data();
134 tester_print("Index Added callback");
135 tester_print(" Index: 0x%04x", index);
137 data->mgmt_index = index;
139 mgmt_send(data->mgmt, MGMT_OP_READ_INFO, data->mgmt_index, 0, NULL,
140 read_info_callback, NULL, NULL);
143 static void index_removed_callback(uint16_t index, uint16_t length,
144 const void *param, void *user_data)
146 struct test_data *data = tester_get_data();
148 tester_print("Index Removed callback");
149 tester_print(" Index: 0x%04x", index);
151 if (index != data->mgmt_index)
154 mgmt_unregister_index(data->mgmt, data->mgmt_index);
156 mgmt_unref(data->mgmt);
159 tester_post_teardown_complete();
162 static void read_index_list_callback(uint8_t status, uint16_t length,
163 const void *param, void *user_data)
165 struct test_data *data = tester_get_data();
167 tester_print("Read Index List callback");
168 tester_print(" Status: 0x%02x", status);
170 if (status || !param) {
171 tester_pre_setup_failed();
175 mgmt_register(data->mgmt, MGMT_EV_INDEX_ADDED, MGMT_INDEX_NONE,
176 index_added_callback, NULL, NULL);
178 mgmt_register(data->mgmt, MGMT_EV_INDEX_REMOVED, MGMT_INDEX_NONE,
179 index_removed_callback, NULL, NULL);
181 data->hciemu = hciemu_new(data->hciemu_type);
183 tester_warn("Failed to setup HCI emulation");
184 tester_pre_setup_failed();
188 tester_print("New hciemu instance created");
191 static void test_pre_setup(const void *data)
193 struct test_data *test_data = tester_get_data();
195 if (!tester_use_debug())
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();
205 mgmt_send(test_data->mgmt, MGMT_OP_READ_INDEX_LIST, MGMT_INDEX_NONE, 0,
206 NULL, read_index_list_callback, NULL, NULL);
209 static void test_post_teardown(const void *data)
211 struct test_data *test_data = tester_get_data();
213 if (test_data->hciemu) {
214 hciemu_unref(test_data->hciemu);
215 test_data->hciemu = NULL;
219 static void bluetoothd_start(int hci_index)
221 char prg_name[PATH_MAX];
225 snprintf(prg_name, sizeof(prg_name), "%s/%s", exec_dir, "bluetoothd");
226 snprintf(index, sizeof(index), "%d", hci_index);
228 prg_argv[0] = prg_name;
233 if (!tester_use_debug())
236 execve(prg_argv[0], prg_argv, NULL);
239 static void emulator(int pipe, int hci_index)
241 static const char SYSTEM_SOCKET_PATH[] = "\0android_system";
243 struct sockaddr_un addr;
248 fd = socket(PF_LOCAL, SOCK_DGRAM | SOCK_CLOEXEC, 0);
252 tv.tv_sec = WAIT_FOR_SIGNAL_TIME;
254 setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(tv));
256 memset(&addr, 0, sizeof(addr));
257 addr.sun_family = AF_UNIX;
258 memcpy(addr.sun_path, SYSTEM_SOCKET_PATH, sizeof(SYSTEM_SOCKET_PATH));
260 if (bind(fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
261 perror("Failed to bind system socket");
265 len = write(pipe, EMULATOR_SIGNAL, sizeof(EMULATOR_SIGNAL));
267 if (len != sizeof(EMULATOR_SIGNAL))
270 memset(buf, 0, sizeof(buf));
272 len = read(fd, buf, sizeof(buf));
273 if (len <= 0 || strcmp(buf, "ctl.start=bluetoothd"))
278 return bluetoothd_start(hci_index);
286 static int accept_connection(int sk)
292 memset(&pfd, 0 , sizeof(pfd));
296 err = poll(&pfd, 1, CONNECT_TIMEOUT);
299 tester_warn("Failed to poll: %d (%s)", err, strerror(err));
304 tester_warn("bluetoothd connect timeout");
308 new_sk = accept(sk, NULL, NULL);
311 tester_warn("Failed to accept socket: %d (%s)",
319 static bool init_ipc(void)
321 struct sockaddr_un addr;
326 sk = socket(AF_LOCAL, SOCK_SEQPACKET, 0);
329 tester_warn("Failed to create socket: %d (%s)", err,
334 memset(&addr, 0, sizeof(addr));
335 addr.sun_family = AF_UNIX;
337 memcpy(addr.sun_path, BLUEZ_HAL_SK_PATH, sizeof(BLUEZ_HAL_SK_PATH));
339 if (bind(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
341 tester_warn("Failed to bind socket: %d (%s)", err,
347 if (listen(sk, 2) < 0) {
349 tester_warn("Failed to listen on socket: %d (%s)", err,
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);
362 cmd_sk = accept_connection(sk);
368 notif_sk = accept_connection(sk);
376 tester_print("bluetoothd connected");
383 static void cleanup_ipc(void)
392 static gboolean check_for_daemon(gpointer user_data)
395 struct test_data *data = user_data;
397 if ((waitpid(data->bluetoothd_pid, &status, WNOHANG))
398 != data->bluetoothd_pid)
401 if (data->setup_done) {
402 if (WIFEXITED(status) &&
403 (WEXITSTATUS(status) == EXIT_SUCCESS)) {
404 tester_test_passed();
407 tester_test_failed();
409 tester_setup_failed();
410 test_post_teardown(data);
413 tester_warn("Unexpected Daemon shutdown with status %d", status);
417 static bool setup_module(int service_id)
419 struct ipc_hdr response;
420 struct ipc_hdr expected_response;
422 struct regmod_msg btmodule_msg = {
424 .service_id = HAL_SERVICE_ID_CORE,
425 .opcode = HAL_OP_REGISTER_MODULE,
426 .len = sizeof(struct hal_cmd_register_module),
429 .service_id = service_id,
430 .mode = HAL_MODE_DEFAULT,
435 if (write(cmd_sk, &btmodule_msg, sizeof(btmodule_msg)) < 0)
438 if (read(cmd_sk, &response, sizeof(response)) < 0)
441 expected_response = btmodule_msg.header;
442 expected_response.len = 0;
444 if (memcmp(&response, &expected_response, sizeof(response)) == 0)
448 tester_warn("Module registration failed.");
452 static void setup(const void *data)
454 const struct generic_data *generic_data = data;
455 struct test_data *test_data = tester_get_data();
474 if (!tester_use_debug())
478 emulator(signal_fd[1], test_data->mgmt_index);
483 test_data->bluetoothd_pid = pid;
485 len = read(signal_fd[0], buf, sizeof(buf));
486 if (len <= 0 || (strcmp(buf, EMULATOR_SIGNAL))) {
491 g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, check_for_daemon, test_data,
495 tester_warn("Cannot initialize IPC mechanism!");
498 tester_print("Will init %d services.", generic_data->num_services);
500 for (i = 0; i < generic_data->num_services; i++)
501 if (!setup_module(generic_data->init_services[i])) {
506 test_data->setup_done = true;
508 tester_setup_complete();
512 g_idle_remove_by_data(test_data);
513 tester_setup_failed();
514 test_post_teardown(data);
517 static void teardown(const void *data)
519 struct test_data *test_data = tester_get_data();
521 g_idle_remove_by_data(test_data);
524 if (test_data->bluetoothd_pid)
525 waitpid(test_data->bluetoothd_pid, NULL, 0);
527 tester_teardown_complete();
530 static void ipc_send_tc(const void *data)
532 const struct generic_data *generic_data = data;
533 const struct ipc_data *ipc_data = &generic_data->ipc_data;
536 if (write(cmd_sk, ipc_data->buffer, ipc_data->len) < 0)
537 tester_test_failed();
541 #define service_data(args...) { args }
543 #define gen_data(writelen, writebuf, servicelist...) \
546 .buffer = writebuf, \
549 .init_services = service_data(servicelist), \
550 .num_services = sizeof((const int[]) \
551 service_data(servicelist)) / \
555 #define test_generic(name, test, setup, teardown, buffer, writelen, \
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)); \
564 user->hciemu_type = HCIEMU_TYPE_BREDRLE; \
565 tester_add_full(name, &data, test_pre_setup, setup, \
566 test, teardown, test_post_teardown, \
570 #define test_opcode_valid(_name, _service, _opcode, _len, _servicelist...) \
572 static struct ipc_hdr hdr = { \
573 .service_id = _service, \
578 test_generic("Opcode out of range: "_name, \
579 ipc_send_tc, setup, teardown, \
587 uint8_t buf[IPC_MTU];
588 } __attribute__((packed));
590 #define test_datasize_valid(_name, _service, _opcode, _hlen, _addatasize, \
593 static struct vardata vdata = { \
594 .hdr.service_id = _service, \
595 .hdr.opcode = _opcode, \
596 .hdr.len = (_hlen) + (_addatasize), \
599 test_generic("Data size "_name, \
600 ipc_send_tc, setup, teardown, \
602 sizeof(vdata.hdr) + (_hlen) + (_addatasize),\
606 static struct regmod_msg register_bt_msg = {
608 .service_id = HAL_SERVICE_ID_CORE,
609 .opcode = HAL_OP_REGISTER_MODULE,
610 .len = sizeof(struct hal_cmd_register_module),
613 .service_id = HAL_SERVICE_ID_BLUETOOTH,
617 static struct regmod_msg register_bt_malformed_size_msg = {
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,
625 .service_id = HAL_SERVICE_ID_CORE,
629 struct malformed_data3_struct {
630 struct regmod_msg valid_msg;
632 } __attribute__((packed));
634 static struct malformed_data3_struct malformed_data3_msg = {
635 /* valid register service message */
638 .service_id = HAL_SERVICE_ID_CORE,
639 .opcode = HAL_OP_REGISTER_MODULE,
640 .len = sizeof(struct hal_cmd_register_module),
643 .service_id = HAL_SERVICE_ID_CORE,
646 /* plus redundant data */
647 . redundant_data = 666,
650 static struct ipc_hdr enable_unknown_service_hdr = {
651 .service_id = HAL_SERVICE_ID_MAX + 1,
652 .opcode = HAL_OP_REGISTER_MODULE,
656 static struct ipc_hdr enable_bt_service_hdr = {
657 .service_id = HAL_SERVICE_ID_BLUETOOTH,
658 .opcode = HAL_OP_ENABLE,
662 struct bt_set_adapter_prop_data {
664 struct hal_cmd_set_adapter_prop prop;
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));
671 #define set_name "new name"
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),
678 .prop.type = HAL_PROP_ADAPTER_NAME,
679 /* declare wrong descriptor length */
680 .prop.len = sizeof(set_name) + 1,
681 /* init prop.val[0] */
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),
690 .prop.type = HAL_PROP_ADAPTER_NAME,
691 /* declare wrong descriptor length */
692 .prop.len = sizeof(set_name) - 1,
693 /* init prop.val[0] */
697 struct bt_set_remote_prop_data {
699 struct hal_cmd_set_remote_device_prop prop;
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));
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) +
713 .prop.type = HAL_PROP_DEVICE_NAME,
714 /* declare wrong descriptor length */
715 .prop.len = sizeof(set_name) + 1,
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) +
726 .prop.type = HAL_PROP_DEVICE_NAME,
727 /* declare wrong descriptor length */
728 .prop.len = sizeof(set_name) - 1,
732 struct hidhost_set_info_data {
734 struct hal_cmd_hidhost_set_info info;
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));
741 #define set_info_data "some descriptor"
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),
749 /* declare wrong descriptor length */
750 .info.descr_len = sizeof(set_info_data) + 1,
751 /* init .info.descr[0] */
752 .buf = set_info_data,
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),
761 /* declare wrong descriptor length */
762 .info.descr_len = sizeof(set_info_data) - 1,
763 /* init .info.descr[0] */
764 .buf = set_info_data,
767 struct hidhost_set_report_data {
769 struct hal_cmd_hidhost_set_report report;
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));
776 #define set_rep_data "1234567890"
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),
784 /* declare wrong descriptor length */
785 .report.len = sizeof(set_rep_data) + 1,
786 /* init report.data[0] */
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),
796 /* declare wrong descriptor length */
797 .report.len = sizeof(set_rep_data) - 1,
798 /* init report.data[0] */
802 struct hidhost_send_data_data {
804 struct hal_cmd_hidhost_send_data hiddata;
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));
811 #define send_data_data "1234567890"
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),
819 /* declare wrong descriptor length */
820 .hiddata.len = sizeof(send_data_data) + 1,
821 /* init .hiddata.data[0] */
822 .buf = send_data_data,
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),
831 /* declare wrong descriptor length */
832 .hiddata.len = sizeof(send_data_data) - 1,
833 /* init .hiddata.data[0] */
834 .buf = send_data_data,
837 #define hfp_number "#1234567890"
839 struct hfp_dial_data {
841 struct hal_cmd_hf_client_dial data;
843 uint8_t buf[IPC_MTU - sizeof(struct ipc_hdr) -
844 sizeof(struct hal_cmd_hf_client_dial)];
845 } __attribute__((packed));
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),
852 .data.number_len = sizeof(hfp_number) + 1,
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),
861 .data.number_len = sizeof(hfp_number) - 1,
865 int main(int argc, char *argv[])
867 snprintf(exec_dir, sizeof(exec_dir), "%s", dirname(argv[0]));
869 tester_init(&argc, &argv);
871 /* check general IPC errors */
872 test_generic("Too small data",
873 ipc_send_tc, setup, teardown,
874 ®ister_bt_msg, 1);
876 test_generic("Malformed data (wrong payload declared)",
877 ipc_send_tc, setup, teardown,
878 ®ister_bt_malformed_size_msg,
879 sizeof(register_bt_malformed_size_msg),
880 HAL_SERVICE_ID_BLUETOOTH);
882 test_generic("Malformed data2 (undersized msg)",
883 ipc_send_tc, setup, teardown,
885 sizeof(register_bt_msg) - 1,
886 HAL_SERVICE_ID_BLUETOOTH);
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);
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);
900 test_generic("Enable unregistered service",
901 ipc_send_tc, setup, teardown,
902 &enable_bt_service_hdr,
903 sizeof(enable_bt_service_hdr));
905 /* check service handler's max opcode value */
906 test_opcode_valid("CORE", HAL_SERVICE_ID_CORE, 0x03, 0);
908 test_opcode_valid("BLUETOOTH", HAL_SERVICE_ID_BLUETOOTH, 0x15, 0,
909 HAL_SERVICE_ID_BLUETOOTH);
911 test_opcode_valid("SOCK", HAL_SERVICE_ID_SOCKET, 0x03, 0,
912 HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_SOCKET);
914 test_opcode_valid("HIDHOST", HAL_SERVICE_ID_HIDHOST, 0x10, 0,
915 HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
917 test_opcode_valid("PAN", HAL_SERVICE_ID_PAN, 0x05, 0,
918 HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_PAN);
920 test_opcode_valid("HANDSFREE", HAL_SERVICE_ID_HANDSFREE, 0x10, 0,
921 HAL_SERVICE_ID_BLUETOOTH,
922 HAL_SERVICE_ID_HANDSFREE);
924 test_opcode_valid("A2DP", HAL_SERVICE_ID_A2DP, 0x03, 0,
925 HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_A2DP);
927 test_opcode_valid("HEALTH", HAL_SERVICE_ID_HEALTH, 0x06, 0,
928 HAL_SERVICE_ID_BLUETOOTH,
929 HAL_SERVICE_ID_HEALTH);
931 test_opcode_valid("AVRCP", HAL_SERVICE_ID_AVRCP, 0x0b, 0,
932 HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_AVRCP);
934 test_opcode_valid("GATT", HAL_SERVICE_ID_GATT, 0x24, 0,
935 HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_GATT);
937 test_opcode_valid("HF_CLIENT", HAL_SERVICE_ID_HANDSFREE_CLIENT, 0x10, 0,
938 HAL_SERVICE_ID_BLUETOOTH,
939 HAL_SERVICE_ID_HANDSFREE_CLIENT);
941 test_opcode_valid("MAP_CLIENT", HAL_SERVICE_ID_MAP_CLIENT, 0x01, 0,
942 HAL_SERVICE_ID_BLUETOOTH,
943 HAL_SERVICE_ID_MAP_CLIENT);
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);
959 /* check for valid data size for BLUETOOTH */
960 test_datasize_valid("BT Enable+", HAL_SERVICE_ID_BLUETOOTH,
963 HAL_SERVICE_ID_BLUETOOTH);
964 test_datasize_valid("BT Disable+", HAL_SERVICE_ID_BLUETOOTH,
967 HAL_SERVICE_ID_BLUETOOTH);
968 test_datasize_valid("BT Get Adapter Props+", HAL_SERVICE_ID_BLUETOOTH,
969 HAL_OP_GET_ADAPTER_PROPS,
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) +
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) +
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) +
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) +
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,
1059 HAL_SERVICE_ID_BLUETOOTH);
1060 test_datasize_valid("BT Cancel Discovery+", HAL_SERVICE_ID_BLUETOOTH,
1061 HAL_OP_CANCEL_DISCOVERY,
1063 HAL_SERVICE_ID_BLUETOOTH);
1064 test_datasize_valid("BT Create Bond+", HAL_SERVICE_ID_BLUETOOTH,
1066 sizeof(struct hal_cmd_create_bond), 1,
1067 HAL_SERVICE_ID_BLUETOOTH);
1068 test_datasize_valid("BT Create Bond-", HAL_SERVICE_ID_BLUETOOTH,
1070 sizeof(struct hal_cmd_create_bond), -1,
1071 HAL_SERVICE_ID_BLUETOOTH);
1072 test_datasize_valid("BT Remove Bond+", HAL_SERVICE_ID_BLUETOOTH,
1074 sizeof(struct hal_cmd_remove_bond), 1,
1075 HAL_SERVICE_ID_BLUETOOTH);
1076 test_datasize_valid("BT Remove Bond-", HAL_SERVICE_ID_BLUETOOTH,
1078 sizeof(struct hal_cmd_remove_bond), -1,
1079 HAL_SERVICE_ID_BLUETOOTH);
1080 test_datasize_valid("BT Cancel Bond+", HAL_SERVICE_ID_BLUETOOTH,
1082 sizeof(struct hal_cmd_cancel_bond), 1,
1083 HAL_SERVICE_ID_BLUETOOTH);
1084 test_datasize_valid("BT Cancel Bond-", HAL_SERVICE_ID_BLUETOOTH,
1086 sizeof(struct hal_cmd_cancel_bond), -1,
1087 HAL_SERVICE_ID_BLUETOOTH);
1088 test_datasize_valid("BT Pin Reply+", HAL_SERVICE_ID_BLUETOOTH,
1090 sizeof(struct hal_cmd_pin_reply), 1,
1091 HAL_SERVICE_ID_BLUETOOTH);
1092 test_datasize_valid("BT Pin Reply-", HAL_SERVICE_ID_BLUETOOTH,
1094 sizeof(struct hal_cmd_pin_reply), -1,
1095 HAL_SERVICE_ID_BLUETOOTH);
1096 test_datasize_valid("BT SSP Reply+", HAL_SERVICE_ID_BLUETOOTH,
1098 sizeof(struct hal_cmd_ssp_reply), 1,
1099 HAL_SERVICE_ID_BLUETOOTH);
1100 test_datasize_valid("BT SSP Reply-", HAL_SERVICE_ID_BLUETOOTH,
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);
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);
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);
1263 /* check for valid data size for PAN */
1264 test_datasize_valid("PAN Enable+", HAL_SERVICE_ID_PAN,
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,
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,
1275 HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_PAN);
1276 test_datasize_valid("PAN Connect+", HAL_SERVICE_ID_PAN,
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,
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);
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);
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
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,
1494 HAL_SERVICE_ID_BLUETOOTH,
1495 HAL_SERVICE_ID_HANDSFREE_CLIENT);
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);
1511 return tester_run();