tools/tester: test COMPLETION timestamps
PATCH v2 1/3 tools/tester: test COMPLETION timestamps
Add support for SOF_TIMESTAMPING_TX_COMPLETION also in cases where errqueue.h is old and doesn't define it.
Support timestamps of different types arriving out of order, as multiple SND may well arrive before COMPLETION. Also allow TX timestamp arriving before bthost receives data, as that may well happen.
Remove tests SCHED timestamps, as those won't be generated for now.
Don't test COMPLETION for SCO, since it's not supported now either.
Add test:
SCO CVSD Send No Flowctl - TX Timestamping
--- configure.ac | 7 +++++++ tools/iso-tester.c | 36 +++++++++++------------------------- tools/l2cap-tester.c | 14 ++++++++------ tools/sco-tester.c | 23 +++++++++++++++++++---- tools/tester.h | 44 ++++++++++++++++++++++++++++++++++++-------- 5 files changed, 81 insertions(+), 43 deletions(-)
configure.ac +7 -0
@@ -389,6 +389,13 @@ AC_ARG_ENABLE(testing, AS_HELP_STRING([--enable-testing], [enable_testing=${enableval}]) AM_CONDITIONAL(TESTING, test "${enable_testing}" = "yes") +if (test "${enable_testing}" = "yes"); then + AC_CHECK_DECLS([SOF_TIMESTAMPING_TX_COMPLETION, SCM_TSTAMP_COMPLETION], + [], [], [[#include <time.h> + #include <linux/errqueue.h> + #include <linux/net_tstamp.h>]]) +fi + AC_ARG_ENABLE(experimental, AS_HELP_STRING([--enable-experimental], [enable experimental tools]), [enable_experimental=${enableval}])
tools/iso-tester.c +11 -25
@@ -1066,28 +1066,19 @@ static const struct iso_client_data connect_send_tx_timestamping = { .send = &send_16_2_1, .so_timestamping = (SOF_TIMESTAMPING_SOFTWARE |SOF_TIMESTAMPING_OPT_ID | - SOF_TIMESTAMPING_TX_SOFTWARE), +SOF_TIMESTAMPING_TX_SOFTWARE | + SOF_TIMESTAMPING_TX_COMPLETION), .repeat_send = 1, .repeat_send_pre_ts = 2, }; -static const struct iso_client_data connect_send_tx_sched_timestamping = { - .qos =QOS_16_2_1 , - .expect_err =0 , - .send = &send_16_2_1, - .so_timestamping = (SOF_TIMESTAMPING_SOFTWARE | -SOF_TIMESTAMPING_TX_SOFTWARE | -SOF_TIMESTAMPING_OPT_TSONLY | -SOF_TIMESTAMPING_TX_SCHED ), - .repeat_send =1 , -}; -static const struct iso_client_data connect_send_tx_cmsg_timestamping = { .qos =QOS_16_2_1 , .expect_err =0 , .send = &send_16_2_1, .so_timestamping = (SOF_TIMESTAMPING_SOFTWARE | -SOF_TIMESTAMPING_TX_SOFTWARE ), +SOF_TIMESTAMPING_OPT_TSONLY | +SOF_TIMESTAMPING_TX_COMPLETION ), .repeat_send =1 , .cmsg_timestamping = true, };
@@ -1097,7 +1088,7 @@ static const struct iso_client_data connect_send_tx_no_poll_timestamping = { .expect_err = 0, .send = &send_16_2_1, .so_timestamping = (SOF_TIMESTAMPING_SOFTWARE | - SOF_TIMESTAMPING_TX_SOFTWARE), + SOF_TIMESTAMPING_TX_COMPLETION), .repeat_send = 1, .no_poll_errqueue = true, };
@@ -2241,10 +2232,10 @@ static gboolean iso_recv_errqueue(GIOChannel *io, GIOCondition cond, err =tx_tstamp_recv (&data->tx_ts, sk, isodata->send->iov_len);if (err >0 )return TRUE; -else if (!err && !data->step) -tester_test_passed (); -else +else if (err)tester_test_failed (); +else if (!data->step) +tester_test_passed (); data->io_id[2 ] =0 ;return FALSE;
@@ -2289,7 +2280,7 @@ static void iso_tx_timestamping(struct test_data *data, GIOChannel *io)int err;unsigned int count; -if (!(isodata->so_timestamping &SOF_TIMESTAMPING_TX_RECORD_MASK )) +if (!(isodata->so_timestamping &TS_TX_RECORD_MASK ))return ;tester_print ("Enabling TX timestamping" );
@@ -2336,7 +2327,7 @@ static void iso_tx_timestamping(struct test_data *data, GIOChannel *io) }if (isodata->cmsg_timestamping) - so &= ~SOF_TIMESTAMPING_TX_RECORD_MASK ; + so &= ~TS_TX_RECORD_MASK ; err =setsockopt (sk,SOL_SOCKET ,SO_TIMESTAMPING , &so,sizeof (so));if (err <0 ) {
@@ -2374,7 +2365,7 @@ static void iso_send_data(struct test_data *data, GIOChannel *io) cmsg->cmsg_len =CMSG_LEN (sizeof (uint32_t )); *((uint32_t *)CMSG_DATA (cmsg)) = (isodata->so_timestamping & -SOF_TIMESTAMPING_TX_RECORD_MASK ); +TS_TX_RECORD_MASK ); } ret =sendmsg (sk, &msg,0 );
@@ -3645,11 +3636,6 @@ int main(int argc, char *argv[])test_iso ("ISO Send - TX Timestamping" , &connect_send_tx_timestamping, setup_powered, test_connect); -/* Test schedule-time TX timestamps are emitted */ -test_iso ("ISO Send - TX Sched Timestamping" , - &connect_send_tx_sched_timestamping, setup_powered, - test_connect); -/* Test TX timestamping with flags set via per-packet CMSG */ test_iso("ISO Send - TX CMSG Timestamping", &connect_send_tx_cmsg_timestamping, setup_powered,
tools/l2cap-tester.c +8 -6
@@ -381,7 +381,8 @@ static const struct l2cap_data client_connect_tx_timestamping_test = { .data_len = sizeof(l2_data), .so_timestamping = (SOF_TIMESTAMPING_SOFTWARE |SOF_TIMESTAMPING_OPT_ID | - SOF_TIMESTAMPING_TX_SOFTWARE), +SOF_TIMESTAMPING_TX_SOFTWARE | + SOF_TIMESTAMPING_TX_COMPLETION), .repeat_send = 2, };
@@ -594,7 +595,8 @@ static const struct l2cap_data le_client_connect_tx_timestamping_test = { .data_len = sizeof(l2_data), .so_timestamping = (SOF_TIMESTAMPING_SOFTWARE |SOF_TIMESTAMPING_OPT_ID | - SOF_TIMESTAMPING_TX_SOFTWARE), +SOF_TIMESTAMPING_TX_SOFTWARE | + SOF_TIMESTAMPING_TX_COMPLETION), };static const struct l2cap_data le_client_connect_adv_success_test_1 = {
@@ -1345,10 +1347,10 @@ static gboolean recv_errqueue(GIOChannel *io, GIOCondition cond, err =tx_tstamp_recv (&data->tx_ts, sk, l2data->data_len);if (err >0 )return TRUE; -else if (!err && !data->step) -tester_test_passed (); -else +else if (err)tester_test_failed (); +else if (!data->step) +tester_test_passed (); data->err_io_id =0 ;return FALSE;
@@ -1362,7 +1364,7 @@ static void l2cap_tx_timestamping(struct test_data *data, GIOChannel *io)int err;unsigned int count; -if (!(l2data->so_timestamping &SOF_TIMESTAMPING_TX_RECORD_MASK )) +if (!(l2data->so_timestamping &TS_TX_RECORD_MASK ))return ; sk =g_io_channel_unix_get_fd (io);
tools/sco-tester.c +19 -4
@@ -314,6 +314,17 @@ static const struct sco_client_data connect_send_success = { };static const struct sco_client_data connect_send_tx_timestamping = { + .expect_err =0 , + .data_len =sizeof (data), + .send_data = data, + .so_timestamping = (SOF_TIMESTAMPING_SOFTWARE | +SOF_TIMESTAMPING_OPT_ID | +SOF_TIMESTAMPING_TX_SOFTWARE | +SOF_TIMESTAMPING_TX_COMPLETION ), + .repeat_send =2 , +}; + +static const struct sco_client_data connect_send_no_flowctl_tx_timestamping = { .expect_err =0 , .data_len =sizeof (data), .send_data = data,
@@ -738,10 +749,10 @@ static gboolean recv_errqueue(GIOChannel *io, GIOCondition cond, err =tx_tstamp_recv (&data->tx_ts, sk, scodata->data_len);if (err >0 )return TRUE; -else if (!err && !data->step) -tester_test_passed (); -else +else if (err)tester_test_failed (); +else if (!data->step) +tester_test_passed (); data->err_io_id =0 ;return FALSE;
@@ -755,7 +766,7 @@ static void sco_tx_timestamping(struct test_data *data, GIOChannel *io)int err;unsigned int count; -if (!(scodata->so_timestamping &SOF_TIMESTAMPING_TX_RECORD_MASK )) +if (!(scodata->so_timestamping &TS_TX_RECORD_MASK ))return ; sk =g_io_channel_unix_get_fd (io);
@@ -1142,6 +1153,10 @@ int main(int argc, char *argv[]) &connect_send_tx_timestamping, setup_powered, test_connect); +test_sco_no_flowctl ("SCO CVSD Send No Flowctl - TX Timestamping" , + &connect_send_no_flowctl_tx_timestamping, + setup_powered, test_connect); +test_sco_11 ("SCO CVSD 1.1 Send - Success" , &connect_send_success, setup_powered, test_connect);
tools/tester.h +36 -8
79 lines not on this page · raw message
Signature · 1 line
2.48.1
PATCH v2 2/3 l2cap-tester: add test for stream socket TX timestamping
Stream socket TX timestamp ids shall refer to the byte positions. Add test:
L2CAP BR/EDR Client - Stream TX Timestamping
--- tools/iso-tester.c | 4 ++-- tools/l2cap-tester.c | 32 ++++++++++++++++++++++++++++---- tools/sco-tester.c | 4 ++-- tools/tester.h | 12 +++++++++--- 4 files changed, 41 insertions(+), 11 deletions(-)
tools/iso-tester.c +2 -2
@@ -2285,10 +2285,10 @@ static void iso_tx_timestamping(struct test_data *data, GIOChannel *io)tester_print ("Enabling TX timestamping" ); -tx_tstamp_init (&data->tx_ts, isodata->so_timestamping); +tx_tstamp_init (&data->tx_ts, isodata->so_timestamping, false);for (count =0 ; count < isodata->repeat_send +1 ; ++count) - data->step +=tx_tstamp_expect (&data->tx_ts); + data->step +=tx_tstamp_expect (&data->tx_ts,0 ); sk =g_io_channel_unix_get_fd (io);
tools/l2cap-tester.c +28 -4
@@ -102,6 +102,9 @@ struct l2cap_data {/* Number of additional packets to send. */ unsigned int repeat_send; + +/* Socket type (0 means SOCK_SEQPACKET) */ +int sock_type; };static void print_debug (const char *str,void *user_data)
@@ -386,6 +389,19 @@ static const struct l2cap_data client_connect_tx_timestamping_test = { .repeat_send = 2, }; +static const struct l2cap_data client_connect_stream_tx_timestamping_test = { + .client_psm =0x1001 , + .server_psm =0x1001 , + .write_data = l2_data, + .data_len =sizeof (l2_data), + .so_timestamping = (SOF_TIMESTAMPING_SOFTWARE | +SOF_TIMESTAMPING_OPT_ID | +SOF_TIMESTAMPING_TX_SOFTWARE | +SOF_TIMESTAMPING_TX_COMPLETION ), + .repeat_send =2 , + .sock_type =SOCK_STREAM , +}; +static const struct l2cap_data client_connect_shut_wr_success_test = { .client_psm =0x1001 , .server_psm =0x1001 ,
@@ -1371,10 +1387,11 @@ static void l2cap_tx_timestamping(struct test_data *data, GIOChannel *io)tester_print ("Enabling TX timestamping" ); -tx_tstamp_init (&data->tx_ts, l2data->so_timestamping); +tx_tstamp_init (&data->tx_ts, l2data->so_timestamping, + l2data->sock_type ==SOCK_STREAM );for (count =0 ; count < l2data->repeat_send +1 ; ++count) - data->step +=tx_tstamp_expect (&data->tx_ts); + data->step +=tx_tstamp_expect (&data->tx_ts, l2data->data_len); err =setsockopt (sk,SOL_SOCKET ,SO_TIMESTAMPING , &so,sizeof (so));if (err <0 ) {
@@ -1523,9 +1540,12 @@ static int create_l2cap_sock(struct test_data *data, uint16_t psm,const uint8_t *central_bdaddr;struct sockaddr_l2 addr;int sk, err; +int sock_type =SOCK_SEQPACKET ; - sk =socket (PF_BLUETOOTH ,SOCK_SEQPACKET |SOCK_NONBLOCK , -BTPROTO_L2CAP ); +if (l2data && l2data->sock_type) + sock_type = l2data->sock_type; + + sk =socket (PF_BLUETOOTH , sock_type |SOCK_NONBLOCK ,BTPROTO_L2CAP );if (sk <0 ) { err = -errno; tester_warn("Can't create socket: %s (%d)", strerror(errno),
@@ -2523,6 +2543,10 @@ int main(int argc, char *argv[]) &client_connect_tx_timestamping_test, setup_powered_client, test_connect); +test_l2cap_bredr ("L2CAP BR/EDR Client - Stream TX Timestamping" , + &client_connect_stream_tx_timestamping_test, + setup_powered_client, test_connect); +test_l2cap_bredr ("L2CAP BR/EDR Client - Invalid PSM 1" , &client_connect_nval_psm_test_1, setup_powered_client, test_connect);
tools/sco-tester.c +2 -2
@@ -773,10 +773,10 @@ static void sco_tx_timestamping(struct test_data *data, GIOChannel *io)tester_print ("Enabling TX timestamping" ); -tx_tstamp_init (&data->tx_ts, scodata->so_timestamping); +tx_tstamp_init (&data->tx_ts, scodata->so_timestamping, false);for (count =0 ; count < scodata->repeat_send +1 ; ++count) - data->step +=tx_tstamp_expect (&data->tx_ts); + data->step +=tx_tstamp_expect (&data->tx_ts,0 ); err =setsockopt (sk,SOL_SOCKET ,SO_TIMESTAMPING , &so,sizeof (so));if (err <0 ) {
tools/tester.h +9 -3
@@ -38,22 +38,27 @@ struct tx_tstamp_data {unsigned int count;unsigned int sent;uint32_t so_timestamping; +bool stream; };static inline void tx_tstamp_init (struct tx_tstamp_data *data, -uint32_t so_timestamping) +uint32_t so_timestamping,bool stream) {memset (data,0 ,sizeof (*data));memset (data->expect,0xff ,sizeof (data->expect)); data->so_timestamping = so_timestamping; + data->stream = stream; } -static inline int tx_tstamp_expect (struct tx_tstamp_data *data) +static inline int tx_tstamp_expect (struct tx_tstamp_data *data,size_t len) {unsigned int pos = data->count;int steps; +if (data->stream && len) + data->sent += len -1 ; +if (data->so_timestamping &SOF_TIMESTAMPING_TX_SCHED ) {g_assert (pos <ARRAY_SIZE (data->expect)); data->expect[pos].type =SCM_TSTAMP_SCHED ;
@@ -75,7 +80,8 @@ static inline int tx_tstamp_expect(struct tx_tstamp_data *data) pos++; } - data->sent++; +if (!data->stream || len) + data->sent++; steps = pos - data->count; data->count = pos;
Signature · 1 line
2.48.1
PATCH v2 3/3 tools/tester: enable TX timestamping tests by default
In reply to Pauli Virtanen--- tools/iso-tester.c | 2 +- tools/l2cap-tester.c | 6 ------ tools/sco-tester.c | 6 ------ 3 files changed, 1 insertion(+), 13 deletions(-)
tools/iso-tester.c +1 -1
@@ -691,7 +691,7 @@ static void test_pre_setup(const void *test_data)struct test_data *data =tester_get_data ();const struct iso_client_data *isodata = test_data; -if (isodata && isodata->so_timestamping) { +if (isodata && isodata->no_poll_errqueue) {if (tester_pre_setup_skip_by_default ())return ; }
tools/l2cap-tester.c +0 -6
@@ -221,12 +221,6 @@ static void read_index_list_callback(uint8_t status, uint16_t length,static void test_pre_setup (const void *test_data) {struct test_data *data =tester_get_data (); -const struct l2cap_data *l2data = test_data; - -if (l2data && l2data->so_timestamping) { -if (tester_pre_setup_skip_by_default ()) -return ; - } data->mgmt =mgmt_new_default ();if (!data->mgmt) {
tools/sco-tester.c +0 -6
@@ -212,12 +212,6 @@ static void read_index_list_callback(uint8_t status, uint16_t length,static void test_pre_setup (const void *test_data) {struct test_data *data =tester_get_data (); -const struct sco_client_data *scodata = test_data; - -if (scodata && scodata->so_timestamping) { -if (tester_pre_setup_skip_by_default ()) -return ; - } data->mgmt =mgmt_new_default ();if (!data->mgmt) {
Signature · 1 line
2.48.1
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=945297
---Test result---
Test Summary:
CheckPatch PENDING 0.18 seconds GitLint PENDING 0.20 seconds BuildEll PASS 20.42 seconds BluezMake PASS 1524.88 seconds MakeCheck PASS 13.55 seconds MakeDistcheck PASS 158.10 seconds CheckValgrind PASS 213.59 seconds CheckSmatch WARNING 287.66 seconds bluezmakeextell PASS 97.90 seconds IncrementalBuild PENDING 0.26 seconds ScanBuild PASS 862.45 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: CheckSmatch - WARNING
Desc: Run smatch tool with source
Output:tools/sco-tester.c: note: in included file:./lib/bluetooth.h:232:15: warning: array of flexible structures./lib/bluetooth.h:237:31: warning: array of flexible structurestools/sco-tester.c: note: in included file:./lib/bluetooth.h:232:15: warning: array of flexible structures./lib/bluetooth.h:237:31: warning: array of flexible structurestools/sco-tester.c: note: in included file:./lib/bluetooth.h:232:15: warning: array of flexible structures./lib/bluetooth.h:237:31: warning: array of flexible structures
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:
---
Regards,
Linux Bluetooth
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 8 lines · On Tue, 18 Mar 2025 21:07:08 +0200 you wrote:
Add support for
SOF_TIMESTAMPING_TX_COMPLETIONalso in cases whereerrqueue.his old and doesn't define it.Support timestamps of different types arriving out of order, as multiple SND may well arrive before COMPLETION. Also allow TX timestamp arriving before bthost receives data, as that may well happen.
[...]
Here is the summary with links:
- [BlueZ,v2,1/3] tools/tester: test COMPLETION timestamps
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=c89e18fa55e2 - [BlueZ,v2,2/3] l2cap-tester: add test for stream socket TX timestamping https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=fe5a5f509e0c - [BlueZ,v2,3/3] tools/tester: enable TX timestamping tests by default https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=f4b6a649ccdd
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html