public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/19] Android/tester-ng: New android tester
@ 2014-07-03 16:00 Grzegorz Kolodziejczyk
  2014-07-03 16:00 ` [PATCH 01/19] shared/tester: Add support for debug logs for tester Grzegorz Kolodziejczyk
                   ` (19 more replies)
  0 siblings, 20 replies; 21+ messages in thread
From: Grzegorz Kolodziejczyk @ 2014-07-03 16:00 UTC (permalink / raw)
  To: linux-bluetooth

Based on past experience with android-tester, new android tester is
written from scrath with fixed all known bugs and framework
inadvertancies.

Each HAL will have it's own file named tester-"hal" which will
contain test cases and test steps macros (multiple usage of repeating
test steps in test cases). Main tester (framework) will gather all
test cases from tester-"hal" and run it.

Once new test case will be added, same one from old android tester
will be removed, until whole test case list will be replaced.

Grzegorz Kolodziejczyk (17):
  shared/tester: Add support for debug logs for tester
  android/tester-ng: Add android-tester-ng
  android/tester-bluetooth: Initial bluetooth HAL tester
  android/tester-bluetooth: Add initial test case
  android/tester-bluetooth: Add enable success test case
  android/tester-ng: Add double enable success test case
  android/tester-socket: Initial socket tester
  android/tester-socket: Add initial test case
  android/tester-hidhost: Initial hidhost tester
  android/tester-hidhost: Add initial test case
  android/tester-gatt: Add initial test case
  android/tester-ng: Add property check handling
  android/tester-bluetooth: Add disable success test case
  android/tester-bluetooth: Add bdname set success tc
  Android/tester-bluetooth: Add scan_mode set success tc
  Android/tester-bluetooth: Add disc_timeout set success tc
  android/android-tester: Remove test cases replaced by tester-ng

Jakub Tyszkowski (2):
  android/tester-ng: Add callback mechanism
  android/tester-gatt: Initial gatt tester

 android/Makefile.am        |   28 ++
 android/android-tester.c   |  248 -----------
 android/tester-bluetooth.c |  269 ++++++++++++
 android/tester-gatt.c      |   46 ++
 android/tester-hidhost.c   |   46 ++
 android/tester-main.c      | 1001 ++++++++++++++++++++++++++++++++++++++++++++
 android/tester-main.h      |  191 +++++++++
 android/tester-socket.c    |   46 ++
 src/shared/tester.c        |   14 +
 src/shared/tester.h        |    2 +
 10 files changed, 1643 insertions(+), 248 deletions(-)
 create mode 100644 android/tester-bluetooth.c
 create mode 100644 android/tester-gatt.c
 create mode 100644 android/tester-hidhost.c
 create mode 100644 android/tester-main.c
 create mode 100644 android/tester-main.h
 create mode 100644 android/tester-socket.c

-- 
1.9.3


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

* [PATCH 01/19] shared/tester: Add support for debug logs for tester
  2014-07-03 16:00 [PATCH 00/19] Android/tester-ng: New android tester Grzegorz Kolodziejczyk
@ 2014-07-03 16:00 ` Grzegorz Kolodziejczyk
  2014-07-03 16:00 ` [PATCH 02/19] android/tester-ng: Add android-tester-ng Grzegorz Kolodziejczyk
                   ` (18 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Grzegorz Kolodziejczyk @ 2014-07-03 16:00 UTC (permalink / raw)
  To: linux-bluetooth

It allows to print debug logs if debug mode is enabled. It could help in
case of additional debug prints need (verbose mode).
---
 src/shared/tester.c | 14 ++++++++++++++
 src/shared/tester.h |  2 ++
 2 files changed, 16 insertions(+)

diff --git a/src/shared/tester.c b/src/shared/tester.c
index 56e5696..88dfaeb 100644
--- a/src/shared/tester.c
+++ b/src/shared/tester.c
@@ -134,6 +134,20 @@ void tester_print(const char *format, ...)
 	printf("%s\n", COLOR_OFF);
 }
 
+void tester_debug(const char *format, ...)
+{
+	va_list ap;
+
+	if (!tester_use_debug())
+		return;
+
+	printf("  %s", COLOR_WHITE);
+	va_start(ap, format);
+	vprintf(format, ap);
+	va_end(ap);
+	printf("%s\n", COLOR_OFF);
+}
+
 void tester_warn(const char *format, ...)
 {
 	va_list ap;
diff --git a/src/shared/tester.h b/src/shared/tester.h
index 85d5e95..0231f19 100644
--- a/src/shared/tester.h
+++ b/src/shared/tester.h
@@ -33,6 +33,8 @@ void tester_print(const char *format, ...)
 				__attribute__((format(printf, 1, 2)));
 void tester_warn(const char *format, ...)
 				__attribute__((format(printf, 1, 2)));
+void tester_debug(const char *format, ...)
+				__attribute__((format(printf, 1, 2)));
 
 typedef void (*tester_destroy_func_t)(void *user_data);
 typedef void (*tester_data_func_t)(const void *test_data);
-- 
1.9.3


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

* [PATCH 02/19] android/tester-ng: Add android-tester-ng
  2014-07-03 16:00 [PATCH 00/19] Android/tester-ng: New android tester Grzegorz Kolodziejczyk
  2014-07-03 16:00 ` [PATCH 01/19] shared/tester: Add support for debug logs for tester Grzegorz Kolodziejczyk
@ 2014-07-03 16:00 ` Grzegorz Kolodziejczyk
  2014-07-03 16:00 ` [PATCH 03/19] android/tester-bluetooth: Initial bluetooth HAL tester Grzegorz Kolodziejczyk
                   ` (17 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Grzegorz Kolodziejczyk @ 2014-07-03 16:00 UTC (permalink / raw)
  To: linux-bluetooth

Based on past experience with android-tester, new android tester is
written from scrath with fixed all known bugs and framework
inadvertancies. Once new test case will be added, same one from old
android tester will be removed, until whole test case list will be
replaced.
---
 android/Makefile.am   |  24 +++
 android/tester-main.c | 503 ++++++++++++++++++++++++++++++++++++++++++++++++++
 android/tester-main.h |  86 +++++++++
 3 files changed, 613 insertions(+)
 create mode 100644 android/tester-main.c
 create mode 100644 android/tester-main.h

diff --git a/android/Makefile.am b/android/Makefile.am
index 730be2f..0192935 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -163,6 +163,30 @@ android_android_tester_LDADD = lib/libbluetooth-internal.la @GLIB_LIBS@
 
 android_android_tester_LDFLAGS = -pthread -ldl
 
+noinst_PROGRAMS += android/android-tester-ng
+
+android_android_tester_ng_SOURCES = emulator/btdev.h emulator/btdev.c \
+				emulator/bthost.h emulator/bthost.c \
+				emulator/smp.c \
+				src/shared/crypto.h src/shared/crypto.c \
+				src/shared/io.h src/shared/io-glib.c \
+				src/shared/queue.h src/shared/queue.c \
+				src/shared/util.h src/shared/util.c \
+				src/shared/mgmt.h src/shared/mgmt.c \
+				src/shared/hciemu.h src/shared/hciemu.c \
+				src/shared/tester.h src/shared/tester.c \
+				src/shared/timeout.h src/shared/timeout-glib.c \
+				monitor/rfcomm.h \
+				android/hardware/hardware.c \
+				android/tester-main.h android/tester-main.c
+
+android_android_tester_ng_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/android \
+				-DPLUGINDIR=\""$(android_plugindir)"\"
+
+android_android_tester_ng_LDADD = lib/libbluetooth-internal.la @GLIB_LIBS@
+
+android_android_tester_ng_LDFLAGS = -pthread -ldl
+
 noinst_PROGRAMS += android/ipc-tester
 
 android_ipc_tester_SOURCES = emulator/btdev.h emulator/btdev.c \
diff --git a/android/tester-main.c b/android/tester-main.c
new file mode 100644
index 0000000..8f52286
--- /dev/null
+++ b/android/tester-main.c
@@ -0,0 +1,503 @@
+/*
+ * Copyright (C) 2014 Intel Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "tester-main.h"
+
+static char exec_dir[PATH_MAX + 1];
+
+static gint scheduled_cbacks_num;
+
+#define EMULATOR_SIGNAL_TIMEOUT 2 /* in seconds */
+#define EMULATOR_SIGNAL "emulator_started"
+
+static gboolean check_callbacks_called(gpointer user_data)
+{
+	/*
+	 * Wait for all callbacks scheduled in current test context to execute
+	 * in main loop. This will avoid late callback calls after test case has
+	 * already failed or timed out.
+	 */
+
+	if (g_atomic_int_get(&scheduled_cbacks_num) == 0) {
+		tester_teardown_complete();
+		return FALSE;
+	} else if (scheduled_cbacks_num < 0) {
+		tester_warn("Unscheduled callback called!");
+		return FALSE;
+	}
+
+	return TRUE;
+}
+
+static void check_daemon_term(void)
+{
+	int status;
+	pid_t pid;
+	struct test_data *data = tester_get_data();
+
+	if (!data)
+		return;
+
+	pid = waitpid(data->bluetoothd_pid, &status, WNOHANG);
+	if (pid != data->bluetoothd_pid)
+		return;
+
+	data->bluetoothd_pid = 0;
+
+	if (WIFEXITED(status) && (WEXITSTATUS(status) == EXIT_SUCCESS)) {
+		g_idle_add(check_callbacks_called, NULL);
+		return;
+	}
+
+	tester_warn("Unexpected Daemon shutdown with status %d", status);
+}
+
+static gboolean signal_handler(GIOChannel *channel, GIOCondition cond,
+							gpointer user_data)
+{
+	struct signalfd_siginfo si;
+	ssize_t result;
+	int fd;
+
+	if (cond & (G_IO_NVAL | G_IO_ERR | G_IO_HUP))
+		return FALSE;
+
+	fd = g_io_channel_unix_get_fd(channel);
+
+	result = read(fd, &si, sizeof(si));
+	if (result != sizeof(si))
+		return FALSE;
+
+	switch (si.ssi_signo) {
+	case SIGCHLD:
+		check_daemon_term();
+		break;
+	}
+
+	return TRUE;
+}
+
+static guint setup_signalfd(void)
+{
+	GIOChannel *channel;
+	guint source;
+	sigset_t mask;
+	int fd;
+
+	sigemptyset(&mask);
+	sigaddset(&mask, SIGCHLD);
+
+	if (sigprocmask(SIG_BLOCK, &mask, NULL) < 0)
+		return 0;
+
+	fd = signalfd(-1, &mask, 0);
+	if (fd < 0)
+		return 0;
+
+	channel = g_io_channel_unix_new(fd);
+
+	g_io_channel_set_close_on_unref(channel, TRUE);
+	g_io_channel_set_encoding(channel, NULL, NULL);
+	g_io_channel_set_buffered(channel, FALSE);
+
+	source = g_io_add_watch(channel,
+				G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
+				signal_handler, NULL);
+
+	g_io_channel_unref(channel);
+
+	return source;
+}
+
+static void test_post_teardown(const void *test_data)
+{
+	struct test_data *data = tester_get_data();
+
+	hciemu_unref(data->hciemu);
+	data->hciemu = NULL;
+
+	g_source_remove(data->signalfd);
+	data->signalfd = 0;
+}
+
+static void bluetoothd_start(int hci_index)
+{
+	char prg_name[PATH_MAX + 1];
+	char index[8];
+	char *prg_argv[5];
+
+	snprintf(prg_name, sizeof(prg_name), "%s/%s", exec_dir, "bluetoothd");
+	snprintf(index, sizeof(index), "%d", hci_index);
+
+	prg_argv[0] = prg_name;
+	prg_argv[1] = "-i";
+	prg_argv[2] = index;
+	prg_argv[3] = "-d";
+	prg_argv[4] = NULL;
+
+	if (!tester_use_debug())
+		fclose(stderr);
+
+	execve(prg_argv[0], prg_argv, NULL);
+}
+
+static void emulator(int pipe, int hci_index)
+{
+	static const char SYSTEM_SOCKET_PATH[] = "\0android_system";
+	char buf[1024];
+	struct sockaddr_un addr;
+	struct timeval tv;
+	int fd;
+	ssize_t len;
+
+	fd = socket(PF_LOCAL, SOCK_DGRAM | SOCK_CLOEXEC, 0);
+	if (fd < 0)
+		goto failed;
+
+	tv.tv_sec = EMULATOR_SIGNAL_TIMEOUT;
+	tv.tv_usec = 0;
+	setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(tv));
+
+	memset(&addr, 0, sizeof(addr));
+	addr.sun_family = AF_UNIX;
+	memcpy(addr.sun_path, SYSTEM_SOCKET_PATH, sizeof(SYSTEM_SOCKET_PATH));
+
+	if (bind(fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
+		perror("Failed to bind system socket");
+		goto failed;
+	}
+
+	len = write(pipe, EMULATOR_SIGNAL, sizeof(EMULATOR_SIGNAL));
+	if (len != sizeof(EMULATOR_SIGNAL))
+		goto failed;
+
+	memset(buf, 0, sizeof(buf));
+
+	len = read(fd, buf, sizeof(buf));
+	if (len <= 0 || strcmp(buf, "bluetooth.start=daemon"))
+		goto failed;
+
+	close(pipe);
+	close(fd);
+	return bluetoothd_start(hci_index);
+
+failed:
+	close(pipe);
+
+	if (fd >= 0)
+		close(fd);
+}
+
+static void mgmt_debug(const char *str, void *user_data)
+{
+	const char *prefix = user_data;
+
+	tester_print("%s%s", prefix, str);
+}
+
+static void read_info_callback(uint8_t status, uint16_t length,
+					const void *param, void *user_data)
+{
+	struct test_data *data = tester_get_data();
+	const struct mgmt_rp_read_info *rp = param;
+	char addr[18];
+	uint16_t manufacturer;
+	uint32_t supported_settings, current_settings;
+
+	tester_print("Read Info callback");
+	tester_print("  Status: 0x%02x", status);
+
+	if (status || !param) {
+		tester_pre_setup_failed();
+		return;
+	}
+
+	ba2str(&rp->bdaddr, addr);
+	manufacturer = btohs(rp->manufacturer);
+	supported_settings = btohl(rp->supported_settings);
+	current_settings = btohl(rp->current_settings);
+
+	tester_print("  Address: %s", addr);
+	tester_print("  Version: 0x%02x", rp->version);
+	tester_print("  Manufacturer: 0x%04x", manufacturer);
+	tester_print("  Supported settings: 0x%08x", supported_settings);
+	tester_print("  Current settings: 0x%08x", current_settings);
+	tester_print("  Class: 0x%02x%02x%02x",
+			rp->dev_class[2], rp->dev_class[1], rp->dev_class[0]);
+	tester_print("  Name: %s", rp->name);
+	tester_print("  Short name: %s", rp->short_name);
+
+	if (strcmp(hciemu_get_address(data->hciemu), addr)) {
+		tester_pre_setup_failed();
+		return;
+	}
+
+	tester_pre_setup_complete();
+}
+
+static void index_added_callback(uint16_t index, uint16_t length,
+					const void *param, void *user_data)
+{
+	struct test_data *data = tester_get_data();
+
+	tester_print("Index Added callback");
+	tester_print("  Index: 0x%04x", index);
+
+	data->mgmt_index = index;
+
+	mgmt_send(data->mgmt, MGMT_OP_READ_INFO, data->mgmt_index, 0, NULL,
+					read_info_callback, NULL, NULL);
+}
+
+static void index_removed_callback(uint16_t index, uint16_t length,
+					const void *param, void *user_data)
+{
+	struct test_data *data = tester_get_data();
+
+	tester_print("Index Removed callback");
+	tester_print("  Index: 0x%04x", index);
+
+	if (index != data->mgmt_index)
+		return;
+
+	mgmt_unregister_index(data->mgmt, data->mgmt_index);
+
+	mgmt_unref(data->mgmt);
+	data->mgmt = NULL;
+
+	tester_post_teardown_complete();
+}
+
+static void read_index_list_callback(uint8_t status, uint16_t length,
+					const void *param, void *user_data)
+{
+	struct test_data *data = tester_get_data();
+
+	tester_print("Read Index List callback");
+	tester_print("  Status: 0x%02x", status);
+
+	if (status || !param) {
+		tester_pre_setup_failed();
+		return;
+	}
+
+	mgmt_register(data->mgmt, MGMT_EV_INDEX_ADDED, MGMT_INDEX_NONE,
+					index_added_callback, NULL, NULL);
+
+	mgmt_register(data->mgmt, MGMT_EV_INDEX_REMOVED, MGMT_INDEX_NONE,
+					index_removed_callback, NULL, NULL);
+
+	data->hciemu = hciemu_new(data->hciemu_type);
+	if (!data->hciemu) {
+		tester_warn("Failed to setup HCI emulation");
+		tester_pre_setup_failed();
+		return;
+	}
+
+	tester_print("New hciemu instance created");
+}
+
+static void test_pre_setup(const void *test_data)
+{
+	struct test_data *data = tester_get_data();
+
+	data->signalfd = setup_signalfd();
+	if (!data->signalfd) {
+		tester_warn("Failed to setup signalfd");
+		tester_pre_setup_failed();
+		return;
+	}
+
+	data->mgmt = mgmt_new_default();
+	if (!data->mgmt) {
+		tester_warn("Failed to setup management interface");
+		tester_pre_setup_failed();
+		return;
+	}
+
+	if (!tester_use_debug())
+		fclose(stderr);
+	else
+		mgmt_set_debug(data->mgmt, mgmt_debug, "mgmt: ", NULL);
+
+	mgmt_send(data->mgmt, MGMT_OP_READ_INDEX_LIST, MGMT_INDEX_NONE, 0,
+				NULL, read_index_list_callback, NULL, NULL);
+}
+
+static bt_callbacks_t bt_callbacks = {
+	.size = sizeof(bt_callbacks),
+	.adapter_state_changed_cb = NULL,
+	.adapter_properties_cb = NULL,
+	.remote_device_properties_cb = NULL,
+	.device_found_cb = NULL,
+	.discovery_state_changed_cb = NULL,
+	.pin_request_cb = NULL,
+	.ssp_request_cb = NULL,
+	.bond_state_changed_cb = NULL,
+	.acl_state_changed_cb = NULL,
+	.thread_evt_cb = NULL,
+	.dut_mode_recv_cb = NULL,
+	.le_test_mode_cb = NULL
+};
+
+static bool setup_base(struct test_data *data)
+{
+	const hw_module_t *module;
+	hw_device_t *device;
+	int signal_fd[2];
+	char buf[1024];
+	pid_t pid;
+	int len;
+	int err;
+
+	if (pipe(signal_fd))
+		return false;
+
+	pid = fork();
+
+	if (pid < 0) {
+		close(signal_fd[0]);
+		close(signal_fd[1]);
+		return false;
+	}
+
+	if (pid == 0) {
+		if (!tester_use_debug())
+			fclose(stderr);
+
+		close(signal_fd[0]);
+		emulator(signal_fd[1], data->mgmt_index);
+		exit(0);
+	}
+
+	close(signal_fd[1]);
+	data->bluetoothd_pid = pid;
+
+	len = read(signal_fd[0], buf, sizeof(buf));
+	if (len <= 0 || strcmp(buf, EMULATOR_SIGNAL)) {
+		close(signal_fd[0]);
+		return false;
+	}
+
+	close(signal_fd[0]);
+
+	err = hw_get_module(BT_HARDWARE_MODULE_ID, &module);
+	if (err)
+		return false;
+
+	err = module->methods->open(module, BT_HARDWARE_MODULE_ID, &device);
+	if (err)
+		return false;
+
+	data->device = device;
+
+	data->if_bluetooth = ((bluetooth_device_t *)
+					device)->get_bluetooth_interface();
+	if (!data->if_bluetooth)
+		return false;
+
+	if (!(data->steps = queue_new()))
+		return false;
+
+
+	return true;
+}
+
+static void setup(const void *test_data)
+{
+	struct test_data *data = tester_get_data();
+	bt_status_t status;
+
+	if (!setup_base(data)) {
+		tester_setup_failed();
+		return;
+	}
+
+	status = data->if_bluetooth->init(&bt_callbacks);
+	if (status != BT_STATUS_SUCCESS) {
+		data->if_bluetooth = NULL;
+		tester_setup_failed();
+		return;
+	}
+
+	tester_setup_complete();
+}
+
+static void teardown(const void *test_data)
+{
+	struct test_data *data = tester_get_data();
+
+	queue_destroy(data->steps, NULL);
+	data->steps = NULL;
+
+	if (data->if_bluetooth) {
+		data->if_bluetooth->cleanup();
+		data->if_bluetooth = NULL;
+	}
+
+	data->device->close(data->device);
+
+	if (!data->bluetoothd_pid)
+		tester_teardown_complete();
+}
+
+#define test_bredr(data, test_setup, test, test_teardown) \
+	do { \
+		struct test_data *user; \
+		user = g_malloc0(sizeof(struct test_data)); \
+		if (!user) \
+			break; \
+		user->hciemu_type = HCIEMU_TYPE_BREDR; \
+		user->test_data = data; \
+		tester_add_full(data->title, data, test_pre_setup, \
+					test_setup, test, test_teardown, \
+					test_post_teardown, 3, user, g_free); \
+	} while (0)
+
+#define test_bredrle(data, test_setup, test, test_teardown) \
+	do { \
+		struct test_data *user; \
+		user = g_malloc0(sizeof(struct test_data)); \
+		if (!user) \
+			break; \
+		user->hciemu_type = HCIEMU_TYPE_BREDRLE; \
+		user->test_data = data; \
+		tester_add_full(data->title, data, test_pre_setup, \
+					test_setup, test, test_teardown, \
+					test_post_teardown, 3, user, g_free); \
+	} while (0)
+
+static void tester_testcases_cleanup(void)
+{
+}
+
+int main(int argc, char *argv[])
+{
+	snprintf(exec_dir, sizeof(exec_dir), "%s", dirname(argv[0]));
+
+	tester_init(&argc, &argv);
+
+	tester_add_full("Init", NULL, test_pre_setup, setup, NULL, teardown,
+					test_post_teardown, 0, NULL, NULL);
+
+	if (tester_run())
+		return 1;
+
+	tester_testcases_cleanup();
+
+	return 0;
+}
diff --git a/android/tester-main.h b/android/tester-main.h
new file mode 100644
index 0000000..da87c8b
--- /dev/null
+++ b/android/tester-main.h
@@ -0,0 +1,86 @@
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright (C) 2014  Intel Corporation. All rights reserved.
+ *
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#include <stdlib.h>
+#include <stdbool.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <limits.h>
+
+#include <glib.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <sys/wait.h>
+#include <libgen.h>
+#include <sys/signalfd.h>
+
+#include "lib/bluetooth.h"
+#include "lib/mgmt.h"
+
+#include "src/shared/tester.h"
+#include "src/shared/hciemu.h"
+#include "src/shared/mgmt.h"
+#include "src/shared/queue.h"
+
+#include <hardware/hardware.h>
+#include <hardware/bluetooth.h>
+
+#define get_test_case_step_num(tc) (sizeof(tc) / sizeof(struct step))
+
+struct test_data {
+	struct mgmt *mgmt;
+	struct hw_device_t *device;
+	struct hciemu *hciemu;
+	enum hciemu_type hciemu_type;
+
+	const bt_interface_t *if_bluetooth;
+
+	const void *test_data;
+	struct queue *steps;
+
+	guint signalfd;
+	uint16_t mgmt_index;
+	pid_t bluetoothd_pid;
+};
+
+struct test_case {
+	struct step *step;
+	char *title;
+	uint16_t step_num;
+};
+
+/*
+ * Struct of data to check within step action.
+ */
+struct bt_action_data {
+	uint8_t status;
+};
+
+/*
+ * Step structure contains expected step data and step
+ * action, which should be performed before step check.
+ */
+struct step {
+	void (*action)(void);
+	struct bt_action_data action_result;
+};
-- 
1.9.3


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

* [PATCH 03/19] android/tester-bluetooth: Initial bluetooth HAL tester
  2014-07-03 16:00 [PATCH 00/19] Android/tester-ng: New android tester Grzegorz Kolodziejczyk
  2014-07-03 16:00 ` [PATCH 01/19] shared/tester: Add support for debug logs for tester Grzegorz Kolodziejczyk
  2014-07-03 16:00 ` [PATCH 02/19] android/tester-ng: Add android-tester-ng Grzegorz Kolodziejczyk
@ 2014-07-03 16:00 ` Grzegorz Kolodziejczyk
  2014-07-03 16:00 ` [PATCH 04/19] android/tester-bluetooth: Add initial test case Grzegorz Kolodziejczyk
                   ` (16 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Grzegorz Kolodziejczyk @ 2014-07-03 16:00 UTC (permalink / raw)
  To: linux-bluetooth

This is initial patch for android bluetooth HAL tester. It'll contain
test cases for bluetooth hal using android tester framework
(tester-main). Test step actions for this and every tester should be
declared in main tester. Cohesion of test action make action function
more useful and centralized.
---
 android/Makefile.am        |  1 +
 android/tester-bluetooth.c | 32 ++++++++++++++++++++++++++++++++
 android/tester-main.h      |  4 ++++
 3 files changed, 37 insertions(+)
 create mode 100644 android/tester-bluetooth.c

diff --git a/android/Makefile.am b/android/Makefile.am
index 0192935..8cb10ab 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -178,6 +178,7 @@ android_android_tester_ng_SOURCES = emulator/btdev.h emulator/btdev.c \
 				src/shared/timeout.h src/shared/timeout-glib.c \
 				monitor/rfcomm.h \
 				android/hardware/hardware.c \
+				android/tester-bluetooth.c \
 				android/tester-main.h android/tester-main.c
 
 android_android_tester_ng_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/android \
diff --git a/android/tester-bluetooth.c b/android/tester-bluetooth.c
new file mode 100644
index 0000000..9acf999
--- /dev/null
+++ b/android/tester-bluetooth.c
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2014 Intel Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "tester-main.h"
+
+static struct queue *list; /* List of bluetooth test cases */
+
+struct queue *get_bluetooth_tests(void)
+{
+	list = queue_new();
+
+	return list;
+}
+
+void remove_bluetooth_tests(void)
+{
+	queue_destroy(list, NULL);
+}
diff --git a/android/tester-main.h b/android/tester-main.h
index da87c8b..8f10e9f 100644
--- a/android/tester-main.h
+++ b/android/tester-main.h
@@ -84,3 +84,7 @@ struct step {
 	void (*action)(void);
 	struct bt_action_data action_result;
 };
+
+/* Get, remove test cases API */
+struct queue *get_bluetooth_tests(void);
+void remove_bluetooth_tests(void);
-- 
1.9.3


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

* [PATCH 04/19] android/tester-bluetooth: Add initial test case
  2014-07-03 16:00 [PATCH 00/19] Android/tester-ng: New android tester Grzegorz Kolodziejczyk
                   ` (2 preceding siblings ...)
  2014-07-03 16:00 ` [PATCH 03/19] android/tester-bluetooth: Initial bluetooth HAL tester Grzegorz Kolodziejczyk
@ 2014-07-03 16:00 ` Grzegorz Kolodziejczyk
  2014-07-03 16:00 ` [PATCH 05/19] android/tester-bluetooth: Add enable success " Grzegorz Kolodziejczyk
                   ` (15 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Grzegorz Kolodziejczyk @ 2014-07-03 16:00 UTC (permalink / raw)
  To: linux-bluetooth

This also adds handle of test steps in android tester framework like:
initializing, matching, verifyng and generic test action which
performes first step action.
---
 android/tester-bluetooth.c |  14 ++++++
 android/tester-main.c      | 117 ++++++++++++++++++++++++++++++++++++++++++++-
 android/tester-main.h      |   3 ++
 3 files changed, 132 insertions(+), 2 deletions(-)

diff --git a/android/tester-bluetooth.c b/android/tester-bluetooth.c
index 9acf999..c912d7d 100644
--- a/android/tester-bluetooth.c
+++ b/android/tester-bluetooth.c
@@ -19,10 +19,24 @@
 
 static struct queue *list; /* List of bluetooth test cases */
 
+static struct step dummy_steps[] = {
+	{
+		.action = dummy_action,
+	},
+};
+static struct test_case bluetooth_init = {
+	.step = dummy_steps,
+	.title = "Bluetooth Init",
+	.step_num = get_test_case_step_num(dummy_steps),
+};
+
 struct queue *get_bluetooth_tests(void)
 {
 	list = queue_new();
 
+	if (!queue_push_tail(list, &bluetooth_init))
+		return NULL;
+
 	return list;
 }
 
diff --git a/android/tester-main.c b/android/tester-main.c
index 8f52286..51326f5 100644
--- a/android/tester-main.c
+++ b/android/tester-main.c
@@ -338,6 +338,85 @@ static void test_pre_setup(const void *test_data)
 				NULL, read_index_list_callback, NULL, NULL);
 }
 
+/*
+ * Check each test case step if test case expected
+ * data is set and match it with expected result.
+ */
+static bool match_data(struct step *step)
+{
+	struct test_data *data = tester_get_data();
+	const struct step *exp;
+
+	exp = queue_peek_head(data->steps);
+
+	if (!exp) {
+		/* Can occure while test passed already */
+		tester_debug("Cannot get step to match");
+		return false;
+	}
+
+	if (exp->action_result.status && (exp->action_result.status !=
+						step->action_result.status)) {
+		tester_debug("Action status don't match");
+		return false;
+	}
+	return true;
+}
+
+static void init_test_steps(struct test_data *data)
+{
+	const struct test_case *test_steps = data->test_data;
+	int i = 0;
+
+	for (i = 0; i < test_steps->step_num; i++)
+		queue_push_tail(data->steps, &(test_steps->step[i]));
+
+	tester_print("tester: Number of test steps=%d",
+						queue_length(data->steps));
+}
+
+/*
+ * Each test case step should be verified, if match with
+ * expected result tester should go to next test step.
+ */
+static void verify_step(struct step *step, queue_destroy_func_t cleanup_cb)
+{
+	struct test_data *data = tester_get_data();
+	const struct test_case *test_steps = data->test_data;
+	struct step *next_step;
+
+	tester_debug("tester: STEP[%d] check",
+			test_steps->step_num-queue_length(data->steps) + 1);
+
+	if (step && !match_data(step)) {
+		if (cleanup_cb)
+			cleanup_cb(step);
+
+		return;
+	}
+
+	queue_pop_head(data->steps);
+
+	if (cleanup_cb)
+		cleanup_cb(step);
+
+	tester_debug("tester: STEP[%d] pass",
+			test_steps->step_num-queue_length(data->steps));
+
+	if (queue_isempty(data->steps)) {
+		tester_print("tester: All steps done, passing");
+		tester_test_passed();
+
+		return;
+	}
+
+	/* goto next step action if declared in step */
+	next_step = queue_peek_head(data->steps);
+
+	if (next_step->action)
+		next_step->action();
+}
+
 static bt_callbacks_t bt_callbacks = {
 	.size = sizeof(bt_callbacks),
 	.adapter_state_changed_cb = NULL,
@@ -455,6 +534,33 @@ static void teardown(const void *test_data)
 		tester_teardown_complete();
 }
 
+void dummy_action(void)
+{
+	struct step step;
+
+	memset(&step, 0, sizeof(step));
+	step.action = dummy_action;
+
+	verify_step(&step, NULL);
+}
+
+static void generic_test_function(const void *test_data)
+{
+	struct test_data *data = tester_get_data();
+	struct step *first_step;
+
+	init_test_steps(data);
+
+	/* first step action */
+	first_step = queue_peek_head(data->steps);
+	if (!first_step->action) {
+		tester_print("tester: No initial action declared");
+		tester_test_failed();
+		return;
+	}
+	first_step->action();
+}
+
 #define test_bredr(data, test_setup, test, test_teardown) \
 	do { \
 		struct test_data *user; \
@@ -483,6 +589,14 @@ static void teardown(const void *test_data)
 
 static void tester_testcases_cleanup(void)
 {
+	remove_bluetooth_tests();
+}
+
+static void add_bluetooth_tests(void *data, void *user_data)
+{
+	struct test_case *tc = data;
+
+	test_bredrle(tc, setup, generic_test_function, teardown);
 }
 
 int main(int argc, char *argv[])
@@ -491,8 +605,7 @@ int main(int argc, char *argv[])
 
 	tester_init(&argc, &argv);
 
-	tester_add_full("Init", NULL, test_pre_setup, setup, NULL, teardown,
-					test_post_teardown, 0, NULL, NULL);
+	queue_foreach(get_bluetooth_tests(), add_bluetooth_tests, NULL);
 
 	if (tester_run())
 		return 1;
diff --git a/android/tester-main.h b/android/tester-main.h
index 8f10e9f..a4f2ed8 100644
--- a/android/tester-main.h
+++ b/android/tester-main.h
@@ -88,3 +88,6 @@ struct step {
 /* Get, remove test cases API */
 struct queue *get_bluetooth_tests(void);
 void remove_bluetooth_tests(void);
+
+/* Actions */
+void dummy_action(void);
-- 
1.9.3


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

* [PATCH 05/19] android/tester-bluetooth: Add enable success test case
  2014-07-03 16:00 [PATCH 00/19] Android/tester-ng: New android tester Grzegorz Kolodziejczyk
                   ` (3 preceding siblings ...)
  2014-07-03 16:00 ` [PATCH 04/19] android/tester-bluetooth: Add initial test case Grzegorz Kolodziejczyk
@ 2014-07-03 16:00 ` Grzegorz Kolodziejczyk
  2014-07-03 16:00 ` [PATCH 06/19] android/tester-ng: Add callback mechanism Grzegorz Kolodziejczyk
                   ` (14 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Grzegorz Kolodziejczyk @ 2014-07-03 16:00 UTC (permalink / raw)
  To: linux-bluetooth

This adds also enable action which enable bluetooth adapter.
---
 android/tester-bluetooth.c | 15 +++++++++++++++
 android/tester-main.c      | 11 +++++++++++
 android/tester-main.h      |  1 +
 3 files changed, 27 insertions(+)

diff --git a/android/tester-bluetooth.c b/android/tester-bluetooth.c
index c912d7d..0f55d9e 100644
--- a/android/tester-bluetooth.c
+++ b/android/tester-bluetooth.c
@@ -30,6 +30,18 @@ static struct test_case bluetooth_init = {
 	.step_num = get_test_case_step_num(dummy_steps),
 };
 
+static struct step bluetooth_enable_success_steps[] = {
+	{
+		.action_result.status = BT_STATUS_SUCCESS,
+		.action = bluetooth_enable_action,
+	},
+};
+static struct test_case bluetooth_enable_success_tc = {
+	.step = bluetooth_enable_success_steps,
+	.title = "Bluetooth Enable - Success",
+	.step_num = get_test_case_step_num(bluetooth_enable_success_steps),
+};
+
 struct queue *get_bluetooth_tests(void)
 {
 	list = queue_new();
@@ -37,6 +49,9 @@ struct queue *get_bluetooth_tests(void)
 	if (!queue_push_tail(list, &bluetooth_init))
 		return NULL;
 
+	if (!queue_push_tail(list, &bluetooth_enable_success_tc))
+		return NULL;
+
 	return list;
 }
 
diff --git a/android/tester-main.c b/android/tester-main.c
index 51326f5..f49ce82 100644
--- a/android/tester-main.c
+++ b/android/tester-main.c
@@ -544,6 +544,17 @@ void dummy_action(void)
 	verify_step(&step, NULL);
 }
 
+void bluetooth_enable_action(void)
+{
+	struct test_data *data = tester_get_data();
+	struct step step;
+
+	memset(&step, 0, sizeof(step));
+	step.action_result.status = data->if_bluetooth->enable();
+
+	verify_step(&step, NULL);
+}
+
 static void generic_test_function(const void *test_data)
 {
 	struct test_data *data = tester_get_data();
diff --git a/android/tester-main.h b/android/tester-main.h
index a4f2ed8..d79e4c5 100644
--- a/android/tester-main.h
+++ b/android/tester-main.h
@@ -91,3 +91,4 @@ void remove_bluetooth_tests(void);
 
 /* Actions */
 void dummy_action(void);
+void bluetooth_enable_action(void);
-- 
1.9.3


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

* [PATCH 06/19] android/tester-ng: Add callback mechanism
  2014-07-03 16:00 [PATCH 00/19] Android/tester-ng: New android tester Grzegorz Kolodziejczyk
                   ` (4 preceding siblings ...)
  2014-07-03 16:00 ` [PATCH 05/19] android/tester-bluetooth: Add enable success " Grzegorz Kolodziejczyk
@ 2014-07-03 16:00 ` Grzegorz Kolodziejczyk
  2014-07-03 16:00 ` [PATCH 07/19] android/tester-ng: Add double enable success test case Grzegorz Kolodziejczyk
                   ` (13 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Grzegorz Kolodziejczyk @ 2014-07-03 16:00 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jakub Tyszkowski

From: Jakub Tyszkowski <jakub.tyszkowski@tieto.com>

This patch adds bt_cb_data to be used for passing callback data from
asynchronous call to tester's main loop. As for now this struct contains
only state but will be extended to handle various callbacks.
---
 android/tester-bluetooth.c |  4 ++++
 android/tester-main.c      | 45 ++++++++++++++++++++++++++++++++++++++++++++-
 android/tester-main.h      | 32 ++++++++++++++++++++++++++++++++
 3 files changed, 80 insertions(+), 1 deletion(-)

diff --git a/android/tester-bluetooth.c b/android/tester-bluetooth.c
index 0f55d9e..d9f26a8 100644
--- a/android/tester-bluetooth.c
+++ b/android/tester-bluetooth.c
@@ -35,6 +35,10 @@ static struct step bluetooth_enable_success_steps[] = {
 		.action_result.status = BT_STATUS_SUCCESS,
 		.action = bluetooth_enable_action,
 	},
+	{
+		.callback = CB_BT_ADAPTER_STATE_CHANGED,
+		.callback_result.state = BT_STATE_ON,
+	},
 };
 static struct test_case bluetooth_enable_success_tc = {
 	.step = bluetooth_enable_success_steps,
diff --git a/android/tester-main.c b/android/tester-main.c
index f49ce82..326853a 100644
--- a/android/tester-main.c
+++ b/android/tester-main.c
@@ -417,9 +417,52 @@ static void verify_step(struct step *step, queue_destroy_func_t cleanup_cb)
 		next_step->action();
 }
 
+/*
+ * NOTICE:
+ * Its mandatory for callback to set proper step.callback value so that
+ * step verification could pass and move to next test step
+ */
+
+static void destroy_callback_step(void *data)
+{
+	struct step *step = data;
+
+	g_free(step);
+	g_atomic_int_dec_and_test(&scheduled_cbacks_num);
+}
+
+static gboolean verify_callback(gpointer user_data)
+{
+	struct step *step = user_data;
+
+	/*
+	 * TODO: This may call action from next step before callback data
+	 * from previous step was freed.
+	 */
+	verify_step(step, destroy_callback_step);
+
+	return FALSE;
+}
+
+static void schedule_callback_call(struct step *step)
+{
+	g_atomic_int_inc(&scheduled_cbacks_num);
+	g_idle_add(verify_callback, step);
+}
+
+static void adapter_state_changed_cb(bt_state_t state)
+{
+	struct step *step = g_new0(struct step, 1);
+
+	step->callback_result.state = state;
+	step->callback = CB_BT_ADAPTER_STATE_CHANGED;
+
+	schedule_callback_call(step);
+}
+
 static bt_callbacks_t bt_callbacks = {
 	.size = sizeof(bt_callbacks),
-	.adapter_state_changed_cb = NULL,
+	.adapter_state_changed_cb = adapter_state_changed_cb,
 	.adapter_properties_cb = NULL,
 	.remote_device_properties_cb = NULL,
 	.device_found_cb = NULL,
diff --git a/android/tester-main.h b/android/tester-main.h
index d79e4c5..6ea9603 100644
--- a/android/tester-main.h
+++ b/android/tester-main.h
@@ -47,6 +47,26 @@
 
 #define get_test_case_step_num(tc) (sizeof(tc) / sizeof(struct step))
 
+/*
+ * NOTICE:
+ * Callback enum sections should be
+ * updated while adding new HAL to tester.
+ */
+typedef enum {
+	CB_BT_ADAPTER_STATE_CHANGED = 1,
+	CB_BT_ADAPTER_PROPERTIES,
+	CB_BT_REMOTE_DEVICE_PROPERTIES,
+	CB_BT_DEVICE_FOUND,
+	CB_BT_DISCOVERY_STATE_CHANGED,
+	CB_BT_PIN_REQUEST,
+	CB_BT_SSP_REQUEST,
+	CB_BT_BOND_STATE_CHANGED,
+	CB_BT_ACL_STATE_CHANGED,
+	CB_BT_THREAD_EVT,
+	CB_BT_DUT_MODE_RECV,
+	CB_BT_LE_TEST_MODE,
+} expected_bt_callback_t;
+
 struct test_data {
 	struct mgmt *mgmt;
 	struct hw_device_t *device;
@@ -77,12 +97,24 @@ struct bt_action_data {
 };
 
 /*
+ * Callback data structure should be enhanced with data
+ * returned by callbacks. It's used for test case step
+ * matching with expected step data.
+ */
+struct bt_callback_data {
+	bt_state_t state;
+};
+
+/*
  * Step structure contains expected step data and step
  * action, which should be performed before step check.
  */
 struct step {
 	void (*action)(void);
 	struct bt_action_data action_result;
+
+	expected_bt_callback_t callback;
+	struct bt_callback_data callback_result;
 };
 
 /* Get, remove test cases API */
-- 
1.9.3


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

* [PATCH 07/19] android/tester-ng: Add double enable success test case
  2014-07-03 16:00 [PATCH 00/19] Android/tester-ng: New android tester Grzegorz Kolodziejczyk
                   ` (5 preceding siblings ...)
  2014-07-03 16:00 ` [PATCH 06/19] android/tester-ng: Add callback mechanism Grzegorz Kolodziejczyk
@ 2014-07-03 16:00 ` Grzegorz Kolodziejczyk
  2014-07-03 16:00 ` [PATCH 08/19] android/tester-socket: Initial socket tester Grzegorz Kolodziejczyk
                   ` (12 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Grzegorz Kolodziejczyk @ 2014-07-03 16:00 UTC (permalink / raw)
  To: linux-bluetooth

---
 android/tester-bluetooth.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/android/tester-bluetooth.c b/android/tester-bluetooth.c
index d9f26a8..5022da4 100644
--- a/android/tester-bluetooth.c
+++ b/android/tester-bluetooth.c
@@ -46,6 +46,26 @@ static struct test_case bluetooth_enable_success_tc = {
 	.step_num = get_test_case_step_num(bluetooth_enable_success_steps),
 };
 
+static struct step bluetooth_enable_success2_steps[] = {
+	{
+		.action_result.status = BT_STATUS_SUCCESS,
+		.action = bluetooth_enable_action,
+	},
+	{
+		.callback = CB_BT_ADAPTER_STATE_CHANGED,
+		.callback_result.state = BT_STATE_ON,
+	},
+	{
+		.action_result.status = BT_STATUS_SUCCESS,
+		.action = bluetooth_enable_action,
+	},
+};
+static struct test_case bluetooth_enable_success2_tc = {
+	.step = bluetooth_enable_success2_steps,
+	.title = "Bluetooth Enable - Success 2",
+	.step_num = get_test_case_step_num(bluetooth_enable_success2_steps),
+};
+
 struct queue *get_bluetooth_tests(void)
 {
 	list = queue_new();
@@ -56,6 +76,9 @@ struct queue *get_bluetooth_tests(void)
 	if (!queue_push_tail(list, &bluetooth_enable_success_tc))
 		return NULL;
 
+	if (!queue_push_tail(list, &bluetooth_enable_success2_tc))
+		return NULL;
+
 	return list;
 }
 
-- 
1.9.3


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

* [PATCH 08/19] android/tester-socket: Initial socket tester
  2014-07-03 16:00 [PATCH 00/19] Android/tester-ng: New android tester Grzegorz Kolodziejczyk
                   ` (6 preceding siblings ...)
  2014-07-03 16:00 ` [PATCH 07/19] android/tester-ng: Add double enable success test case Grzegorz Kolodziejczyk
@ 2014-07-03 16:00 ` Grzegorz Kolodziejczyk
  2014-07-03 16:00 ` [PATCH 09/19] android/tester-socket: Add initial test case Grzegorz Kolodziejczyk
                   ` (11 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Grzegorz Kolodziejczyk @ 2014-07-03 16:00 UTC (permalink / raw)
  To: linux-bluetooth

This is initial patch for android socket HAL tester. It'll contain test
cases for socket hal.
---
 android/Makefile.am     |  1 +
 android/tester-main.c   | 38 ++++++++++++++++++++++++++++++++++++++
 android/tester-main.h   |  4 ++++
 android/tester-socket.c | 32 ++++++++++++++++++++++++++++++++
 4 files changed, 75 insertions(+)
 create mode 100644 android/tester-socket.c

diff --git a/android/Makefile.am b/android/Makefile.am
index 8cb10ab..e351485 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -179,6 +179,7 @@ android_android_tester_ng_SOURCES = emulator/btdev.h emulator/btdev.c \
 				monitor/rfcomm.h \
 				android/hardware/hardware.c \
 				android/tester-bluetooth.c \
+				android/tester-socket.c \
 				android/tester-main.h android/tester-main.c
 
 android_android_tester_ng_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/android \
diff --git a/android/tester-main.c b/android/tester-main.c
index 326853a..bbf7f2e 100644
--- a/android/tester-main.c
+++ b/android/tester-main.c
@@ -559,6 +559,35 @@ static void setup(const void *test_data)
 	tester_setup_complete();
 }
 
+static void setup_socket(const void *test_data)
+{
+	struct test_data *data = tester_get_data();
+	bt_status_t status;
+	const void *sock;
+
+	if (!setup_base(data)) {
+		tester_setup_failed();
+		return;
+	}
+
+	status = data->if_bluetooth->init(&bt_callbacks);
+	if (status != BT_STATUS_SUCCESS) {
+		data->if_bluetooth = NULL;
+		tester_setup_failed();
+		return;
+	}
+
+	sock = data->if_bluetooth->get_profile_interface(BT_PROFILE_SOCKETS_ID);
+	if (!sock) {
+		tester_setup_failed();
+		return;
+	}
+
+	data->if_sock = sock;
+
+	tester_setup_complete();
+}
+
 static void teardown(const void *test_data)
 {
 	struct test_data *data = tester_get_data();
@@ -644,6 +673,7 @@ static void generic_test_function(const void *test_data)
 static void tester_testcases_cleanup(void)
 {
 	remove_bluetooth_tests();
+	remove_socket_tests();
 }
 
 static void add_bluetooth_tests(void *data, void *user_data)
@@ -653,6 +683,13 @@ static void add_bluetooth_tests(void *data, void *user_data)
 	test_bredrle(tc, setup, generic_test_function, teardown);
 }
 
+static void add_socket_tests(void *data, void *user_data)
+{
+	struct test_case *tc = data;
+
+	test_bredrle(tc, setup_socket, generic_test_function, teardown);
+}
+
 int main(int argc, char *argv[])
 {
 	snprintf(exec_dir, sizeof(exec_dir), "%s", dirname(argv[0]));
@@ -660,6 +697,7 @@ int main(int argc, char *argv[])
 	tester_init(&argc, &argv);
 
 	queue_foreach(get_bluetooth_tests(), add_bluetooth_tests, NULL);
+	queue_foreach(get_socket_tests(), add_socket_tests, NULL);
 
 	if (tester_run())
 		return 1;
diff --git a/android/tester-main.h b/android/tester-main.h
index 6ea9603..37b3fd4 100644
--- a/android/tester-main.h
+++ b/android/tester-main.h
@@ -44,6 +44,7 @@
 
 #include <hardware/hardware.h>
 #include <hardware/bluetooth.h>
+#include <hardware/bt_sock.h>
 
 #define get_test_case_step_num(tc) (sizeof(tc) / sizeof(struct step))
 
@@ -74,6 +75,7 @@ struct test_data {
 	enum hciemu_type hciemu_type;
 
 	const bt_interface_t *if_bluetooth;
+	const btsock_interface_t *if_sock;
 
 	const void *test_data;
 	struct queue *steps;
@@ -120,6 +122,8 @@ struct step {
 /* Get, remove test cases API */
 struct queue *get_bluetooth_tests(void);
 void remove_bluetooth_tests(void);
+struct queue *get_socket_tests(void);
+void remove_socket_tests(void);
 
 /* Actions */
 void dummy_action(void);
diff --git a/android/tester-socket.c b/android/tester-socket.c
new file mode 100644
index 0000000..4b06b15
--- /dev/null
+++ b/android/tester-socket.c
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2014 Intel Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "tester-main.h"
+
+static struct queue *list; /* List of socket test cases */
+
+struct queue *get_socket_tests(void)
+{
+	list = queue_new();
+
+	return list;
+}
+
+void remove_socket_tests(void)
+{
+	queue_destroy(list, NULL);
+}
-- 
1.9.3


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

* [PATCH 09/19] android/tester-socket: Add initial test case
  2014-07-03 16:00 [PATCH 00/19] Android/tester-ng: New android tester Grzegorz Kolodziejczyk
                   ` (7 preceding siblings ...)
  2014-07-03 16:00 ` [PATCH 08/19] android/tester-socket: Initial socket tester Grzegorz Kolodziejczyk
@ 2014-07-03 16:00 ` Grzegorz Kolodziejczyk
  2014-07-03 16:00 ` [PATCH 10/19] android/tester-hidhost: Initial hidhost tester Grzegorz Kolodziejczyk
                   ` (10 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Grzegorz Kolodziejczyk @ 2014-07-03 16:00 UTC (permalink / raw)
  To: linux-bluetooth

This is patch with initial test case testing setup for socket hal test
cases.
---
 android/tester-socket.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/android/tester-socket.c b/android/tester-socket.c
index 4b06b15..8e8b6d2 100644
--- a/android/tester-socket.c
+++ b/android/tester-socket.c
@@ -19,10 +19,24 @@
 
 static struct queue *list; /* List of socket test cases */
 
+static struct step dummy_steps[] = {
+	{
+		.action = dummy_action,
+	},
+};
+static struct test_case socket_init = {
+	.step = dummy_steps,
+	.title = "Socket Init",
+	.step_num = get_test_case_step_num(dummy_steps),
+};
+
 struct queue *get_socket_tests(void)
 {
 	list = queue_new();
 
+	if (!queue_push_tail(list, &socket_init))
+		return NULL;
+
 	return list;
 }
 
-- 
1.9.3


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

* [PATCH 10/19] android/tester-hidhost: Initial hidhost tester
  2014-07-03 16:00 [PATCH 00/19] Android/tester-ng: New android tester Grzegorz Kolodziejczyk
                   ` (8 preceding siblings ...)
  2014-07-03 16:00 ` [PATCH 09/19] android/tester-socket: Add initial test case Grzegorz Kolodziejczyk
@ 2014-07-03 16:00 ` Grzegorz Kolodziejczyk
  2014-07-03 16:00 ` [PATCH 11/19] android/tester-hidhost: Add initial test case Grzegorz Kolodziejczyk
                   ` (9 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Grzegorz Kolodziejczyk @ 2014-07-03 16:00 UTC (permalink / raw)
  To: linux-bluetooth

This is initial patch for android hidhost HAL tester. It'll contain test
cases for hidhost hal.
---
 android/Makefile.am      |  1 +
 android/tester-hidhost.c | 32 ++++++++++++++++++++++++++
 android/tester-main.c    | 59 ++++++++++++++++++++++++++++++++++++++++++++++++
 android/tester-main.h    | 12 ++++++++++
 4 files changed, 104 insertions(+)
 create mode 100644 android/tester-hidhost.c

diff --git a/android/Makefile.am b/android/Makefile.am
index e351485..f98facc 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -180,6 +180,7 @@ android_android_tester_ng_SOURCES = emulator/btdev.h emulator/btdev.c \
 				android/hardware/hardware.c \
 				android/tester-bluetooth.c \
 				android/tester-socket.c \
+				android/tester-hidhost.c \
 				android/tester-main.h android/tester-main.c
 
 android_android_tester_ng_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/android \
diff --git a/android/tester-hidhost.c b/android/tester-hidhost.c
new file mode 100644
index 0000000..1df7e7c
--- /dev/null
+++ b/android/tester-hidhost.c
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2014 Intel Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "tester-main.h"
+
+static struct queue *list; /* List of hidhost test cases */
+
+struct queue *get_hidhost_tests(void)
+{
+	list = queue_new();
+
+	return list;
+}
+
+void remove_hidhost_tests(void)
+{
+	queue_destroy(list, NULL);
+}
diff --git a/android/tester-main.c b/android/tester-main.c
index bbf7f2e..3a30d60 100644
--- a/android/tester-main.c
+++ b/android/tester-main.c
@@ -476,6 +476,16 @@ static bt_callbacks_t bt_callbacks = {
 	.le_test_mode_cb = NULL
 };
 
+static bthh_callbacks_t bthh_callbacks = {
+	.size = sizeof(bthh_callbacks),
+	.connection_state_cb = NULL,
+	.hid_info_cb = NULL,
+	.protocol_mode_cb = NULL,
+	.idle_time_cb = NULL,
+	.get_report_cb = NULL,
+	.virtual_unplug_cb = NULL
+};
+
 static bool setup_base(struct test_data *data)
 {
 	const hw_module_t *module;
@@ -588,6 +598,42 @@ static void setup_socket(const void *test_data)
 	tester_setup_complete();
 }
 
+static void setup_hidhost(const void *test_data)
+{
+	struct test_data *data = tester_get_data();
+	bt_status_t status;
+	const void *hid;
+
+	if (!setup_base(data)) {
+		tester_setup_failed();
+		return;
+	}
+
+	status = data->if_bluetooth->init(&bt_callbacks);
+	if (status != BT_STATUS_SUCCESS) {
+		data->if_bluetooth = NULL;
+		tester_setup_failed();
+		return;
+	}
+
+	hid = data->if_bluetooth->get_profile_interface(BT_PROFILE_HIDHOST_ID);
+	if (!hid) {
+		tester_setup_failed();
+		return;
+	}
+
+	data->if_hid = hid;
+
+	status = data->if_hid->init(&bthh_callbacks);
+	if (status != BT_STATUS_SUCCESS) {
+		data->if_hid = NULL;
+		tester_setup_failed();
+		return;
+	}
+
+	tester_setup_complete();
+}
+
 static void teardown(const void *test_data)
 {
 	struct test_data *data = tester_get_data();
@@ -595,6 +641,11 @@ static void teardown(const void *test_data)
 	queue_destroy(data->steps, NULL);
 	data->steps = NULL;
 
+	if (data->if_hid) {
+		data->if_hid->cleanup();
+		data->if_hid = NULL;
+	}
+
 	if (data->if_bluetooth) {
 		data->if_bluetooth->cleanup();
 		data->if_bluetooth = NULL;
@@ -690,6 +741,13 @@ static void add_socket_tests(void *data, void *user_data)
 	test_bredrle(tc, setup_socket, generic_test_function, teardown);
 }
 
+static void add_hidhost_tests(void *data, void *user_data)
+{
+	struct test_case *tc = data;
+
+	test_bredrle(tc, setup_hidhost, generic_test_function, teardown);
+}
+
 int main(int argc, char *argv[])
 {
 	snprintf(exec_dir, sizeof(exec_dir), "%s", dirname(argv[0]));
@@ -698,6 +756,7 @@ int main(int argc, char *argv[])
 
 	queue_foreach(get_bluetooth_tests(), add_bluetooth_tests, NULL);
 	queue_foreach(get_socket_tests(), add_socket_tests, NULL);
+	queue_foreach(get_hidhost_tests(), add_hidhost_tests, NULL);
 
 	if (tester_run())
 		return 1;
diff --git a/android/tester-main.h b/android/tester-main.h
index 37b3fd4..9ce19ca 100644
--- a/android/tester-main.h
+++ b/android/tester-main.h
@@ -45,6 +45,7 @@
 #include <hardware/hardware.h>
 #include <hardware/bluetooth.h>
 #include <hardware/bt_sock.h>
+#include <hardware/bt_hh.h>
 
 #define get_test_case_step_num(tc) (sizeof(tc) / sizeof(struct step))
 
@@ -66,6 +67,14 @@ typedef enum {
 	CB_BT_THREAD_EVT,
 	CB_BT_DUT_MODE_RECV,
 	CB_BT_LE_TEST_MODE,
+
+	/* Hidhost cb */
+	CB_HH_CONNECTION_STATE,
+	CB_HH_HID_INFO,
+	CB_HH_PROTOCOL_MODE,
+	CB_HH_IDLE_TIME,
+	CB_HH_GET_REPORT,
+	CB_HH_VIRTUAL_UNPLUG,
 } expected_bt_callback_t;
 
 struct test_data {
@@ -76,6 +85,7 @@ struct test_data {
 
 	const bt_interface_t *if_bluetooth;
 	const btsock_interface_t *if_sock;
+	const bthh_interface_t *if_hid;
 
 	const void *test_data;
 	struct queue *steps;
@@ -124,6 +134,8 @@ struct queue *get_bluetooth_tests(void);
 void remove_bluetooth_tests(void);
 struct queue *get_socket_tests(void);
 void remove_socket_tests(void);
+struct queue *get_hidhost_tests(void);
+void remove_hidhost_tests(void);
 
 /* Actions */
 void dummy_action(void);
-- 
1.9.3


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

* [PATCH 11/19] android/tester-hidhost: Add initial test case
  2014-07-03 16:00 [PATCH 00/19] Android/tester-ng: New android tester Grzegorz Kolodziejczyk
                   ` (9 preceding siblings ...)
  2014-07-03 16:00 ` [PATCH 10/19] android/tester-hidhost: Initial hidhost tester Grzegorz Kolodziejczyk
@ 2014-07-03 16:00 ` Grzegorz Kolodziejczyk
  2014-07-03 16:00 ` [PATCH 12/19] android/tester-gatt: Initial gatt tester Grzegorz Kolodziejczyk
                   ` (8 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Grzegorz Kolodziejczyk @ 2014-07-03 16:00 UTC (permalink / raw)
  To: linux-bluetooth

---
 android/tester-hidhost.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/android/tester-hidhost.c b/android/tester-hidhost.c
index 1df7e7c..87c9452 100644
--- a/android/tester-hidhost.c
+++ b/android/tester-hidhost.c
@@ -19,10 +19,24 @@
 
 static struct queue *list; /* List of hidhost test cases */
 
+static struct step dummy_steps[] = {
+	{
+		.action = dummy_action,
+	},
+};
+static struct test_case hidhost_init = {
+	.step = dummy_steps,
+	.title = "Hidhost Init",
+	.step_num = get_test_case_step_num(dummy_steps),
+};
+
 struct queue *get_hidhost_tests(void)
 {
 	list = queue_new();
 
+	if (!queue_push_tail(list, &hidhost_init))
+		return NULL;
+
 	return list;
 }
 
-- 
1.9.3


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

* [PATCH 12/19] android/tester-gatt: Initial gatt tester
  2014-07-03 16:00 [PATCH 00/19] Android/tester-ng: New android tester Grzegorz Kolodziejczyk
                   ` (10 preceding siblings ...)
  2014-07-03 16:00 ` [PATCH 11/19] android/tester-hidhost: Add initial test case Grzegorz Kolodziejczyk
@ 2014-07-03 16:00 ` Grzegorz Kolodziejczyk
  2014-07-03 16:00 ` [PATCH 13/19] android/tester-gatt: Add initial test case Grzegorz Kolodziejczyk
                   ` (7 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Grzegorz Kolodziejczyk @ 2014-07-03 16:00 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Jakub Tyszkowski

From: Jakub Tyszkowski <jakub.tyszkowski@tieto.com>

This is initial patch for android gatt HAL tester. It'll contain test
cases for gatt hal.
---
 android/Makefile.am   |  1 +
 android/tester-gatt.c | 32 ++++++++++++++++++
 android/tester-main.c | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++
 android/tester-main.h | 41 +++++++++++++++++++++++
 4 files changed, 167 insertions(+)
 create mode 100644 android/tester-gatt.c

diff --git a/android/Makefile.am b/android/Makefile.am
index f98facc..8b2ec5b 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -181,6 +181,7 @@ android_android_tester_ng_SOURCES = emulator/btdev.h emulator/btdev.c \
 				android/tester-bluetooth.c \
 				android/tester-socket.c \
 				android/tester-hidhost.c \
+				android/tester-gatt.c \
 				android/tester-main.h android/tester-main.c
 
 android_android_tester_ng_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/android \
diff --git a/android/tester-gatt.c b/android/tester-gatt.c
new file mode 100644
index 0000000..b16a844
--- /dev/null
+++ b/android/tester-gatt.c
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2014 Intel Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "tester-main.h"
+
+static struct queue *list; /* List of gatt test cases */
+
+struct queue *get_gatt_tests(void)
+{
+	list = queue_new();
+
+	return list;
+}
+
+void remove_gatt_tests(void)
+{
+	queue_destroy(list, NULL);
+}
diff --git a/android/tester-main.c b/android/tester-main.c
index 3a30d60..6a20eb8 100644
--- a/android/tester-main.c
+++ b/android/tester-main.c
@@ -486,6 +486,49 @@ static bthh_callbacks_t bthh_callbacks = {
 	.virtual_unplug_cb = NULL
 };
 
+static const btgatt_client_callbacks_t btgatt_client_callbacks = {
+	.register_client_cb = NULL,
+	.scan_result_cb = NULL,
+	.open_cb = NULL,
+	.close_cb = NULL,
+	.search_complete_cb = NULL,
+	.search_result_cb = NULL,
+	.get_characteristic_cb = NULL,
+	.get_descriptor_cb = NULL,
+	.get_included_service_cb = NULL,
+	.register_for_notification_cb = NULL,
+	.notify_cb = NULL,
+	.read_characteristic_cb = NULL,
+	.write_characteristic_cb = NULL,
+	.read_descriptor_cb = NULL,
+	.write_descriptor_cb = NULL,
+	.execute_write_cb = NULL,
+	.read_remote_rssi_cb = NULL,
+	.listen_cb = NULL
+};
+
+static const btgatt_server_callbacks_t btgatt_server_callbacks = {
+	.register_server_cb = NULL,
+	.connection_cb = NULL,
+	.service_added_cb = NULL,
+	.included_service_added_cb = NULL,
+	.characteristic_added_cb = NULL,
+	.descriptor_added_cb = NULL,
+	.service_started_cb = NULL,
+	.service_stopped_cb = NULL,
+	.service_deleted_cb = NULL,
+	.request_read_cb = NULL,
+	.request_write_cb = NULL,
+	.request_exec_write_cb = NULL,
+	.response_confirmation_cb = NULL
+};
+
+static const btgatt_callbacks_t btgatt_callbacks = {
+	.size = sizeof(btgatt_callbacks),
+	.client = &btgatt_client_callbacks,
+	.server = &btgatt_server_callbacks
+};
+
 static bool setup_base(struct test_data *data)
 {
 	const hw_module_t *module;
@@ -634,6 +677,43 @@ static void setup_hidhost(const void *test_data)
 	tester_setup_complete();
 }
 
+static void setup_gatt(const void *test_data)
+{
+	struct test_data *data = tester_get_data();
+	bt_status_t status;
+	const void *gatt;
+
+	if (!setup_base(data)) {
+		tester_setup_failed();
+		return;
+	}
+
+	status = data->if_bluetooth->init(&bt_callbacks);
+	if (status != BT_STATUS_SUCCESS) {
+		data->if_bluetooth = NULL;
+		tester_setup_failed();
+		return;
+	}
+
+	gatt = data->if_bluetooth->get_profile_interface(BT_PROFILE_GATT_ID);
+	if (!gatt) {
+		tester_setup_failed();
+		return;
+	}
+
+	data->if_gatt = gatt;
+
+	status = data->if_gatt->init(&btgatt_callbacks);
+	if (status != BT_STATUS_SUCCESS) {
+		data->if_gatt = NULL;
+
+		tester_setup_failed();
+		return;
+	}
+
+	tester_setup_complete();
+}
+
 static void teardown(const void *test_data)
 {
 	struct test_data *data = tester_get_data();
@@ -641,6 +721,11 @@ static void teardown(const void *test_data)
 	queue_destroy(data->steps, NULL);
 	data->steps = NULL;
 
+	if (data->if_gatt) {
+		data->if_gatt->cleanup();
+		data->if_gatt = NULL;
+	}
+
 	if (data->if_hid) {
 		data->if_hid->cleanup();
 		data->if_hid = NULL;
@@ -748,6 +833,13 @@ static void add_hidhost_tests(void *data, void *user_data)
 	test_bredrle(tc, setup_hidhost, generic_test_function, teardown);
 }
 
+static void add_gatt_tests(void *data, void *user_data)
+{
+	struct test_case *tc = data;
+
+	test_bredrle(tc, setup_gatt, generic_test_function, teardown);
+}
+
 int main(int argc, char *argv[])
 {
 	snprintf(exec_dir, sizeof(exec_dir), "%s", dirname(argv[0]));
@@ -757,6 +849,7 @@ int main(int argc, char *argv[])
 	queue_foreach(get_bluetooth_tests(), add_bluetooth_tests, NULL);
 	queue_foreach(get_socket_tests(), add_socket_tests, NULL);
 	queue_foreach(get_hidhost_tests(), add_hidhost_tests, NULL);
+	queue_foreach(get_gatt_tests(), add_gatt_tests, NULL);
 
 	if (tester_run())
 		return 1;
diff --git a/android/tester-main.h b/android/tester-main.h
index 9ce19ca..2157d8a 100644
--- a/android/tester-main.h
+++ b/android/tester-main.h
@@ -46,6 +46,9 @@
 #include <hardware/bluetooth.h>
 #include <hardware/bt_sock.h>
 #include <hardware/bt_hh.h>
+#include <hardware/bt_gatt.h>
+#include <hardware/bt_gatt_client.h>
+#include <hardware/bt_gatt_server.h>
 
 #define get_test_case_step_num(tc) (sizeof(tc) / sizeof(struct step))
 
@@ -75,6 +78,41 @@ typedef enum {
 	CB_HH_IDLE_TIME,
 	CB_HH_GET_REPORT,
 	CB_HH_VIRTUAL_UNPLUG,
+
+	/* Gatt client */
+	CB_GATTC_REGISTER_CLIENT,
+	CB_GATTC_SCAN_RESULT,
+	CB_GATTC_OPEN,
+	CB_GATTC_CLOSE,
+	CB_GATTC_SEARCH_COMPLETE,
+	CB_GATTC_SEARCH_RESULT,
+	CB_GATTC_GET_CHARACTERISTIC,
+	CB_GATTC_GET_DESCRIPTOR,
+	CB_GATTC_GET_INCLUDED_SERVICE,
+	CB_GATTC_REGISTER_FOR_NOTIFICATION,
+	CB_GATTC_NOTIFY,
+	CB_GATTC_READ_CHARACTERISTIC,
+	CB_GATTC_WRITE_CHARACTERISTIC,
+	CB_GATTC_READ_DESCRIPTOR,
+	CB_GATTC_WRITE_DESCRIPTOR,
+	CB_GATTC_EXECUTE_WRITE,
+	CB_GATTC_READ_REMOTE_RSSI,
+	CB_GATTC_LISTEN,
+
+	/* Gatt server */
+	CB_GATTS_REGISTER_SERVER,
+	CB_GATTS_CONNECTION,
+	CB_GATTS_SERVICE_ADDED,
+	CB_GATTS_INCLUDED_SERVICE_ADDED,
+	CB_GATTS_CHARACTERISTIC_ADDED,
+	CB_GATTS_DESCRIPTOR_ADDED,
+	CB_GATTS_SERVICE_STARTED,
+	CB_GATTS_SERVICE_STOPPED,
+	CB_GATTS_SERVICE_DELETED,
+	CB_GATTS_REQUEST_READ,
+	CB_GATTS_REQUEST_WRITE,
+	CB_GATTS_REQUEST_EXEC_WRITE,
+	CB_GATTS_RESPONSE_CONFIRMATION,
 } expected_bt_callback_t;
 
 struct test_data {
@@ -86,6 +124,7 @@ struct test_data {
 	const bt_interface_t *if_bluetooth;
 	const btsock_interface_t *if_sock;
 	const bthh_interface_t *if_hid;
+	const btgatt_interface_t *if_gatt;
 
 	const void *test_data;
 	struct queue *steps;
@@ -136,6 +175,8 @@ struct queue *get_socket_tests(void);
 void remove_socket_tests(void);
 struct queue *get_hidhost_tests(void);
 void remove_hidhost_tests(void);
+struct queue *get_gatt_tests(void);
+void remove_gatt_tests(void);
 
 /* Actions */
 void dummy_action(void);
-- 
1.9.3


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

* [PATCH 13/19] android/tester-gatt: Add initial test case
  2014-07-03 16:00 [PATCH 00/19] Android/tester-ng: New android tester Grzegorz Kolodziejczyk
                   ` (11 preceding siblings ...)
  2014-07-03 16:00 ` [PATCH 12/19] android/tester-gatt: Initial gatt tester Grzegorz Kolodziejczyk
@ 2014-07-03 16:00 ` Grzegorz Kolodziejczyk
  2014-07-03 16:00 ` [PATCH 14/19] android/tester-ng: Add property check handling Grzegorz Kolodziejczyk
                   ` (6 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Grzegorz Kolodziejczyk @ 2014-07-03 16:00 UTC (permalink / raw)
  To: linux-bluetooth

---
 android/tester-gatt.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/android/tester-gatt.c b/android/tester-gatt.c
index b16a844..b58886f 100644
--- a/android/tester-gatt.c
+++ b/android/tester-gatt.c
@@ -19,10 +19,24 @@
 
 static struct queue *list; /* List of gatt test cases */
 
+static struct step dummy_steps[] = {
+	{
+		.action = dummy_action,
+	},
+};
+static struct test_case gatt_init = {
+	.step = dummy_steps,
+	.title = "Socket Init",
+	.step_num = get_test_case_step_num(dummy_steps),
+};
+
 struct queue *get_gatt_tests(void)
 {
 	list = queue_new();
 
+	if (!queue_push_tail(list, &gatt_init))
+		return NULL;
+
 	return list;
 }
 
-- 
1.9.3


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

* [PATCH 14/19] android/tester-ng: Add property check handling
  2014-07-03 16:00 [PATCH 00/19] Android/tester-ng: New android tester Grzegorz Kolodziejczyk
                   ` (12 preceding siblings ...)
  2014-07-03 16:00 ` [PATCH 13/19] android/tester-gatt: Add initial test case Grzegorz Kolodziejczyk
@ 2014-07-03 16:00 ` Grzegorz Kolodziejczyk
  2014-07-03 16:00 ` [PATCH 15/19] android/tester-bluetooth: Add disable success test case Grzegorz Kolodziejczyk
                   ` (5 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Grzegorz Kolodziejczyk @ 2014-07-03 16:00 UTC (permalink / raw)
  To: linux-bluetooth

This adds property check handling. Existing test cases (enable, enable
done) are updated with property check. If property type/len/val is not
expected in test step its value should be set to 0/NULL. Order of
property is not considered while checking.
---
 android/tester-bluetooth.c |  42 +++++++++++++++++
 android/tester-main.c      | 110 ++++++++++++++++++++++++++++++++++++++++++++-
 android/tester-main.h      |   3 ++
 3 files changed, 154 insertions(+), 1 deletion(-)

diff --git a/android/tester-bluetooth.c b/android/tester-bluetooth.c
index 5022da4..e89011f 100644
--- a/android/tester-bluetooth.c
+++ b/android/tester-bluetooth.c
@@ -30,12 +30,49 @@ static struct test_case bluetooth_init = {
 	.step_num = get_test_case_step_num(dummy_steps),
 };
 
+static bt_bdaddr_t enable_bdaddr_val = {
+	.address = { 0x00, 0xaa, 0x01, 0x00, 0x00, 0x00 },
+};
+static const char enable_bdname_val[] = "BlueZ for Android";
+static const char enable_uuids_val[] = {
+	/* Multi profile UUID */
+	0x00, 0x00, 0x11, 0x3b, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00,
+					0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB,
+	/* Device identification profile UUID */
+	0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00,
+					0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB,
+};
+static bt_device_type_t enable_tod_val = BT_DEVICE_DEVTYPE_DUAL;
+static bt_scan_mode_t enable_scanmode_val = BT_SCAN_MODE_NONE;
+static uint32_t enable_disctimeout_val = 120;
+
+static bt_property_t enable_props[] = {
+	{ BT_PROPERTY_BDADDR, sizeof(enable_bdaddr_val), NULL },
+	{ BT_PROPERTY_BDNAME, sizeof(enable_bdname_val) - 1,
+						&enable_bdname_val },
+	{ BT_PROPERTY_CLASS_OF_DEVICE, sizeof(uint32_t), NULL },
+	{ BT_PROPERTY_TYPE_OF_DEVICE, sizeof(enable_tod_val),
+						&enable_tod_val },
+	{ BT_PROPERTY_ADAPTER_SCAN_MODE, sizeof(enable_scanmode_val),
+						&enable_scanmode_val },
+	{ BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT,
+						sizeof(enable_disctimeout_val),
+						&enable_disctimeout_val },
+	{ BT_PROPERTY_ADAPTER_BONDED_DEVICES, 0, NULL },
+	{ BT_PROPERTY_UUIDS, sizeof(enable_uuids_val), &enable_uuids_val },
+};
+
 static struct step bluetooth_enable_success_steps[] = {
 	{
 		.action_result.status = BT_STATUS_SUCCESS,
 		.action = bluetooth_enable_action,
 	},
 	{
+		.callback = CB_BT_ADAPTER_PROPERTIES,
+		.callback_result.properties = enable_props,
+		.callback_result.num_properties = 8,
+	},
+	{
 		.callback = CB_BT_ADAPTER_STATE_CHANGED,
 		.callback_result.state = BT_STATE_ON,
 	},
@@ -52,6 +89,11 @@ static struct step bluetooth_enable_success2_steps[] = {
 		.action = bluetooth_enable_action,
 	},
 	{
+		.callback = CB_BT_ADAPTER_PROPERTIES,
+		.callback_result.properties = enable_props,
+		.callback_result.num_properties = 8,
+	},
+	{
 		.callback = CB_BT_ADAPTER_STATE_CHANGED,
 		.callback_result.state = BT_STATE_ON,
 	},
diff --git a/android/tester-main.c b/android/tester-main.c
index 6a20eb8..4a81b3c 100644
--- a/android/tester-main.c
+++ b/android/tester-main.c
@@ -338,6 +338,47 @@ static void test_pre_setup(const void *test_data)
 				NULL, read_index_list_callback, NULL, NULL);
 }
 
+static bool match_property(bt_property_t *exp_prop, bt_property_t *rec_prop,
+								int prop_num)
+{
+	if (exp_prop->type && (exp_prop->type != rec_prop->type))
+		return 0;
+
+	if (exp_prop->len && (exp_prop->len != rec_prop->len)) {
+		tester_debug("Property [%d] len don't match! received=%d, "
+					"expected=%d", prop_num, rec_prop->len,
+					exp_prop->len);
+		return 0;
+	}
+
+	if (exp_prop->val && memcmp(exp_prop->val, rec_prop->val,
+							exp_prop->len)) {
+		tester_debug("Property [%d] value don't match!", prop_num);
+		return 0;
+	}
+
+	return 1;
+}
+
+static int verify_property(bt_property_t *exp_props, int exp_num_props,
+				bt_property_t *rec_props, int rec_num_props)
+{
+	int i, j;
+	int exp_prop_to_find = exp_num_props;
+
+	/* Get first exp prop to match and search for it */
+	for (i = 0; i < exp_num_props; i++) {
+		for (j = 0; j < rec_num_props; j++) {
+			if (match_property(&exp_props[i], &rec_props[j], i)) {
+				exp_prop_to_find--;
+				break;
+			}
+		}
+	}
+
+	return exp_prop_to_find;
+}
+
 /*
  * Check each test case step if test case expected
  * data is set and match it with expected result.
@@ -360,6 +401,29 @@ static bool match_data(struct step *step)
 		tester_debug("Action status don't match");
 		return false;
 	}
+
+	if (exp->callback) {
+		if (exp->callback != step->callback) {
+			tester_debug("Callback type don't match");
+			return false;
+		}
+
+		if (exp->callback_result.state !=
+						step->callback_result.state) {
+			tester_debug("Callback state don't match");
+			return false;
+		}
+
+		if (exp->callback_result.properties &&
+				verify_property(exp->callback_result.properties,
+				exp->callback_result.num_properties,
+				step->callback_result.properties,
+				step->callback_result.num_properties)) {
+			tester_debug("Gatt properties don't match");
+			return false;
+		}
+	}
+
 	return true;
 }
 
@@ -423,10 +487,25 @@ static void verify_step(struct step *step, queue_destroy_func_t cleanup_cb)
  * step verification could pass and move to next test step
  */
 
+static void free_properties(struct step *step)
+{
+	bt_property_t *properties = step->callback_result.properties;
+	int num_properties = step->callback_result.num_properties;
+	int i;
+
+	for (i = 0; i < num_properties; i++)
+		g_free(properties[i].val);
+
+	g_free(properties);
+}
+
 static void destroy_callback_step(void *data)
 {
 	struct step *step = data;
 
+	if (step->callback_result.properties)
+		free_properties(step);
+
 	g_free(step);
 	g_atomic_int_dec_and_test(&scheduled_cbacks_num);
 }
@@ -460,10 +539,39 @@ static void adapter_state_changed_cb(bt_state_t state)
 	schedule_callback_call(step);
 }
 
+static bt_property_t *copy_properties(int num_properties,
+						bt_property_t *properties)
+{
+	int i;
+	bt_property_t *props = g_new0(bt_property_t, num_properties);
+
+	for (i = 0; i < num_properties; i++) {
+		props[i].type = properties[i].type;
+		props[i].len = properties[i].len;
+		props[i].val = g_memdup(properties[i].val, properties[i].len);
+	}
+
+	return props;
+}
+
+static void adapter_properties_cb(bt_status_t status, int num_properties,
+						bt_property_t *properties)
+{
+	struct step *step = g_new0(struct step, 1);
+
+	step->callback_result.status = status;
+	step->callback_result.num_properties = num_properties;
+	step->callback_result.properties = copy_properties(num_properties,
+								properties);
+	step->callback = CB_BT_ADAPTER_PROPERTIES;
+
+	schedule_callback_call(step);
+}
+
 static bt_callbacks_t bt_callbacks = {
 	.size = sizeof(bt_callbacks),
 	.adapter_state_changed_cb = adapter_state_changed_cb,
-	.adapter_properties_cb = NULL,
+	.adapter_properties_cb = adapter_properties_cb,
 	.remote_device_properties_cb = NULL,
 	.device_found_cb = NULL,
 	.discovery_state_changed_cb = NULL,
diff --git a/android/tester-main.h b/android/tester-main.h
index 2157d8a..aaeada7 100644
--- a/android/tester-main.h
+++ b/android/tester-main.h
@@ -154,6 +154,9 @@ struct bt_action_data {
  */
 struct bt_callback_data {
 	bt_state_t state;
+	bt_status_t status;
+	int num_properties;
+	bt_property_t *properties;
 };
 
 /*
-- 
1.9.3


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

* [PATCH 15/19] android/tester-bluetooth: Add disable success test case
  2014-07-03 16:00 [PATCH 00/19] Android/tester-ng: New android tester Grzegorz Kolodziejczyk
                   ` (13 preceding siblings ...)
  2014-07-03 16:00 ` [PATCH 14/19] android/tester-ng: Add property check handling Grzegorz Kolodziejczyk
@ 2014-07-03 16:00 ` Grzegorz Kolodziejczyk
  2014-07-03 16:00 ` [PATCH 16/19] android/tester-bluetooth: Add bdname set success tc Grzegorz Kolodziejczyk
                   ` (4 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Grzegorz Kolodziejczyk @ 2014-07-03 16:00 UTC (permalink / raw)
  To: linux-bluetooth

This also adds disable action.
---
 android/tester-bluetooth.c | 27 +++++++++++++++++++++++++++
 android/tester-main.c      | 11 +++++++++++
 android/tester-main.h      |  1 +
 3 files changed, 39 insertions(+)

diff --git a/android/tester-bluetooth.c b/android/tester-bluetooth.c
index e89011f..8289b85 100644
--- a/android/tester-bluetooth.c
+++ b/android/tester-bluetooth.c
@@ -108,6 +108,30 @@ static struct test_case bluetooth_enable_success2_tc = {
 	.step_num = get_test_case_step_num(bluetooth_enable_success2_steps),
 };
 
+static struct step bluetooth_disable_success_steps[] = {
+	{
+		.action_result.status = BT_STATUS_SUCCESS,
+		.action = bluetooth_enable_action,
+	},
+	{
+		.callback = CB_BT_ADAPTER_STATE_CHANGED,
+		.callback_result.state = BT_STATE_ON,
+	},
+	{
+		.action_result.status = BT_STATUS_SUCCESS,
+		.action = bluetooth_disable_action,
+	},
+	{
+		.callback = CB_BT_ADAPTER_STATE_CHANGED,
+		.callback_result.state = BT_STATE_OFF,
+	},
+};
+static struct test_case bluetooth_disable_success_tc = {
+	.step = bluetooth_disable_success_steps,
+	.title = "Bluetooth Disable - Success",
+	.step_num = get_test_case_step_num(bluetooth_disable_success_steps),
+};
+
 struct queue *get_bluetooth_tests(void)
 {
 	list = queue_new();
@@ -121,6 +145,9 @@ struct queue *get_bluetooth_tests(void)
 	if (!queue_push_tail(list, &bluetooth_enable_success2_tc))
 		return NULL;
 
+	if (!queue_push_tail(list, &bluetooth_disable_success_tc))
+		return NULL;
+
 	return list;
 }
 
diff --git a/android/tester-main.c b/android/tester-main.c
index 4a81b3c..c8a399d 100644
--- a/android/tester-main.c
+++ b/android/tester-main.c
@@ -871,6 +871,17 @@ void bluetooth_enable_action(void)
 	verify_step(&step, NULL);
 }
 
+void bluetooth_disable_action(void)
+{
+	struct test_data *data = tester_get_data();
+	struct step step;
+
+	memset(&step, 0, sizeof(step));
+	step.action_result.status = data->if_bluetooth->disable();
+
+	verify_step(&step, NULL);
+}
+
 static void generic_test_function(const void *test_data)
 {
 	struct test_data *data = tester_get_data();
diff --git a/android/tester-main.h b/android/tester-main.h
index aaeada7..be28b55 100644
--- a/android/tester-main.h
+++ b/android/tester-main.h
@@ -184,3 +184,4 @@ void remove_gatt_tests(void);
 /* Actions */
 void dummy_action(void);
 void bluetooth_enable_action(void);
+void bluetooth_disable_action(void);
-- 
1.9.3


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

* [PATCH 16/19] android/tester-bluetooth: Add bdname set success tc
  2014-07-03 16:00 [PATCH 00/19] Android/tester-ng: New android tester Grzegorz Kolodziejczyk
                   ` (14 preceding siblings ...)
  2014-07-03 16:00 ` [PATCH 15/19] android/tester-bluetooth: Add disable success test case Grzegorz Kolodziejczyk
@ 2014-07-03 16:00 ` Grzegorz Kolodziejczyk
  2014-07-03 16:00 ` [PATCH 17/19] Android/tester-bluetooth: Add scan_mode " Grzegorz Kolodziejczyk
                   ` (3 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Grzegorz Kolodziejczyk @ 2014-07-03 16:00 UTC (permalink / raw)
  To: linux-bluetooth

This adds handling of property check and bdname set property success
test case. Android tester framework is enhanced by set bd name action.
Test data is enchanced by user step data which can be used inside test
case step.
---
 android/tester-bluetooth.c | 37 +++++++++++++++++++++++++++++++++++++
 android/tester-main.c      | 22 ++++++++++++++++++++++
 android/tester-main.h      |  4 ++++
 3 files changed, 63 insertions(+)

diff --git a/android/tester-bluetooth.c b/android/tester-bluetooth.c
index 8289b85..f071910 100644
--- a/android/tester-bluetooth.c
+++ b/android/tester-bluetooth.c
@@ -132,6 +132,40 @@ static struct test_case bluetooth_disable_success_tc = {
 	.step_num = get_test_case_step_num(bluetooth_disable_success_steps),
 };
 
+static char test_set_bdname[] = "test_bdname_set";
+
+static bt_property_t setprop_bdname_prop = {
+	.type = BT_PROPERTY_BDNAME,
+	.val = test_set_bdname,
+	.len = sizeof(test_set_bdname) - 1,
+};
+
+static struct step bluetooth_setprop_bdname_success_steps[] = {
+	{
+		.action_result.status = BT_STATUS_SUCCESS,
+		.action = bluetooth_enable_action,
+	},
+	{
+		.callback = CB_BT_ADAPTER_STATE_CHANGED,
+		.callback_result.state = BT_STATE_ON,
+	},
+	{
+		.action_result.status = BT_STATUS_SUCCESS,
+		.set_data = &setprop_bdname_prop,
+		.action = bt_set_property_action,
+	},
+	{
+		.callback = CB_BT_ADAPTER_PROPERTIES,
+		.callback_result.properties = &setprop_bdname_prop,
+	}
+};
+static struct test_case bluetooth_setprop_bdname_success_tc = {
+	.step = bluetooth_setprop_bdname_success_steps,
+	.title = "Bluetooth Set BDNAME - Success",
+	.step_num =
+		get_test_case_step_num(bluetooth_setprop_bdname_success_steps),
+};
+
 struct queue *get_bluetooth_tests(void)
 {
 	list = queue_new();
@@ -148,6 +182,9 @@ struct queue *get_bluetooth_tests(void)
 	if (!queue_push_tail(list, &bluetooth_disable_success_tc))
 		return NULL;
 
+	if (!queue_push_tail(list, &bluetooth_setprop_bdname_success_tc))
+		return NULL;
+
 	return list;
 }
 
diff --git a/android/tester-main.c b/android/tester-main.c
index c8a399d..8a1f6ed 100644
--- a/android/tester-main.c
+++ b/android/tester-main.c
@@ -882,6 +882,28 @@ void bluetooth_disable_action(void)
 	verify_step(&step, NULL);
 }
 
+void bt_set_property_action(void)
+{
+	struct test_data *data = tester_get_data();
+	struct step step;
+	struct step *current_data_step = queue_peek_head(data->steps);
+	bt_property_t *prop;
+
+	if (!current_data_step->set_data) {
+		tester_debug("BT property not set for step");
+		tester_test_failed();
+		return;
+	}
+
+	prop = (bt_property_t *)current_data_step->set_data;
+
+	memset(&step, 0, sizeof(step));
+	step.action_result.status = data->if_bluetooth->set_adapter_property(
+									prop);
+
+	verify_step(&step, NULL);
+}
+
 static void generic_test_function(const void *test_data)
 {
 	struct test_data *data = tester_get_data();
diff --git a/android/tester-main.h b/android/tester-main.h
index be28b55..a740f6b 100644
--- a/android/tester-main.h
+++ b/android/tester-main.h
@@ -169,6 +169,9 @@ struct step {
 
 	expected_bt_callback_t callback;
 	struct bt_callback_data callback_result;
+
+	void *set_data;
+	int set_data_len;
 };
 
 /* Get, remove test cases API */
@@ -185,3 +188,4 @@ void remove_gatt_tests(void);
 void dummy_action(void);
 void bluetooth_enable_action(void);
 void bluetooth_disable_action(void);
+void bt_set_property_action(void);
-- 
1.9.3


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

* [PATCH 17/19] Android/tester-bluetooth: Add scan_mode set success tc
  2014-07-03 16:00 [PATCH 00/19] Android/tester-ng: New android tester Grzegorz Kolodziejczyk
                   ` (15 preceding siblings ...)
  2014-07-03 16:00 ` [PATCH 16/19] android/tester-bluetooth: Add bdname set success tc Grzegorz Kolodziejczyk
@ 2014-07-03 16:00 ` Grzegorz Kolodziejczyk
  2014-07-03 16:00 ` [PATCH 18/19] Android/tester-bluetooth: Add disc_timeout " Grzegorz Kolodziejczyk
                   ` (2 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Grzegorz Kolodziejczyk @ 2014-07-03 16:00 UTC (permalink / raw)
  To: linux-bluetooth

This adds scan_mode set property success test case.
---
 android/tester-bluetooth.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/android/tester-bluetooth.c b/android/tester-bluetooth.c
index f071910..bff6ea9 100644
--- a/android/tester-bluetooth.c
+++ b/android/tester-bluetooth.c
@@ -166,6 +166,41 @@ static struct test_case bluetooth_setprop_bdname_success_tc = {
 		get_test_case_step_num(bluetooth_setprop_bdname_success_steps),
 };
 
+static bt_scan_mode_t test_setprop_scanmode_val =
+					BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE;
+
+static bt_property_t setprop_scanmode_prop = {
+	.type = BT_PROPERTY_ADAPTER_SCAN_MODE,
+	.val = &test_setprop_scanmode_val,
+	.len = sizeof(bt_scan_mode_t),
+};
+
+static struct step bluetooth_setprop_scanmode_success_steps[] = {
+	{
+		.action_result.status = BT_STATUS_SUCCESS,
+		.action = bluetooth_enable_action,
+	},
+	{
+		.callback = CB_BT_ADAPTER_STATE_CHANGED,
+		.callback_result.state = BT_STATE_ON,
+	},
+	{
+		.action_result.status = BT_STATUS_SUCCESS,
+		.set_data = &setprop_scanmode_prop,
+		.action = bt_set_property_action,
+	},
+	{
+		.callback = CB_BT_ADAPTER_PROPERTIES,
+		.callback_result.properties = &setprop_scanmode_prop,
+	},
+};
+static struct test_case bluetooth_setprop_scanmode_success_tc = {
+	.step = bluetooth_setprop_scanmode_success_steps,
+	.title = "Bluetooth Set SCAN_MODE - Success",
+	.step_num = get_test_case_step_num(
+				bluetooth_setprop_scanmode_success_steps),
+};
+
 struct queue *get_bluetooth_tests(void)
 {
 	list = queue_new();
@@ -185,6 +220,9 @@ struct queue *get_bluetooth_tests(void)
 	if (!queue_push_tail(list, &bluetooth_setprop_bdname_success_tc))
 		return NULL;
 
+	if (!queue_push_tail(list, &bluetooth_setprop_scanmode_success_tc))
+		return NULL;
+
 	return list;
 }
 
-- 
1.9.3


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

* [PATCH 18/19] Android/tester-bluetooth: Add disc_timeout set success tc
  2014-07-03 16:00 [PATCH 00/19] Android/tester-ng: New android tester Grzegorz Kolodziejczyk
                   ` (16 preceding siblings ...)
  2014-07-03 16:00 ` [PATCH 17/19] Android/tester-bluetooth: Add scan_mode " Grzegorz Kolodziejczyk
@ 2014-07-03 16:00 ` Grzegorz Kolodziejczyk
  2014-07-03 16:00 ` [PATCH 19/19] android/android-tester: Remove test cases replaced by tester-ng Grzegorz Kolodziejczyk
  2014-07-14 15:02 ` [PATCH 00/19] Android/tester-ng: New android tester Szymon Janc
  19 siblings, 0 replies; 21+ messages in thread
From: Grzegorz Kolodziejczyk @ 2014-07-03 16:00 UTC (permalink / raw)
  To: linux-bluetooth

This adds discovery timeout set property success test case.
---
 android/tester-bluetooth.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/android/tester-bluetooth.c b/android/tester-bluetooth.c
index bff6ea9..56518ea 100644
--- a/android/tester-bluetooth.c
+++ b/android/tester-bluetooth.c
@@ -201,6 +201,40 @@ static struct test_case bluetooth_setprop_scanmode_success_tc = {
 				bluetooth_setprop_scanmode_success_steps),
 };
 
+static uint32_t test_setprop_disctimeout_val = 600;
+
+static bt_property_t setprop_disctimeout_prop = {
+	.type = BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT,
+	.val = &test_setprop_disctimeout_val,
+	.len = sizeof(test_setprop_disctimeout_val),
+};
+
+static struct step bluetooth_setprop_disctimeout_success_steps[] = {
+	{
+		.action_result.status = BT_STATUS_SUCCESS,
+		.action = bluetooth_enable_action,
+	},
+	{
+		.callback = CB_BT_ADAPTER_STATE_CHANGED,
+		.callback_result.state = BT_STATE_ON,
+	},
+	{
+		.action_result.status = BT_STATUS_SUCCESS,
+		.set_data = &setprop_disctimeout_prop,
+		.action = bt_set_property_action,
+	},
+	{
+		.callback = CB_BT_ADAPTER_PROPERTIES,
+		.callback_result.properties = NULL,
+	},
+};
+static struct test_case bluetooth_setprop_disctimeout_success_tc = {
+	.step = bluetooth_setprop_disctimeout_success_steps,
+	.title = "Bluetooth Set DISCOVERY_TIMEOUT - Success",
+	.step_num = get_test_case_step_num(
+				bluetooth_setprop_disctimeout_success_steps),
+};
+
 struct queue *get_bluetooth_tests(void)
 {
 	list = queue_new();
@@ -223,6 +257,9 @@ struct queue *get_bluetooth_tests(void)
 	if (!queue_push_tail(list, &bluetooth_setprop_scanmode_success_tc))
 		return NULL;
 
+	if (!queue_push_tail(list, &bluetooth_setprop_disctimeout_success_tc))
+		return NULL;
+
 	return list;
 }
 
-- 
1.9.3


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

* [PATCH 19/19] android/android-tester: Remove test cases replaced by tester-ng
  2014-07-03 16:00 [PATCH 00/19] Android/tester-ng: New android tester Grzegorz Kolodziejczyk
                   ` (17 preceding siblings ...)
  2014-07-03 16:00 ` [PATCH 18/19] Android/tester-bluetooth: Add disc_timeout " Grzegorz Kolodziejczyk
@ 2014-07-03 16:00 ` Grzegorz Kolodziejczyk
  2014-07-14 15:02 ` [PATCH 00/19] Android/tester-ng: New android tester Szymon Janc
  19 siblings, 0 replies; 21+ messages in thread
From: Grzegorz Kolodziejczyk @ 2014-07-03 16:00 UTC (permalink / raw)
  To: linux-bluetooth

Enable, Enable done, Disable, set bdname, discovery timeout, scan mode
test cases are no longer needed in android-tester because of
android-tester-ng test rewrite.
---
 android/android-tester.c | 248 -----------------------------------------------
 1 file changed, 248 deletions(-)

diff --git a/android/android-tester.c b/android/android-tester.c
index bf39517..8b67db9 100644
--- a/android/android-tester.c
+++ b/android/android-tester.c
@@ -706,27 +706,6 @@ static void setup_powered_emulated_remote(void)
 		bthost_write_scan_enable(bthost, 0x03);
 }
 
-static void enable_success_cb(bt_state_t state)
-{
-	struct test_data *data = tester_get_data();
-
-	if (state == BT_STATE_ON) {
-		setup_powered_emulated_remote();
-		data->cb_count--;
-		check_cb_count();
-	}
-}
-
-static void disable_success_cb(bt_state_t state)
-{
-	struct test_data *data = tester_get_data();
-
-	if (state == BT_STATE_OFF) {
-		data->cb_count--;
-		check_cb_count();
-	}
-}
-
 static gboolean adapter_state_changed(gpointer user_data)
 {
 	struct test_data *data = tester_get_data();
@@ -1406,110 +1385,6 @@ static void ssp_request_cb(bt_bdaddr_t *remote_bd_addr, bt_bdname_t *bd_name,
 	g_idle_add(ssp_request, cb_data);
 }
 
-static bt_bdaddr_t enable_done_bdaddr_val = { {0x00} };
-static const char enable_done_bdname_val[] = "BlueZ for Android";
-static const char enable_done_uuids_val[] = {
-	/* Multi profile UUID */
-	0x00, 0x00, 0x11, 0x3b, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00,
-					0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB,
-	/* Device identification profile UUID */
-	0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00,
-					0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB,
-};
-static bt_device_type_t enable_done_tod_val = BT_DEVICE_DEVTYPE_DUAL;
-static bt_scan_mode_t enable_done_scanmode_val = BT_SCAN_MODE_NONE;
-static uint32_t enable_done_disctimeout_val = 120;
-
-static struct priority_property enable_done_props[] = {
-	{
-	.prop.type = BT_PROPERTY_BDADDR,
-	.prop.len = sizeof(enable_done_bdaddr_val),
-	.prop.val = &enable_done_bdaddr_val,
-	.prio = 1,
-	},
-	{
-	.prop.type = BT_PROPERTY_BDNAME,
-	.prop.len = sizeof(enable_done_bdname_val) - 1,
-	.prop.val = &enable_done_bdname_val,
-	.prio = 2,
-	},
-	{
-	.prop.type = BT_PROPERTY_UUIDS,
-	.prop.len = sizeof(enable_done_uuids_val),
-	.prop.val = &enable_done_uuids_val,
-	.prio = 2,
-	},
-	{
-	.prop.type = BT_PROPERTY_CLASS_OF_DEVICE,
-	.prop.len = sizeof(uint32_t),
-	.prop.val = NULL,
-	.prio = 2,
-	},
-	{
-	.prop.type = BT_PROPERTY_TYPE_OF_DEVICE,
-	.prop.len = sizeof(enable_done_tod_val),
-	.prop.val = &enable_done_tod_val,
-	.prio = 2,
-	},
-	{
-	.prop.type = BT_PROPERTY_ADAPTER_SCAN_MODE,
-	.prop.len = sizeof(enable_done_scanmode_val),
-	.prop.val = &enable_done_scanmode_val,
-	.prio = 2,
-	},
-	{
-	.prop.type = BT_PROPERTY_ADAPTER_BONDED_DEVICES,
-	.prop.len = 0,
-	.prop.val = NULL,
-	.prio = 2,
-	},
-	{
-	.prop.type = BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT,
-	.prop.len = sizeof(enable_done_disctimeout_val),
-	.prop.val = &enable_done_disctimeout_val,
-	.prio = 2,
-	},
-};
-
-static const struct generic_data bluetooth_enable_success_test = {
-	.expected_hal_cb.adapter_state_changed_cb = enable_success_cb,
-	.expected_hal_cb.adapter_properties_cb = check_count_properties_cb,
-	.expected_cb_count = 1,
-	.expected_properties_num = 8,
-	.expected_properties = enable_done_props,
-	.expected_adapter_status = BT_STATUS_SUCCESS,
-};
-
-static const struct generic_data bluetooth_enable_success2_test = {
-	.expected_hal_cb.adapter_properties_cb = check_count_properties_cb,
-	.expected_adapter_status = BT_STATUS_SUCCESS,
-	.expected_properties_num = 8,
-	.expected_properties = enable_done_props,
-};
-
-static const struct generic_data bluetooth_disable_success_test = {
-	.expected_hal_cb.adapter_state_changed_cb = disable_success_cb,
-	.expected_cb_count = 1,
-	.expected_adapter_status = BT_STATUS_SUCCESS,
-};
-
-static char test_set_bdname[] = "test_bdname_set";
-
-static struct priority_property setprop_bdname_props[] = {
-	{
-	.prop.type = BT_PROPERTY_BDNAME,
-	.prop.val = test_set_bdname,
-	.prop.len = sizeof(test_set_bdname) - 1,
-	.prio = 0,
-	},
-};
-
-static const struct generic_data bluetooth_setprop_bdname_success_test = {
-	.expected_hal_cb.adapter_properties_cb = check_count_properties_cb,
-	.expected_properties_num = 1,
-	.expected_properties = setprop_bdname_props,
-};
-
 static bt_scan_mode_t test_setprop_scanmode_val =
 					BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE;
 
@@ -1521,13 +1396,6 @@ static struct priority_property setprop_scanmode_props[] = {
 	},
 };
 
-static const struct generic_data bluetooth_setprop_scanmode_success_test = {
-	.expected_hal_cb.adapter_properties_cb = check_count_properties_cb,
-	.expected_properties_num = 1,
-	.expected_properties = setprop_scanmode_props,
-	.expected_adapter_status = BT_STATUS_SUCCESS,
-};
-
 static uint32_t test_setprop_disctimeout_val = 120;
 
 static struct priority_property setprop_disctimeout_props[] = {
@@ -1538,13 +1406,6 @@ static struct priority_property setprop_disctimeout_props[] = {
 	},
 };
 
-static const struct generic_data bluetooth_setprop_disctimeout_success_test = {
-	.expected_hal_cb.adapter_properties_cb = check_count_properties_cb,
-	.expected_properties_num = 1,
-	.expected_properties = setprop_disctimeout_props,
-	.expected_adapter_status = BT_STATUS_SUCCESS,
-};
-
 static bt_bdaddr_t test_getprop_bdaddr_val = { {0x00} };
 
 static struct priority_property getprop_bdaddr_props[] = {
@@ -2639,85 +2500,6 @@ static void test_dummy(const void *test_data)
 	tester_test_passed();
 }
 
-static void test_enable(const void *test_data)
-{
-	struct test_data *data = tester_get_data();
-	bt_status_t adapter_status;
-
-	uint8_t *bdaddr = (uint8_t *)hciemu_get_master_bdaddr(data->hciemu);
-
-	init_test_conditions(data);
-
-	bdaddr2android((const bdaddr_t *)bdaddr,
-					&enable_done_bdaddr_val.address);
-
-	adapter_status = data->if_bluetooth->enable();
-	check_expected_status(adapter_status);
-}
-
-static void test_enable_done(const void *test_data)
-{
-	struct test_data *data = tester_get_data();
-	bt_status_t adapter_status;
-
-	uint8_t *bdaddr = (uint8_t *)hciemu_get_master_bdaddr(data->hciemu);
-
-	init_test_conditions(data);
-
-	bdaddr2android((const bdaddr_t *)bdaddr,
-					&enable_done_bdaddr_val.address);
-
-	adapter_status = data->if_bluetooth->enable();
-	check_expected_status(adapter_status);
-}
-
-static void test_disable(const void *test_data)
-{
-	struct test_data *data = tester_get_data();
-	bt_status_t adapter_status;
-
-	init_test_conditions(data);
-
-	adapter_status = data->if_bluetooth->disable();
-	check_expected_status(adapter_status);
-}
-
-static void test_setprop_bdname_success(const void *test_data)
-{
-	struct test_data *data = tester_get_data();
-	const bt_property_t *prop = &(setprop_bdname_props[0].prop);
-	bt_status_t adapter_status;
-
-	init_test_conditions(data);
-
-	adapter_status = data->if_bluetooth->set_adapter_property(prop);
-	check_expected_status(adapter_status);
-}
-
-static void test_setprop_scanmode_succes(const void *test_data)
-{
-	struct test_data *data = tester_get_data();
-	const bt_property_t *prop = &(setprop_scanmode_props[0].prop);
-	bt_status_t adapter_status;
-
-	init_test_conditions(data);
-
-	adapter_status = data->if_bluetooth->set_adapter_property(prop);
-	check_expected_status(adapter_status);
-}
-
-static void test_setprop_disctimeout_succes(const void *test_data)
-{
-	struct test_data *data = tester_get_data();
-	const bt_property_t *prop = &(setprop_disctimeout_props[0].prop);
-	bt_status_t adapter_status;
-
-	init_test_conditions(data);
-
-	adapter_status = data->if_bluetooth->set_adapter_property(prop);
-	check_expected_status(adapter_status);
-}
-
 static void test_getprop_bdaddr_success(const void *test_data)
 {
 	struct test_data *data = tester_get_data();
@@ -4431,36 +4213,6 @@ int main(int argc, char *argv[])
 
 	test_bredrle("Bluetooth Init", NULL, setup_base, test_dummy, teardown);
 
-	test_bredrle("Bluetooth Enable - Success",
-						&bluetooth_enable_success_test,
-						setup_base, test_enable,
-						teardown);
-
-	test_bredrle("Bluetooth Enable - Success 2",
-						&bluetooth_enable_success2_test,
-						setup_enabled_adapter,
-						test_enable_done, teardown);
-
-	test_bredrle("Bluetooth Disable - Success",
-						&bluetooth_disable_success_test,
-						setup_enabled_adapter,
-						test_disable, teardown);
-
-	test_bredrle("Bluetooth Set BDNAME - Success",
-					&bluetooth_setprop_bdname_success_test,
-					setup_enabled_adapter,
-					test_setprop_bdname_success, teardown);
-
-	test_bredrle("Bluetooth Set SCAN_MODE - Success",
-				&bluetooth_setprop_scanmode_success_test,
-				setup_enabled_adapter,
-				test_setprop_scanmode_succes, teardown);
-
-	test_bredrle("Bluetooth Set DISCOVERY_TIMEOUT - Success",
-				&bluetooth_setprop_disctimeout_success_test,
-				setup_enabled_adapter,
-				test_setprop_disctimeout_succes, teardown);
-
 	test_bredrle("Bluetooth Get BDADDR - Success",
 					&bluetooth_getprop_bdaddr_success_test,
 					setup_enabled_adapter,
-- 
1.9.3


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

* Re: [PATCH 00/19] Android/tester-ng: New android tester
  2014-07-03 16:00 [PATCH 00/19] Android/tester-ng: New android tester Grzegorz Kolodziejczyk
                   ` (18 preceding siblings ...)
  2014-07-03 16:00 ` [PATCH 19/19] android/android-tester: Remove test cases replaced by tester-ng Grzegorz Kolodziejczyk
@ 2014-07-14 15:02 ` Szymon Janc
  19 siblings, 0 replies; 21+ messages in thread
From: Szymon Janc @ 2014-07-14 15:02 UTC (permalink / raw)
  To: Grzegorz Kolodziejczyk; +Cc: linux-bluetooth

Hi Grzegorz,

On Thursday 03 of July 2014 18:00:03 Grzegorz Kolodziejczyk wrote:
> Based on past experience with android-tester, new android tester is
> written from scrath with fixed all known bugs and framework
> inadvertancies.
> 
> Each HAL will have it's own file named tester-"hal" which will
> contain test cases and test steps macros (multiple usage of repeating
> test steps in test cases). Main tester (framework) will gather all
> test cases from tester-"hal" and run it.
> 
> Once new test case will be added, same one from old android tester
> will be removed, until whole test case list will be replaced.
> 
> Grzegorz Kolodziejczyk (17):
>   shared/tester: Add support for debug logs for tester
>   android/tester-ng: Add android-tester-ng
>   android/tester-bluetooth: Initial bluetooth HAL tester
>   android/tester-bluetooth: Add initial test case
>   android/tester-bluetooth: Add enable success test case
>   android/tester-ng: Add double enable success test case
>   android/tester-socket: Initial socket tester
>   android/tester-socket: Add initial test case
>   android/tester-hidhost: Initial hidhost tester
>   android/tester-hidhost: Add initial test case
>   android/tester-gatt: Add initial test case
>   android/tester-ng: Add property check handling
>   android/tester-bluetooth: Add disable success test case
>   android/tester-bluetooth: Add bdname set success tc
>   Android/tester-bluetooth: Add scan_mode set success tc
>   Android/tester-bluetooth: Add disc_timeout set success tc
>   android/android-tester: Remove test cases replaced by tester-ng
> 
> Jakub Tyszkowski (2):
>   android/tester-ng: Add callback mechanism
>   android/tester-gatt: Initial gatt tester
> 
>  android/Makefile.am        |   28 ++
>  android/android-tester.c   |  248 -----------
>  android/tester-bluetooth.c |  269 ++++++++++++
>  android/tester-gatt.c      |   46 ++
>  android/tester-hidhost.c   |   46 ++
>  android/tester-main.c      | 1001 ++++++++++++++++++++++++++++++++++++++++++++
>  android/tester-main.h      |  191 +++++++++
>  android/tester-socket.c    |   46 ++
>  src/shared/tester.c        |   14 +
>  src/shared/tester.h        |    2 +
>  10 files changed, 1643 insertions(+), 248 deletions(-)
>  create mode 100644 android/tester-bluetooth.c
>  create mode 100644 android/tester-gatt.c
>  create mode 100644 android/tester-hidhost.c
>  create mode 100644 android/tester-main.c
>  create mode 100644 android/tester-main.h
>  create mode 100644 android/tester-socket.c
> 

All patches applied, thanks. 

-- 
Best regards, 
Szymon Janc

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

end of thread, other threads:[~2014-07-14 15:02 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-03 16:00 [PATCH 00/19] Android/tester-ng: New android tester Grzegorz Kolodziejczyk
2014-07-03 16:00 ` [PATCH 01/19] shared/tester: Add support for debug logs for tester Grzegorz Kolodziejczyk
2014-07-03 16:00 ` [PATCH 02/19] android/tester-ng: Add android-tester-ng Grzegorz Kolodziejczyk
2014-07-03 16:00 ` [PATCH 03/19] android/tester-bluetooth: Initial bluetooth HAL tester Grzegorz Kolodziejczyk
2014-07-03 16:00 ` [PATCH 04/19] android/tester-bluetooth: Add initial test case Grzegorz Kolodziejczyk
2014-07-03 16:00 ` [PATCH 05/19] android/tester-bluetooth: Add enable success " Grzegorz Kolodziejczyk
2014-07-03 16:00 ` [PATCH 06/19] android/tester-ng: Add callback mechanism Grzegorz Kolodziejczyk
2014-07-03 16:00 ` [PATCH 07/19] android/tester-ng: Add double enable success test case Grzegorz Kolodziejczyk
2014-07-03 16:00 ` [PATCH 08/19] android/tester-socket: Initial socket tester Grzegorz Kolodziejczyk
2014-07-03 16:00 ` [PATCH 09/19] android/tester-socket: Add initial test case Grzegorz Kolodziejczyk
2014-07-03 16:00 ` [PATCH 10/19] android/tester-hidhost: Initial hidhost tester Grzegorz Kolodziejczyk
2014-07-03 16:00 ` [PATCH 11/19] android/tester-hidhost: Add initial test case Grzegorz Kolodziejczyk
2014-07-03 16:00 ` [PATCH 12/19] android/tester-gatt: Initial gatt tester Grzegorz Kolodziejczyk
2014-07-03 16:00 ` [PATCH 13/19] android/tester-gatt: Add initial test case Grzegorz Kolodziejczyk
2014-07-03 16:00 ` [PATCH 14/19] android/tester-ng: Add property check handling Grzegorz Kolodziejczyk
2014-07-03 16:00 ` [PATCH 15/19] android/tester-bluetooth: Add disable success test case Grzegorz Kolodziejczyk
2014-07-03 16:00 ` [PATCH 16/19] android/tester-bluetooth: Add bdname set success tc Grzegorz Kolodziejczyk
2014-07-03 16:00 ` [PATCH 17/19] Android/tester-bluetooth: Add scan_mode " Grzegorz Kolodziejczyk
2014-07-03 16:00 ` [PATCH 18/19] Android/tester-bluetooth: Add disc_timeout " Grzegorz Kolodziejczyk
2014-07-03 16:00 ` [PATCH 19/19] android/android-tester: Remove test cases replaced by tester-ng Grzegorz Kolodziejczyk
2014-07-14 15:02 ` [PATCH 00/19] Android/tester-ng: New android tester Szymon Janc

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox