All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mat Martineau <martineau@kernel.org>
To: "Matthieu Baerts (NGI0)" <matttbe@kernel.org>
Cc: mptcp@lists.linux.dev
Subject: Re: [PATCH mptcp-net 3/3] selftests: mptcp: print trailing bytes with hexdump
Date: Thu, 21 Aug 2025 18:04:50 -0700 (PDT)	[thread overview]
Message-ID: <63cac2fd-a90f-e165-c0b3-85584e81ef37@kernel.org> (raw)
In-Reply-To: <20250819-sft-mptcp-disc-err-v1-3-9d0cf296bc13@kernel.org>

On Tue, 19 Aug 2025, Matthieu Baerts (NGI0) wrote:

> If hexdump or busybox hexdump is available.
>
> This is better than printing random bytes in the terminal.
>
> Suggested-by: Jakub Kicinski <kuba@kernel.org>
> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
> ---
> tools/testing/selftests/net/mptcp/mptcp_lib.sh | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/net/mptcp/mptcp_lib.sh b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
> index 09cd24b2ae466205dacbdf8289eb86c08534c475..20ce95c9d35538a03c1c3cac843657d258fc9715 100644
> --- a/tools/testing/selftests/net/mptcp/mptcp_lib.sh
> +++ b/tools/testing/selftests/net/mptcp/mptcp_lib.sh
> @@ -382,9 +382,19 @@ mptcp_lib_make_file() {
>
> # $1: file
> mptcp_lib_print_file_err() {
> +	local end
> +
> 	ls -l "${1}" 1>&2
> 	echo "Trailing bytes are: "
> -	tail -c 27 "${1}"
> +	end=$(tail -c 32 "${1}")
> +	if command -v hexdump >/dev/null; then

Hi Matthieu -

How about:

tail -c 32 "${1}" | od -t x1

'od' is in the posix spec so it should be on more systems than hexdump 
(it's in coreutils along with 'tail', for example). Also, today I learned 
that 'od' can format hexadecimal...


> +		echo "${end}" | hexdump -C | head -n2
> +	elif busybox hexdump --help 2>/dev/null; then
> +		echo "${end}" | busybox hexdump -C | head -n2
> +	else
> +		echo "${end}"

Would be best to avoid fallback to raw binary (hence the 'od' suggestion 
above).

- Mat


> +		echo
> +	fi
> }
>
> # $1: input file ; $2: output file ; $3: what kind of file
>
> -- 
> 2.50.0
>
>
>

  reply	other threads:[~2025-08-22  1:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-19 18:05 [PATCH mptcp-net 0/3] selftests: mptcp: avoid spurious errors on TCP disconnect Matthieu Baerts (NGI0)
2025-08-19 18:05 ` [PATCH mptcp-net 1/3] selftests: mptcp: connect: catch IO errors on listen side Matthieu Baerts (NGI0)
2025-08-19 18:05 ` [PATCH mptcp-net 2/3] selftests: mptcp: avoid spurious errors on TCP disconnect Matthieu Baerts (NGI0)
2025-08-20  7:51   ` Paolo Abeni
2025-08-19 18:05 ` [PATCH mptcp-net 3/3] selftests: mptcp: print trailing bytes with hexdump Matthieu Baerts (NGI0)
2025-08-22  1:04   ` Mat Martineau [this message]
2025-08-19 20:00 ` [PATCH mptcp-net 0/3] selftests: mptcp: avoid spurious errors on TCP disconnect MPTCP CI
2025-08-22  1:06 ` Mat Martineau

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=63cac2fd-a90f-e165-c0b3-85584e81ef37@kernel.org \
    --to=martineau@kernel.org \
    --cc=matttbe@kernel.org \
    --cc=mptcp@lists.linux.dev \
    /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 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.