All of lore.kernel.org
 help / color / mirror / Atom feed
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
	 netdev@vger.kernel.org
Cc: davem@davemloft.net,  kuba@kernel.org,  edumazet@google.com,
	 pabeni@redhat.com,  horms@kernel.org,
	 Willem de Bruijn <willemb@google.com>
Subject: Re: [PATCH net-next] selftests/net: convert so_txtime to drv-net
Date: Fri, 03 Apr 2026 16:00:34 -0400	[thread overview]
Message-ID: <willemdebruijn.kernel.1b2030e08937c@gmail.com> (raw)
In-Reply-To: <20260403175047.152646-1-willemdebruijn.kernel@gmail.com>

Willem de Bruijn wrote:
> From: Willem de Bruijn <willemb@google.com>
> 
> In preparation for extending to pacing hardware offload, convert the
> so_txtime.sh test to a drv-net test that can be run against netdevsim
> and real hardware.
> 
> Also move so_txtime.c to lib so that it is easily accessible for the
> new drv-net test, similar to gro.c in commit 8888bf4fb980 ("selftests:
> net: move gro to lib for HW vs SW reuse").
> 
> Also update so_txtime.c to not exit on first failure, but run to
> completion and report exit code there. This helps with debugging
> unexpected results, especially when processing multiple packets,
> as in the "reverse_order" testcase.
> 
> Signed-off-by: Willem de Bruijn <willemb@google.com>

Sashiko already has a few correct comments (below). Will fix in v2.

Also, indentation incorrectly uses 2 instead of 4 spaces.

> +def test_so_txtime(cfg, clockid, ipver, args_tx, args_rx, expect_fail):
> +  bin_path = cfg.net_lib_dir / "so_txtime"
> +
> +  tstart = time.time_ns() + 100_000_000
> +
> +  cmd_addr = f"-S {cfg.addr_v[ipver]} -D {cfg.remote_addr_v[ipver]}"
> +  cmd_base = f"{bin_path} -{ipver} -c {clockid} -t {tstart} {cmd_addr}"
> +  cmd_rx = f"{cmd_base} {args_rx} -r"
> +  cmd_tx = f"{cmd_base} {args_tx}"
> +
> +  try:
> +    with bkg(cmd_rx, host=cfg.remote, exit_wait=True):
> +      cmd(cmd_tx)
> +  except:
> +    if not expect_fail:
> +      raise

Also test against a test succeeding when failure is expected. Will add
an else: clause.


> @@ -131,13 +135,15 @@ static void do_recv_one(int fdr, struct timed_send *ts)
>  	fprintf(stderr, "payload:%c delay:%lld expected:%lld (us)\n",
>  			rbuf[0], (long long)tstop, (long long)texpect);
>  
> -	if (rbuf[0] != ts->data)
> -		error(1, 0, "payload mismatch. expected %c", ts->data);
> +	if (rbuf[0] != ts->data) {
> +		fprintf(stderr, "payload mismatch. expected %c", ts->data);

Add \n when converting from error to fprintf

> @@ -255,8 +261,10 @@ static void start_time_wait(void)
>  		return;
>  
>  	now = gettime_ns(CLOCK_REALTIME);
> -	if (cfg_start_time_ns < now)
> -		return;
> +	if (cfg_start_time_ns < now) {
> +		fprintf(stderr, "FAIL: start time already passed\n");
> +		errors++;
> +	}
>  
>  	err = usleep((cfg_start_time_ns - now) / 1000);

Do not call usleep when already late: uint64_t will have negative
overflow. Also, waiting makes no sense when late. Add return to the
error branch.

  reply	other threads:[~2026-04-03 20:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-03 17:50 [PATCH net-next] selftests/net: convert so_txtime to drv-net Willem de Bruijn
2026-04-03 20:00 ` Willem de Bruijn [this message]
2026-04-03 20:28 ` Jakub Kicinski
2026-04-03 23:54   ` Willem de Bruijn

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=willemdebruijn.kernel.1b2030e08937c@gmail.com \
    --to=willemdebruijn.kernel@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=willemb@google.com \
    /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.