linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] android/tester: Check status returned from HAL calls
@ 2013-12-18  8:55 Andrei Emeltchenko
  2013-12-18  8:55 ` [PATCH 2/3] android/tester: Check return status for enable() Andrei Emeltchenko
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Andrei Emeltchenko @ 2013-12-18  8:55 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

In test setup phase check status returned from  enable() call.
---
 android/android-tester.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/android/android-tester.c b/android/android-tester.c
index bd6fa02..4a75704 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -696,10 +696,13 @@ static void setup_base(const void *test_data)
 static void setup_enabled_adapter(const void *test_data)
 {
 	struct test_data *data = tester_get_data();
+	bt_status_t status;
 
 	setup(data);
 
-	data->if_bluetooth->enable();
+	status = data->if_bluetooth->enable();
+	if (status != BT_STATUS_SUCCESS)
+		tester_setup_failed();
 }
 
 static void teardown(const void *test_data)
-- 
1.8.3.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] android/tester: Check return status for enable()
  2013-12-18  8:55 [PATCH 1/3] android/tester: Check status returned from HAL calls Andrei Emeltchenko
@ 2013-12-18  8:55 ` Andrei Emeltchenko
  2013-12-18  8:55 ` [PATCH 3/3] android/tester: Enable bthost after device is enabled Andrei Emeltchenko
  2013-12-18 10:26 ` [PATCH 1/3] android/tester: Check status returned from HAL calls Johan Hedberg
  2 siblings, 0 replies; 4+ messages in thread
From: Andrei Emeltchenko @ 2013-12-18  8:55 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Use check_expected_status helper for test for returned status in
enable() HAL call.
---
 android/android-tester.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/android/android-tester.c b/android/android-tester.c
index 4a75704..423dd6a 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -542,7 +542,8 @@ fail:
 
 static const struct generic_data bluetooth_enable_success_test = {
 	.expected_hal_callbacks = {ADAPTER_PROPS, ADAPTER_STATE_CHANGED_ON,
-							ADAPTER_TEST_END}
+							ADAPTER_TEST_END},
+	.expected_adapter_status = BT_STATUS_SUCCESS
 };
 
 static const struct generic_data bluetooth_enable_done_test = {
@@ -726,10 +727,12 @@ static void teardown(const void *test_data)
 static void test_enable(const void *test_data)
 {
 	struct test_data *data = tester_get_data();
+	bt_status_t adapter_status;
 
 	init_test_conditions(data);
 
-	data->if_bluetooth->enable();
+	adapter_status = data->if_bluetooth->enable();
+	check_expected_status(adapter_status);
 }
 
 static void test_enable_done(const void *test_data)
-- 
1.8.3.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] android/tester: Enable bthost after device is enabled
  2013-12-18  8:55 [PATCH 1/3] android/tester: Check status returned from HAL calls Andrei Emeltchenko
  2013-12-18  8:55 ` [PATCH 2/3] android/tester: Check return status for enable() Andrei Emeltchenko
@ 2013-12-18  8:55 ` Andrei Emeltchenko
  2013-12-18 10:26 ` [PATCH 1/3] android/tester: Check status returned from HAL calls Johan Hedberg
  2 siblings, 0 replies; 4+ messages in thread
From: Andrei Emeltchenko @ 2013-12-18  8:55 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

This puts bthost to connectible mode allowing us to use powered setup
for connect to emulated device.
---
 android/android-tester.c | 43 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 42 insertions(+), 1 deletion(-)

diff --git a/android/android-tester.c b/android/android-tester.c
index 423dd6a..736cd70 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -33,10 +33,15 @@
 #include "src/shared/mgmt.h"
 #include "src/shared/hciemu.h"
 
+#include "emulator/bthost.h"
+#include "monitor/bt.h"
+
 #include <hardware/hardware.h>
 #include <hardware/bluetooth.h>
 #include <hardware/bt_sock.h>
 
+#include "utils.h"
+
 #define ADAPTER_PROPS ADAPTER_PROP_BDADDR, ADAPTER_PROP_BDNAME, \
 			ADAPTER_PROP_UUIDS, ADAPTER_PROP_COD, \
 			ADAPTER_PROP_TYPE, ADAPTER_PROP_SCAN_MODE, \
@@ -466,12 +471,48 @@ failed:
 		close(fd);
 }
 
+static void emu_connectable_complete(uint16_t opcode, uint8_t status,
+					const void *param, uint8_t len,
+					void *user_data)
+{
+	switch (opcode) {
+	case BT_HCI_CMD_WRITE_SCAN_ENABLE:
+	case BT_HCI_CMD_LE_SET_ADV_ENABLE:
+		break;
+	default:
+		return;
+	}
+
+	tester_print("Emulated remote set connectable status 0x%02x", status);
+
+	if (status)
+		tester_setup_failed();
+	else
+		tester_setup_complete();
+}
+
+static void setup_powered_emulated_remote(void)
+{
+	struct test_data *data = tester_get_data();
+	struct bthost *bthost;
+
+	tester_print("Controller powered on");
+
+	bthost = hciemu_client_get_host(data->hciemu);
+	bthost_set_cmd_complete_cb(bthost, emu_connectable_complete, data);
+
+	if (data->hciemu_type == HCIEMU_TYPE_LE)
+		bthost_set_adv_enable(bthost, 0x01);
+	else
+		bthost_write_scan_enable(bthost, 0x03);
+}
+
 static void adapter_state_changed_cb(bt_state_t state)
 {
 	switch (state) {
 	case BT_STATE_ON:
 		if (is_empty_halcb_list())
-			tester_setup_complete();
+			setup_powered_emulated_remote();
 		update_hal_cb_list(ADAPTER_STATE_CHANGED_ON);
 		break;
 	case BT_STATE_OFF:
-- 
1.8.3.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/3] android/tester: Check status returned from HAL calls
  2013-12-18  8:55 [PATCH 1/3] android/tester: Check status returned from HAL calls Andrei Emeltchenko
  2013-12-18  8:55 ` [PATCH 2/3] android/tester: Check return status for enable() Andrei Emeltchenko
  2013-12-18  8:55 ` [PATCH 3/3] android/tester: Enable bthost after device is enabled Andrei Emeltchenko
@ 2013-12-18 10:26 ` Johan Hedberg
  2 siblings, 0 replies; 4+ messages in thread
From: Johan Hedberg @ 2013-12-18 10:26 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth

Hi Andrei,

On Wed, Dec 18, 2013, Andrei Emeltchenko wrote:
> In test setup phase check status returned from  enable() call.
> ---
>  android/android-tester.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)

All three patches have been applied. Thanks.

Johan

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-12-18 10:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-18  8:55 [PATCH 1/3] android/tester: Check status returned from HAL calls Andrei Emeltchenko
2013-12-18  8:55 ` [PATCH 2/3] android/tester: Check return status for enable() Andrei Emeltchenko
2013-12-18  8:55 ` [PATCH 3/3] android/tester: Enable bthost after device is enabled Andrei Emeltchenko
2013-12-18 10:26 ` [PATCH 1/3] android/tester: Check status returned from HAL calls Johan Hedberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).