All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/5] unit/test-avctp: Remove DBG calls
@ 2015-03-27  8:49 Luiz Augusto von Dentz
  2015-03-27  8:49 ` [PATCH BlueZ 2/5] unit/test-avrcp: Use tester framework Luiz Augusto von Dentz
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2015-03-27  8:49 UTC (permalink / raw)
  To: linux-bluetooth

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

---
 unit/test-avctp.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/unit/test-avctp.c b/unit/test-avctp.c
index ce52222..689a825 100644
--- a/unit/test-avctp.c
+++ b/unit/test-avctp.c
@@ -220,9 +220,6 @@ static ssize_t handler(struct avctp *session,
 					uint8_t *subunit, uint8_t *operands,
 					size_t operand_count, void *user_data)
 {
-	DBG("transaction %d code %d subunit %d operand_count %zu",
-		transaction, *code, *subunit, operand_count);
-
 	g_assert_cmpint(transaction, ==, 0);
 	g_assert_cmpint(*code, ==, 0);
 	g_assert_cmpint(*subunit, ==, 0);
@@ -238,9 +235,6 @@ static gboolean handler_response(struct avctp *session,
 {
 	struct context *context = user_data;
 
-	DBG("code 0x%02x subunit %d operand_count %zu", code, subunit,
-								operand_count);
-
 	g_assert_cmpint(code, ==, 0x0a);
 	g_assert_cmpint(subunit, ==, 0);
 	g_assert_cmpint(operand_count, ==, 0);
@@ -265,7 +259,6 @@ static void test_server(gconstpointer data)
 
 		ret = avctp_register_pdu_handler(context->session,
 					AVC_OP_VENDORDEP, handler, NULL);
-		DBG("ret %d", ret);
 		g_assert_cmpint(ret, !=, 0);
 	}
 
-- 
2.1.0


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

* [PATCH BlueZ 2/5] unit/test-avrcp: Use tester framework
  2015-03-27  8:49 [PATCH BlueZ 1/5] unit/test-avctp: Remove DBG calls Luiz Augusto von Dentz
@ 2015-03-27  8:49 ` Luiz Augusto von Dentz
  2015-03-27  8:49 ` [PATCH BlueZ 3/5] android/avrcp-lib: Fix test /TP/MPS/BV-06-C Luiz Augusto von Dentz
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2015-03-27  8:49 UTC (permalink / raw)
  To: linux-bluetooth

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

Our tester framework actually produces much better output.
---
 unit/test-avrcp.c | 73 +++++++++++++++++++++----------------------------------
 1 file changed, 28 insertions(+), 45 deletions(-)

diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
index cffba78..b0404c9 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -37,6 +37,7 @@
 #include <glib.h>
 
 #include "src/shared/util.h"
+#include "src/shared/tester.h"
 #include "src/log.h"
 #include "lib/bluetooth.h"
 
@@ -58,7 +59,6 @@ struct test_data {
 };
 
 struct context {
-	GMainLoop *main_loop;
 	struct avrcp *session;
 	guint source;
 	guint browse_source;
@@ -111,14 +111,14 @@ struct context {
 		data.test_name = g_strdup(name);			\
 		data.pdu_list = g_malloc(sizeof(pdus));			\
 		memcpy(data.pdu_list, pdus, sizeof(pdus));		\
-		g_test_add_data_func(name, &data, function);		\
+		tester_add(name, &data, NULL, function, NULL);		\
 	} while (0)
 
 static void test_debug(const char *str, void *user_data)
 {
 	const char *prefix = user_data;
 
-	g_print("%s%s\n", prefix, str);
+	tester_debug("%s%s", prefix, str);
 }
 
 static void test_free(gconstpointer user_data)
@@ -129,6 +129,20 @@ static void test_free(gconstpointer user_data)
 	g_free(data->pdu_list);
 }
 
+static void destroy_context(struct context *context)
+{
+	if (context->source > 0)
+		g_source_remove(context->source);
+
+	if (context->browse_source > 0)
+		g_source_remove(context->browse_source);
+
+	avrcp_shutdown(context->session);
+
+	test_free(context->data);
+	g_free(context);
+}
+
 static gboolean context_quit(gpointer user_data)
 {
 	struct context *context = user_data;
@@ -136,7 +150,9 @@ static gboolean context_quit(gpointer user_data)
 	if (context->process > 0)
 		g_source_remove(context->process);
 
-	g_main_loop_quit(context->main_loop);
+	destroy_context(context);
+
+	tester_test_passed();
 
 	return FALSE;
 }
@@ -154,8 +170,7 @@ static gboolean send_pdu(gpointer user_data)
 	else
 		len = write(context->fd, pdu->data, pdu->size);
 
-	if (g_test_verbose())
-		util_hexdump('<', pdu->data, len, test_debug, "AVRCP: ");
+	util_hexdump('<', pdu->data, len, test_debug, "AVRCP: ");
 
 	g_assert_cmpint(len, ==, pdu->size);
 
@@ -193,7 +208,7 @@ static gboolean test_handler(GIOChannel *channel, GIOCondition cond,
 
 	if (cond & (G_IO_NVAL | G_IO_ERR | G_IO_HUP)) {
 		context->source = 0;
-		g_print("%s: cond %x\n", __func__, cond);
+		tester_debug("%s: cond %x\n", __func__, cond);
 		return FALSE;
 	}
 
@@ -234,7 +249,7 @@ static gboolean browse_test_handler(GIOChannel *channel, GIOCondition cond,
 
 	if (cond & (G_IO_NVAL | G_IO_ERR | G_IO_HUP)) {
 		context->browse_source = 0;
-		g_print("%s: cond %x\n", __func__, cond);
+		tester_debug("%s: cond %x\n", __func__, cond);
 		return FALSE;
 	}
 
@@ -244,8 +259,7 @@ static gboolean browse_test_handler(GIOChannel *channel, GIOCondition cond,
 
 	g_assert(len > 0);
 
-	if (g_test_verbose())
-		util_hexdump('>', buf, len, test_debug, "AVRCP: ");
+	util_hexdump('>', buf, len, test_debug, "AVRCP: ");
 
 	g_assert_cmpint(len, ==, pdu->size);
 
@@ -265,9 +279,6 @@ static struct context *create_context(uint16_t version, gconstpointer data)
 
 	DBG("");
 
-	context->main_loop = g_main_loop_new(NULL, FALSE);
-	g_assert(context->main_loop);
-
 	/* Control channel setup */
 
 	err = socketpair(AF_UNIX, SOCK_SEQPACKET | SOCK_CLOEXEC, 0, sv);
@@ -319,34 +330,11 @@ static struct context *create_context(uint16_t version, gconstpointer data)
 	return context;
 }
 
-static void destroy_context(struct context *context)
-{
-	if (context->source > 0)
-		g_source_remove(context->source);
-
-	avrcp_shutdown(context->session);
-
-	if (context->browse_source > 0)
-		g_source_remove(context->browse_source);
-
-	g_main_loop_unref(context->main_loop);
-
-	test_free(context->data);
-	g_free(context);
-}
-
 static void test_dummy(gconstpointer data)
 {
 	struct context *context =  create_context(0x0100, data);
 
-	destroy_context(context);
-}
-
-static void execute_context(struct context *context)
-{
-	g_main_loop_run(context->main_loop);
-
-	destroy_context(context);
+	context_quit(context);
 }
 
 static bool handle_play(struct avrcp *session, bool pressed, void *user_data)
@@ -877,8 +865,6 @@ static void test_server(gconstpointer data)
 	avrcp_register_player(context->session, &control_ind, NULL, context);
 
 	g_idle_add(send_pdu, context);
-
-	execute_context(context);
 }
 
 static void get_folder_items_rsp(struct avrcp *session, int err,
@@ -1083,16 +1069,13 @@ static void test_client(gconstpointer data)
 
 	if (g_str_equal(context->data->test_name, "/TP/PTH/BV-02-C"))
 		avrcp_send_passthrough(context->session, 0, AVC_FAST_FORWARD);
-
-	execute_context(context);
 }
 
 int main(int argc, char *argv[])
 {
-	g_test_init(&argc, &argv, NULL);
+	tester_init(&argc, &argv);
 
-	if (g_test_verbose())
-		__btd_log_init("*", 0);
+	__btd_log_init("*", 0);
 
 	/* Media Player Selection Commands and Notifications */
 
@@ -2182,5 +2165,5 @@ int main(int argc, char *argv[])
 				0x00, 0x19, 0x58, AVRCP_ABORT_CONTINUING,
 				0x00, 0x00, 0x00));
 
-	return g_test_run();
+	return tester_run();
 }
-- 
2.1.0


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

* [PATCH BlueZ 3/5] android/avrcp-lib: Fix test /TP/MPS/BV-06-C
  2015-03-27  8:49 [PATCH BlueZ 1/5] unit/test-avctp: Remove DBG calls Luiz Augusto von Dentz
  2015-03-27  8:49 ` [PATCH BlueZ 2/5] unit/test-avrcp: Use tester framework Luiz Augusto von Dentz
@ 2015-03-27  8:49 ` Luiz Augusto von Dentz
  2015-03-27  8:49 ` [PATCH BlueZ 4/5] unit/test-avrcp: Remove DBG calls Luiz Augusto von Dentz
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2015-03-27  8:49 UTC (permalink / raw)
  To: linux-bluetooth

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

This fixes the following crash on /TP/MPS/BV-06-C:

Invalid write of size 4
   at 0x414A98: browsing_disconnect_cb (avrcp-lib.c:652)
   by 0x4122B2: handler_free (avctp.c:1121)
   by 0x4E9C7FC: g_slist_foreach (in /usr/lib64/libglib-2.0.so.0.4200.2)
   by 0x4E9C81A: g_slist_free_full (in /usr/lib64/libglib-2.0.so.0.4200.2)
   by 0x413219: avctp_destroy_browsing (avctp.c:1130)
   by 0x4132B4: avctp_channel_destroy (avctp.c:499)
   by 0x4133E0: avctp_unref (avctp.c:729)
   by 0x413682: avctp_shutdown (avctp.c:1650)
   by 0x413682: session_cb (avctp.c:1020)
   by 0x4E7E7FA: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.4200.2)
   by 0x4E7EB97: ??? (in /usr/lib64/libglib-2.0.so.0.4200.2)
   by 0x4E7EEC1: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.4200.2)
   by 0x41D301: tester_run (tester.c:831)
 Address 0x57bc0e8 is 88 bytes inside a block of size 112 free'd
   at 0x4C2ACE9: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x4E8450E: g_free (in /usr/lib64/libglib-2.0.so.0.4200.2)
   by 0x419A75: avrcp_shutdown (avrcp-lib.c:382)
   by 0x40E77E: destroy_context (test-avrcp.c:140)
   by 0x40E82F: context_quit (test-avrcp.c:153)
   by 0x40EA01: get_folder_items_rsp (test-avrcp.c:884)
   by 0x415DA0: get_folder_items_rsp (avrcp-lib.c:2731)
   by 0x413EC1: browsing_response (avctp.c:835)
   by 0x413EC1: session_browsing_cb (avctp.c:883)
   by 0x4E7E7FA: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.4200.2)
   by 0x4E7EB97: ??? (in /usr/lib64/libglib-2.0.so.0.4200.2)
   by 0x4E7EEC1: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.4200.2)
   by 0x41D301: tester_run (tester.c:831)
---
 android/avrcp-lib.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/android/avrcp-lib.c b/android/avrcp-lib.c
index 23dea62..353bee5 100644
--- a/android/avrcp-lib.c
+++ b/android/avrcp-lib.c
@@ -367,6 +367,10 @@ void avrcp_shutdown(struct avrcp *session)
 			avctp_unregister_passthrough_handler(session->conn,
 						session->passthrough_id);
 
+		if (session->browsing_id > 0)
+			avctp_unregister_browsing_pdu_handler(session->conn,
+							session->browsing_id);
+
 		/* clear destroy callback that would call shutdown again */
 		avctp_set_destroy_cb(session->conn, NULL, NULL);
 		avctp_shutdown(session->conn);
-- 
2.1.0


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

* [PATCH BlueZ 4/5] unit/test-avrcp: Remove DBG calls
  2015-03-27  8:49 [PATCH BlueZ 1/5] unit/test-avctp: Remove DBG calls Luiz Augusto von Dentz
  2015-03-27  8:49 ` [PATCH BlueZ 2/5] unit/test-avrcp: Use tester framework Luiz Augusto von Dentz
  2015-03-27  8:49 ` [PATCH BlueZ 3/5] android/avrcp-lib: Fix test /TP/MPS/BV-06-C Luiz Augusto von Dentz
@ 2015-03-27  8:49 ` Luiz Augusto von Dentz
  2015-03-27  8:49 ` [PATCH BlueZ 5/5] unit: Replace use of g_malloc+memcpy with gmemdup Luiz Augusto von Dentz
  2015-03-27 14:36 ` [PATCH BlueZ 1/5] unit/test-avctp: Remove DBG calls Luiz Augusto von Dentz
  4 siblings, 0 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2015-03-27  8:49 UTC (permalink / raw)
  To: linux-bluetooth

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

---
 unit/test-avrcp.c | 70 -------------------------------------------------------
 1 file changed, 70 deletions(-)

diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
index b0404c9..024e38e 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -200,8 +200,6 @@ static gboolean test_handler(GIOChannel *channel, GIOCondition cond,
 	ssize_t len;
 	int fd;
 
-	DBG("");
-
 	pdu = &context->data->pdu_list[context->pdu_offset++];
 
 	g_assert(!pdu->browse);
@@ -241,8 +239,6 @@ static gboolean browse_test_handler(GIOChannel *channel, GIOCondition cond,
 	ssize_t len;
 	int fd;
 
-	DBG("");
-
 	pdu = &context->data->pdu_list[context->pdu_offset++];
 
 	g_assert(pdu->browse);
@@ -277,8 +273,6 @@ static struct context *create_context(uint16_t version, gconstpointer data)
 	GIOChannel *channel;
 	int err, sv[2];
 
-	DBG("");
-
 	/* Control channel setup */
 
 	err = socketpair(AF_UNIX, SOCK_SEQPACKET | SOCK_CLOEXEC, 0, sv);
@@ -339,39 +333,29 @@ static void test_dummy(gconstpointer data)
 
 static bool handle_play(struct avrcp *session, bool pressed, void *user_data)
 {
-	DBG("");
-
 	return true;
 }
 
 static bool handle_volume_up(struct avrcp *session, bool pressed,
 							void *user_data)
 {
-	DBG("");
-
 	return true;
 }
 
 static bool handle_channel_up(struct avrcp *session, bool pressed,
 							void *user_data)
 {
-	DBG("");
-
 	return true;
 }
 
 static bool handle_select(struct avrcp *session, bool pressed, void *user_data)
 {
-	DBG("");
-
 	return true;
 }
 
 static bool handle_vendor_uniq(struct avrcp *session, bool pressed,
 								void *user_data)
 {
-	DBG("");
-
 	return true;
 }
 
@@ -393,8 +377,6 @@ static int get_capabilities(struct avrcp *session, uint8_t transaction,
 static int list_attributes(struct avrcp *session, uint8_t transaction,
 							void *user_data)
 {
-	DBG("");
-
 	avrcp_list_player_attributes_rsp(session, transaction, 0, NULL);
 
 	return 0;
@@ -406,8 +388,6 @@ static int get_attribute_text(struct avrcp *session, uint8_t transaction,
 {
 	const char *text[number];
 
-	DBG("");
-
 	if (number) {
 		memset(text, 0, number);
 		text[0] = "equalizer";
@@ -422,8 +402,6 @@ static int get_attribute_text(struct avrcp *session, uint8_t transaction,
 static int list_values(struct avrcp *session, uint8_t transaction,
 						uint8_t attr, void *user_data)
 {
-	DBG("");
-
 	avrcp_list_player_values_rsp(session, transaction, 0, NULL);
 
 	return -EINVAL;
@@ -435,8 +413,6 @@ static int get_value_text(struct avrcp *session, uint8_t transaction,
 {
 	const char *text[number];
 
-	DBG("");
-
 	if (number) {
 		memset(text, 0, number);
 		text[0] = "on";
@@ -453,8 +429,6 @@ static int get_value(struct avrcp *session, uint8_t transaction,
 {
 	uint8_t values[number];
 
-	DBG("");
-
 	memset(values, 0, number);
 
 	avrcp_get_current_player_value_rsp(session, transaction, number, attrs,
@@ -467,8 +441,6 @@ static int set_value(struct avrcp *session, uint8_t transaction,
 			uint8_t number, uint8_t *attrs, uint8_t *values,
 			void *user_data)
 {
-	DBG("");
-
 	avrcp_set_player_value_rsp(session, transaction);
 
 	return 0;
@@ -477,8 +449,6 @@ static int set_value(struct avrcp *session, uint8_t transaction,
 static int get_play_status(struct avrcp *session, uint8_t transaction,
 							void *user_data)
 {
-	DBG("");
-
 	avrcp_get_play_status_rsp(session, transaction, 0xaaaaaaaa, 0xbbbbbbbb,
 									0x00);
 
@@ -491,8 +461,6 @@ static int get_element_attributes(struct avrcp *session, uint8_t transaction,
 {
 	struct context *context = user_data;
 
-	DBG("");
-
 	if (g_str_has_prefix(context->data->test_name, "/TP/RCR")) {
 		uint8_t params[1024];
 
@@ -513,8 +481,6 @@ static int track_changed(struct avrcp *session, uint8_t transaction,
 	struct context *context = user_data;
 	uint64_t track;
 
-	DBG("");
-
 	if (g_str_equal(context->data->test_name, "/TP/NFY/BV-05-C") ||
 		g_str_equal(context->data->test_name, "/TP/NFY/BV-08-C"))
 		memset(&track, 0, sizeof(track));
@@ -537,8 +503,6 @@ static int settings_changed(struct avrcp *session, uint8_t transaction,
 {
 	uint8_t settings[3];
 
-	DBG("");
-
 	settings[0] = 0x01;
 	settings[1] = 0x01;
 	settings[2] = 0x02;
@@ -557,8 +521,6 @@ static int settings_changed(struct avrcp *session, uint8_t transaction,
 static int available_players_changed(struct avrcp *session, uint8_t transaction,
 					uint32_t interval, void *user_data)
 {
-	DBG("");
-
 	avrcp_register_notification_rsp(session, transaction, AVC_CTYPE_INTERIM,
 					AVRCP_EVENT_AVAILABLE_PLAYERS_CHANGED,
 					NULL, 0);
@@ -575,8 +537,6 @@ static int addressed_player_changed(struct avrcp *session, uint8_t transaction,
 {
 	uint16_t player[2];
 
-	DBG("");
-
 	player[0] = 0x0001;
 	player[1] = 0x0001;
 
@@ -600,8 +560,6 @@ static int uids_changed(struct avrcp *session, uint8_t transaction,
 	struct context *context = user_data;
 	uint16_t counter;
 
-	DBG("");
-
 	if (g_str_equal(context->data->test_name, "/TP/MCN/CB/BV-09-C"))
 		counter = 0x0000;
 	else
@@ -628,8 +586,6 @@ static int now_playing_content_changed(struct avrcp *session,
 					uint8_t transaction, uint32_t interval,
 					void *user_data)
 {
-	DBG("");
-
 	avrcp_register_notification_rsp(session, transaction, AVC_CTYPE_INTERIM,
 					AVRCP_EVENT_NOW_PLAYING_CONTENT_CHANGED,
 					NULL, 0);
@@ -646,8 +602,6 @@ static int volume_changed(struct avrcp *session, uint8_t transaction,
 {
 	uint8_t volume = 0x00;
 
-	DBG("");
-
 	avrcp_register_notification_rsp(session, transaction, AVC_CTYPE_INTERIM,
 					AVRCP_EVENT_VOLUME_CHANGED,
 					&volume, sizeof(volume));
@@ -665,8 +619,6 @@ static int register_notification(struct avrcp *session, uint8_t transaction,
 					uint8_t event, uint32_t interval,
 					void *user_data)
 {
-	DBG("");
-
 	switch (event) {
 	case AVRCP_EVENT_TRACK_CHANGED:
 		return track_changed(session, transaction, interval, user_data);
@@ -695,8 +647,6 @@ static int register_notification(struct avrcp *session, uint8_t transaction,
 static int set_volume(struct avrcp *session, uint8_t transaction,
 					uint8_t volume, void *user_data)
 {
-	DBG("");
-
 	avrcp_set_volume_rsp(session, transaction, volume);
 
 	return 0;
@@ -708,8 +658,6 @@ static int set_addressed(struct avrcp *session, uint8_t transaction,
 	struct context *context = user_data;
 	uint8_t status;
 
-	DBG("");
-
 	if (g_str_equal(context->data->test_name, "/TP/MPS/BI-01-C"))
 		status = AVRCP_STATUS_INVALID_PLAYER_ID;
 	else
@@ -726,8 +674,6 @@ static int set_browsed(struct avrcp *session, uint8_t transaction,
 	struct context *context = user_data;
 	const char *folders[1] = { "Filesystem" };
 
-	DBG("");
-
 	if (g_str_equal(context->data->test_name, "/TP/MPS/BI-02-C"))
 		avrcp_set_browsed_player_rsp(session, transaction,
 						AVRCP_STATUS_INVALID_PLAYER_ID,
@@ -747,8 +693,6 @@ static int get_folder_items(struct avrcp *session, uint8_t transaction,
 {
 	struct context *context = user_data;
 
-	DBG("");
-
 	if (g_str_equal(context->data->test_name, "/TP/MCN/CB/BI-02-C"))
 		return -ERANGE;
 
@@ -765,8 +709,6 @@ static int change_path(struct avrcp *session, uint8_t transaction,
 					uint16_t counter, uint8_t direction,
 					uint64_t uid, void *user_data)
 {
-	DBG("");
-
 	if (!uid)
 		return -ENOTDIR;
 
@@ -783,8 +725,6 @@ static int get_item_attributes(struct avrcp *session, uint8_t transaction,
 	struct context *context = user_data;
 	uint8_t status;
 
-	DBG("");
-
 	if (g_str_equal(context->data->test_name, "/TP/MCN/CB/BI-05-C"))
 		status = AVRCP_STATUS_UID_CHANGED;
 	else
@@ -799,8 +739,6 @@ static int get_item_attributes(struct avrcp *session, uint8_t transaction,
 static int play_item(struct avrcp *session, uint8_t transaction, uint8_t scope,
 			uint64_t uid, uint16_t counter, void *user_data)
 {
-	DBG("");
-
 	if (!uid)
 		return -ENOENT;
 
@@ -812,8 +750,6 @@ static int play_item(struct avrcp *session, uint8_t transaction, uint8_t scope,
 static int search(struct avrcp *session, uint8_t transaction,
 					const char *string, void *user_data)
 {
-	DBG("");
-
 	avrcp_search_rsp(session, transaction, AVRCP_STATUS_SUCCESS, 0xaabb, 0);
 
 	return 0;
@@ -823,8 +759,6 @@ static int add_to_now_playing(struct avrcp *session, uint8_t transaction,
 				uint8_t scope, uint64_t uid, uint16_t counter,
 				void *user_data)
 {
-	DBG("");
-
 	if (!uid)
 		return -ENOENT;
 
@@ -873,8 +807,6 @@ static void get_folder_items_rsp(struct avrcp *session, int err,
 {
 	struct context *context = user_data;
 
-	DBG("");
-
 	g_assert_cmpint(err, ==, 0);
 	g_assert_cmpint(counter, ==, 0xabcd);
 	g_assert_cmpint(number, ==, 0);
@@ -899,8 +831,6 @@ static bool register_notification_rsp(struct avrcp *session, int err,
 {
 	struct context *context = user_data;
 
-	DBG("");
-
 	g_assert_cmpint(err, ==, 0);
 
 	switch (event) {
-- 
2.1.0


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

* [PATCH BlueZ 5/5] unit: Replace use of g_malloc+memcpy with gmemdup
  2015-03-27  8:49 [PATCH BlueZ 1/5] unit/test-avctp: Remove DBG calls Luiz Augusto von Dentz
                   ` (2 preceding siblings ...)
  2015-03-27  8:49 ` [PATCH BlueZ 4/5] unit/test-avrcp: Remove DBG calls Luiz Augusto von Dentz
@ 2015-03-27  8:49 ` Luiz Augusto von Dentz
  2015-03-27 14:36 ` [PATCH BlueZ 1/5] unit/test-avctp: Remove DBG calls Luiz Augusto von Dentz
  4 siblings, 0 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2015-03-27  8:49 UTC (permalink / raw)
  To: linux-bluetooth

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

This seems to fix problems of make check not working in 32 bit systems
with gcc 5.0.
---
 unit/test-avctp.c | 3 +--
 unit/test-avdtp.c | 3 +--
 unit/test-avrcp.c | 3 +--
 unit/test-gatt.c  | 3 +--
 unit/test-hfp.c   | 6 ++----
 unit/test-hog.c   | 3 +--
 unit/test-sdp.c   | 3 +--
 unit/test-uhid.c  | 3 +--
 8 files changed, 9 insertions(+), 18 deletions(-)

diff --git a/unit/test-avctp.c b/unit/test-avctp.c
index 689a825..3bc3569 100644
--- a/unit/test-avctp.c
+++ b/unit/test-avctp.c
@@ -77,8 +77,7 @@ struct context {
 		};							\
 		static struct test_data data;				\
 		data.test_name = g_strdup(name);			\
-		data.pdu_list = g_malloc(sizeof(pdus));			\
-		memcpy(data.pdu_list, pdus, sizeof(pdus));		\
+		data.pdu_list = g_memdup(pdus, sizeof(pdus));		\
 		tester_add(name, &data, NULL, function, NULL);		\
 	} while (0)
 
diff --git a/unit/test-avdtp.c b/unit/test-avdtp.c
index 58628a7..dd8aed7 100644
--- a/unit/test-avdtp.c
+++ b/unit/test-avdtp.c
@@ -80,8 +80,7 @@ struct test_data {
 		};							\
 		static struct test_data data;				\
 		data.test_name = g_strdup(name);			\
-		data.pdu_list = g_malloc(sizeof(pdus));			\
-		memcpy(data.pdu_list, pdus, sizeof(pdus));		\
+		data.pdu_list = g_memdup(pdus, sizeof(pdus));		\
 		tester_add(name, &data, NULL, function, NULL);		\
 	} while (0)
 
diff --git a/unit/test-avrcp.c b/unit/test-avrcp.c
index 024e38e..a610ad5 100644
--- a/unit/test-avrcp.c
+++ b/unit/test-avrcp.c
@@ -109,8 +109,7 @@ struct context {
 		};							\
 		static struct test_data data;				\
 		data.test_name = g_strdup(name);			\
-		data.pdu_list = g_malloc(sizeof(pdus));			\
-		memcpy(data.pdu_list, pdus, sizeof(pdus));		\
+		data.pdu_list = g_memdup(pdus, sizeof(pdus));		\
 		tester_add(name, &data, NULL, function, NULL);		\
 	} while (0)
 
diff --git a/unit/test-gatt.c b/unit/test-gatt.c
index 92ab6dc..5cb2e9f 100644
--- a/unit/test-gatt.c
+++ b/unit/test-gatt.c
@@ -102,8 +102,7 @@ struct context {
 		data.uuid = bt_uuid;					\
 		data.step = test_step;					\
 		data.source_db = db;					\
-		data.pdu_list = g_malloc(sizeof(pdus));			\
-		memcpy(data.pdu_list, pdus, sizeof(pdus));		\
+		data.pdu_list = g_memdup(pdus, sizeof(pdus));		\
 		tester_add(name, &data, NULL, function, NULL);		\
 	} while (0)
 
diff --git a/unit/test-hfp.c b/unit/test-hfp.c
index face9a4..66966ce 100644
--- a/unit/test-hfp.c
+++ b/unit/test-hfp.c
@@ -95,9 +95,8 @@ struct test_data {
 		};							\
 		static struct test_data data;				\
 		data.test_name = g_strdup(name);			\
-		data.pdu_list = g_malloc(sizeof(pdus));			\
+		data.pdu_list = g_memdup(pdus, sizeof(pdus));		\
 		data.result_func = result_function;			\
-		memcpy(data.pdu_list, pdus, sizeof(pdus));		\
 		g_test_add_data_func(name, &data, function);		\
 		data.test_handler = test_handler;			\
 	} while (0)
@@ -110,10 +109,9 @@ struct test_data {
 		};							\
 		static struct test_data data;				\
 		data.test_name = g_strdup(name);			\
-		data.pdu_list = g_malloc(sizeof(pdus));			\
+		data.pdu_list = g_memdup(pdus, sizeof(pdus));		\
 		data.hf_result_func = result_func;			\
 		data.response_func = response_function;			\
-		memcpy(data.pdu_list, pdus, sizeof(pdus));		\
 		g_test_add_data_func(name, &data, function);		\
 		data.test_handler = test_hf_handler;			\
 	} while (0)
diff --git a/unit/test-hog.c b/unit/test-hog.c
index 2a25d09..778f087 100644
--- a/unit/test-hog.c
+++ b/unit/test-hog.c
@@ -81,8 +81,7 @@ struct context {
 		};		\
 		static struct test_data data;      \
 		data.test_name = g_strdup(name);   \
-		data.pdu_list = g_malloc(sizeof(pdus));			\
-		memcpy(data.pdu_list, pdus, sizeof(pdus));		\
+		data.pdu_list = g_memdup(pdus, sizeof(pdus));		\
 		tester_add(name, &data, NULL, function, NULL);     \
 	} while (0)
 
diff --git a/unit/test-sdp.c b/unit/test-sdp.c
index a89dbfc..b4ef4d1 100644
--- a/unit/test-sdp.c
+++ b/unit/test-sdp.c
@@ -77,8 +77,7 @@ struct test_data {
 		};							\
 		static struct test_data data;				\
 		data.mtu = _mtu;					\
-		data.pdu_list = g_malloc(sizeof(pdus));			\
-		memcpy(data.pdu_list, pdus, sizeof(pdus));		\
+		data.pdu_list = g_memdup(pdus, sizeof(pdus));		\
 		g_test_add_data_func(name, &data, test_sdp);		\
 	} while (0)
 
diff --git a/unit/test-uhid.c b/unit/test-uhid.c
index 85e1356..b48e0fa 100644
--- a/unit/test-uhid.c
+++ b/unit/test-uhid.c
@@ -73,8 +73,7 @@ struct context {
 		};							\
 		static struct test_data data;				\
 		data.test_name = g_strdup(name);			\
-		data.pdu_list = g_malloc(sizeof(pdus));			\
-		memcpy(data.pdu_list, pdus, sizeof(pdus));		\
+		data.pdu_list = g_memdup(pdus, sizeof(pdus));		\
 		g_test_add_data_func(name, &data, function);		\
 	} while (0)
 
-- 
2.1.0


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

* Re: [PATCH BlueZ 1/5] unit/test-avctp: Remove DBG calls
  2015-03-27  8:49 [PATCH BlueZ 1/5] unit/test-avctp: Remove DBG calls Luiz Augusto von Dentz
                   ` (3 preceding siblings ...)
  2015-03-27  8:49 ` [PATCH BlueZ 5/5] unit: Replace use of g_malloc+memcpy with gmemdup Luiz Augusto von Dentz
@ 2015-03-27 14:36 ` Luiz Augusto von Dentz
  4 siblings, 0 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2015-03-27 14:36 UTC (permalink / raw)
  To: linux-bluetooth

Hi,

On Fri, Mar 27, 2015 at 10:49 AM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> ---
>  unit/test-avctp.c | 7 -------
>  1 file changed, 7 deletions(-)
>
> diff --git a/unit/test-avctp.c b/unit/test-avctp.c
> index ce52222..689a825 100644
> --- a/unit/test-avctp.c
> +++ b/unit/test-avctp.c
> @@ -220,9 +220,6 @@ static ssize_t handler(struct avctp *session,
>                                         uint8_t *subunit, uint8_t *operands,
>                                         size_t operand_count, void *user_data)
>  {
> -       DBG("transaction %d code %d subunit %d operand_count %zu",
> -               transaction, *code, *subunit, operand_count);
> -
>         g_assert_cmpint(transaction, ==, 0);
>         g_assert_cmpint(*code, ==, 0);
>         g_assert_cmpint(*subunit, ==, 0);
> @@ -238,9 +235,6 @@ static gboolean handler_response(struct avctp *session,
>  {
>         struct context *context = user_data;
>
> -       DBG("code 0x%02x subunit %d operand_count %zu", code, subunit,
> -                                                               operand_count);
> -
>         g_assert_cmpint(code, ==, 0x0a);
>         g_assert_cmpint(subunit, ==, 0);
>         g_assert_cmpint(operand_count, ==, 0);
> @@ -265,7 +259,6 @@ static void test_server(gconstpointer data)
>
>                 ret = avctp_register_pdu_handler(context->session,
>                                         AVC_OP_VENDORDEP, handler, NULL);
> -               DBG("ret %d", ret);
>                 g_assert_cmpint(ret, !=, 0);
>         }
>
> --
> 2.1.0

Applied.


-- 
Luiz Augusto von Dentz

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

end of thread, other threads:[~2015-03-27 14:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-27  8:49 [PATCH BlueZ 1/5] unit/test-avctp: Remove DBG calls Luiz Augusto von Dentz
2015-03-27  8:49 ` [PATCH BlueZ 2/5] unit/test-avrcp: Use tester framework Luiz Augusto von Dentz
2015-03-27  8:49 ` [PATCH BlueZ 3/5] android/avrcp-lib: Fix test /TP/MPS/BV-06-C Luiz Augusto von Dentz
2015-03-27  8:49 ` [PATCH BlueZ 4/5] unit/test-avrcp: Remove DBG calls Luiz Augusto von Dentz
2015-03-27  8:49 ` [PATCH BlueZ 5/5] unit: Replace use of g_malloc+memcpy with gmemdup Luiz Augusto von Dentz
2015-03-27 14:36 ` [PATCH BlueZ 1/5] unit/test-avctp: Remove DBG calls Luiz Augusto von Dentz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.