public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: Martin Doucha <mdoucha@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH 2/2] ioctl_sg01: Print buffer contents on failure
Date: Wed, 29 Oct 2025 10:54:16 +0100	[thread overview]
Message-ID: <aQHkSPsLyx4O_VXk@rei> (raw)
In-Reply-To: <20251022095740.8747-2-mdoucha@suse.cz>

Hi!
> +static void dump_hex(const char *str, size_t size)
> +{
> +	size_t i;
> +
> +	for (; size && !str[size - 1]; size--)
> +		;
> +
> +	for (i = 0; i < size; i++) {
> +		if (i && (i % 32) == 0)
> +			printf("\n");
> +		else if (i && (i % 4) == 0)
> +			printf(" ");
> +
> +		printf("%02x", (unsigned int)str[i]);
> +	}
> +
> +	printf("\n");
> +}
> +
>  static void setup(void)
>  {
>  	const char *devpath = find_generic_scsi_device(O_RDONLY, 1);
> @@ -135,6 +154,7 @@ static void run(void)
>  
>  	for (i = 0; i < 100; i++) {
>  		TEST(ioctl(devfd, SG_IO, &query));
> +		buffer[BUF_SIZE] = '\0';
>  
>  		if (TST_RET != 0 && TST_RET != -1)
>  			tst_brk(TBROK|TTERRNO, "Invalid ioctl() return value");
> @@ -143,6 +163,8 @@ static void run(void)
>  		for (j = 0; j < BUF_SIZE; j++) {
>  			if (buffer[j]) {
>  				tst_res(TFAIL, "Kernel memory leaked");
> +				tst_res(TINFO, "Buffer contents: %s", buffer);

Any reason why we don't use tst_res_hexd() instead?

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  parent reply	other threads:[~2025-10-29  9:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-22  9:57 [LTP] [PATCH 1/2] ioctl_sg01: Skip USB devices Martin Doucha
2025-10-22  9:57 ` [LTP] [PATCH 2/2] ioctl_sg01: Print buffer contents on failure Martin Doucha
2025-10-22 13:31   ` Petr Vorel
2025-10-24  8:57     ` Petr Vorel
2025-10-29  9:54   ` Cyril Hrubis [this message]
2025-11-03 12:49     ` Martin Doucha
2025-11-03 14:58       ` Cyril Hrubis
2025-10-22 13:13 ` [LTP] [PATCH 1/2] ioctl_sg01: Skip USB devices Petr Vorel
2025-10-22 13:37   ` Petr Vorel

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=aQHkSPsLyx4O_VXk@rei \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    --cc=mdoucha@suse.cz \
    /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