public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Gabriel Krisman Bertazi <krisman@suse.de>
Cc: io-uring@vger.kernel.org, csander@purestorage.com
Subject: Re: [PATCH liburing v2 3/4] bind-listen.t: Add tests for getsockname
Date: Wed, 26 Nov 2025 13:58:47 -0700	[thread overview]
Message-ID: <62bbd237-532a-444a-9689-951c3d297d56@kernel.dk> (raw)
In-Reply-To: <20251125212715.2679630-4-krisman@suse.de>

On 11/25/25 2:27 PM, Gabriel Krisman Bertazi wrote:
> @@ -192,6 +192,30 @@ static int test_good_server(unsigned int ring_flags)
>  	}
>  	io_uring_cqe_seen(&ring, cqe);
>  
> +	/* Test that getsockname on the peer (getpeername) yields a
> +         * sane result.
> +	 */

Please use:

/*
 * xxx
 */

for multi-line comments.

> +	sqe = io_uring_get_sqe(&ring);
> +	saddr_len = sizeof(saddr);
> +	port = saddr.sin_port;
> +	io_uring_prep_cmd_getsockname(sqe, CLI_INDEX, (struct sockaddr*)&saddr,
> +				      &saddr_len, 1);
> +	sqe->flags |= IOSQE_FIXED_FILE;
> +	io_uring_submit(&ring);
> +	io_uring_wait_cqe(&ring, &cqe);
> +	if (cqe->res < 0) {
> +		fprintf(stderr, "getsockname client failed. %d\n", cqe->res);
> +		return T_EXIT_FAIL;

This will also fail on older kernels, where it should just return
T_EXIT_SKIP and the main "call these tests" part of main() should handle
that.

Any liburing test should run on any kernel. This is important as
regression tests are in there too, it's not just feature tests. I should
be able to run this on eg 5.10-stable and not get spurious errors and
then need to look at why that happened.

> @@ -417,5 +512,10 @@ int main(int argc, char *argv[])
>  		return T_EXIT_FAIL;
>  	}
>  
> +	ret = test_bad_sockname();
> +	if (ret) {
> +		fprintf(stderr, "bad sockname failed\n");
> +		return T_EXIT_FAIL;
> +	}
>  	return T_EXIT_PASS;
>  }

So here you'd just do:

	if (ret == T_EXIT_FAIL) {
		...
	}

	return T_EXIT_PASS;

so the test only fails if the test explicitly failed, which it should
not if getsockname isn't available on the running kernel.

-- 
Jens Axboe

  reply	other threads:[~2025-11-26 20:58 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-25 21:27 [PATCH liburing v2 0/4] liburing: getsockname support Gabriel Krisman Bertazi
2025-11-25 21:27 ` [PATCH liburing v2 1/4] liburing: Introduce getsockname operation Gabriel Krisman Bertazi
2025-11-25 21:27 ` [PATCH liburing v2 2/4] test/bind-listen.t: Use ephemeral port Gabriel Krisman Bertazi
2025-11-26 20:49   ` Jens Axboe
2025-12-02 23:37     ` Gabriel Krisman Bertazi
2025-12-03  2:49       ` Jens Axboe
2025-11-25 21:27 ` [PATCH liburing v2 3/4] bind-listen.t: Add tests for getsockname Gabriel Krisman Bertazi
2025-11-26 20:58   ` Jens Axboe [this message]
2025-11-25 21:27 ` [PATCH liburing v2 4/4] man/io_uring_prep_getsockname.3: Add man page Gabriel Krisman Bertazi
2025-11-26 20:54   ` Jens Axboe
2025-12-02 15:16 ` [PATCH liburing v2 0/4] liburing: getsockname support Jens Axboe
  -- strict thread matches above, loose matches on Subject: below --
2025-11-20 22:13 Gabriel Krisman Bertazi
2025-11-20 22:13 ` [PATCH liburing v2 3/4] bind-listen.t: Add tests for getsockname Gabriel Krisman Bertazi

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=62bbd237-532a-444a-9689-951c3d297d56@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=csander@purestorage.com \
    --cc=io-uring@vger.kernel.org \
    --cc=krisman@suse.de \
    /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