linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH obexd 1/4] gobex: always set CONNECTION_ID to 1 on unit tests
@ 2011-12-05 12:35 Luiz Augusto von Dentz
  2011-12-05 12:35 ` [PATCH obexd 2/4] gobex: fix wrong name of test_get_rsp_eagain Luiz Augusto von Dentz
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2011-12-05 12:35 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This simplify the creation of new test by not requiring different
variables for every connection response.
---
 unit/test-gobex-transfer.c |   41 ++++++++++++-----------------------------
 1 files changed, 12 insertions(+), 29 deletions(-)

diff --git a/unit/test-gobex-transfer.c b/unit/test-gobex-transfer.c
index f769fc6..ae3e28a 100644
--- a/unit/test-gobex-transfer.c
+++ b/unit/test-gobex-transfer.c
@@ -82,18 +82,6 @@ static guint8 conn_rsp[] = { G_OBEX_RSP_SUCCESS | FINAL_BIT, 0x00, 0x0c,
 					0x10, 0x00, 0x10, 0x00,
 					G_OBEX_HDR_CONNECTION, 0x00, 0x00,
 					0x00, 0x01 };
-static guint8 conn_rsp_2[] = { G_OBEX_RSP_SUCCESS | FINAL_BIT, 0x00, 0x0c,
-					0x10, 0x00, 0x10, 0x00,
-					G_OBEX_HDR_CONNECTION, 0x00, 0x00,
-					0x00, 0x02 };
-static guint8 conn_rsp_3[] = { G_OBEX_RSP_SUCCESS | FINAL_BIT, 0x00, 0x0c,
-					0x10, 0x00, 0x10, 0x00,
-					G_OBEX_HDR_CONNECTION, 0x00, 0x00,
-					0x00, 0x03 };
-static guint8 conn_rsp_4[] = { G_OBEX_RSP_SUCCESS | FINAL_BIT, 0x00, 0x0c,
-					0x10, 0x00, 0x10, 0x00,
-					G_OBEX_HDR_CONNECTION, 0x00, 0x00,
-					0x00, 0x04 };
 
 static guint8 unavailable_rsp[] = { G_OBEX_RSP_SERVICE_UNAVAILABLE | FINAL_BIT,
 					0x00, 0x03 };
@@ -104,8 +92,9 @@ static guint8 conn_get_req_first[] = { G_OBEX_OP_GET | FINAL_BIT, 0x00, 0x28,
 	'f', 'o', 'o', '/', 'b', 'a', 'r', '\0',
 	G_OBEX_HDR_NAME, 0x00, 0x15,
 	0, 'f', 0, 'i', 0, 'l', 0, 'e', 0, '.', 0, 't', 0, 'x', 0, 't', 0, 0 };
-static guint8 conn_get_req_first_2[] = { G_OBEX_OP_GET | FINAL_BIT, 0x00, 0x28,
-	G_OBEX_HDR_CONNECTION, 0x00, 0x00, 0x00, 0x02,
+
+static guint8 conn_get_req_wrg[] = { G_OBEX_OP_GET | FINAL_BIT, 0x00, 0x28,
+	G_OBEX_HDR_CONNECTION, 0x00, 0x00, 0x00, 0xFF,
 	G_OBEX_HDR_TYPE, 0x00, 0x0b,
 	'f', 'o', 'o', '/', 'b', 'a', 'r', '\0',
 	G_OBEX_HDR_NAME, 0x00, 0x15,
@@ -119,14 +108,6 @@ static guint8 conn_put_req_first[] = { G_OBEX_OP_PUT, 0x00, 0x35,
 	0, 'f', 0, 'i', 0, 'l', 0, 'e', 0, '.', 0, 't', 0, 'x', 0, 't', 0, 0,
 	G_OBEX_HDR_BODY, 0x00, 0x0d,
 	0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
-static guint8 conn_put_req_first_3[] = { G_OBEX_OP_PUT, 0x00, 0x35,
-	G_OBEX_HDR_CONNECTION, 0x00, 0x00, 0x00, 0x03,
-	G_OBEX_HDR_TYPE, 0x00, 0x0b,
-	'f', 'o', 'o', '/', 'b', 'a', 'r', '\0',
-	G_OBEX_HDR_NAME, 0x00, 0x15,
-	0, 'f', 0, 'i', 0, 'l', 0, 'e', 0, '.', 0, 't', 0, 'x', 0, 't', 0, 0,
-	G_OBEX_HDR_BODY, 0x00, 0x0d,
-	0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
 
 static guint8 hdr_type[] = "foo/bar";
 static guint8 hdr_app[] = { 0, 1, 2, 3 };
@@ -983,7 +964,9 @@ static void handle_conn_rsp(GObex *obex, GObexPacket *req,
 		return;
 	}
 
-	rsp = g_obex_packet_new(G_OBEX_RSP_SUCCESS, TRUE, G_OBEX_HDR_INVALID);
+	rsp = g_obex_packet_new(G_OBEX_RSP_SUCCESS, TRUE,
+						G_OBEX_HDR_CONNECTION, 1,
+						G_OBEX_HDR_INVALID);
 	g_obex_send(obex, rsp, &d->err);
 }
 
@@ -1093,10 +1076,10 @@ static void test_conn_get_rsp(void)
 	guint io_id, timer_id;
 	GObex *obex;
 	struct test_data d = { 0, NULL, {
-			{ conn_rsp_2, sizeof(conn_rsp_2) },
+			{ conn_rsp, sizeof(conn_rsp) },
 			{ get_rsp_first, sizeof(get_rsp_first) },
 			{ get_rsp_last, sizeof(get_rsp_last) } }, {
-			{ conn_get_req_first_2, sizeof(conn_get_req_first_2) },
+			{ conn_get_req_first, sizeof(conn_get_req_first) },
 			{ get_req_last, sizeof(get_req_last) },
 			{ NULL, 0 } } };
 
@@ -1199,10 +1182,10 @@ static void test_conn_put_rsp(void)
 	guint io_id, timer_id;
 	GObex *obex;
 	struct test_data d = { 0, NULL, {
-			{ conn_rsp_3, sizeof(conn_rsp_3) },
+			{ conn_rsp, sizeof(conn_rsp) },
 			{ put_rsp_first, sizeof(put_rsp_first) },
 			{ put_rsp_last, sizeof(put_rsp_last) } }, {
-			{ conn_put_req_first_3, sizeof(conn_put_req_first_3) },
+			{ conn_put_req_first, sizeof(conn_put_req_first) },
 			{ put_req_last, sizeof(put_req_last) },
 			{ NULL, 0 } } };
 
@@ -1247,9 +1230,9 @@ static void test_conn_get_wrg_rsp(void)
 	guint io_id, timer_id;
 	GObex *obex;
 	struct test_data d = { 0, NULL, {
-			{ conn_rsp_4, sizeof(conn_rsp_4) },
+			{ conn_rsp, sizeof(conn_rsp) },
 			{ unavailable_rsp, sizeof(unavailable_rsp) } }, {
-			{ conn_get_req_first, sizeof(conn_get_req_first) },
+			{ conn_get_req_wrg, sizeof(conn_get_req_wrg) },
 			{ NULL, 0 } } };
 
 	create_endpoints(&obex, &io, SOCK_STREAM);
-- 
1.7.7.3


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

* [PATCH obexd 2/4] gobex: fix wrong name of test_get_rsp_eagain
  2011-12-05 12:35 [PATCH obexd 1/4] gobex: always set CONNECTION_ID to 1 on unit tests Luiz Augusto von Dentz
@ 2011-12-05 12:35 ` Luiz Augusto von Dentz
  2011-12-05 12:35 ` [PATCH obexd 3/4] gobex: remove unused delay on test_put_req_random Luiz Augusto von Dentz
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2011-12-05 12:35 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 unit/test-gobex-transfer.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/unit/test-gobex-transfer.c b/unit/test-gobex-transfer.c
index ae3e28a..518fd94 100644
--- a/unit/test-gobex-transfer.c
+++ b/unit/test-gobex-transfer.c
@@ -1349,7 +1349,7 @@ int main(int argc, char *argv[])
 	g_test_add_func("/gobex/test_get_rsp_delay", test_get_rsp_delay);
 
 	g_test_add_func("/gobex/test_put_req_eagain", test_put_req_eagain);
-	g_test_add_func("/gobex/test_put_req_eagain", test_get_rsp_eagain);
+	g_test_add_func("/gobex/test_get_req_eagain", test_get_rsp_eagain);
 
 	g_test_add_func("/gobex/test_put_req_random", test_put_req_random);
 
-- 
1.7.7.3


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

* [PATCH obexd 3/4] gobex: remove unused delay on test_put_req_random
  2011-12-05 12:35 [PATCH obexd 1/4] gobex: always set CONNECTION_ID to 1 on unit tests Luiz Augusto von Dentz
  2011-12-05 12:35 ` [PATCH obexd 2/4] gobex: fix wrong name of test_get_rsp_eagain Luiz Augusto von Dentz
@ 2011-12-05 12:35 ` Luiz Augusto von Dentz
  2011-12-05 12:35 ` [PATCH obexd 4/4] gobex: add unit test for packet PUT request with random data Luiz Augusto von Dentz
  2011-12-08 12:33 ` [PATCH obexd 1/4] gobex: always set CONNECTION_ID to 1 on unit tests Johan Hedberg
  3 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2011-12-05 12:35 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 unit/test-gobex-transfer.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/unit/test-gobex-transfer.c b/unit/test-gobex-transfer.c
index 518fd94..5bdd71b 100644
--- a/unit/test-gobex-transfer.c
+++ b/unit/test-gobex-transfer.c
@@ -465,7 +465,6 @@ static void test_put_req_random(void)
 
 	create_endpoints(&obex, &io, SOCK_STREAM);
 	d.obex = obex;
-	d.provide_delay = 200;
 
 	cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
 	io_id = g_io_add_watch(io, cond, test_io_cb, &d);
-- 
1.7.7.3


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

* [PATCH obexd 4/4] gobex: add unit test for packet PUT request with random data
  2011-12-05 12:35 [PATCH obexd 1/4] gobex: always set CONNECTION_ID to 1 on unit tests Luiz Augusto von Dentz
  2011-12-05 12:35 ` [PATCH obexd 2/4] gobex: fix wrong name of test_get_rsp_eagain Luiz Augusto von Dentz
  2011-12-05 12:35 ` [PATCH obexd 3/4] gobex: remove unused delay on test_put_req_random Luiz Augusto von Dentz
@ 2011-12-05 12:35 ` Luiz Augusto von Dentz
  2011-12-08 12:33 ` [PATCH obexd 1/4] gobex: always set CONNECTION_ID to 1 on unit tests Johan Hedberg
  3 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2011-12-05 12:35 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

---
 unit/test-gobex-transfer.c |   19 ++++++++++++++++---
 1 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/unit/test-gobex-transfer.c b/unit/test-gobex-transfer.c
index 5bdd71b..f677503 100644
--- a/unit/test-gobex-transfer.c
+++ b/unit/test-gobex-transfer.c
@@ -447,7 +447,7 @@ static void handle_get(GObex *obex, GObexPacket *req, gpointer user_data)
 		g_main_loop_quit(d->mainloop);
 }
 
-static void test_put_req_random(void)
+static void test_put_req_random(int sock_type)
 {
 	GIOChannel *io;
 	GIOCondition cond;
@@ -463,7 +463,7 @@ static void test_put_req_random(void)
 				{ put_rsp_first, sizeof(put_rsp_first) },
 				{ put_rsp_last, sizeof(put_rsp_last) } } };
 
-	create_endpoints(&obex, &io, SOCK_STREAM);
+	create_endpoints(&obex, &io, sock_type);
 	d.obex = obex;
 
 	cond = G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL;
@@ -493,6 +493,16 @@ static void test_put_req_random(void)
 	g_assert_no_error(d.err);
 }
 
+static void test_stream_put_req_random(void)
+{
+	test_put_req_random(SOCK_STREAM);
+}
+
+static void test_packet_put_req_random(void)
+{
+	test_put_req_random(SOCK_SEQPACKET);
+}
+
 static void test_put_req_eagain(void)
 {
 	GIOChannel *io;
@@ -1350,7 +1360,10 @@ int main(int argc, char *argv[])
 	g_test_add_func("/gobex/test_put_req_eagain", test_put_req_eagain);
 	g_test_add_func("/gobex/test_get_req_eagain", test_get_rsp_eagain);
 
-	g_test_add_func("/gobex/test_put_req_random", test_put_req_random);
+	g_test_add_func("/gobex/test_stream_put_req_random",
+						test_stream_put_req_random);
+	g_test_add_func("/gobex/test_packet_put_req_random",
+						test_packet_put_req_random);
 
 	g_test_add_func("/gobex/test_conn_get_req", test_conn_get_req);
 	g_test_add_func("/gobex/test_conn_get_rsp", test_conn_get_rsp);
-- 
1.7.7.3


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

* Re: [PATCH obexd 1/4] gobex: always set CONNECTION_ID to 1 on unit tests
  2011-12-05 12:35 [PATCH obexd 1/4] gobex: always set CONNECTION_ID to 1 on unit tests Luiz Augusto von Dentz
                   ` (2 preceding siblings ...)
  2011-12-05 12:35 ` [PATCH obexd 4/4] gobex: add unit test for packet PUT request with random data Luiz Augusto von Dentz
@ 2011-12-08 12:33 ` Johan Hedberg
  3 siblings, 0 replies; 5+ messages in thread
From: Johan Hedberg @ 2011-12-08 12:33 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hi Luiz,

On Mon, Dec 05, 2011, Luiz Augusto von Dentz wrote:
> This simplify the creation of new test by not requiring different
> variables for every connection response.
> ---
>  unit/test-gobex-transfer.c |   41 ++++++++++++-----------------------------
>  1 files changed, 12 insertions(+), 29 deletions(-)

All four patches have been applied. Thanks.

Johan

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

end of thread, other threads:[~2011-12-08 12:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-05 12:35 [PATCH obexd 1/4] gobex: always set CONNECTION_ID to 1 on unit tests Luiz Augusto von Dentz
2011-12-05 12:35 ` [PATCH obexd 2/4] gobex: fix wrong name of test_get_rsp_eagain Luiz Augusto von Dentz
2011-12-05 12:35 ` [PATCH obexd 3/4] gobex: remove unused delay on test_put_req_random Luiz Augusto von Dentz
2011-12-05 12:35 ` [PATCH obexd 4/4] gobex: add unit test for packet PUT request with random data Luiz Augusto von Dentz
2011-12-08 12:33 ` [PATCH obexd 1/4] gobex: always set CONNECTION_ID to 1 on unit tests Johan Hedberg

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