Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/2] unit: Add initial tests for sdp_extract_attr()
@ 2013-01-08 18:43 Anderson Lizardo
  2013-01-08 18:43 ` [PATCH BlueZ 2/2] lib: Fix SDP_TEXT_STR16/SDP_URL_STR16 parsing Anderson Lizardo
  2013-01-08 19:10 ` [PATCH BlueZ 1/2] unit: Add initial tests for sdp_extract_attr() Marcel Holtmann
  0 siblings, 2 replies; 11+ messages in thread
From: Anderson Lizardo @ 2013-01-08 18:43 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Anderson Lizardo

These tests do not use the full SDP PDU building code because they try
to catch errors on SDP "extraction" code, which may not appear on a
response PDU (but still cause hard to find bugs).
---
 unit/test-sdp.c |   27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/unit/test-sdp.c b/unit/test-sdp.c
index 315a5cd..61449aa 100644
--- a/unit/test-sdp.c
+++ b/unit/test-sdp.c
@@ -754,6 +754,31 @@ static void test_sdp(gconstpointer data)
 	g_free(test->pdu_list);
 }
 
+static void test_sdp_extract_attr(void)
+{
+	const struct sdp_pdu pdus[] = {
+		raw_pdu(SDP_DATA_NIL),
+		raw_pdu(SDP_TEXT_STR8, 0x04, 'A', 'B', 'C', 'D'),
+		raw_pdu(SDP_TEXT_STR16, 0x00, 0x04, 'A', 'B', 'C', 'D'),
+		{ },
+	};
+	int i;
+
+	for (i = 0; pdus[i].valid; i++) {
+		sdp_data_t *d;
+		int size = 0;
+
+		if (g_test_verbose() == TRUE)
+			g_print("dtd=0x%02x\n", *(char *) pdus[i].raw_data);
+
+		d = sdp_extract_attr(pdus[i].raw_data, pdus[i].raw_size, &size,
+									NULL);
+		g_assert(d != NULL);
+		g_assert_cmpuint(size, ==, pdus[i].raw_size);
+		sdp_data_free(d);
+	}
+}
+
 int main(int argc, char *argv[])
 {
 	g_test_init(&argc, &argv, NULL);
@@ -2709,5 +2734,7 @@ int main(int argc, char *argv[])
 			0x08, 0x09, 0x00, 0x01, 0x35, 0x03, 0x19, 0x11,
 			0x06, 0x00));
 
+	g_test_add_func("/MISC/sdp_extract_attr", test_sdp_extract_attr);
+
 	return g_test_run();
 }
-- 
1.7.9.5


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

end of thread, other threads:[~2013-01-09 15:14 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-08 18:43 [PATCH BlueZ 1/2] unit: Add initial tests for sdp_extract_attr() Anderson Lizardo
2013-01-08 18:43 ` [PATCH BlueZ 2/2] lib: Fix SDP_TEXT_STR16/SDP_URL_STR16 parsing Anderson Lizardo
2013-01-08 19:13   ` Marcel Holtmann
2013-01-08 20:27     ` Anderson Lizardo
2013-01-08 22:41       ` Marcel Holtmann
2013-01-08 23:05   ` [PATCH v2 BlueZ] " Anderson Lizardo
2013-01-09  2:25     ` Marcel Holtmann
2013-01-08 19:10 ` [PATCH BlueZ 1/2] unit: Add initial tests for sdp_extract_attr() Marcel Holtmann
2013-01-08 20:45   ` Anderson Lizardo
2013-01-08 22:46     ` Marcel Holtmann
2013-01-09 15:14       ` Anderson Lizardo

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