linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH Bluez v3 0/2] unit/test-gatt: Add initial server role tests.
@ 2014-11-24 20:05 Arman Uguray
  2014-11-24 20:05 ` [PATCH BlueZ v3 1/2] unit/test-gatt: Add /TP/GAC/SR/BV-01-C test Arman Uguray
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Arman Uguray @ 2014-11-24 20:05 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Arman Uguray

This patch set adds the "Server Configuration" and "Discover All Primary
Services" test cases using bt_gatt_server.

*v1: - Removed COEX test type for now.
     - Added macro for the first incoming "Exchange MTU" request PDU for
       server tests.

*v2: Fixed compile warning.

*v3: Added test case description from the TS to the commit messages.

Arman Uguray (2):
  unit/test-gatt: Add /TP/GAC/SR/BV-01-C test
  unit/test-gatt: Add /TP/GAD/SR/BV-01-C test

 unit/test-gatt.c | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 97 insertions(+), 1 deletion(-)

-- 
2.1.0.rc2.206.gedb03e5


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

* [PATCH BlueZ v3 1/2] unit/test-gatt: Add /TP/GAC/SR/BV-01-C test
  2014-11-24 20:05 [PATCH Bluez v3 0/2] unit/test-gatt: Add initial server role tests Arman Uguray
@ 2014-11-24 20:05 ` Arman Uguray
  2014-11-24 20:05 ` [PATCH BlueZ v3 2/2] unit/test-gatt: Add /TP/GAD/SR/BV-01-C test Arman Uguray
  2014-11-24 20:57 ` [PATCH Bluez v3 0/2] unit/test-gatt: Add initial server role tests Luiz Augusto von Dentz
  2 siblings, 0 replies; 4+ messages in thread
From: Arman Uguray @ 2014-11-24 20:05 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Arman Uguray

Verify that a Generic Attribute Profile server can accept an Exchange
MTU Request and respond with an Exchange MTU response.
---
 unit/test-gatt.c | 46 +++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 45 insertions(+), 1 deletion(-)

diff --git a/unit/test-gatt.c b/unit/test-gatt.c
index 7923c8b..58885a4 100644
--- a/unit/test-gatt.c
+++ b/unit/test-gatt.c
@@ -40,6 +40,9 @@
 #include "src/shared/att.h"
 #include "src/shared/gatt-helpers.h"
 #include "src/shared/gatt-client.h"
+#include "src/shared/queue.h"
+#include "src/shared/gatt-db.h"
+#include "src/shared/gatt-server.h"
 
 struct test_pdu {
 	bool valid;
@@ -72,7 +75,9 @@ struct test_data {
 struct context {
 	GMainLoop *main_loop;
 	struct bt_gatt_client *client;
+	struct bt_gatt_server *server;
 	struct bt_att *att;
+	struct gatt_db *db;
 	guint source;
 	guint process;
 	int fd;
@@ -114,6 +119,9 @@ struct context {
 #define define_test_client(name, function, bt_services, test_step, args...)\
 	define_test(name, function, CLIENT, NULL, bt_services, test_step, args)
 
+#define define_test_server(name, function, bt_services, test_step, args...)\
+	define_test(name, function, SERVER, NULL, bt_services, test_step, args)
+
 #define SERVICE_DATA_1_PDU						\
 		raw_pdu(0x02, 0x00, 0x02),				\
 		raw_pdu(0x03, 0x00, 0x02),				\
@@ -144,6 +152,8 @@ struct context {
 		raw_pdu(0x04, 0x08, 0x00, 0x08, 0x00),			\
 		raw_pdu(0x05, 0x01, 0x08, 0x00, 0x01, 0x29)
 
+#define SERVER_MTU_EXCHANGE_PDU raw_pdu(0x02, 0x17, 0x00);
+
 static bt_uuid_t uuid_16 = {
 	.type = BT_UUID16,
 	.value.u16 = 0x1800
@@ -282,6 +292,7 @@ static gboolean send_pdu(gpointer user_data)
 
 static void context_process(struct context *context)
 {
+	/* Quit the context if we processed the last PDU */
 	if (!context->data->pdu_list[context->pdu_offset].valid) {
 		context_quit(context);
 		return;
@@ -447,6 +458,18 @@ static struct context *create_context(uint16_t mtu, gconstpointer data)
 
 		bt_gatt_exchange_mtu(context->att, mtu, NULL, NULL, NULL);
 		break;
+	case SERVER:
+		context->db = gatt_db_new();
+		g_assert(context->db);
+
+		context->server = bt_gatt_server_new(context->db, att, mtu);
+		g_assert(context->server);
+
+		if (g_test_verbose())
+			bt_gatt_server_set_debug(context->server, print_debug,
+						"bt_gatt_server:", NULL);
+		bt_att_unref(att);
+		break;
 	case CLIENT:
 		context->client = bt_gatt_client_new(att, mtu);
 		g_assert(context->client);
@@ -500,6 +523,8 @@ static void destroy_context(struct context *context)
 		g_source_remove(context->source);
 
 	bt_gatt_client_unref(context->client);
+	bt_gatt_server_unref(context->server);
+	gatt_db_destroy(context->db);
 
 	if (context->att)
 		bt_att_unref(context->att);
@@ -577,6 +602,22 @@ static void test_client(gconstpointer data)
 	execute_context(context);
 }
 
+static void test_server(gconstpointer data)
+{
+	struct context *context = create_context(512, data);
+	ssize_t len;
+	const struct test_pdu pdu = SERVER_MTU_EXCHANGE_PDU;
+
+	len = write(context->fd, pdu.data, pdu.size);
+
+	if (g_test_verbose())
+		util_hexdump('<', pdu.data, len, test_debug, "GATT: ");
+
+	g_assert_cmpint(len, ==, pdu.size);
+
+	execute_context(context);
+}
+
 static void test_search_primary(gconstpointer data)
 {
 	struct context *context = create_context(512, data);
@@ -785,7 +826,10 @@ int main(int argc, char *argv[])
 	 */
 
 	define_test_client("/TP/GAC/CL/BV-01-C", test_client, NULL, NULL,
-				raw_pdu(0x02, 0x00, 0x02));
+						raw_pdu(0x02, 0x00, 0x02));
+
+	define_test_server("/TP/GAC/SR/BV-01-C", test_server, NULL, NULL,
+						raw_pdu(0x03, 0x00, 0x02));
 
 	/*
 	 * Discovery
-- 
2.1.0.rc2.206.gedb03e5


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

* [PATCH BlueZ v3 2/2] unit/test-gatt: Add /TP/GAD/SR/BV-01-C test
  2014-11-24 20:05 [PATCH Bluez v3 0/2] unit/test-gatt: Add initial server role tests Arman Uguray
  2014-11-24 20:05 ` [PATCH BlueZ v3 1/2] unit/test-gatt: Add /TP/GAC/SR/BV-01-C test Arman Uguray
@ 2014-11-24 20:05 ` Arman Uguray
  2014-11-24 20:57 ` [PATCH Bluez v3 0/2] unit/test-gatt: Add initial server role tests Luiz Augusto von Dentz
  2 siblings, 0 replies; 4+ messages in thread
From: Arman Uguray @ 2014-11-24 20:05 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Arman Uguray

Verify that a Generic Attribute Profile server can support a search for
all Primary Services it contains.
---
 unit/test-gatt.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

diff --git a/unit/test-gatt.c b/unit/test-gatt.c
index 58885a4..84925af 100644
--- a/unit/test-gatt.c
+++ b/unit/test-gatt.c
@@ -431,6 +431,42 @@ static void client_ready_cb(bool success, uint8_t att_ecode, void *user_data)
 	context_quit(context);
 }
 
+static void populate_db(struct context *context)
+{
+	struct gatt_db *db = context->db;
+	struct gatt_db_attribute *attr;
+	bt_uuid_t uuid;
+	uint128_t u128 = {
+		.data = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+				0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }
+	};
+
+	/* Service 1 */
+	bt_uuid16_create(&uuid, 0x1800);
+	attr = gatt_db_add_service(db, &uuid, true, 5);
+	gatt_db_service_set_active(attr, true);
+
+	/* Service 2 */
+	bt_uuid16_create(&uuid, 0x1801);
+	attr = gatt_db_add_service(db, &uuid, true, 3);
+	gatt_db_service_set_active(attr, true);
+
+	/* Service 3 */
+	bt_uuid16_create(&uuid, 0x180f);
+	attr = gatt_db_add_service(db, &uuid, false, 5);
+	gatt_db_service_set_active(attr, true);
+
+	/* Service 4 */
+	bt_uuid16_create(&uuid, 0x180d);
+	attr = gatt_db_add_service(db, &uuid, true, 8);
+	gatt_db_service_set_active(attr, true);
+
+	/* Service 5 */
+	bt_uuid128_create(&uuid, u128);
+	attr = gatt_db_add_service(db, &uuid, true, 1);
+	gatt_db_service_set_active(attr, true);
+}
+
 static struct context *create_context(uint16_t mtu, gconstpointer data)
 {
 	struct context *context = g_new0(struct context, 1);
@@ -465,6 +501,8 @@ static struct context *create_context(uint16_t mtu, gconstpointer data)
 		context->server = bt_gatt_server_new(context->db, att, mtu);
 		g_assert(context->server);
 
+		populate_db(context);
+
 		if (g_test_verbose())
 			bt_gatt_server_set_debug(context->server, print_debug,
 						"bt_gatt_server:", NULL);
@@ -852,6 +890,20 @@ int main(int argc, char *argv[])
 			raw_pdu(0x10, 0x97, 0x00, 0xff, 0xff, 0x00, 0x28),
 			raw_pdu(0x01, 0x10, 0x97, 0x00, 0x0a));
 
+	define_test_server("/TP/GAD/SR/BV-01-C", test_server, NULL, NULL,
+			raw_pdu(0x03, 0x00, 0x02),
+			raw_pdu(0x10, 0x01, 0x00, 0xff, 0xff, 0x00, 0x28),
+			raw_pdu(0x11, 0x06, 0x01, 0x00, 0x05, 0x00, 0x00, 0x18,
+					0x06, 0x00, 0x08, 0x00, 0x01, 0x18,
+					0x0e, 0x00, 0x15, 0x00, 0x0d, 0x18),
+			raw_pdu(0x10, 0x16, 0x00, 0xff, 0xff, 0x00, 0x28),
+			raw_pdu(0x11, 0x14, 0x16, 0x00, 0x16, 0x00, 0x0f,
+					0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09,
+					0x08, 0x07, 0x06, 0x05, 0x04, 0x03,
+					0x02, 0x01, 0x00),
+			raw_pdu(0x10, 0x17, 0x00, 0xff, 0xff, 0x00, 0x28),
+			raw_pdu(0x01, 0x10, 0x17, 0x00, 0x0a));
+
 	define_test_att("/TP/GAD/CL/BV-02-C-1", test_search_primary, &uuid_16,
 			NULL,
 			raw_pdu(0x02, 0x00, 0x02),
-- 
2.1.0.rc2.206.gedb03e5


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

* Re: [PATCH Bluez v3 0/2] unit/test-gatt: Add initial server role tests.
  2014-11-24 20:05 [PATCH Bluez v3 0/2] unit/test-gatt: Add initial server role tests Arman Uguray
  2014-11-24 20:05 ` [PATCH BlueZ v3 1/2] unit/test-gatt: Add /TP/GAC/SR/BV-01-C test Arman Uguray
  2014-11-24 20:05 ` [PATCH BlueZ v3 2/2] unit/test-gatt: Add /TP/GAD/SR/BV-01-C test Arman Uguray
@ 2014-11-24 20:57 ` Luiz Augusto von Dentz
  2 siblings, 0 replies; 4+ messages in thread
From: Luiz Augusto von Dentz @ 2014-11-24 20:57 UTC (permalink / raw)
  To: Arman Uguray; +Cc: linux-bluetooth@vger.kernel.org

Hi Arman,

On Mon, Nov 24, 2014 at 10:05 PM, Arman Uguray <armansito@chromium.org> wrote:
> This patch set adds the "Server Configuration" and "Discover All Primary
> Services" test cases using bt_gatt_server.
>
> *v1: - Removed COEX test type for now.
>      - Added macro for the first incoming "Exchange MTU" request PDU for
>        server tests.
>
> *v2: Fixed compile warning.
>
> *v3: Added test case description from the TS to the commit messages.
>
> Arman Uguray (2):
>   unit/test-gatt: Add /TP/GAC/SR/BV-01-C test
>   unit/test-gatt: Add /TP/GAD/SR/BV-01-C test
>
>  unit/test-gatt.c | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 97 insertions(+), 1 deletion(-)
>
> --
> 2.1.0.rc2.206.gedb03e5

Applied, thanks.


-- 
Luiz Augusto von Dentz

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

end of thread, other threads:[~2014-11-24 20:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-24 20:05 [PATCH Bluez v3 0/2] unit/test-gatt: Add initial server role tests Arman Uguray
2014-11-24 20:05 ` [PATCH BlueZ v3 1/2] unit/test-gatt: Add /TP/GAC/SR/BV-01-C test Arman Uguray
2014-11-24 20:05 ` [PATCH BlueZ v3 2/2] unit/test-gatt: Add /TP/GAD/SR/BV-01-C test Arman Uguray
2014-11-24 20:57 ` [PATCH Bluez v3 0/2] unit/test-gatt: Add initial server role tests Luiz Augusto von Dentz

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