Skip to contentSkip to conversation

unit/test-hfp: Re-order TS tests in alphabetical order

PATCH Applied Frédéric Danis 3 participants 5 messages Sep 1, 2025 – Sep 4, 2025 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 unit/test-hfp: Re-order TS tests in alphabetical order

This will simplify when looking for a test.

---
 unit/test-hfp.c | 42 +++++++++++++++++++++---------------------
 1 file changed, 21 insertions(+), 21 deletions(-)
unit/test-hfp.c +21 -21
index 9be1b05ae..0a6828b7c 100644
@@ -771,15 +771,7 @@ static void hf_update_indicator(enum hfp_indicator indicator, uint32_t val,
 		return;
 	}
 
-	if (g_str_equal(test_name, "/HFP/HF/TRS/BV-01-C")) {
-		context->session.step++;
-		g_assert_cmpint(indicator, ==, HFP_INDICATOR_SERVICE);
-		g_assert_cmpint(val, ==, context->session.step % 2);
-
-		if (context->session.step == 3)
-			context->data->response_func(HFP_RESULT_OK, 0,
-								context);
-	} else if (g_str_equal(test_name, "/HFP/HF/PSI/BV-01-C")) {
+	if (g_str_equal(test_name, "/HFP/HF/PSI/BV-01-C")) {
 		g_assert_cmpint(indicator, ==, HFP_INDICATOR_SIGNAL);
 		g_assert_cmpint(val, ==, 3);
 		context->data->response_func(HFP_RESULT_OK, 0, context);
@@ -795,6 +787,14 @@ static void hf_update_indicator(enum hfp_indicator indicator, uint32_t val,
 		g_assert_cmpint(indicator, ==, HFP_INDICATOR_BATTCHG);
 		g_assert_cmpint(val, ==, 3);
 		context->data->response_func(HFP_RESULT_OK, 0, context);
+	} else if (g_str_equal(test_name, "/HFP/HF/TRS/BV-01-C")) {
+		context->session.step++;
+		g_assert_cmpint(indicator, ==, HFP_INDICATOR_SERVICE);
+		g_assert_cmpint(val, ==, context->session.step % 2);
+
+		if (context->session.step == 3)
+			context->data->response_func(HFP_RESULT_OK, 0,
+								context);
 	}
 }
 
@@ -1008,18 +1008,6 @@ int main(int argc, char *argv[])
 			MINIMAL_SLC_SESSION,
 			data_end());
 
-	/* Transfer Registration Status - HF */
-	define_hf_test("/HFP/HF/TRS/BV-01-C", test_hf_session,
-			NULL, test_hf_session_done,
-			MINIMAL_SLC_SESSION,
-			frg_pdu('\r', '\n', '+', 'C', 'I', 'E', 'V', ':'),
-			frg_pdu(' ', '1', ',', '1', '\r', '\n'),
-			frg_pdu('\r', '\n', '+', 'C', 'I', 'E', 'V', ':'),
-			frg_pdu(' ', '1', ',', '0', '\r', '\n'),
-			frg_pdu('\r', '\n', '+', 'C', 'I', 'E', 'V', ':'),
-			frg_pdu(' ', '1', ',', '1', '\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,
@@ -1046,5 +1034,17 @@ int main(int argc, char *argv[])
 			frg_pdu(' ', '7', ',', '3', '\r', '\n'),
 			data_end());
 
+	/* Transfer Registration Status - HF */
+	define_hf_test("/HFP/HF/TRS/BV-01-C", test_hf_session,
+			NULL, test_hf_session_done,
+			MINIMAL_SLC_SESSION,
+			frg_pdu('\r', '\n', '+', 'C', 'I', 'E', 'V', ':'),
+			frg_pdu(' ', '1', ',', '1', '\r', '\n'),
+			frg_pdu('\r', '\n', '+', 'C', 'I', 'E', 'V', ':'),
+			frg_pdu(' ', '1', ',', '0', '\r', '\n'),
+			frg_pdu('\r', '\n', '+', 'C', 'I', 'E', 'V', ':'),
+			frg_pdu(' ', '1', ',', '1', '\r', '\n'),
+			data_end());
+
 	return tester_run();
 }
Signature · 1 line
2.43.0
#1 lore raw

PATCH 2/3 shared/hfp: Fix typos

---
 src/shared/hfp.c | 14 +++++++-------
 src/shared/hfp.h |  2 +-
 2 files changed, 8 insertions(+), 8 deletions(-)
src/shared/hfp.c +7 -7
index 71f193f83..d01915ab1 100644
@@ -1576,7 +1576,7 @@ static void ciev_service_cb(uint8_t val, void *user_data)
 
 	if (val < hfp->ag_ind[HFP_INDICATOR_SERVICE].min ||
 			val > hfp->ag_ind[HFP_INDICATOR_SERVICE].max) {
-		DBG(hfp, "hf: Incorrect state %u:", val);
+		DBG(hfp, "hf: Incorrect state: %u", val);
 		return;
 	}
 
@@ -1594,7 +1594,7 @@ static void ciev_call_cb(uint8_t val, void *user_data)
 
 	if (val < hfp->ag_ind[HFP_INDICATOR_CALL].min ||
 			val > hfp->ag_ind[HFP_INDICATOR_CALL].max) {
-		DBG(hfp, "hf: Incorrect call state %u:", val);
+		DBG(hfp, "hf: Incorrect call state: %u", val);
 		return;
 	}
 }
@@ -1607,7 +1607,7 @@ static void ciev_callsetup_cb(uint8_t val, void *user_data)
 
 	if (val < hfp->ag_ind[HFP_INDICATOR_CALLSETUP].min ||
 			val > hfp->ag_ind[HFP_INDICATOR_CALLSETUP].max) {
-		DBG(hfp, "hf: Incorrect call setup state %u:", val);
+		DBG(hfp, "hf: Incorrect call setup state: %u", val);
 		return;
 	}
 }
@@ -1620,7 +1620,7 @@ static void ciev_callheld_cb(uint8_t val, void *user_data)
 
 	if (val < hfp->ag_ind[HFP_INDICATOR_CALLHELD].min ||
 			val > hfp->ag_ind[HFP_INDICATOR_CALLHELD].max) {
-		DBG(hfp, "hf: Incorrect call held state %u:", val);
+		DBG(hfp, "hf: Incorrect call held state: %u", val);
 		return;
 	}
 }
@@ -1633,7 +1633,7 @@ static void ciev_signal_cb(uint8_t val, void *user_data)
 
 	if (val < hfp->ag_ind[HFP_INDICATOR_SIGNAL].min ||
 			val > hfp->ag_ind[HFP_INDICATOR_SIGNAL].max) {
-		DBG(hfp, "hf: Incorrect signal value %u:", val);
+		DBG(hfp, "hf: Incorrect signal value: %u", val);
 		return;
 	}
 
@@ -1651,7 +1651,7 @@ static void ciev_roam_cb(uint8_t val, void *user_data)
 
 	if (val < hfp->ag_ind[HFP_INDICATOR_ROAM].min ||
 			val > hfp->ag_ind[HFP_INDICATOR_ROAM].max) {
-		DBG(hfp, "hf: Incorrect roaming state %u:", val);
+		DBG(hfp, "hf: Incorrect roaming state: %u", val);
 		return;
 	}
 
@@ -1669,7 +1669,7 @@ static void ciev_battchg_cb(uint8_t val, void *user_data)
 
 	if (val < hfp->ag_ind[HFP_INDICATOR_BATTCHG].min ||
 			val > hfp->ag_ind[HFP_INDICATOR_BATTCHG].max) {
-		DBG(hfp, "hf: Incorrect battery charge value %u:", val);
+		DBG(hfp, "hf: Incorrect battery charge value: %u", val);
 		return;
 	}
 
src/shared/hfp.h +1 -1
index f54b86a92..e6f7bbbb6 100644
@@ -36,7 +36,7 @@
 #define HFP_AG_FEAT_HF_INDICATORS			0x00000400
 #define HFP_AG_FEAT_ESCO_S4_T2				0x00000800
 #define HFP_AG_FEAT_ENHANCED_VOICE_RECOGNITION_STATUS	0x00001000
-#define HFP_AG_FEAT_VOICE_RECOGNITION_TEXT		0x00001000
+#define HFP_AG_FEAT_VOICE_RECOGNITION_TEXT		0x00002000
 
 enum hfp_result {
 	HFP_RESULT_OK		= 0,
Signature · 1 line
2.43.0
#2 lore raw

PATCH 3/3 unit/test-hfp: Play PDUs up to the last one for HF tests

In reply to Frédéric Danis

This will allows to create PDU set for TS tests which may end with events not triggering actions, e.g. when receiving +CIEV:<callsetup>,0 where call status has already been updated by +CIEV:<call>,1

Free context->data only after completing hfp_*_unref calls.

---
 unit/test-hfp.c | 27 +++++++++------------------
 1 file changed, 9 insertions(+), 18 deletions(-)
unit/test-hfp.c +9 -18
index 0a6828b7c..9b4d60a3b 100644
@@ -136,14 +136,14 @@ static void destroy_context(struct context *context)
 	if (context->watch_id)
 		g_source_remove(context->watch_id);
 
-	test_free(context->data);
-
 	if (context->hfp)
 		hfp_gw_unref(context->hfp);
 
 	if (context->hfp_hf)
 		hfp_hf_unref(context->hfp_hf);
 
+	test_free(context->data);
+
 	g_free(context);
 }
 
@@ -182,14 +182,19 @@ static gboolean send_pdu(gpointer user_data)
 	ssize_t len;
 
 	pdu = &context->data->pdu_list[context->pdu_offset++];
-	if (!pdu || !pdu->valid)
+	if (!pdu)
 		return FALSE;
 
+	if (!pdu->valid) {
+		context->data->response_func(HFP_RESULT_OK, 0, context);
+		return FALSE;
+	}
+
 	len = write(context->fd_server, pdu->data, pdu->size);
 	g_assert_cmpint(len, ==, pdu->size);
 
 	pdu = &context->data->pdu_list[context->pdu_offset];
-	if (pdu->fragmented)
+	if (pdu->fragmented || (!pdu->valid && context->data->response_func))
 		g_idle_add(send_pdu, context);
 
 	return FALSE;
@@ -726,13 +731,9 @@ 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/test_session_minimal"))
-		context->data->response_func(res, cme_err, context);
 }
 
 static void hf_update_indicator(enum hfp_indicator indicator, uint32_t val,
@@ -774,27 +775,17 @@ static void hf_update_indicator(enum hfp_indicator indicator, uint32_t val,
 	if (g_str_equal(test_name, "/HFP/HF/PSI/BV-01-C")) {
 		g_assert_cmpint(indicator, ==, HFP_INDICATOR_SIGNAL);
 		g_assert_cmpint(val, ==, 3);
-		context->data->response_func(HFP_RESULT_OK, 0, context);
 	} else if (g_str_equal(test_name, "/HFP/HF/PSI/BV-02-C")) {
 		context->session.step++;
 		g_assert_cmpint(indicator, ==, HFP_INDICATOR_ROAM);
 		g_assert_cmpint(val, ==, context->session.step % 2);
-
-		if (context->session.step == 2)
-			context->data->response_func(HFP_RESULT_OK, 0,
-								context);
 	} else if (g_str_equal(test_name, "/HFP/HF/PSI/BV-03-C")) {
 		g_assert_cmpint(indicator, ==, HFP_INDICATOR_BATTCHG);
 		g_assert_cmpint(val, ==, 3);
-		context->data->response_func(HFP_RESULT_OK, 0, context);
 	} else if (g_str_equal(test_name, "/HFP/HF/TRS/BV-01-C")) {
 		context->session.step++;
 		g_assert_cmpint(indicator, ==, HFP_INDICATOR_SERVICE);
 		g_assert_cmpint(val, ==, context->session.step % 2);
-
-		if (context->session.step == 3)
-			context->data->response_func(HFP_RESULT_OK, 0,
-								context);
 	}
 }
 
Signature · 1 line
2.43.0
#3 lore raw
In reply to Frédéric Danis

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=997681

---Test result---

Test Summary:

CheckPatch                    PENDING   0.30 seconds
GitLint                       PENDING   0.34 seconds
BuildEll                      PASS      19.84 seconds
BluezMake                     PASS      2581.64 seconds
MakeCheck                     PASS      19.75 seconds
MakeDistcheck                 PASS      183.17 seconds
CheckValgrind                 PASS      235.06 seconds
CheckSmatch                   PASS      303.85 seconds
bluezmakeextell               PASS      126.71 seconds
IncrementalBuild              PENDING   0.30 seconds
ScanBuild                     PASS      908.11 seconds

Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:

##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:

##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series Output:

---
Regards,
Linux Bluetooth

#4 lore raw
In reply to Frédéric Danis
This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Hello:

This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Quoted 4 lines · On Mon, 1 Sep 2025 17:49:01 +0200 you wrote:

This will simplify when looking for a test.

---
 unit/test-hfp.c | 42 +++++++++++++++++++++---------------------
 1 file changed, 21 insertions(+), 21 deletions(-)

Here is the summary with links:
- [BlueZ,1/3] unit/test-hfp: Re-order TS tests in alphabetical order

    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=c779eb8183a7
  - [BlueZ,2/3] shared/hfp: Fix typos
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=bef16e9c4d8d
  - [BlueZ,3/3] unit/test-hfp: Play PDUs up to the last one for HF tests
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=f9a98ff26e50

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html