[PATCH BlueZ 3/3] unit: Make use of tester_monitor to print input/output PDUs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

tester_monitor will forward the data to btmon when -m/--monitor is
enabled which will attempt to decode the PDUs:

= test-gatt: /robustness/unkown-command - init                                                                                                                        11:44:53.464325
= test-gatt: /robustness/unkown-command - setup
= test-gatt: /robustness/unkown-command - setup complete
= test-gatt: /robustness/unkown-command - run
< test-gatt: User Data TX
      ATT: Exchange MTU Request (0x02) len 2
        Client RX MTU: 23
> test-gatt: User Data RX
      ATT: Exchange MTU Response (0x03) len 2
        Server RX MTU: 512
< test-gatt: User Data TX
      ATT: Unknown (0xff) len 1
        00                                               .
= test-gatt: /robustness/unkown-command - test passed
= test-gatt: /robustness/unkown-command - teardown
= test-gatt: /robustness/unkown-command - teardown complete
= test-gatt: /robustness/unkown-command - done
---
 unit/test-avctp.c | 11 ++---------
 unit/test-avdtp.c | 11 ++---------
 unit/test-avrcp.c | 21 +++++++--------------
 unit/test-gatt.c  |  6 +++---
 unit/test-sdp.c   | 11 ++---------
 5 files changed, 16 insertions(+), 44 deletions(-)

diff --git a/unit/test-avctp.c b/unit/test-avctp.c
index 3bc35696d..60fd6ad71 100644
--- a/unit/test-avctp.c
+++ b/unit/test-avctp.c
@@ -81,13 +81,6 @@ struct context {
 		tester_add(name, &data, NULL, function, NULL);		\
 	} while (0)
 
-static void test_debug(const char *str, void *user_data)
-{
-	const char *prefix = user_data;
-
-	tester_debug("%s%s", prefix, str);
-}
-
 static void test_free(gconstpointer user_data)
 {
 	const struct test_data *data = user_data;
@@ -131,7 +124,7 @@ static gboolean send_pdu(gpointer user_data)
 
 	len = write(context->fd, pdu->data, pdu->size);
 
-	util_hexdump('<', pdu->data, len, test_debug, "AVCTP: ");
+	tester_monitor('<', 0x0000, 0x0017, pdu->data, len);
 
 	g_assert_cmpint(len, ==, pdu->size);
 
@@ -172,7 +165,7 @@ static gboolean test_handler(GIOChannel *channel, GIOCondition cond,
 
 	g_assert(len > 0);
 
-	util_hexdump('>', buf, len, test_debug, "AVCTP: ");
+	tester_monitor('>', 0x0000, 0x0017, buf, len);
 
 	g_assert_cmpint(len, ==, pdu->size);
 
diff --git a/unit/test-avdtp.c b/unit/test-avdtp.c
index dd8aed73c..176852ae7 100644
--- a/unit/test-avdtp.c
+++ b/unit/test-avdtp.c
@@ -99,13 +99,6 @@ struct context {
 	const struct test_data *data;
 };
 
-static void test_debug(const char *str, void *user_data)
-{
-	const char *prefix = user_data;
-
-	tester_debug("%s%s", prefix, str);
-}
-
 static void test_free(gconstpointer user_data)
 {
 	const struct test_data *data = user_data;
@@ -158,7 +151,7 @@ static gboolean send_pdu(gpointer user_data)
 
 	len = write(context->fd, pdu->data, pdu->size);
 
-	util_hexdump('<', pdu->data, len, test_debug, "AVDTP: ");
+	tester_monitor('<', 0x0000, 0x0019, pdu->data, len);
 
 	g_assert_cmpint(len, ==, pdu->size);
 
@@ -215,7 +208,7 @@ static gboolean test_handler(GIOChannel *channel, GIOCondition cond,
 
 	g_assert(len > 0);
 
-	util_hexdump('>', buf, len, test_debug, "AVDTP: ");
+	tester_monitor('>', 0x0000, 0x0019, buf, len);
 
 	g_assert_cmpint(len, ==, pdu->size);
 
diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
index 01307e679..9ffd44cfd 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -113,13 +113,6 @@ struct context {
 		tester_add(name, &data, NULL, function, NULL);		\
 	} while (0)
 
-static void test_debug(const char *str, void *user_data)
-{
-	const char *prefix = user_data;
-
-	tester_debug("%s%s", prefix, str);
-}
-
 static void test_free(gconstpointer user_data)
 {
 	const struct test_data *data = user_data;
@@ -164,12 +157,13 @@ static gboolean send_pdu(gpointer user_data)
 
 	pdu = &context->data->pdu_list[context->pdu_offset++];
 
-	if (pdu->browse)
+	if (pdu->browse) {
 		len = write(context->browse_fd, pdu->data, pdu->size);
-	else
+		tester_monitor('<', 0x0000, 0x001b, pdu->data, len);
+	} else {
 		len = write(context->fd, pdu->data, pdu->size);
-
-	util_hexdump('<', pdu->data, len, test_debug, "AVRCP: ");
+		tester_monitor('<', 0x0000, 0x0017, pdu->data, len);
+	}
 
 	g_assert_cmpint(len, ==, pdu->size);
 
@@ -215,8 +209,7 @@ static gboolean test_handler(GIOChannel *channel, GIOCondition cond,
 
 	g_assert(len > 0);
 
-	if (g_test_verbose())
-		util_hexdump('>', buf, len, test_debug, "AVRCP: ");
+	tester_monitor('>', 0x0000, 0x0017, buf, len);
 
 	if (!pdu->continuing)
 		g_assert_cmpint(len, ==, pdu->size);
@@ -254,7 +247,7 @@ static gboolean browse_test_handler(GIOChannel *channel, GIOCondition cond,
 
 	g_assert(len > 0);
 
-	util_hexdump('>', buf, len, test_debug, "AVRCP: ");
+	tester_monitor('>', 0x0000, 0x001b, buf, len);
 
 	g_assert_cmpint(len, ==, pdu->size);
 
diff --git a/unit/test-gatt.c b/unit/test-gatt.c
index c7e28f865..d8d007386 100644
--- a/unit/test-gatt.c
+++ b/unit/test-gatt.c
@@ -382,7 +382,7 @@ static gboolean send_pdu(gpointer user_data)
 
 	len = write(context->fd, pdu->data, pdu->size);
 
-	util_hexdump('<', pdu->data, len, test_debug, "GATT: ");
+	tester_monitor('<', 0x0004, 0x0000, pdu->data, len);
 
 	g_assert_cmpint(len, ==, pdu->size);
 
@@ -440,7 +440,7 @@ static gboolean test_handler(GIOChannel *channel, GIOCondition cond,
 
 	g_assert(len > 0);
 
-	util_hexdump('>', buf, len, test_debug, "GATT: ");
+	tester_monitor('>', 0x0004, 0x0000, buf, len);
 
 	util_hexdump('=', pdu->data, pdu->size, test_debug, "PDU: ");
 
@@ -1910,7 +1910,7 @@ static void test_server(gconstpointer data)
 
 	g_assert_cmpint(len, ==, pdu.size);
 
-	util_hexdump('<', pdu.data, len, test_debug, "GATT: ");
+	tester_monitor('<', 0x0004, 0x0000, pdu.data, len);
 }
 
 static void test_search_primary(gconstpointer data)
diff --git a/unit/test-sdp.c b/unit/test-sdp.c
index ac921a9a0..b67a55189 100644
--- a/unit/test-sdp.c
+++ b/unit/test-sdp.c
@@ -120,13 +120,6 @@ struct context {
 	const struct test_data *data;
 };
 
-static void sdp_debug(const char *str, void *user_data)
-{
-	const char *prefix = user_data;
-
-	tester_debug("%s%s\n", prefix, str);
-}
-
 static void destroy_context(struct context *context)
 {
 	sdp_svcdb_collect_all(context->fd);
@@ -186,7 +179,7 @@ static gboolean server_handler(GIOChannel *channel, GIOCondition cond,
 		return FALSE;
 	}
 
-	util_hexdump('<', buf, len, sdp_debug, "SDP: ");
+	tester_monitor('<', 0x0000, 0x0001, buf, len);
 
 	handle_internal_request(fd, context->data->mtu, buf, len);
 
@@ -254,7 +247,7 @@ static gboolean client_handler(GIOChannel *channel, GIOCondition cond,
 	if (len < 0)
 		return FALSE;
 
-	util_hexdump('>', buf, len, sdp_debug, "SDP: ");
+	tester_monitor('>', 0x0000, 0x0001, buf, len);
 
 	g_assert(len > 0);
 	g_assert((size_t) len == rsp_pdu->raw_size + rsp_pdu->cont_len);
-- 
2.17.1




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux