This changes all enums values and defines to uppercase instead of
lowercase according to coding style.
---
android/android-tester.c | 86 ++++++++++++++++++++++++------------------------
1 file changed, 43 insertions(+), 43 deletions(-)
diff --git a/android/android-tester.c b/android/android-tester.c
index eb938d0..4eb265b 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -37,10 +37,10 @@
#include <hardware/bluetooth.h>
#include <hardware/bt_sock.h>
-#define adapter_props adapter_prop_bdaddr, adapter_prop_bdname, \
- adapter_prop_uuids, adapter_prop_cod, \
- adapter_prop_type, adapter_prop_scan_mode, \
- adapter_prop_bonded_devices, adapter_prop_disc_timeout
+#define ADAPTER_PROPS ADAPTER_PROP_BDADDR, ADAPTER_PROP_BDNAME, \
+ ADAPTER_PROP_UUIDS, ADAPTER_PROP_COD, \
+ ADAPTER_PROP_TYPE, ADAPTER_PROP_SCAN_MODE, \
+ ADAPTER_PROP_BONDED_DEVICES, ADAPTER_PROP_DISC_TIMEOUT
static bt_scan_mode_t test_setprop_scanmode_val =
BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE;
@@ -52,19 +52,19 @@ static uint32_t test_setprop_disctimeout_val = 120;
*/
enum hal_bluetooth_callbacks_id {
- adapter_test_end,
- adapter_test_setup_mode,
- adapter_state_changed_on,
- adapter_state_changed_off,
- adapter_prop_bdaddr,
- adapter_prop_bdname,
- adapter_prop_uuids,
- adapter_prop_cod,
- adapter_prop_type,
- adapter_prop_scan_mode,
- adapter_prop_disc_timeout,
- adapter_prop_service_record,
- adapter_prop_bonded_devices
+ ADAPTER_TEST_END,
+ ADAPTER_TEST_SETUP_MODE,
+ ADAPTER_STATE_CHANGED_ON,
+ ADAPTER_STATE_CHANGED_OFF,
+ ADAPTER_PROP_BDADDR,
+ ADAPTER_PROP_BDNAME,
+ ADAPTER_PROP_UUIDS,
+ ADAPTER_PROP_COD,
+ ADAPTER_PROP_TYPE,
+ ADAPTER_PROP_SCAN_MODE,
+ ADAPTER_PROP_DISC_TIMEOUT,
+ ADAPTER_PROP_SERVICE_RECORD,
+ ADAPTER_PROP_BONDED_DEVICES
};
struct generic_data {
@@ -250,7 +250,7 @@ static int get_expected_hal_cb(void)
struct test_data *data = tester_get_data();
if (!(g_slist_length(data->expected_callbacks)))
- return adapter_test_setup_mode;
+ return ADAPTER_TEST_SETUP_MODE;
return GPOINTER_TO_INT(data->expected_callbacks->data);
}
@@ -470,19 +470,19 @@ static void adapter_state_changed_cb(bt_state_t state)
hal_cb = get_expected_hal_cb();
switch (hal_cb) {
- case adapter_state_changed_on:
+ case ADAPTER_STATE_CHANGED_ON:
if (state == BT_STATE_ON)
remove_expected_hal_cb();
else
tester_test_failed();
break;
- case adapter_state_changed_off:
+ case ADAPTER_STATE_CHANGED_OFF:
if (state == BT_STATE_OFF)
remove_expected_hal_cb();
else
tester_test_failed();
break;
- case adapter_test_setup_mode:
+ case ADAPTER_TEST_SETUP_MODE:
if (state == BT_STATE_ON)
tester_setup_complete();
else
@@ -502,50 +502,50 @@ static void adapter_properties_cb(bt_status_t status, int num_properties,
for (i = 0; i < num_properties; i++) {
hal_cb = get_expected_hal_cb();
- if (hal_cb == adapter_test_setup_mode)
+ if (hal_cb == ADAPTER_TEST_SETUP_MODE)
break;
data->test_property = *properties;
if (g_slist_next(data->expected_callbacks) ==
- adapter_test_end)
+ ADAPTER_TEST_END)
check_test_property();
switch (properties[i].type) {
case BT_PROPERTY_BDADDR:
- if (hal_cb != adapter_prop_bdaddr)
+ if (hal_cb != ADAPTER_PROP_BDADDR)
goto fail;
break;
case BT_PROPERTY_BDNAME:
- if (hal_cb != adapter_prop_bdname)
+ if (hal_cb != ADAPTER_PROP_BDNAME)
goto fail;
break;
case BT_PROPERTY_UUIDS:
- if (hal_cb != adapter_prop_uuids)
+ if (hal_cb != ADAPTER_PROP_UUIDS)
goto fail;
break;
case BT_PROPERTY_CLASS_OF_DEVICE:
- if (hal_cb != adapter_prop_cod)
+ if (hal_cb != ADAPTER_PROP_COD)
goto fail;
break;
case BT_PROPERTY_TYPE_OF_DEVICE:
- if (hal_cb != adapter_prop_type)
+ if (hal_cb != ADAPTER_PROP_TYPE)
goto fail;
break;
case BT_PROPERTY_SERVICE_RECORD:
- if (hal_cb != adapter_prop_service_record)
+ if (hal_cb != ADAPTER_PROP_SERVICE_RECORD)
goto fail;
break;
case BT_PROPERTY_ADAPTER_SCAN_MODE:
- if (hal_cb != adapter_prop_scan_mode)
+ if (hal_cb != ADAPTER_PROP_SCAN_MODE)
goto fail;
break;
case BT_PROPERTY_ADAPTER_BONDED_DEVICES:
- if (hal_cb != adapter_prop_bonded_devices)
+ if (hal_cb != ADAPTER_PROP_BONDED_DEVICES)
goto fail;
break;
case BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT:
- if (hal_cb != adapter_prop_disc_timeout)
+ if (hal_cb != ADAPTER_PROP_DISC_TIMEOUT)
goto fail;
break;
default:
@@ -563,21 +563,21 @@ fail:
}
static const struct generic_data bluetooth_enable_success_test = {
- .expected_hal_callbacks = {adapter_props, adapter_state_changed_on,
- adapter_test_end}
+ .expected_hal_callbacks = {ADAPTER_PROPS, ADAPTER_STATE_CHANGED_ON,
+ ADAPTER_TEST_END}
};
static const struct generic_data bluetooth_enable_done_test = {
- .expected_hal_callbacks = {adapter_props, adapter_test_end},
+ .expected_hal_callbacks = {ADAPTER_PROPS, ADAPTER_TEST_END},
.expected_adapter_status = BT_STATUS_DONE
};
static const struct generic_data bluetooth_disable_success_test = {
- .expected_hal_callbacks = {adapter_state_changed_off, adapter_test_end}
+ .expected_hal_callbacks = {ADAPTER_STATE_CHANGED_OFF, ADAPTER_TEST_END}
};
static const struct generic_data bluetooth_setprop_bdname_success_test = {
- .expected_hal_callbacks = {adapter_prop_bdname, adapter_test_end},
+ .expected_hal_callbacks = {ADAPTER_PROP_BDNAME, ADAPTER_TEST_END},
.expected_adapter_status = BT_STATUS_SUCCESS,
.expected_property.type = BT_PROPERTY_BDNAME,
.expected_property.val = "test_bdname",
@@ -585,8 +585,8 @@ static const struct generic_data bluetooth_setprop_bdname_success_test = {
};
static const struct generic_data bluetooth_setprop_scanmode_success_test = {
- .expected_hal_callbacks = {adapter_prop_scan_mode,
- adapter_prop_scan_mode, adapter_test_end},
+ .expected_hal_callbacks = {ADAPTER_PROP_SCAN_MODE,
+ ADAPTER_PROP_SCAN_MODE, ADAPTER_TEST_END},
.expected_adapter_status = BT_STATUS_SUCCESS,
.expected_property.type = BT_PROPERTY_ADAPTER_SCAN_MODE,
.expected_property.val = &test_setprop_scanmode_val,
@@ -594,7 +594,7 @@ static const struct generic_data bluetooth_setprop_scanmode_success_test = {
};
static const struct generic_data bluetooth_setprop_disctimeout_success_test = {
- .expected_hal_callbacks = {adapter_prop_disc_timeout, adapter_test_end},
+ .expected_hal_callbacks = {ADAPTER_PROP_DISC_TIMEOUT, ADAPTER_TEST_END},
.expected_adapter_status = BT_STATUS_SUCCESS,
.expected_property.type = BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT,
.expected_property.val = &test_setprop_disctimeout_val,
@@ -602,7 +602,7 @@ static const struct generic_data bluetooth_setprop_disctimeout_success_test = {
};
static const struct generic_data bluetooth_getprop_bdaddr_success_test = {
- .expected_hal_callbacks = {adapter_prop_bdaddr, adapter_test_end},
+ .expected_hal_callbacks = {ADAPTER_PROP_BDADDR, ADAPTER_TEST_END},
.expected_adapter_status = BT_STATUS_SUCCESS,
.expected_property.type = BT_PROPERTY_BDADDR,
.expected_property.val = NULL,
@@ -610,8 +610,8 @@ static const struct generic_data bluetooth_getprop_bdaddr_success_test = {
};
static const struct generic_data bluetooth_getprop_bdname_success_test = {
- .expected_hal_callbacks = {adapter_prop_bdname, adapter_prop_bdname,
- adapter_test_end},
+ .expected_hal_callbacks = {ADAPTER_PROP_BDNAME, ADAPTER_PROP_BDNAME,
+ ADAPTER_TEST_END},
.expected_adapter_status = BT_STATUS_SUCCESS,
.expected_property.type = BT_PROPERTY_BDNAME,
.expected_property.val = "test_bdname_setget",
--
1.8.4.2
Hi Andrei,
On Wed, Dec 18, 2013, Andrei Emeltchenko wrote:
> On Wed, Dec 18, 2013 at 10:00:34AM +0200, Johan Hedberg wrote:
> > Hi Grzegorz,
> >
> > On Tue, Dec 17, 2013, Grzegorz Kolodziejczyk wrote:
> > > +static int32_t setprop_remote_rssi = 0;
> > > +
> > > +static const struct generic_data bluetooth_setprop_remote_rssi_invalid_test = {
> > > + .expected_hal_callbacks = {ADAPTER_TEST_END},
>
> btw: do we need to have space after "{" ?
Yes, and before } too.
Johan
On Wed, Dec 18, 2013 at 10:00:34AM +0200, Johan Hedberg wrote:
> Hi Grzegorz,
>
> On Tue, Dec 17, 2013, Grzegorz Kolodziejczyk wrote:
> > +static int32_t setprop_remote_rssi = 0;
> > +
> > +static const struct generic_data bluetooth_setprop_remote_rssi_invalid_test = {
> > + .expected_hal_callbacks = {ADAPTER_TEST_END},
btw: do we need to have space after "{" ?
Best regards
Andrei Emeltchenko
> > + .expected_adapter_status = BT_STATUS_FAIL,
> > + .expected_property.type = BT_PROPERTY_REMOTE_RSSI,
> > + .expected_property.val = &setprop_remote_rssi,
> > + .expected_property.len = sizeof(int32_t)
>
> sizeof(setprop_remote_rssi);
>
> Johan
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Grzegorz,
On Tue, Dec 17, 2013, Grzegorz Kolodziejczyk wrote:
> +static int32_t setprop_remote_rssi = 0;
> +
> +static const struct generic_data bluetooth_setprop_remote_rssi_invalid_test = {
> + .expected_hal_callbacks = {ADAPTER_TEST_END},
> + .expected_adapter_status = BT_STATUS_FAIL,
> + .expected_property.type = BT_PROPERTY_REMOTE_RSSI,
> + .expected_property.val = &setprop_remote_rssi,
> + .expected_property.len = sizeof(int32_t)
sizeof(setprop_remote_rssi);
Johan
Hi Grzegorz,
On Tue, Dec 17, 2013, Grzegorz Kolodziejczyk wrote:
> +static bt_service_record_t setprop_remote_service = {
> + .uuid = { {0x00} },
> + .channel = 12,
> + .name = "bt_name"
> +};
> +
> +static const struct generic_data
> + bluetooth_setprop_service_record_invalid_test = {
> + .expected_hal_callbacks = {ADAPTER_TEST_END},
> + .expected_adapter_status = BT_STATUS_FAIL,
> + .expected_property.type = BT_PROPERTY_SERVICE_RECORD,
> + .expected_property.val = &setprop_remote_service,
> + .expected_property.len = sizeof(bt_service_record_t)
sizeof(setprop_remote_service);
Johan
Hi Luiz,
On Tue, Dec 17, 2013, Luiz Augusto von Dentz wrote:
> On Tue, Dec 17, 2013 at 2:37 PM, Grzegorz Kolodziejczyk
> <[email protected]> wrote:
> > This changes all enums values and defines to uppercase instead of
> > lowercase according to coding style.
> > ---
> > android/android-tester.c | 86 ++++++++++++++++++++++++------------------------
> > 1 file changed, 43 insertions(+), 43 deletions(-)
> >
> > diff --git a/android/android-tester.c b/android/android-tester.c
> > index eb938d0..4eb265b 100644
> > --- a/android/android-tester.c
> > +++ b/android/android-tester.c
> > @@ -37,10 +37,10 @@
> > #include <hardware/bluetooth.h>
> > #include <hardware/bt_sock.h>
> >
> > -#define adapter_props adapter_prop_bdaddr, adapter_prop_bdname, \
> > - adapter_prop_uuids, adapter_prop_cod, \
> > - adapter_prop_type, adapter_prop_scan_mode, \
> > - adapter_prop_bonded_devices, adapter_prop_disc_timeout
> > +#define ADAPTER_PROPS ADAPTER_PROP_BDADDR, ADAPTER_PROP_BDNAME, \
> > + ADAPTER_PROP_UUIDS, ADAPTER_PROP_COD, \
> > + ADAPTER_PROP_TYPE, ADAPTER_PROP_SCAN_MODE, \
> > + ADAPTER_PROP_BONDED_DEVICES, ADAPTER_PROP_DISC_TIMEOUT
> >
> > static bt_scan_mode_t test_setprop_scanmode_val =
> > BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE;
> > @@ -52,19 +52,19 @@ static uint32_t test_setprop_disctimeout_val = 120;
> > */
> >
> > enum hal_bluetooth_callbacks_id {
> > - adapter_test_end,
> > - adapter_test_setup_mode,
> > - adapter_state_changed_on,
> > - adapter_state_changed_off,
> > - adapter_prop_bdaddr,
> > - adapter_prop_bdname,
> > - adapter_prop_uuids,
> > - adapter_prop_cod,
> > - adapter_prop_type,
> > - adapter_prop_scan_mode,
> > - adapter_prop_disc_timeout,
> > - adapter_prop_service_record,
> > - adapter_prop_bonded_devices
> > + ADAPTER_TEST_END,
> > + ADAPTER_TEST_SETUP_MODE,
> > + ADAPTER_STATE_CHANGED_ON,
> > + ADAPTER_STATE_CHANGED_OFF,
> > + ADAPTER_PROP_BDADDR,
> > + ADAPTER_PROP_BDNAME,
> > + ADAPTER_PROP_UUIDS,
> > + ADAPTER_PROP_COD,
> > + ADAPTER_PROP_TYPE,
> > + ADAPTER_PROP_SCAN_MODE,
> > + ADAPTER_PROP_DISC_TIMEOUT,
> > + ADAPTER_PROP_SERVICE_RECORD,
> > + ADAPTER_PROP_BONDED_DEVICES
> > };
>
> This is something I dislike right now, why are defining these and not
> using directly the values defined in hal-msg.h? We should probably
> have a struct with expected opcode and value e.g:
> .{HAL_EV_ADAPTER_PROPS_CHANGED, BT_STATE_ON} and don't try to invent
> another ID for each of those.
I missed this email from you and already applied the patch. You're right
that if these are already defined elsewhere they should not be
redefined. What bugged me most about this was the lower-case so whatever
fix is done will have to be on top of this patch.
Johan
Hi Grzegorz,
On Tue, Dec 17, 2013, Grzegorz Kolodziejczyk wrote:
> This adds TYPE_OF_DEVICE set property fail test case due to only
> get possibility.
> ---
> android/android-tester.c | 28 ++++++++++++++++++++++++++++
> 1 file changed, 28 insertions(+)
>
> diff --git a/android/android-tester.c b/android/android-tester.c
> index a6f66c2..4923a6c 100644
> --- a/android/android-tester.c
> +++ b/android/android-tester.c
> @@ -618,6 +618,16 @@ static const struct generic_data bluetooth_setprop_cod_invalid_test = {
> .expected_property.len = sizeof(uint32_t)
> };
>
> +static bt_device_type_t setprop_type_of_device = BT_DEVICE_DEVTYPE_BREDR;
> +
> +static const struct generic_data bluetooth_setprop_tod_invalid_test = {
> + .expected_hal_callbacks = {ADAPTER_TEST_END},
> + .expected_adapter_status = BT_STATUS_FAIL,
> + .expected_property.type = BT_PROPERTY_TYPE_OF_DEVICE,
> + .expected_property.val = &setprop_type_of_device,
> + .expected_property.len = sizeof(bt_device_type_t)
sizeof(setprop_type_of_device)
Johan
Hi Grzegorz,
On Tue, Dec 17, 2013, Grzegorz Kolodziejczyk wrote:
> This adds CLASS_OF_DEVICE set property fail test case due to only
> get possibility.
> ---
> android/android-tester.c | 28 ++++++++++++++++++++++++++++
> 1 file changed, 28 insertions(+)
>
> diff --git a/android/android-tester.c b/android/android-tester.c
> index 4fe0033..a6f66c2 100644
> --- a/android/android-tester.c
> +++ b/android/android-tester.c
> @@ -608,6 +608,16 @@ static const struct generic_data bluetooth_setprop_uuid_invalid_test = {
> .expected_property.len = 17
> };
>
> +static uint32_t setprop_class_of_device = 0;
> +
> +static const struct generic_data bluetooth_setprop_cod_invalid_test = {
> + .expected_hal_callbacks = {ADAPTER_TEST_END},
> + .expected_adapter_status = BT_STATUS_FAIL,
> + .expected_property.type = BT_PROPERTY_CLASS_OF_DEVICE,
> + .expected_property.val = &setprop_class_of_device,
> + .expected_property.len = sizeof(uint32_t)
sizeof(setprop_class_of_device) makes more sense than uint32_t.
Johan
Hi Grzegorz,
On Tue, Dec 17, 2013, Grzegorz Kolodziejczyk wrote:
> This adds UUIDS set property fail test case due to only get
> possibility.
> ---
> android/android-tester.c | 30 ++++++++++++++++++++++++++++++
> 1 file changed, 30 insertions(+)
The first two patches have been applied, but a minor thing with this
one:
> +static unsigned char setprop_uuids[] = { 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00,
> + 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
> + 0x00, 0x00 };
> +
> +static const struct generic_data bluetooth_setprop_uuid_invalid_test = {
> + .expected_hal_callbacks = {ADAPTER_TEST_END},
> + .expected_adapter_status = BT_STATUS_FAIL,
> + .expected_property.type = BT_PROPERTY_UUIDS,
> + .expected_property.val = &setprop_uuids,
> + .expected_property.len = 17
How about sizeof(setprop_uuids) here instead of 17?
Johan
Hi Grzegorz,
On Tue, Dec 17, 2013 at 2:37 PM, Grzegorz Kolodziejczyk
<[email protected]> wrote:
> This changes all enums values and defines to uppercase instead of
> lowercase according to coding style.
> ---
> android/android-tester.c | 86 ++++++++++++++++++++++++------------------------
> 1 file changed, 43 insertions(+), 43 deletions(-)
>
> diff --git a/android/android-tester.c b/android/android-tester.c
> index eb938d0..4eb265b 100644
> --- a/android/android-tester.c
> +++ b/android/android-tester.c
> @@ -37,10 +37,10 @@
> #include <hardware/bluetooth.h>
> #include <hardware/bt_sock.h>
>
> -#define adapter_props adapter_prop_bdaddr, adapter_prop_bdname, \
> - adapter_prop_uuids, adapter_prop_cod, \
> - adapter_prop_type, adapter_prop_scan_mode, \
> - adapter_prop_bonded_devices, adapter_prop_disc_timeout
> +#define ADAPTER_PROPS ADAPTER_PROP_BDADDR, ADAPTER_PROP_BDNAME, \
> + ADAPTER_PROP_UUIDS, ADAPTER_PROP_COD, \
> + ADAPTER_PROP_TYPE, ADAPTER_PROP_SCAN_MODE, \
> + ADAPTER_PROP_BONDED_DEVICES, ADAPTER_PROP_DISC_TIMEOUT
>
> static bt_scan_mode_t test_setprop_scanmode_val =
> BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE;
> @@ -52,19 +52,19 @@ static uint32_t test_setprop_disctimeout_val = 120;
> */
>
> enum hal_bluetooth_callbacks_id {
> - adapter_test_end,
> - adapter_test_setup_mode,
> - adapter_state_changed_on,
> - adapter_state_changed_off,
> - adapter_prop_bdaddr,
> - adapter_prop_bdname,
> - adapter_prop_uuids,
> - adapter_prop_cod,
> - adapter_prop_type,
> - adapter_prop_scan_mode,
> - adapter_prop_disc_timeout,
> - adapter_prop_service_record,
> - adapter_prop_bonded_devices
> + ADAPTER_TEST_END,
> + ADAPTER_TEST_SETUP_MODE,
> + ADAPTER_STATE_CHANGED_ON,
> + ADAPTER_STATE_CHANGED_OFF,
> + ADAPTER_PROP_BDADDR,
> + ADAPTER_PROP_BDNAME,
> + ADAPTER_PROP_UUIDS,
> + ADAPTER_PROP_COD,
> + ADAPTER_PROP_TYPE,
> + ADAPTER_PROP_SCAN_MODE,
> + ADAPTER_PROP_DISC_TIMEOUT,
> + ADAPTER_PROP_SERVICE_RECORD,
> + ADAPTER_PROP_BONDED_DEVICES
> };
This is something I dislike right now, why are defining these and not
using directly the values defined in hal-msg.h? We should probably
have a struct with expected opcode and value e.g:
.{HAL_EV_ADAPTER_PROPS_CHANGED, BT_STATE_ON} and don't try to invent
another ID for each of those.
Luiz Augusto von Dentz
This adds RSSI set property fail test case due to be only remote device
property.
---
android/android-tester.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/android/android-tester.c b/android/android-tester.c
index 4923a6c..c260a69 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -628,6 +628,16 @@ static const struct generic_data bluetooth_setprop_tod_invalid_test = {
.expected_property.len = sizeof(bt_device_type_t)
};
+static int32_t setprop_remote_rssi = 0;
+
+static const struct generic_data bluetooth_setprop_remote_rssi_invalid_test = {
+ .expected_hal_callbacks = {ADAPTER_TEST_END},
+ .expected_adapter_status = BT_STATUS_FAIL,
+ .expected_property.type = BT_PROPERTY_REMOTE_RSSI,
+ .expected_property.val = &setprop_remote_rssi,
+ .expected_property.len = sizeof(int32_t)
+};
+
static bt_callbacks_t bt_callbacks = {
.size = sizeof(bt_callbacks),
.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -1044,6 +1054,19 @@ static void test_setprop_tod_invalid(const void *test_data)
check_expected_status(adapter_status);
}
+static void test_setprop_rssi_invalid(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ const struct generic_data *test = data->test_data;
+ const bt_property_t *prop = &test->expected_property;
+ bt_status_t adapter_status;
+
+ init_test_conditions(data);
+
+ adapter_status = data->if_bluetooth->set_adapter_property(prop);
+ check_expected_status(adapter_status);
+}
+
#define test_bredrle(name, data, test_setup, test, test_teardown) \
do { \
struct test_data *user; \
@@ -1114,6 +1137,11 @@ int main(int argc, char *argv[])
setup_enabled_adapter,
test_setprop_tod_invalid, teardown);
+ test_bredrle("Set REMOTE_RSSI - Invalid",
+ &bluetooth_setprop_remote_rssi_invalid_test,
+ setup_enabled_adapter,
+ test_setprop_rssi_invalid, teardown);
+
test_bredrle("Socket Init", NULL, setup_socket_interface,
test_dummy, teardown);
--
1.8.4.2
This adds SERVICE_RECORD set property fail test case due to only
get possibility.
---
android/android-tester.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/android/android-tester.c b/android/android-tester.c
index c260a69..2c1a089 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -638,6 +638,21 @@ static const struct generic_data bluetooth_setprop_remote_rssi_invalid_test = {
.expected_property.len = sizeof(int32_t)
};
+static bt_service_record_t setprop_remote_service = {
+ .uuid = { {0x00} },
+ .channel = 12,
+ .name = "bt_name"
+};
+
+static const struct generic_data
+ bluetooth_setprop_service_record_invalid_test = {
+ .expected_hal_callbacks = {ADAPTER_TEST_END},
+ .expected_adapter_status = BT_STATUS_FAIL,
+ .expected_property.type = BT_PROPERTY_SERVICE_RECORD,
+ .expected_property.val = &setprop_remote_service,
+ .expected_property.len = sizeof(bt_service_record_t)
+};
+
static bt_callbacks_t bt_callbacks = {
.size = sizeof(bt_callbacks),
.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -1067,6 +1082,19 @@ static void test_setprop_rssi_invalid(const void *test_data)
check_expected_status(adapter_status);
}
+static void test_setprop_service_record(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ const struct generic_data *test = data->test_data;
+ const bt_property_t *prop = &test->expected_property;
+ bt_status_t adapter_status;
+
+ init_test_conditions(data);
+
+ adapter_status = data->if_bluetooth->set_adapter_property(prop);
+ check_expected_status(adapter_status);
+}
+
#define test_bredrle(name, data, test_setup, test, test_teardown) \
do { \
struct test_data *user; \
@@ -1142,6 +1170,11 @@ int main(int argc, char *argv[])
setup_enabled_adapter,
test_setprop_rssi_invalid, teardown);
+ test_bredrle("Set SERVICE_RECORD - Invalid",
+ &bluetooth_setprop_service_record_invalid_test,
+ setup_enabled_adapter,
+ test_setprop_service_record, teardown);
+
test_bredrle("Socket Init", NULL, setup_socket_interface,
test_dummy, teardown);
--
1.8.4.2
This adds CLASS_OF_DEVICE set property fail test case due to only
get possibility.
---
android/android-tester.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/android/android-tester.c b/android/android-tester.c
index 4fe0033..a6f66c2 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -608,6 +608,16 @@ static const struct generic_data bluetooth_setprop_uuid_invalid_test = {
.expected_property.len = 17
};
+static uint32_t setprop_class_of_device = 0;
+
+static const struct generic_data bluetooth_setprop_cod_invalid_test = {
+ .expected_hal_callbacks = {ADAPTER_TEST_END},
+ .expected_adapter_status = BT_STATUS_FAIL,
+ .expected_property.type = BT_PROPERTY_CLASS_OF_DEVICE,
+ .expected_property.val = &setprop_class_of_device,
+ .expected_property.len = sizeof(uint32_t)
+};
+
static bt_callbacks_t bt_callbacks = {
.size = sizeof(bt_callbacks),
.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -998,6 +1008,19 @@ static void test_setprop_uuid_invalid(const void *test_data)
check_expected_status(adapter_status);
}
+static void test_setprop_cod_invalid(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ const struct generic_data *test = data->test_data;
+ const bt_property_t *prop = &test->expected_property;
+ bt_status_t adapter_status;
+
+ init_test_conditions(data);
+
+ adapter_status = data->if_bluetooth->set_adapter_property(prop);
+ check_expected_status(adapter_status);
+}
+
#define test_bredrle(name, data, test_setup, test, test_teardown) \
do { \
struct test_data *user; \
@@ -1058,6 +1081,11 @@ int main(int argc, char *argv[])
setup_enabled_adapter,
test_setprop_uuid_invalid, teardown);
+ test_bredrle("Set CLASS_OF_DEVICE - Invalid",
+ &bluetooth_setprop_cod_invalid_test,
+ setup_enabled_adapter,
+ test_setprop_cod_invalid, teardown);
+
test_bredrle("Socket Init", NULL, setup_socket_interface,
test_dummy, teardown);
--
1.8.4.2
This adds TYPE_OF_DEVICE set property fail test case due to only
get possibility.
---
android/android-tester.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/android/android-tester.c b/android/android-tester.c
index a6f66c2..4923a6c 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -618,6 +618,16 @@ static const struct generic_data bluetooth_setprop_cod_invalid_test = {
.expected_property.len = sizeof(uint32_t)
};
+static bt_device_type_t setprop_type_of_device = BT_DEVICE_DEVTYPE_BREDR;
+
+static const struct generic_data bluetooth_setprop_tod_invalid_test = {
+ .expected_hal_callbacks = {ADAPTER_TEST_END},
+ .expected_adapter_status = BT_STATUS_FAIL,
+ .expected_property.type = BT_PROPERTY_TYPE_OF_DEVICE,
+ .expected_property.val = &setprop_type_of_device,
+ .expected_property.len = sizeof(bt_device_type_t)
+};
+
static bt_callbacks_t bt_callbacks = {
.size = sizeof(bt_callbacks),
.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -1021,6 +1031,19 @@ static void test_setprop_cod_invalid(const void *test_data)
check_expected_status(adapter_status);
}
+static void test_setprop_tod_invalid(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ const struct generic_data *test = data->test_data;
+ const bt_property_t *prop = &test->expected_property;
+ bt_status_t adapter_status;
+
+ init_test_conditions(data);
+
+ adapter_status = data->if_bluetooth->set_adapter_property(prop);
+ check_expected_status(adapter_status);
+}
+
#define test_bredrle(name, data, test_setup, test, test_teardown) \
do { \
struct test_data *user; \
@@ -1086,6 +1109,11 @@ int main(int argc, char *argv[])
setup_enabled_adapter,
test_setprop_cod_invalid, teardown);
+ test_bredrle("Set TYPE_OF_DEVICE - Invalid",
+ &bluetooth_setprop_tod_invalid_test,
+ setup_enabled_adapter,
+ test_setprop_tod_invalid, teardown);
+
test_bredrle("Socket Init", NULL, setup_socket_interface,
test_dummy, teardown);
--
1.8.4.2
This patch change checking of expected callbacks from static order to
dynamic. For example properties can be received in different order
than now.
---
android/android-tester.c | 100 ++++++++++++++++++-----------------------------
1 file changed, 39 insertions(+), 61 deletions(-)
diff --git a/android/android-tester.c b/android/android-tester.c
index 4eb265b..92e6080 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -53,7 +53,6 @@ static uint32_t test_setprop_disctimeout_val = 120;
enum hal_bluetooth_callbacks_id {
ADAPTER_TEST_END,
- ADAPTER_TEST_SETUP_MODE,
ADAPTER_STATE_CHANGED_ON,
ADAPTER_STATE_CHANGED_OFF,
ADAPTER_PROP_BDADDR,
@@ -156,6 +155,13 @@ static void command_generic_new_settings(uint16_t index, uint16_t length,
mgmt_unregister(data->mgmt, data->mgmt_settings_id);
}
+static bool is_empty_halcb_list(void)
+{
+ struct test_data *data = tester_get_data();
+
+ return !(g_slist_length(data->expected_callbacks));
+}
+
static void hal_cb_init(struct test_data *data)
{
const struct generic_data *test_data = data->test_data;
@@ -167,6 +173,9 @@ static void hal_cb_init(struct test_data *data)
GINT_TO_POINTER(test_data->expected_hal_callbacks[i]));
i++;
}
+
+ if (is_empty_halcb_list())
+ data->hal_cb_called = true;
}
static void mgmt_cb_init(struct test_data *data)
@@ -193,7 +202,7 @@ static void test_property_init(struct test_data *data)
{
const struct generic_data *test_data = data->test_data;
- if (!(test_data->expected_property.type))
+ if (is_empty_halcb_list() || !(test_data->expected_property.type))
data->property_checked = true;
}
@@ -245,22 +254,16 @@ static void check_test_property(void)
test_update_state();
}
-static int get_expected_hal_cb(void)
+static void update_hal_cb_list(enum hal_bluetooth_callbacks_id
+ expected_callback)
{
struct test_data *data = tester_get_data();
- if (!(g_slist_length(data->expected_callbacks)))
- return ADAPTER_TEST_SETUP_MODE;
-
- return GPOINTER_TO_INT(data->expected_callbacks->data);
-}
-
-static void remove_expected_hal_cb(void)
-{
- struct test_data *data = tester_get_data();
+ if (is_empty_halcb_list())
+ return;
data->expected_callbacks = g_slist_remove(data->expected_callbacks,
- data->expected_callbacks->data);
+ GINT_TO_POINTER(expected_callback));
if (!data->expected_callbacks)
data->hal_cb_called = true;
@@ -465,28 +468,17 @@ failed:
static void adapter_state_changed_cb(bt_state_t state)
{
- enum hal_bluetooth_callbacks_id hal_cb;
-
- hal_cb = get_expected_hal_cb();
-
- switch (hal_cb) {
- case ADAPTER_STATE_CHANGED_ON:
- if (state == BT_STATE_ON)
- remove_expected_hal_cb();
- else
- tester_test_failed();
- break;
- case ADAPTER_STATE_CHANGED_OFF:
- if (state == BT_STATE_OFF)
- remove_expected_hal_cb();
- else
- tester_test_failed();
- break;
- case ADAPTER_TEST_SETUP_MODE:
- if (state == BT_STATE_ON)
+ switch (state) {
+ case BT_STATE_ON:
+ if (is_empty_halcb_list())
tester_setup_complete();
- else
+ update_hal_cb_list(ADAPTER_STATE_CHANGED_ON);
+ break;
+ case BT_STATE_OFF:
+ if (is_empty_halcb_list())
tester_setup_failed();
+ update_hal_cb_list(ADAPTER_STATE_CHANGED_OFF);
+ break;
default:
break;
}
@@ -495,65 +487,51 @@ static void adapter_state_changed_cb(bt_state_t state)
static void adapter_properties_cb(bt_status_t status, int num_properties,
bt_property_t *properties)
{
- enum hal_bluetooth_callbacks_id hal_cb;
struct test_data *data = tester_get_data();
int i;
- for (i = 0; i < num_properties; i++) {
- hal_cb = get_expected_hal_cb();
+ if (is_empty_halcb_list())
+ return;
- if (hal_cb == ADAPTER_TEST_SETUP_MODE)
- break;
+ for (i = 0; i < num_properties; i++) {
- data->test_property = *properties;
+ data->test_property = properties[i];
- if (g_slist_next(data->expected_callbacks) ==
- ADAPTER_TEST_END)
+ if (g_slist_length(data->expected_callbacks) == 1)
check_test_property();
switch (properties[i].type) {
case BT_PROPERTY_BDADDR:
- if (hal_cb != ADAPTER_PROP_BDADDR)
- goto fail;
+ update_hal_cb_list(ADAPTER_PROP_BDADDR);
break;
case BT_PROPERTY_BDNAME:
- if (hal_cb != ADAPTER_PROP_BDNAME)
- goto fail;
+ update_hal_cb_list(ADAPTER_PROP_BDNAME);
break;
case BT_PROPERTY_UUIDS:
- if (hal_cb != ADAPTER_PROP_UUIDS)
- goto fail;
+ update_hal_cb_list(ADAPTER_PROP_UUIDS);
break;
case BT_PROPERTY_CLASS_OF_DEVICE:
- if (hal_cb != ADAPTER_PROP_COD)
- goto fail;
+ update_hal_cb_list(ADAPTER_PROP_COD);
break;
case BT_PROPERTY_TYPE_OF_DEVICE:
- if (hal_cb != ADAPTER_PROP_TYPE)
- goto fail;
+ update_hal_cb_list(ADAPTER_PROP_TYPE);
break;
case BT_PROPERTY_SERVICE_RECORD:
- if (hal_cb != ADAPTER_PROP_SERVICE_RECORD)
- goto fail;
+ update_hal_cb_list(ADAPTER_PROP_SERVICE_RECORD);
break;
case BT_PROPERTY_ADAPTER_SCAN_MODE:
- if (hal_cb != ADAPTER_PROP_SCAN_MODE)
- goto fail;
+ update_hal_cb_list(ADAPTER_PROP_SCAN_MODE);
break;
case BT_PROPERTY_ADAPTER_BONDED_DEVICES:
- if (hal_cb != ADAPTER_PROP_BONDED_DEVICES)
- goto fail;
+ update_hal_cb_list(ADAPTER_PROP_BONDED_DEVICES);
break;
case BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT:
- if (hal_cb != ADAPTER_PROP_DISC_TIMEOUT)
- goto fail;
+ update_hal_cb_list(ADAPTER_PROP_DISC_TIMEOUT);
break;
default:
goto fail;
}
- remove_expected_hal_cb();
}
-
return;
fail:
--
1.8.4.2
This adds UUIDS set property fail test case due to only get
possibility.
---
android/android-tester.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/android/android-tester.c b/android/android-tester.c
index 92e6080..4fe0033 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -596,6 +596,18 @@ static const struct generic_data bluetooth_getprop_bdname_success_test = {
.expected_property.len = 17
};
+static unsigned char setprop_uuids[] = { 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00,
+ 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00 };
+
+static const struct generic_data bluetooth_setprop_uuid_invalid_test = {
+ .expected_hal_callbacks = {ADAPTER_TEST_END},
+ .expected_adapter_status = BT_STATUS_FAIL,
+ .expected_property.type = BT_PROPERTY_UUIDS,
+ .expected_property.val = &setprop_uuids,
+ .expected_property.len = 17
+};
+
static bt_callbacks_t bt_callbacks = {
.size = sizeof(bt_callbacks),
.adapter_state_changed_cb = adapter_state_changed_cb,
@@ -973,6 +985,19 @@ static void test_getprop_bdname_success(const void *test_data)
check_expected_status(adapter_status);
}
+static void test_setprop_uuid_invalid(const void *test_data)
+{
+ struct test_data *data = tester_get_data();
+ const struct generic_data *test = data->test_data;
+ const bt_property_t *prop = &test->expected_property;
+ bt_status_t adapter_status;
+
+ init_test_conditions(data);
+
+ adapter_status = data->if_bluetooth->set_adapter_property(prop);
+ check_expected_status(adapter_status);
+}
+
#define test_bredrle(name, data, test_setup, test, test_teardown) \
do { \
struct test_data *user; \
@@ -1028,6 +1053,11 @@ int main(int argc, char *argv[])
setup_enabled_adapter,
test_getprop_bdname_success, teardown);
+ test_bredrle("Set UUID - Invalid",
+ &bluetooth_setprop_uuid_invalid_test,
+ setup_enabled_adapter,
+ test_setprop_uuid_invalid, teardown);
+
test_bredrle("Socket Init", NULL, setup_socket_interface,
test_dummy, teardown);
--
1.8.4.2