All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv5 00/11] IPC negative tester
@ 2014-01-20  9:35 Jakub Tyszkowski
  2014-01-20  9:36 ` [PATCHv5 01/11] android/ipc-tester: Skeleton for ipc " Jakub Tyszkowski
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: Jakub Tyszkowski @ 2014-01-20  9:35 UTC (permalink / raw)
  To: linux-bluetooth

Following patchset adds IPC negative tester framework along with test cases
checking IPC's behaviour on daemon side. Expected daemon's behaviour is to
shut down gracefully in case of receiving invalid IPC data.

v2 changes:
  * fixed few indentation issues
  * fixed missing __attribute__((packed))
  * fixed amount of data written for 'malformed data' test case
  * fixed opcode for 'invalid service' test case
  * added patch(8) with more 'malformed data' cases

v3 changes:
  * changed license to GPL
  * changed 'ipc-negative-tester' name to 'ipc-tester'

v4 changes:
  * fixed typo in first test case and last commit's message
  * fixed daemon shutdown handler function

v5 changes:
  * added clean up in case of setup failure
  * added test execution macro enhancement for easy data creation
  * added test cases for core BT interfaces (Patches: 9, 10, 11)

Jakub Tyszkowski (11):
  android/ipc-tester: Skeleton for ipc negative tester
  android/ipc-tester: Run daemon in separate process
  android/ipc-tester: Add IPC initialization
  android/ipc-tester: Add daemon shutdown handler
  android/ipc-tester: Add sending test data with ipc
  android/ipc-tester: Register services
  android/ipc-tester: Add basic test cases for IPC's daemon site
  android/ipc-tester: Add more cases for malformed data
  android/ipc-tester: Add cases for service opcode boundaries
  android/ipc-tester: Add cases for Core message data size
  android/ipc-tester: Add cases for BT message data size

 .gitignore           |   1 +
 android/Makefile.am  |  17 +
 android/ipc-tester.c | 868 +++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 886 insertions(+)
 create mode 100644 android/ipc-tester.c

--
1.8.5.2


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

* [PATCHv5 01/11] android/ipc-tester: Skeleton for ipc negative tester
  2014-01-20  9:35 [PATCHv5 00/11] IPC negative tester Jakub Tyszkowski
@ 2014-01-20  9:36 ` Jakub Tyszkowski
  2014-01-20  9:36 ` [PATCHv5 02/11] android/ipc-tester: Run daemon in separate process Jakub Tyszkowski
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Jakub Tyszkowski @ 2014-01-20  9:36 UTC (permalink / raw)
  To: linux-bluetooth

Add skeleton for ipc negative testing.
---
 .gitignore           |   1 +
 android/Makefile.am  |  17 +++++
 android/ipc-tester.c | 207 +++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 225 insertions(+)
 create mode 100644 android/ipc-tester.c

diff --git a/.gitignore b/.gitignore
index 2c8e033..67e9850 100644
--- a/.gitignore
+++ b/.gitignore
@@ -114,4 +114,5 @@ android/system-emulator
 android/bluetoothd
 android/haltest
 android/android-tester
+android/ipc-tester
 android/bluetoothd-snoop
diff --git a/android/Makefile.am b/android/Makefile.am
index f24b754..e027cff 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -120,6 +120,23 @@ android_android_tester_LDFLAGS = -pthread -ldl
 
 plugin_LTLIBRARIES += android/audio.a2dp.default.la
 
+noinst_PROGRAMS += android/ipc-tester
+
+android_ipc_tester_SOURCES = emulator/btdev.h emulator/btdev.c \
+				emulator/bthost.h emulator/bthost.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 \
+				android/hal-utils.h android/hal-utils.c \
+				android/ipc-tester.c
+
+android_ipc_tester_CFLAGS = $(AM_CFLAGS) -I$(srcdir)/android
+
+android_ipc_tester_LDADD = lib/libbluetooth-internal.la @GLIB_LIBS@
+
 android_audio_a2dp_default_la_SOURCES = android/audio-msg.h \
 					android/hal-msg.h \
 					android/hal-audio.c \
diff --git a/android/ipc-tester.c b/android/ipc-tester.c
new file mode 100644
index 0000000..021919e
--- /dev/null
+++ b/android/ipc-tester.c
@@ -0,0 +1,207 @@
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright (C) 2014  Intel Corporation. All rights reserved.
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program 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 General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#include <unistd.h>
+
+#include <glib.h>
+
+#include "lib/bluetooth.h"
+#include "lib/mgmt.h"
+
+#include "src/shared/tester.h"
+#include "src/shared/mgmt.h"
+#include "src/shared/hciemu.h"
+
+
+struct test_data {
+	struct mgmt *mgmt;
+	uint16_t mgmt_index;
+	struct hciemu *hciemu;
+	enum hciemu_type hciemu_type;
+};
+
+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 *data)
+{
+	struct test_data *test_data = tester_get_data();
+
+	if (!tester_use_debug())
+		fclose(stderr);
+
+	test_data->mgmt = mgmt_new_default();
+	if (!test_data->mgmt) {
+		tester_warn("Failed to setup management interface");
+		tester_pre_setup_failed();
+		return;
+	}
+
+	mgmt_send(test_data->mgmt, MGMT_OP_READ_INDEX_LIST, MGMT_INDEX_NONE, 0,
+				NULL, read_index_list_callback, NULL, NULL);
+}
+
+static void test_post_teardown(const void *data)
+{
+	struct test_data *test_data = tester_get_data();
+
+	if (test_data->hciemu) {
+		hciemu_unref(test_data->hciemu);
+		test_data->hciemu = NULL;
+	}
+}
+
+static void setup(const void *data)
+{
+	tester_setup_failed();
+	test_post_teardown(data);
+}
+
+static void teardown(const void *data)
+{
+	tester_teardown_complete();
+}
+
+static void ipc_send_tc(const void *data)
+{
+}
+
+#define test_generic(name, 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;		\
+		tester_add_full(name, data, test_pre_setup, test_setup,	\
+				test, test_teardown, test_post_teardown,\
+				3, user, g_free);			\
+	} while (0)
+
+int main(int argc, char *argv[])
+{
+	tester_init(&argc, &argv);
+
+	test_generic("Test Dummy", NULL, setup, ipc_send_tc, teardown);
+
+	return tester_run();
+}
-- 
1.8.5.2


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

* [PATCHv5 02/11] android/ipc-tester: Run daemon in separate process
  2014-01-20  9:35 [PATCHv5 00/11] IPC negative tester Jakub Tyszkowski
  2014-01-20  9:36 ` [PATCHv5 01/11] android/ipc-tester: Skeleton for ipc " Jakub Tyszkowski
@ 2014-01-20  9:36 ` Jakub Tyszkowski
  2014-01-20  9:36 ` [PATCHv5 03/11] android/ipc-tester: Add IPC initialization Jakub Tyszkowski
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Jakub Tyszkowski @ 2014-01-20  9:36 UTC (permalink / raw)
  To: linux-bluetooth

This patch adds new process waiting to run daemon when needed.
---
 android/ipc-tester.c | 123 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 123 insertions(+)

diff --git a/android/ipc-tester.c b/android/ipc-tester.c
index 021919e..c8d1f0b 100644
--- a/android/ipc-tester.c
+++ b/android/ipc-tester.c
@@ -21,8 +21,14 @@
  *
  */
 
+#include <stdlib.h>
 #include <unistd.h>
 
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/un.h>
+#include <libgen.h>
 #include <glib.h>
 
 #include "lib/bluetooth.h"
@@ -33,13 +39,19 @@
 #include "src/shared/hciemu.h"
 
 
+#define WAIT_FOR_SIGNAL_TIME 2 /* in seconds */
+#define EMULATOR_SIGNAL "emulator_started"
+
 struct test_data {
 	struct mgmt *mgmt;
 	uint16_t mgmt_index;
 	struct hciemu *hciemu;
 	enum hciemu_type hciemu_type;
+	pid_t bluetoothd_pid;
 };
 
+static char exec_dir[PATH_MAX + 1];
+
 static void read_info_callback(uint8_t status, uint16_t length,
 					const void *param, void *user_data)
 {
@@ -170,14 +182,123 @@ static void test_post_teardown(const void *data)
 	}
 }
 
+static void bluetoothd_start(int hci_index)
+{
+	char prg_name[PATH_MAX + 1];
+	char index[8];
+	char *prg_argv[4];
+
+	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] = 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 = WAIT_FOR_SIGNAL_TIME;
+	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, "ctl.start=bluetoothd")))
+		goto failed;
+
+	close(pipe);
+	close(fd);
+	bluetoothd_start(hci_index);
+
+failed:
+	close(pipe);
+	close(fd);
+}
+
 static void setup(const void *data)
 {
+	struct test_data *test_data = tester_get_data();
+	int signal_fd[2];
+	char buf[1024];
+	pid_t pid;
+	int len;
+
+	if (pipe(signal_fd))
+		goto failed;
+
+	pid = fork();
+
+	if (pid < 0) {
+		close(signal_fd[0]);
+		close(signal_fd[1]);
+		goto failed;
+	}
+
+	if (pid == 0) {
+		if (!tester_use_debug())
+			fclose(stderr);
+
+		close(signal_fd[0]);
+		emulator(signal_fd[1], test_data->mgmt_index);
+		exit(0);
+	}
+
+	close(signal_fd[1]);
+	test_data->bluetoothd_pid = pid;
+
+	len = read(signal_fd[0], buf, sizeof(buf));
+	if (len <= 0 || (strcmp(buf, EMULATOR_SIGNAL))) {
+		close(signal_fd[0]);
+		goto failed;
+	}
+
+	return;
+
+failed:
 	tester_setup_failed();
 	test_post_teardown(data);
 }
 
 static void teardown(const void *data)
 {
+	struct test_data *test_data = tester_get_data();
+
+	if (test_data->bluetoothd_pid)
+		waitpid(test_data->bluetoothd_pid, NULL, 0);
+
 	tester_teardown_complete();
 }
 
@@ -199,6 +320,8 @@ static void ipc_send_tc(const void *data)
 
 int main(int argc, char *argv[])
 {
+	snprintf(exec_dir, sizeof(exec_dir), "%s", dirname(argv[0]));
+
 	tester_init(&argc, &argv);
 
 	test_generic("Test Dummy", NULL, setup, ipc_send_tc, teardown);
-- 
1.8.5.2


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

* [PATCHv5 03/11] android/ipc-tester: Add IPC initialization
  2014-01-20  9:35 [PATCHv5 00/11] IPC negative tester Jakub Tyszkowski
  2014-01-20  9:36 ` [PATCHv5 01/11] android/ipc-tester: Skeleton for ipc " Jakub Tyszkowski
  2014-01-20  9:36 ` [PATCHv5 02/11] android/ipc-tester: Run daemon in separate process Jakub Tyszkowski
@ 2014-01-20  9:36 ` Jakub Tyszkowski
  2014-01-20  9:36 ` [PATCHv5 04/11] android/ipc-tester: Add daemon shutdown handler Jakub Tyszkowski
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Jakub Tyszkowski @ 2014-01-20  9:36 UTC (permalink / raw)
  To: linux-bluetooth

This patch adds IPC mechanism initialization.
The deamon is being started and IPC socket connection is established.
---
 android/ipc-tester.c | 125 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 125 insertions(+)

diff --git a/android/ipc-tester.c b/android/ipc-tester.c
index c8d1f0b..ff17ced 100644
--- a/android/ipc-tester.c
+++ b/android/ipc-tester.c
@@ -23,6 +23,8 @@
 
 #include <stdlib.h>
 #include <unistd.h>
+#include <errno.h>
+#include <poll.h>
 
 #include <sys/socket.h>
 #include <sys/types.h>
@@ -38,6 +40,8 @@
 #include "src/shared/mgmt.h"
 #include "src/shared/hciemu.h"
 
+#include "hal-msg.h"
+#include <cutils/properties.h>
 
 #define WAIT_FOR_SIGNAL_TIME 2 /* in seconds */
 #define EMULATOR_SIGNAL "emulator_started"
@@ -50,8 +54,14 @@ struct test_data {
 	pid_t bluetoothd_pid;
 };
 
+#define CONNECT_TIMEOUT (5 * 1000)
+#define SERVICE_NAME "bluetoothd"
+
 static char exec_dir[PATH_MAX + 1];
 
+static int cmd_sk = -1;
+static int notif_sk = -1;
+
 static void read_info_callback(uint8_t status, uint16_t length,
 					const void *param, void *user_data)
 {
@@ -248,6 +258,112 @@ failed:
 	close(fd);
 }
 
+static int accept_connection(int sk)
+{
+	int err;
+	struct pollfd pfd;
+	int new_sk;
+
+	memset(&pfd, 0 , sizeof(pfd));
+	pfd.fd = sk;
+	pfd.events = POLLIN;
+
+	err = poll(&pfd, 1, CONNECT_TIMEOUT);
+	if (err < 0) {
+		err = errno;
+		tester_warn("Failed to poll: %d (%s)", err, strerror(err));
+		return -errno;
+	}
+
+	if (err == 0) {
+		tester_warn("bluetoothd connect timeout");
+		return -errno;
+	}
+
+	new_sk = accept(sk, NULL, NULL);
+	if (new_sk < 0) {
+		err = errno;
+		tester_warn("Failed to accept socket: %d (%s)",
+							err, strerror(err));
+		return -errno;
+	}
+
+	return new_sk;
+}
+
+static bool init_ipc(void)
+{
+	struct sockaddr_un addr;
+
+	int sk;
+	int err;
+
+	sk = socket(AF_LOCAL, SOCK_SEQPACKET, 0);
+	if (sk < 0) {
+		err = errno;
+		tester_warn("Failed to create socket: %d (%s)", err,
+							strerror(err));
+		return false;
+	}
+
+	memset(&addr, 0, sizeof(addr));
+	addr.sun_family = AF_UNIX;
+
+	memcpy(addr.sun_path, BLUEZ_HAL_SK_PATH, sizeof(BLUEZ_HAL_SK_PATH));
+
+	if (bind(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
+		err = errno;
+		tester_warn("Failed to bind socket: %d (%s)", err,
+								strerror(err));
+		close(sk);
+		return false;
+	}
+
+	if (listen(sk, 2) < 0) {
+		err = errno;
+		tester_warn("Failed to listen on socket: %d (%s)", err,
+								strerror(err));
+		close(sk);
+		return false;
+	}
+
+	/* Start Android Bluetooth daemon service */
+	if (property_set("ctl.start", SERVICE_NAME) < 0) {
+		tester_warn("Failed to start service %s", SERVICE_NAME);
+		close(sk);
+		return false;
+	}
+
+	cmd_sk = accept_connection(sk);
+	if (cmd_sk < 0) {
+		close(sk);
+		return false;
+	}
+
+	notif_sk = accept_connection(sk);
+	if (notif_sk < 0) {
+		close(sk);
+		close(cmd_sk);
+		cmd_sk = -1;
+		return false;
+	}
+
+	tester_print("bluetoothd connected");
+
+	close(sk);
+
+	return true;
+}
+
+static void cleanup_ipc(void)
+{
+	if (cmd_sk < 0)
+		return;
+
+	close(cmd_sk);
+	cmd_sk = -1;
+}
+
 static void setup(const void *data)
 {
 	struct test_data *test_data = tester_get_data();
@@ -285,6 +401,12 @@ static void setup(const void *data)
 		goto failed;
 	}
 
+	if (!init_ipc()) {
+		tester_warn("Cannot initialize IPC mechanism!");
+		goto failed;
+	}
+	/* TODO: register modules */
+
 	return;
 
 failed:
@@ -292,10 +414,13 @@ failed:
 	test_post_teardown(data);
 }
 
+
 static void teardown(const void *data)
 {
 	struct test_data *test_data = tester_get_data();
 
+	cleanup_ipc();
+
 	if (test_data->bluetoothd_pid)
 		waitpid(test_data->bluetoothd_pid, NULL, 0);
 
-- 
1.8.5.2


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

* [PATCHv5 04/11] android/ipc-tester: Add daemon shutdown handler
  2014-01-20  9:35 [PATCHv5 00/11] IPC negative tester Jakub Tyszkowski
                   ` (2 preceding siblings ...)
  2014-01-20  9:36 ` [PATCHv5 03/11] android/ipc-tester: Add IPC initialization Jakub Tyszkowski
@ 2014-01-20  9:36 ` Jakub Tyszkowski
  2014-01-20  9:36 ` [PATCHv5 05/11] android/ipc-tester: Add sending test data with ipc Jakub Tyszkowski
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Jakub Tyszkowski @ 2014-01-20  9:36 UTC (permalink / raw)
  To: linux-bluetooth

Handle daemon shutdown asynchronously.
---
 android/ipc-tester.c | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/android/ipc-tester.c b/android/ipc-tester.c
index ff17ced..b6f8131 100644
--- a/android/ipc-tester.c
+++ b/android/ipc-tester.c
@@ -52,6 +52,7 @@ struct test_data {
 	struct hciemu *hciemu;
 	enum hciemu_type hciemu_type;
 	pid_t bluetoothd_pid;
+	bool setup_done;
 };
 
 #define CONNECT_TIMEOUT (5 * 1000)
@@ -364,6 +365,31 @@ static void cleanup_ipc(void)
 	cmd_sk = -1;
 }
 
+static gboolean check_for_daemon(gpointer user_data)
+{
+	int status;
+	struct test_data *data = user_data;
+
+	if ((waitpid(data->bluetoothd_pid, &status, WNOHANG))
+							!= data->bluetoothd_pid)
+		return true;
+
+	if (data->setup_done) {
+		if (WIFEXITED(status) &&
+				(WEXITSTATUS(status) == EXIT_SUCCESS)) {
+			tester_test_passed();
+			return false;
+		}
+		tester_test_failed();
+	} else {
+		tester_setup_failed();
+		test_post_teardown(data);
+	}
+
+	tester_warn("Unexpected Daemon shutdown with status %d", status);
+	return false;
+}
+
 static void setup(const void *data)
 {
 	struct test_data *test_data = tester_get_data();
@@ -401,24 +427,29 @@ static void setup(const void *data)
 		goto failed;
 	}
 
+	g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, check_for_daemon, test_data,
+									NULL);
+
 	if (!init_ipc()) {
 		tester_warn("Cannot initialize IPC mechanism!");
 		goto failed;
 	}
 	/* TODO: register modules */
 
+	test_data->setup_done = true;
 	return;
 
 failed:
+	g_idle_remove_by_data(test_data);
 	tester_setup_failed();
 	test_post_teardown(data);
 }
 
-
 static void teardown(const void *data)
 {
 	struct test_data *test_data = tester_get_data();
 
+	g_idle_remove_by_data(test_data);
 	cleanup_ipc();
 
 	if (test_data->bluetoothd_pid)
-- 
1.8.5.2


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

* [PATCHv5 05/11] android/ipc-tester: Add sending test data with ipc
  2014-01-20  9:35 [PATCHv5 00/11] IPC negative tester Jakub Tyszkowski
                   ` (3 preceding siblings ...)
  2014-01-20  9:36 ` [PATCHv5 04/11] android/ipc-tester: Add daemon shutdown handler Jakub Tyszkowski
@ 2014-01-20  9:36 ` Jakub Tyszkowski
  2014-01-20  9:36 ` [PATCHv5 06/11] android/ipc-tester: Register services Jakub Tyszkowski
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Jakub Tyszkowski @ 2014-01-20  9:36 UTC (permalink / raw)
  To: linux-bluetooth

This patch adds some data structures used to send data with ipc during
test setup and run stage. Test execution macro is extended for easy
data preparation.
---
 android/ipc-tester.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 58 insertions(+), 4 deletions(-)

diff --git a/android/ipc-tester.c b/android/ipc-tester.c
index b6f8131..7cd50f5 100644
--- a/android/ipc-tester.c
+++ b/android/ipc-tester.c
@@ -55,6 +55,23 @@ struct test_data {
 	bool setup_done;
 };
 
+struct ipc_data {
+	void *buffer;
+	size_t len;
+};
+
+struct generic_data {
+	struct ipc_data ipc_data;
+
+	unsigned int num_services;
+	int init_services[];
+};
+
+struct regmod_msg {
+	struct hal_hdr header;
+	struct hal_cmd_register_module cmd;
+} __attribute__((packed));
+
 #define CONNECT_TIMEOUT (5 * 1000)
 #define SERVICE_NAME "bluetoothd"
 
@@ -460,27 +477,64 @@ static void teardown(const void *data)
 
 static void ipc_send_tc(const void *data)
 {
+	const struct generic_data *generic_data = data;
+	const struct ipc_data *ipc_data = &generic_data->ipc_data;
+
+	if (ipc_data->len) {
+		if (write(cmd_sk, ipc_data->buffer, ipc_data->len) < 0)
+			tester_test_failed();
+	}
 }
 
-#define test_generic(name, data, test_setup, test, test_teardown) \
+#define service_data(args...) { args }
+
+#define gen_data(writelen, writebuf, servicelist...) \
+	{								\
+		.ipc_data = {						\
+			.buffer = writebuf,				\
+			.len = writelen,				\
+		},							\
+		.init_services = service_data(servicelist),		\
+		.num_services = sizeof((const int[])			\
+					service_data(servicelist)) /	\
+					sizeof(int),			\
+	}
+
+#define test_generic(name, test, setup, teardown, buffer, writelen, \
+							services...) \
 	do {								\
 		struct test_data *user;					\
+		static const struct generic_data data =			\
+				gen_data(writelen, buffer, services);	\
 		user = g_malloc0(sizeof(struct test_data));		\
 		if (!user)						\
 			break;						\
 		user->hciemu_type = HCIEMU_TYPE_BREDRLE;		\
-		tester_add_full(name, data, test_pre_setup, test_setup,	\
-				test, test_teardown, test_post_teardown,\
+		tester_add_full(name, &data, test_pre_setup, setup,	\
+				test, teardown, test_post_teardown,	\
 				3, user, g_free);			\
 	} while (0)
 
+struct regmod_msg register_bt_msg = {
+	.header = {
+		.service_id = HAL_SERVICE_ID_CORE,
+		.opcode = HAL_OP_REGISTER_MODULE,
+		.len = sizeof(struct hal_cmd_register_module),
+		},
+	.cmd = {
+		.service_id = HAL_SERVICE_ID_BLUETOOTH,
+		},
+};
+
 int main(int argc, char *argv[])
 {
 	snprintf(exec_dir, sizeof(exec_dir), "%s", dirname(argv[0]));
 
 	tester_init(&argc, &argv);
 
-	test_generic("Test Dummy", NULL, setup, ipc_send_tc, teardown);
+	test_generic("Too small data",
+				ipc_send_tc, setup, teardown,
+				&register_bt_msg, 1);
 
 	return tester_run();
 }
-- 
1.8.5.2


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

* [PATCHv5 06/11] android/ipc-tester: Register services
  2014-01-20  9:35 [PATCHv5 00/11] IPC negative tester Jakub Tyszkowski
                   ` (4 preceding siblings ...)
  2014-01-20  9:36 ` [PATCHv5 05/11] android/ipc-tester: Add sending test data with ipc Jakub Tyszkowski
@ 2014-01-20  9:36 ` Jakub Tyszkowski
  2014-01-20  9:36 ` [PATCHv5 07/11] android/ipc-tester: Add basic test cases for IPC's daemon site Jakub Tyszkowski
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Jakub Tyszkowski @ 2014-01-20  9:36 UTC (permalink / raw)
  To: linux-bluetooth

This patch adds basic bluetooth service registration during setup procedure.
Without this daemon would reject commands for not registered services.
---
 android/ipc-tester.c | 45 ++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 44 insertions(+), 1 deletion(-)

diff --git a/android/ipc-tester.c b/android/ipc-tester.c
index 7cd50f5..816719c 100644
--- a/android/ipc-tester.c
+++ b/android/ipc-tester.c
@@ -407,13 +407,48 @@ static gboolean check_for_daemon(gpointer user_data)
 	return false;
 }
 
+static bool setup_module(int service_id)
+{
+	struct hal_hdr response;
+	struct hal_hdr expected_response;
+
+	struct regmod_msg btmodule_msg = {
+		.header = {
+			.service_id = HAL_SERVICE_ID_CORE,
+			.opcode = HAL_OP_REGISTER_MODULE,
+			.len = sizeof(struct hal_cmd_register_module),
+			},
+		.cmd = {
+			.service_id = service_id,
+			},
+	};
+
+	if (write(cmd_sk, &btmodule_msg, sizeof(btmodule_msg)) < 0)
+		goto fail;
+
+	if (read(cmd_sk, &response, sizeof(response)) < 0)
+		goto fail;
+
+	expected_response = btmodule_msg.header;
+	expected_response.len = 0;
+
+	if (memcmp(&response, &expected_response, sizeof(response)) == 0)
+		return true;
+
+fail:
+	tester_warn("Module registration failed.");
+	return false;
+}
+
 static void setup(const void *data)
 {
+	const struct generic_data *generic_data = data;
 	struct test_data *test_data = tester_get_data();
 	int signal_fd[2];
 	char buf[1024];
 	pid_t pid;
 	int len;
+	unsigned int i;
 
 	if (pipe(signal_fd))
 		goto failed;
@@ -451,9 +486,17 @@ static void setup(const void *data)
 		tester_warn("Cannot initialize IPC mechanism!");
 		goto failed;
 	}
-	/* TODO: register modules */
+	tester_print("Will init %d services.", generic_data->num_services);
+
+	for (i = 0; i < generic_data->num_services; i++)
+		if (!setup_module(generic_data->init_services[i])) {
+			cleanup_ipc();
+			goto failed;
+		}
 
 	test_data->setup_done = true;
+
+	tester_setup_complete();
 	return;
 
 failed:
-- 
1.8.5.2


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

* [PATCHv5 07/11] android/ipc-tester: Add basic test cases for IPC's daemon site
  2014-01-20  9:35 [PATCHv5 00/11] IPC negative tester Jakub Tyszkowski
                   ` (5 preceding siblings ...)
  2014-01-20  9:36 ` [PATCHv5 06/11] android/ipc-tester: Register services Jakub Tyszkowski
@ 2014-01-20  9:36 ` Jakub Tyszkowski
  2014-01-20  9:36 ` [PATCHv5 08/11] android/ipc-tester: Add more cases for malformed data Jakub Tyszkowski
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Jakub Tyszkowski @ 2014-01-20  9:36 UTC (permalink / raw)
  To: linux-bluetooth

This patch adds first few test cases checking for proper daemon
termination in case of receiving invalid IPC data.
---
 android/ipc-tester.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/android/ipc-tester.c b/android/ipc-tester.c
index 816719c..c8bc9b8 100644
--- a/android/ipc-tester.c
+++ b/android/ipc-tester.c
@@ -569,15 +569,57 @@ struct regmod_msg register_bt_msg = {
 		},
 };
 
+struct regmod_msg register_bt_malformed_size_msg = {
+	.header = {
+		.service_id = HAL_SERVICE_ID_CORE,
+		.opcode = HAL_OP_REGISTER_MODULE,
+		/* wrong payload size declared */
+		.len = sizeof(struct hal_cmd_register_module) - 1,
+		},
+	.cmd = {
+		.service_id = HAL_SERVICE_ID_CORE,
+		},
+};
+
+struct hal_hdr enable_unknown_service_hdr = {
+	.service_id = HAL_SERVICE_ID_MAX + 1,
+	.opcode = HAL_OP_REGISTER_MODULE,
+	.len = 0,
+};
+
+struct hal_hdr enable_bt_service_hdr = {
+	.service_id = HAL_SERVICE_ID_BLUETOOTH,
+	.opcode = HAL_OP_ENABLE,
+	.len = 0,
+};
+
 int main(int argc, char *argv[])
 {
 	snprintf(exec_dir, sizeof(exec_dir), "%s", dirname(argv[0]));
 
 	tester_init(&argc, &argv);
 
+	/* check general IPC errors */
 	test_generic("Too small data",
 				ipc_send_tc, setup, teardown,
 				&register_bt_msg, 1);
 
+	test_generic("Malformed data (wrong payload declared)",
+				ipc_send_tc, setup, teardown,
+				&register_bt_malformed_size_msg,
+				sizeof(register_bt_malformed_size_msg),
+				HAL_SERVICE_ID_BLUETOOTH);
+
+	test_generic("Invalid service",
+				ipc_send_tc, setup, teardown,
+				&enable_unknown_service_hdr,
+				sizeof(enable_unknown_service_hdr),
+				HAL_SERVICE_ID_BLUETOOTH);
+
+	test_generic("Enable unregistered service",
+				ipc_send_tc, setup, teardown,
+				&enable_bt_service_hdr,
+				sizeof(enable_bt_service_hdr));
+
 	return tester_run();
 }
-- 
1.8.5.2


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

* [PATCHv5 08/11] android/ipc-tester: Add more cases for malformed data
  2014-01-20  9:35 [PATCHv5 00/11] IPC negative tester Jakub Tyszkowski
                   ` (6 preceding siblings ...)
  2014-01-20  9:36 ` [PATCHv5 07/11] android/ipc-tester: Add basic test cases for IPC's daemon site Jakub Tyszkowski
@ 2014-01-20  9:36 ` Jakub Tyszkowski
  2014-01-20  9:36 ` [PATCHv5 09/11] android/ipc-tester: Add cases for service opcode boundaries Jakub Tyszkowski
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Jakub Tyszkowski @ 2014-01-20  9:36 UTC (permalink / raw)
  To: linux-bluetooth

This patch adds tests for more types of possible data malformations.
---
 android/ipc-tester.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/android/ipc-tester.c b/android/ipc-tester.c
index c8bc9b8..db0a30a 100644
--- a/android/ipc-tester.c
+++ b/android/ipc-tester.c
@@ -581,6 +581,27 @@ struct regmod_msg register_bt_malformed_size_msg = {
 		},
 };
 
+struct malformed_data3_struct {
+	struct regmod_msg valid_msg;
+	int redundant_data;
+}  __attribute__((packed));
+
+static struct malformed_data3_struct malformed_data3_msg = {
+	/* valid register service message */
+	.valid_msg = {
+		.header = {
+			.service_id = HAL_SERVICE_ID_CORE,
+			.opcode = HAL_OP_REGISTER_MODULE,
+			.len = sizeof(struct hal_cmd_register_module),
+			},
+		.cmd = {
+			.service_id = HAL_SERVICE_ID_CORE,
+			},
+	},
+	/* plus redundant data */
+	. redundant_data = 666,
+};
+
 struct hal_hdr enable_unknown_service_hdr = {
 	.service_id = HAL_SERVICE_ID_MAX + 1,
 	.opcode = HAL_OP_REGISTER_MODULE,
@@ -610,6 +631,18 @@ int main(int argc, char *argv[])
 				sizeof(register_bt_malformed_size_msg),
 				HAL_SERVICE_ID_BLUETOOTH);
 
+	test_generic("Malformed data2 (undersized msg)",
+				ipc_send_tc, setup, teardown,
+				&register_bt_msg,
+				sizeof(register_bt_msg) - 1,
+				HAL_SERVICE_ID_BLUETOOTH);
+
+	test_generic("Malformed data3 (oversized msg)",
+				ipc_send_tc, setup, teardown,
+				&malformed_data3_msg,
+				sizeof(malformed_data3_msg),
+				HAL_SERVICE_ID_BLUETOOTH);
+
 	test_generic("Invalid service",
 				ipc_send_tc, setup, teardown,
 				&enable_unknown_service_hdr,
-- 
1.8.5.2


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

* [PATCHv5 09/11] android/ipc-tester: Add cases for service opcode boundaries
  2014-01-20  9:35 [PATCHv5 00/11] IPC negative tester Jakub Tyszkowski
                   ` (7 preceding siblings ...)
  2014-01-20  9:36 ` [PATCHv5 08/11] android/ipc-tester: Add more cases for malformed data Jakub Tyszkowski
@ 2014-01-20  9:36 ` Jakub Tyszkowski
  2014-01-20  9:36 ` [PATCHv5 10/11] android/ipc-tester: Add cases for Core message data size Jakub Tyszkowski
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Jakub Tyszkowski @ 2014-01-20  9:36 UTC (permalink / raw)
  To: linux-bluetooth

This patch adds tests sending out of range opcode for each service.
---
 android/ipc-tester.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/android/ipc-tester.c b/android/ipc-tester.c
index db0a30a..cebe751 100644
--- a/android/ipc-tester.c
+++ b/android/ipc-tester.c
@@ -558,6 +558,21 @@ static void ipc_send_tc(const void *data)
 				3, user, g_free);			\
 	} while (0)
 
+#define test_opcode_valid(_name, _service, _opcode, _len, _servicelist...) \
+	do {								\
+		static struct hal_hdr hdr = {				\
+			.service_id = _service,				\
+			.opcode = _opcode,				\
+			.len = _len,					\
+		};							\
+									\
+		test_generic("Opcode out of range: "_name,		\
+				ipc_send_tc, setup, teardown,		\
+				&hdr,					\
+				sizeof(hdr),				\
+				_servicelist);				\
+	} while (0)
+
 struct regmod_msg register_bt_msg = {
 	.header = {
 		.service_id = HAL_SERVICE_ID_CORE,
@@ -654,5 +669,22 @@ int main(int argc, char *argv[])
 				&enable_bt_service_hdr,
 				sizeof(enable_bt_service_hdr));
 
+	/* check service handler's max opcode value */
+	test_opcode_valid("CORE", HAL_SERVICE_ID_CORE, 0x03, 0);
+
+	test_opcode_valid("BLUETOOTH", HAL_SERVICE_ID_BLUETOOTH, 0x15, 0,
+			HAL_SERVICE_ID_BLUETOOTH);
+
+	test_opcode_valid("SOCK", HAL_SERVICE_ID_SOCK, 0x03, 0,
+			HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_SOCK);
+
+	test_opcode_valid("HIDHOST", HAL_SERVICE_ID_HIDHOST, 0x10, 0,
+			HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_HIDHOST);
+
+	test_opcode_valid("PAN", HAL_SERVICE_ID_PAN, 0x05, 0,
+			HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_PAN);
+
+	test_opcode_valid("A2DP", HAL_SERVICE_ID_A2DP, 0x03, 0,
+			HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_A2DP);
 	return tester_run();
 }
-- 
1.8.5.2


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

* [PATCHv5 10/11] android/ipc-tester: Add cases for Core message data size
  2014-01-20  9:35 [PATCHv5 00/11] IPC negative tester Jakub Tyszkowski
                   ` (8 preceding siblings ...)
  2014-01-20  9:36 ` [PATCHv5 09/11] android/ipc-tester: Add cases for service opcode boundaries Jakub Tyszkowski
@ 2014-01-20  9:36 ` Jakub Tyszkowski
  2014-01-20  9:36 ` [PATCHv5 11/11] android/ipc-tester: Add cases for BT " Jakub Tyszkowski
  2014-01-20 22:26 ` [PATCHv5 00/11] IPC negative tester Szymon Janc
  11 siblings, 0 replies; 13+ messages in thread
From: Jakub Tyszkowski @ 2014-01-20  9:36 UTC (permalink / raw)
  To: linux-bluetooth

Add testing for improper data sizes for Core service opcodes.
---
 android/ipc-tester.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/android/ipc-tester.c b/android/ipc-tester.c
index cebe751..3d1561d 100644
--- a/android/ipc-tester.c
+++ b/android/ipc-tester.c
@@ -573,6 +573,27 @@ static void ipc_send_tc(const void *data)
 				_servicelist);				\
 	} while (0)
 
+struct vardata {
+	struct hal_hdr hdr;
+	uint8_t buf[BLUEZ_HAL_MTU];
+} __attribute__((packed));
+
+#define test_datasize_valid(_name, _service, _opcode, _hlen, _addatasize, \
+							_servicelist...) \
+	do {								\
+		static struct vardata vdata = {				\
+			.hdr.service_id = _service,			\
+			.hdr.opcode = _opcode,				\
+			.hdr.len = (_hlen) + (_addatasize),		\
+			.buf = {},					\
+		};							\
+		test_generic("Data size "_name,				\
+				ipc_send_tc, setup, teardown,		\
+				&vdata,					\
+				sizeof(vdata.hdr) + (_hlen) + (_addatasize),\
+				_servicelist);				\
+	} while (0)
+
 struct regmod_msg register_bt_msg = {
 	.header = {
 		.service_id = HAL_SERVICE_ID_CORE,
@@ -686,5 +707,19 @@ int main(int argc, char *argv[])
 
 	test_opcode_valid("A2DP", HAL_SERVICE_ID_A2DP, 0x03, 0,
 			HAL_SERVICE_ID_BLUETOOTH, HAL_SERVICE_ID_A2DP);
+
+	/* check for valid data size */
+	test_datasize_valid("CORE Register+", HAL_SERVICE_ID_CORE,
+			HAL_OP_REGISTER_MODULE,
+			sizeof(struct hal_cmd_register_module), 1);
+	test_datasize_valid("CORE Register-", HAL_SERVICE_ID_CORE,
+			HAL_OP_REGISTER_MODULE,
+			sizeof(struct hal_cmd_register_module), -1);
+	test_datasize_valid("CORE Unregister+", HAL_SERVICE_ID_CORE,
+			HAL_OP_UNREGISTER_MODULE,
+			sizeof(struct hal_cmd_register_module), 1);
+	test_datasize_valid("CORE Unregister-", HAL_SERVICE_ID_CORE,
+			HAL_OP_UNREGISTER_MODULE,
+			sizeof(struct hal_cmd_register_module), -1);
 	return tester_run();
 }
-- 
1.8.5.2


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

* [PATCHv5 11/11] android/ipc-tester: Add cases for BT message data size
  2014-01-20  9:35 [PATCHv5 00/11] IPC negative tester Jakub Tyszkowski
                   ` (9 preceding siblings ...)
  2014-01-20  9:36 ` [PATCHv5 10/11] android/ipc-tester: Add cases for Core message data size Jakub Tyszkowski
@ 2014-01-20  9:36 ` Jakub Tyszkowski
  2014-01-20 22:26 ` [PATCHv5 00/11] IPC negative tester Szymon Janc
  11 siblings, 0 replies; 13+ messages in thread
From: Jakub Tyszkowski @ 2014-01-20  9:36 UTC (permalink / raw)
  To: linux-bluetooth

This patch adds sending invalid size data for each of
Bluetooth service opcodes.
---
 android/ipc-tester.c | 143 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 143 insertions(+)

diff --git a/android/ipc-tester.c b/android/ipc-tester.c
index 3d1561d..ed0dd10 100644
--- a/android/ipc-tester.c
+++ b/android/ipc-tester.c
@@ -721,5 +721,148 @@ int main(int argc, char *argv[])
 	test_datasize_valid("CORE Unregister-", HAL_SERVICE_ID_CORE,
 			HAL_OP_UNREGISTER_MODULE,
 			sizeof(struct hal_cmd_register_module), -1);
+
+	/* check for valid data size for BLUETOOTH */
+	test_datasize_valid("BT Enable+", HAL_SERVICE_ID_BLUETOOTH,
+			HAL_OP_ENABLE,
+			0, 1,
+			HAL_SERVICE_ID_BLUETOOTH);
+	test_datasize_valid("BT Disable+", HAL_SERVICE_ID_BLUETOOTH,
+			HAL_OP_DISABLE,
+			0, 1,
+			HAL_SERVICE_ID_BLUETOOTH);
+	test_datasize_valid("BT Get Adapter Props+", HAL_SERVICE_ID_BLUETOOTH,
+			HAL_OP_GET_ADAPTER_PROPS,
+			0, 1,
+			HAL_SERVICE_ID_BLUETOOTH);
+	test_datasize_valid("BT Get Adapter Prop+", HAL_SERVICE_ID_BLUETOOTH,
+			HAL_OP_GET_ADAPTER_PROP,
+			sizeof(struct hal_cmd_get_adapter_prop), 1,
+			HAL_SERVICE_ID_BLUETOOTH);
+	test_datasize_valid("BT Get Adapter Prop-", HAL_SERVICE_ID_BLUETOOTH,
+			HAL_OP_GET_ADAPTER_PROP,
+			sizeof(struct hal_cmd_get_adapter_prop), -1,
+			HAL_SERVICE_ID_BLUETOOTH);
+	test_datasize_valid("BT Set Adapter Prop+", HAL_SERVICE_ID_BLUETOOTH,
+			HAL_OP_SET_ADAPTER_PROP,
+			sizeof(struct hal_cmd_set_adapter_prop), 1,
+			HAL_SERVICE_ID_BLUETOOTH);
+	test_datasize_valid("BT Set Adapter Prop-", HAL_SERVICE_ID_BLUETOOTH,
+			HAL_OP_SET_ADAPTER_PROP,
+			sizeof(struct hal_cmd_set_adapter_prop), -1,
+			HAL_SERVICE_ID_BLUETOOTH);
+	test_datasize_valid("BT Get Remote Props+", HAL_SERVICE_ID_BLUETOOTH,
+			HAL_OP_GET_REMOTE_DEVICE_PROPS,
+			sizeof(struct hal_cmd_get_remote_device_props), 1,
+			HAL_SERVICE_ID_BLUETOOTH);
+	test_datasize_valid("BT Get Remote Props-", HAL_SERVICE_ID_BLUETOOTH,
+			HAL_OP_GET_REMOTE_DEVICE_PROPS,
+			sizeof(struct hal_cmd_get_remote_device_props), -1,
+			HAL_SERVICE_ID_BLUETOOTH);
+	test_datasize_valid("BT Get Remote Prop+", HAL_SERVICE_ID_BLUETOOTH,
+			HAL_OP_GET_REMOTE_DEVICE_PROP,
+			sizeof(struct hal_cmd_get_remote_device_prop), 1,
+			HAL_SERVICE_ID_BLUETOOTH);
+	test_datasize_valid("BT Get Remote Prop-", HAL_SERVICE_ID_BLUETOOTH,
+			HAL_OP_GET_REMOTE_DEVICE_PROP,
+			sizeof(struct hal_cmd_get_remote_device_prop), -1,
+			HAL_SERVICE_ID_BLUETOOTH);
+	test_datasize_valid("BT Set Remote Prop+", HAL_SERVICE_ID_BLUETOOTH,
+			HAL_OP_SET_REMOTE_DEVICE_PROP,
+			sizeof(struct hal_cmd_set_remote_device_prop), 1,
+			HAL_SERVICE_ID_BLUETOOTH);
+	test_datasize_valid("BT Set Remote Prop-", HAL_SERVICE_ID_BLUETOOTH,
+			HAL_OP_SET_REMOTE_DEVICE_PROP,
+			sizeof(struct hal_cmd_set_remote_device_prop), -1,
+			HAL_SERVICE_ID_BLUETOOTH);
+	test_datasize_valid("BT Get Remote SV Rec+", HAL_SERVICE_ID_BLUETOOTH,
+			HAL_OP_GET_REMOTE_SERVICE_REC,
+			sizeof(struct hal_cmd_get_remote_service_rec), 1,
+			HAL_SERVICE_ID_BLUETOOTH);
+	test_datasize_valid("BT Get Remote SV Rec-", HAL_SERVICE_ID_BLUETOOTH,
+			HAL_OP_GET_REMOTE_SERVICE_REC,
+			sizeof(struct hal_cmd_get_remote_service_rec), -1,
+			HAL_SERVICE_ID_BLUETOOTH);
+	test_datasize_valid("BT Get Remote Services+", HAL_SERVICE_ID_BLUETOOTH,
+			HAL_OP_GET_REMOTE_SERVICES,
+			sizeof(struct hal_cmd_get_remote_services), 1,
+			HAL_SERVICE_ID_BLUETOOTH);
+	test_datasize_valid("BT Get Remote Services-", HAL_SERVICE_ID_BLUETOOTH,
+			HAL_OP_GET_REMOTE_SERVICES,
+			sizeof(struct hal_cmd_get_remote_services), -1,
+			HAL_SERVICE_ID_BLUETOOTH);
+	test_datasize_valid("BT Start Discovery+", HAL_SERVICE_ID_BLUETOOTH,
+			HAL_OP_START_DISCOVERY,
+			0, 1,
+			HAL_SERVICE_ID_BLUETOOTH);
+	test_datasize_valid("BT Cancel Discovery+", HAL_SERVICE_ID_BLUETOOTH,
+			HAL_OP_CANCEL_DISCOVERY,
+			0, 1,
+			HAL_SERVICE_ID_BLUETOOTH);
+	test_datasize_valid("BT Create Bond+", HAL_SERVICE_ID_BLUETOOTH,
+			HAL_OP_CREATE_BOND,
+			sizeof(struct hal_cmd_create_bond), 1,
+			HAL_SERVICE_ID_BLUETOOTH);
+	test_datasize_valid("BT Create Bond-", HAL_SERVICE_ID_BLUETOOTH,
+			HAL_OP_CREATE_BOND,
+			sizeof(struct hal_cmd_create_bond), -1,
+			HAL_SERVICE_ID_BLUETOOTH);
+	test_datasize_valid("BT Remove Bond+", HAL_SERVICE_ID_BLUETOOTH,
+			HAL_OP_REMOVE_BOND,
+			sizeof(struct hal_cmd_remove_bond), 1,
+			HAL_SERVICE_ID_BLUETOOTH);
+	test_datasize_valid("BT Remove Bond-", HAL_SERVICE_ID_BLUETOOTH,
+			HAL_OP_REMOVE_BOND,
+			sizeof(struct hal_cmd_remove_bond), -1,
+			HAL_SERVICE_ID_BLUETOOTH);
+	test_datasize_valid("BT Cancel Bond+", HAL_SERVICE_ID_BLUETOOTH,
+			HAL_OP_CANCEL_BOND,
+			sizeof(struct hal_cmd_cancel_bond), 1,
+			HAL_SERVICE_ID_BLUETOOTH);
+	test_datasize_valid("BT Cancel Bond-", HAL_SERVICE_ID_BLUETOOTH,
+			HAL_OP_CANCEL_BOND,
+			sizeof(struct hal_cmd_cancel_bond), -1,
+			HAL_SERVICE_ID_BLUETOOTH);
+	test_datasize_valid("BT Pin Reply+", HAL_SERVICE_ID_BLUETOOTH,
+			HAL_OP_PIN_REPLY,
+			sizeof(struct hal_cmd_pin_reply), 1,
+			HAL_SERVICE_ID_BLUETOOTH);
+	test_datasize_valid("BT Pin Reply-", HAL_SERVICE_ID_BLUETOOTH,
+			HAL_OP_PIN_REPLY,
+			sizeof(struct hal_cmd_pin_reply), -1,
+			HAL_SERVICE_ID_BLUETOOTH);
+	test_datasize_valid("BT SSP Reply+", HAL_SERVICE_ID_BLUETOOTH,
+			HAL_OP_SSP_REPLY,
+			sizeof(struct hal_cmd_ssp_reply), 1,
+			HAL_SERVICE_ID_BLUETOOTH);
+	test_datasize_valid("BT SSP Reply-", HAL_SERVICE_ID_BLUETOOTH,
+			HAL_OP_SSP_REPLY,
+			sizeof(struct hal_cmd_ssp_reply), -1,
+			HAL_SERVICE_ID_BLUETOOTH);
+	test_datasize_valid("BT DUT Mode Conf+", HAL_SERVICE_ID_BLUETOOTH,
+			HAL_OP_DUT_MODE_CONF,
+			sizeof(struct hal_cmd_dut_mode_conf), 1,
+			HAL_SERVICE_ID_BLUETOOTH);
+	test_datasize_valid("BT DUT Mode Conf-", HAL_SERVICE_ID_BLUETOOTH,
+			HAL_OP_DUT_MODE_CONF,
+			sizeof(struct hal_cmd_dut_mode_conf), -1,
+			HAL_SERVICE_ID_BLUETOOTH);
+	test_datasize_valid("BT DUT Mode Send+", HAL_SERVICE_ID_BLUETOOTH,
+			HAL_OP_DUT_MODE_SEND,
+			sizeof(struct hal_cmd_dut_mode_send), 1,
+			HAL_SERVICE_ID_BLUETOOTH);
+	test_datasize_valid("BT DUT Mode Send-", HAL_SERVICE_ID_BLUETOOTH,
+			HAL_OP_DUT_MODE_SEND,
+			sizeof(struct hal_cmd_dut_mode_send), -1,
+			HAL_SERVICE_ID_BLUETOOTH);
+	test_datasize_valid("BT LE Test+", HAL_SERVICE_ID_BLUETOOTH,
+			HAL_OP_LE_TEST_MODE,
+			sizeof(struct hal_cmd_le_test_mode), 1,
+			HAL_SERVICE_ID_BLUETOOTH);
+	test_datasize_valid("BT LE Test-", HAL_SERVICE_ID_BLUETOOTH,
+			HAL_OP_LE_TEST_MODE,
+			sizeof(struct hal_cmd_le_test_mode), -1,
+			HAL_SERVICE_ID_BLUETOOTH);
+
 	return tester_run();
 }
-- 
1.8.5.2


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

* Re: [PATCHv5 00/11] IPC negative tester
  2014-01-20  9:35 [PATCHv5 00/11] IPC negative tester Jakub Tyszkowski
                   ` (10 preceding siblings ...)
  2014-01-20  9:36 ` [PATCHv5 11/11] android/ipc-tester: Add cases for BT " Jakub Tyszkowski
@ 2014-01-20 22:26 ` Szymon Janc
  11 siblings, 0 replies; 13+ messages in thread
From: Szymon Janc @ 2014-01-20 22:26 UTC (permalink / raw)
  To: Jakub Tyszkowski; +Cc: linux-bluetooth

Hi Jakub,

On Monday 20 January 2014 10:35:59 Jakub Tyszkowski wrote:
> Following patchset adds IPC negative tester framework along with test cases
> checking IPC's behaviour on daemon side. Expected daemon's behaviour is to
> shut down gracefully in case of receiving invalid IPC data.
> 
> v2 changes:
>   * fixed few indentation issues
>   * fixed missing __attribute__((packed))
>   * fixed amount of data written for 'malformed data' test case
>   * fixed opcode for 'invalid service' test case
>   * added patch(8) with more 'malformed data' cases
> 
> v3 changes:
>   * changed license to GPL
>   * changed 'ipc-negative-tester' name to 'ipc-tester'
> 
> v4 changes:
>   * fixed typo in first test case and last commit's message
>   * fixed daemon shutdown handler function
> 
> v5 changes:
>   * added clean up in case of setup failure
>   * added test execution macro enhancement for easy data creation
>   * added test cases for core BT interfaces (Patches: 9, 10, 11)
> 
> Jakub Tyszkowski (11):
>   android/ipc-tester: Skeleton for ipc negative tester
>   android/ipc-tester: Run daemon in separate process
>   android/ipc-tester: Add IPC initialization
>   android/ipc-tester: Add daemon shutdown handler
>   android/ipc-tester: Add sending test data with ipc
>   android/ipc-tester: Register services
>   android/ipc-tester: Add basic test cases for IPC's daemon site
>   android/ipc-tester: Add more cases for malformed data
>   android/ipc-tester: Add cases for service opcode boundaries
>   android/ipc-tester: Add cases for Core message data size
>   android/ipc-tester: Add cases for BT message data size
> 
>  .gitignore           |   1 +
>  android/Makefile.am  |  17 +
>  android/ipc-tester.c | 868
> +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 886
> insertions(+)
>  create mode 100644 android/ipc-tester.c
> 

All patches in this set have been applied, thanks.

-- 
Szymon K. Janc
szymon.janc@gmail.com

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

end of thread, other threads:[~2014-01-20 22:26 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-20  9:35 [PATCHv5 00/11] IPC negative tester Jakub Tyszkowski
2014-01-20  9:36 ` [PATCHv5 01/11] android/ipc-tester: Skeleton for ipc " Jakub Tyszkowski
2014-01-20  9:36 ` [PATCHv5 02/11] android/ipc-tester: Run daemon in separate process Jakub Tyszkowski
2014-01-20  9:36 ` [PATCHv5 03/11] android/ipc-tester: Add IPC initialization Jakub Tyszkowski
2014-01-20  9:36 ` [PATCHv5 04/11] android/ipc-tester: Add daemon shutdown handler Jakub Tyszkowski
2014-01-20  9:36 ` [PATCHv5 05/11] android/ipc-tester: Add sending test data with ipc Jakub Tyszkowski
2014-01-20  9:36 ` [PATCHv5 06/11] android/ipc-tester: Register services Jakub Tyszkowski
2014-01-20  9:36 ` [PATCHv5 07/11] android/ipc-tester: Add basic test cases for IPC's daemon site Jakub Tyszkowski
2014-01-20  9:36 ` [PATCHv5 08/11] android/ipc-tester: Add more cases for malformed data Jakub Tyszkowski
2014-01-20  9:36 ` [PATCHv5 09/11] android/ipc-tester: Add cases for service opcode boundaries Jakub Tyszkowski
2014-01-20  9:36 ` [PATCHv5 10/11] android/ipc-tester: Add cases for Core message data size Jakub Tyszkowski
2014-01-20  9:36 ` [PATCHv5 11/11] android/ipc-tester: Add cases for BT " Jakub Tyszkowski
2014-01-20 22:26 ` [PATCHv5 00/11] IPC negative tester Szymon Janc

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.