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

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).