All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ] iso-tester: Introduce tests for Disconnect/Reconnect
@ 2022-08-15 19:04 Luiz Augusto von Dentz
  2022-08-15 21:27 ` [BlueZ] " bluez.test.bot
  2022-08-16 23:20 ` [PATCH BlueZ] " patchwork-bot+bluetooth
  0 siblings, 2 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2022-08-15 19:04 UTC (permalink / raw)
  To: linux-bluetooth

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

This introduces a test that do use shutdown to disconnect an ISO socket
and then another one that attempts to reconnect it again to emulate
upper profile transitions.
---
 tools/iso-tester.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 80 insertions(+)

diff --git a/tools/iso-tester.c b/tools/iso-tester.c
index df46bc953f37..e4950ead7c69 100644
--- a/tools/iso-tester.c
+++ b/tools/iso-tester.c
@@ -136,6 +136,7 @@ struct test_data {
 	unsigned int io_id[2];
 	uint8_t client_num;
 	int step;
+	bool reconnect;
 };
 
 struct iso_client_data {
@@ -146,6 +147,7 @@ struct iso_client_data {
 	bool server;
 	bool bcast;
 	bool defer;
+	bool disconnect;
 };
 
 static void mgmt_debug(const char *str, void *user_data)
@@ -611,6 +613,18 @@ static const struct iso_client_data connect_16_2_1_send_recv = {
 	.recv = &send_16_2_1,
 };
 
+static const struct iso_client_data disconnect_16_2_1 = {
+	.qos = QOS_16_2_1,
+	.expect_err = 0,
+	.disconnect = true,
+};
+
+static const struct iso_client_data reconnect_16_2_1 = {
+	.qos = QOS_16_2_1,
+	.expect_err = 0,
+	.disconnect = true,
+};
+
 static const struct iso_client_data bcast_16_2_1_send = {
 	.qos = QOS_OUT_16_2_1,
 	.expect_err = 0,
@@ -1142,6 +1156,49 @@ static void iso_send(struct test_data *data, GIOChannel *io)
 		iso_recv(data, io);
 }
 
+static void setup_connect(struct test_data *data, uint8_t num, GIOFunc func);
+static gboolean iso_connect_cb(GIOChannel *io, GIOCondition cond,
+							gpointer user_data);
+
+static gboolean iso_disconnected(GIOChannel *io, GIOCondition cond,
+							gpointer user_data)
+{
+	struct test_data *data = user_data;
+
+	data->io_id[0] = 0;
+
+	if (cond & G_IO_HUP) {
+		tester_print("Successfully disconnected");
+
+		if (data->reconnect) {
+			data->reconnect = false;
+			setup_connect(data, 0, iso_connect_cb);
+			return FALSE;
+		}
+
+		tester_test_passed();
+	} else
+		tester_test_failed();
+
+	return FALSE;
+}
+
+static void iso_shutdown(struct test_data *data, GIOChannel *io)
+{
+	int sk, cl;
+
+	sk = g_io_channel_unix_get_fd(io);
+	cl = dup(sk);
+
+	data->io_id[0] = g_io_add_watch(io, G_IO_HUP, iso_disconnected, data);
+
+	/* Shutdown clone fd so the original fd don't HUP immediately and
+	 * properly wait for socket to be closed.
+	 */
+	shutdown(cl, SHUT_RDWR);
+	close(cl);
+}
+
 static gboolean iso_connect(GIOChannel *io, GIOCondition cond,
 							gpointer user_data)
 {
@@ -1195,6 +1252,8 @@ static gboolean iso_connect(GIOChannel *io, GIOCondition cond,
 			iso_send(data, io);
 		else if (isodata->recv)
 			iso_recv(data, io);
+		else if (isodata->disconnect)
+			iso_shutdown(data, io);
 		else
 			tester_test_passed();
 	}
@@ -1306,6 +1365,19 @@ static void test_connect(const void *test_data)
 	setup_connect(data, 0, iso_connect_cb);
 }
 
+static void setup_reconnect(struct test_data *data, uint8_t num, GIOFunc func)
+{
+	data->reconnect = true;
+	setup_connect(data, num, func);
+}
+
+static void test_reconnect(const void *test_data)
+{
+	struct test_data *data = tester_get_data();
+
+	setup_reconnect(data, 0, iso_connect_cb);
+}
+
 static void test_defer(const void *test_data)
 {
 	struct test_data *data = tester_get_data();
@@ -1726,6 +1798,14 @@ int main(int argc, char *argv[])
 							setup_powered,
 							test_connect);
 
+	test_iso("ISO Disconnect - Success", &disconnect_16_2_1,
+							setup_powered,
+							test_connect);
+
+	test_iso("ISO Reconnect - Success", &reconnect_16_2_1,
+							setup_powered,
+							test_reconnect);
+
 	test_iso("ISO Broadcaster - Success", &bcast_16_2_1_send, setup_powered,
 							test_bcast);
 	test_iso("ISO Broadcaster BIG 0x01 - Success", &bcast_1_16_2_1_send,
-- 
2.37.2


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

* RE: [BlueZ] iso-tester: Introduce tests for Disconnect/Reconnect
  2022-08-15 19:04 [PATCH BlueZ] iso-tester: Introduce tests for Disconnect/Reconnect Luiz Augusto von Dentz
@ 2022-08-15 21:27 ` bluez.test.bot
  2022-08-16 23:20 ` [PATCH BlueZ] " patchwork-bot+bluetooth
  1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2022-08-15 21:27 UTC (permalink / raw)
  To: linux-bluetooth, luiz.dentz

[-- Attachment #1: Type: text/plain, Size: 1049 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=667762

---Test result---

Test Summary:
CheckPatch                    PASS      1.21 seconds
GitLint                       PASS      0.71 seconds
Prep - Setup ELL              PASS      32.82 seconds
Build - Prep                  PASS      0.83 seconds
Build - Configure             PASS      10.46 seconds
Build - Make                  PASS      962.41 seconds
Make Check                    PASS      13.13 seconds
Make Check w/Valgrind         PASS      342.14 seconds
Make Distcheck                PASS      289.07 seconds
Build w/ext ELL - Configure   PASS      10.59 seconds
Build w/ext ELL - Make        PASS      98.66 seconds
Incremental Build w/ patches  PASS      0.00 seconds
Scan Build                    PASS      582.45 seconds



---
Regards,
Linux Bluetooth


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

* Re: [PATCH BlueZ] iso-tester: Introduce tests for Disconnect/Reconnect
  2022-08-15 19:04 [PATCH BlueZ] iso-tester: Introduce tests for Disconnect/Reconnect Luiz Augusto von Dentz
  2022-08-15 21:27 ` [BlueZ] " bluez.test.bot
@ 2022-08-16 23:20 ` patchwork-bot+bluetooth
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+bluetooth @ 2022-08-16 23:20 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hello:

This patch was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Mon, 15 Aug 2022 12:04:01 -0700 you wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> 
> This introduces a test that do use shutdown to disconnect an ISO socket
> and then another one that attempts to reconnect it again to emulate
> upper profile transitions.
> ---
>  tools/iso-tester.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 80 insertions(+)

Here is the summary with links:
  - [BlueZ] iso-tester: Introduce tests for Disconnect/Reconnect
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=9c3f35d6fd12

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2022-08-16 23:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-15 19:04 [PATCH BlueZ] iso-tester: Introduce tests for Disconnect/Reconnect Luiz Augusto von Dentz
2022-08-15 21:27 ` [BlueZ] " bluez.test.bot
2022-08-16 23:20 ` [PATCH BlueZ] " patchwork-bot+bluetooth

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.