public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: "Frédéric Danis" <frederic.danis@collabora.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v2 2/6] unit/test-hfp: Add dial tests for HF
Date: Thu,  9 Oct 2025 21:58:38 +0200	[thread overview]
Message-ID: <20251009195842.776231-2-frederic.danis@collabora.com> (raw)
In-Reply-To: <20251009195842.776231-1-frederic.danis@collabora.com>

This add the following tests:
- /HFP/HF/OCL/BV-01-C
  Initiate a call placed to the last number
- /HFP/HF/OCL/BV-02-C
  Handling ERROR response to a call placed to last number
- /HFP/HF/OCM/BV-01-C
  Initiate a request to place a call with a memory location
- /HFP/HF/OCM/BV-02-C
  Handling ERROR response to a call placed to an empty memory location
- /HFP/HF/OCN/BV-01-C
  HF places a call with a phone number
---
 unit/test-hfp.c | 166 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 166 insertions(+)

diff --git a/unit/test-hfp.c b/unit/test-hfp.c
index 190604ba2..8afb15fa3 100644
--- a/unit/test-hfp.c
+++ b/unit/test-hfp.c
@@ -739,13 +739,62 @@ static void hf_cmd_complete(enum hfp_result res, enum hfp_error cme_err,
 	g_assert_cmpint(res, ==, HFP_RESULT_OK);
 }
 
+static void hf_cmd_error(enum hfp_result res, enum hfp_error cme_err,
+							void *user_data)
+{
+	g_assert_cmpint(res, ==, HFP_RESULT_ERROR);
+}
+
 static void hf_session_ready_cb(enum hfp_result res, enum hfp_error cme_err,
 							void *user_data)
 {
 	struct context *context = user_data;
+	const char *test_name = context->data->test_name;
 
 	g_assert_cmpint(res, ==, HFP_RESULT_OK);
 	context->session.completed = true;
+
+	if (g_str_equal(test_name, "/HFP/HF/OCL/BV-01-C")) {
+		bool ret;
+
+		if (tester_use_debug())
+			tester_debug("calling last dialed number");
+		ret = hfp_hf_dial(context->hfp_hf, "", hf_cmd_complete,
+							context);
+		g_assert(ret);
+	} else if (g_str_equal(test_name, "/HFP/HF/OCL/BV-02-C")) {
+		bool ret;
+
+		if (tester_use_debug())
+			tester_debug("calling last dialed number");
+		ret = hfp_hf_dial(context->hfp_hf, "", hf_cmd_error,
+							context);
+		g_assert(ret);
+	} else if (g_str_equal(test_name, "/HFP/HF/OCM/BV-01-C")) {
+		bool ret;
+
+		if (tester_use_debug())
+			tester_debug("calling memory 1");
+		ret = hfp_hf_dial(context->hfp_hf, ">1", hf_cmd_complete,
+							context);
+		g_assert(ret);
+	} else if (g_str_equal(test_name, "/HFP/HF/OCM/BV-02-C")) {
+		bool ret;
+
+		if (tester_use_debug())
+			tester_debug("calling memory 1");
+		ret = hfp_hf_dial(context->hfp_hf, ">1", hf_cmd_error,
+							context);
+		g_assert(ret);
+	} else if (g_str_equal(test_name, "/HFP/HF/OCN/BV-01-C")) {
+		bool ret;
+
+		if (tester_use_debug())
+			tester_debug("calling number");
+		ret = hfp_hf_dial(context->hfp_hf, "1234567", hf_cmd_complete,
+							context);
+		g_assert(ret);
+	}
 }
 
 static void hf_update_indicator(enum hfp_indicator indicator, uint32_t val,
@@ -836,6 +885,27 @@ static void hf_call_added(uint id, enum hfp_call_status status,
 		g_str_equal(test_name, "/HFP/HF/TCA/BV-02-C")) {
 		g_assert_cmpint(id, ==, 1);
 		g_assert_cmpint(status, ==, CALL_STATUS_INCOMING);
+	} else if (g_str_equal(test_name, "/HFP/HF/OCL/BV-01-C")) {
+		const char *number;
+
+		g_assert_cmpint(id, ==, 1);
+		g_assert_cmpint(status, ==, CALL_STATUS_DIALING);
+		number = hfp_hf_call_get_number(context->hfp_hf, id);
+		g_assert_null(number);
+	} else if (g_str_equal(test_name, "/HFP/HF/OCM/BV-01-C")) {
+		const char *number;
+
+		g_assert_cmpint(id, ==, 1);
+		g_assert_cmpint(status, ==, CALL_STATUS_DIALING);
+		number = hfp_hf_call_get_number(context->hfp_hf, id);
+		g_assert_cmpstr(number, ==, ">1");
+	} else if (g_str_equal(test_name, "/HFP/HF/OCN/BV-01-C")) {
+		const char *number;
+
+		g_assert_cmpint(id, ==, 1);
+		g_assert_cmpint(status, ==, CALL_STATUS_DIALING);
+		number = hfp_hf_call_get_number(context->hfp_hf, id);
+		g_assert_cmpstr(number, ==, "1234567");
 	} else if (g_str_equal(test_name, "/HFP/HF/TCA/BV-04-C")) {
 		bool ret;
 
@@ -917,6 +987,39 @@ static void hf_call_status_updated(uint id, enum hfp_call_status status,
 		if (tester_use_debug())
 			tester_debug("Error: unexpected update");
 		tester_test_failed();
+	} else if (g_str_equal(test_name, "/HFP/HF/OCL/BV-01-C")) {
+		const char *number;
+
+		g_assert_cmpint(id, ==, 1);
+		if (context->session.step == 0)
+			g_assert_cmpint(status, ==, CALL_STATUS_ALERTING);
+		else
+			g_assert_cmpint(status, ==, CALL_STATUS_ACTIVE);
+		number = hfp_hf_call_get_number(context->hfp_hf, id);
+		g_assert_null(number);
+		context->session.step++;
+	} else if (g_str_equal(test_name, "/HFP/HF/OCM/BV-01-C")) {
+		const char *number;
+
+		g_assert_cmpint(id, ==, 1);
+		if (context->session.step == 0)
+			g_assert_cmpint(status, ==, CALL_STATUS_ALERTING);
+		else
+			g_assert_cmpint(status, ==, CALL_STATUS_ACTIVE);
+		number = hfp_hf_call_get_number(context->hfp_hf, id);
+		g_assert_cmpstr(number, ==, ">1");
+		context->session.step++;
+	} else if (g_str_equal(test_name, "/HFP/HF/OCN/BV-01-C")) {
+		const char *number;
+
+		g_assert_cmpint(id, ==, 1);
+		if (context->session.step == 0)
+			g_assert_cmpint(status, ==, CALL_STATUS_ALERTING);
+		else
+			g_assert_cmpint(status, ==, CALL_STATUS_ACTIVE);
+		number = hfp_hf_call_get_number(context->hfp_hf, id);
+		g_assert_cmpstr(number, ==, "1234567");
+		context->session.step++;
 	} else if (g_str_equal(test_name, "/HFP/HF/TCA/BV-01-C")) {
 		const char *number;
 		bool ret;
@@ -1231,6 +1334,69 @@ int main(int argc, char *argv[])
 				'3', ',', '0', '\r', '\n'),
 			data_end());
 
+	/* Initiate a call placed to the last number - HF */
+	define_hf_test("/HFP/HF/OCL/BV-01-C", test_hf_session,
+			NULL, test_hf_session_done,
+			MINIMAL_SLC_SESSION('1', '0', '0', '0'),
+			raw_pdu('\r', '\n', 'O', 'K', '\r', '\n'),
+			frg_pdu('\r', '\n', '+', 'C', 'I', 'E', 'V', ':', ' ',
+				'3', ',', '2', '\r', '\n'),
+			frg_pdu('\r', '\n', '+', 'C', 'I', 'E', 'V', ':', ' ',
+				'3', ',', '3', '\r', '\n'),
+			frg_pdu('\r', '\n', '+', 'C', 'I', 'E', 'V', ':', ' ',
+				'2', ',', '1', '\r', '\n'),
+			frg_pdu('\r', '\n', '+', 'C', 'I', 'E', 'V', ':', ' ',
+				'3', ',', '0', '\r', '\n'),
+			data_end());
+
+	/* Handling ERROR response to a call placed to last number - HF */
+	define_hf_test("/HFP/HF/OCL/BV-02-C", test_hf_session,
+			NULL, test_hf_session_done,
+			MINIMAL_SLC_SESSION('1', '0', '0', '0'),
+			raw_pdu('\r', '\n', 'E', 'R', 'R', 'O', 'R'),
+			frg_pdu('\r', '\n'),
+			data_end());
+
+	/* Initiate a request to place a call with a memory location - HF */
+	define_hf_test("/HFP/HF/OCM/BV-01-C", test_hf_session,
+			NULL, test_hf_session_done,
+			MINIMAL_SLC_SESSION('1', '0', '0', '0'),
+			raw_pdu('\r', '\n', 'O', 'K', '\r', '\n'),
+			frg_pdu('\r', '\n', '+', 'C', 'I', 'E', 'V', ':', ' ',
+				'3', ',', '2', '\r', '\n'),
+			frg_pdu('\r', '\n', '+', 'C', 'I', 'E', 'V', ':', ' ',
+				'3', ',', '3', '\r', '\n'),
+			frg_pdu('\r', '\n', '+', 'C', 'I', 'E', 'V', ':', ' ',
+				'2', ',', '1', '\r', '\n'),
+			frg_pdu('\r', '\n', '+', 'C', 'I', 'E', 'V', ':', ' ',
+				'3', ',', '0', '\r', '\n'),
+			data_end());
+
+	/* Handling ERROR response to a call placed to an empty memory
+	 * location - HF
+	 */
+	define_hf_test("/HFP/HF/OCM/BV-02-C", test_hf_session,
+			NULL, test_hf_session_done,
+			MINIMAL_SLC_SESSION('1', '0', '0', '0'),
+			raw_pdu('\r', '\n', 'E', 'R', 'R', 'O', 'R'),
+			frg_pdu('\r', '\n'),
+			data_end());
+
+	/* HF places a call with a phone number - HF */
+	define_hf_test("/HFP/HF/OCN/BV-01-C", test_hf_session,
+			NULL, test_hf_session_done,
+			MINIMAL_SLC_SESSION('1', '0', '0', '0'),
+			raw_pdu('\r', '\n', 'O', 'K', '\r', '\n'),
+			frg_pdu('\r', '\n', '+', 'C', 'I', 'E', 'V', ':', ' ',
+				'3', ',', '2', '\r', '\n'),
+			frg_pdu('\r', '\n', '+', 'C', 'I', 'E', 'V', ':', ' ',
+				'3', ',', '3', '\r', '\n'),
+			frg_pdu('\r', '\n', '+', 'C', 'I', 'E', 'V', ':', ' ',
+				'2', ',', '1', '\r', '\n'),
+			frg_pdu('\r', '\n', '+', 'C', 'I', 'E', 'V', ':', ' ',
+				'3', ',', '0', '\r', '\n'),
+			data_end());
+
 	/* Transfer Signal Strength Indication - HF */
 	define_hf_test("/HFP/HF/PSI/BV-01-C", test_hf_session,
 			NULL, test_hf_session_done,
-- 
2.43.0


  reply	other threads:[~2025-10-09 19:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-09 19:58 [PATCH BlueZ v2 1/6] shared/hfp: Add dial support Frédéric Danis
2025-10-09 19:58 ` Frédéric Danis [this message]
2025-10-09 19:58 ` [PATCH BlueZ v2 3/6] shared/hfp: Add in-band ring tone setting support Frédéric Danis
2025-10-09 19:58 ` [PATCH BlueZ v2 4/6] unit/test-hfp: Add Answer Incoming Call with In-Band Ring tests for HF Frédéric Danis
2025-10-09 19:58 ` [PATCH BlueZ v2 5/6] unit/test-hfp: Add incoming call prior to connection test Frédéric Danis
2025-10-09 19:58 ` [PATCH BlueZ v2 6/6] unit/test-hfp: Add incoming call interrupted test Frédéric Danis
2025-10-09 21:31 ` [BlueZ,v2,1/6] shared/hfp: Add dial support bluez.test.bot
2025-10-13 16:00 ` [PATCH BlueZ v2 1/6] " patchwork-bot+bluetooth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251009195842.776231-2-frederic.danis@collabora.com \
    --to=frederic.danis@collabora.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox