public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Stefano Brivio <sbrivio@redhat.com>
To: David Gibson <david@gibson.dropbear.id.au>
Cc: passt-dev@passt.top
Subject: Re: [PATCH 2/2] test: Make log truncation test more robust
Date: Thu, 25 Apr 2024 00:01:00 +0200	[thread overview]
Message-ID: <20240425000100.23624505@elisabeth> (raw)
In-Reply-To: <20240424043000.1485776-3-david@gibson.dropbear.id.au>

On Wed, 24 Apr 2024 14:30:00 +1000
David Gibson <david@gibson.dropbear.id.au> wrote:

> test/pasta_options/log_to_file checks that pasta truncates its log file
> when started.  It does that by starting pasta with a log file once, then
> starting it again and checking that after the second round, the log file
> has only one line: the startup banner from the second invocation.
> 
> However, this test will break if the second invocation logs any additional
> messages at startup.  This can easily happen on a host with multiple
> network interfaces due to the "Multiple default route" informational
> messages added in 639fdf06e ("netlink: Fix selection of template
> interface").  I believe it could also happen on a host without IPv6
> connectivity due to the "Couldn't pick external interface" messages, though
> I haven't confirmed this.
> 
> Make the log file test more robust, by not testing for a single line, but
> instead explicitly testing for the PID of the second pasta invocation in
> the banner line.
> 
> Link: https://bugs.passt.top/show_bug.cgi?id=88
> 
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
> ---
>  test/pasta_options/log_to_file | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/test/pasta_options/log_to_file b/test/pasta_options/log_to_file
> index f1002167..fe50e50b 100644
> --- a/test/pasta_options/log_to_file
> +++ b/test/pasta_options/log_to_file
> @@ -37,8 +37,9 @@ passt	./pasta -l __LOG_FILE__ -- /bin/true
>  check	[ -s __LOG_FILE__ ]
>  
>  test	Log truncated on creation
> -passt	./pasta -l __LOG_FILE__ -- /bin/true
> -check	[ $(cat __LOG_FILE__ | wc -l) -eq 1 ]
> +passt	./pasta -l __LOG_FILE__ -- /bin/true & wait
> +pout	PID2 echo $!
> +check	head -1 __LOG_FILE__ | grep '^pasta .* [(]__PID2__[)]$'
                                                       ^^^^^^^^^^^^^^

I'm mildly amused that this actually works. :)

-- 
Stefano


  reply	other threads:[~2024-04-24 22:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-24  4:29 [PATCH 0/2] Fixes for logging tests David Gibson
2024-04-24  4:29 ` [PATCH 1/2] test: Slight simplification to pasta log tests David Gibson
2024-04-24  4:30 ` [PATCH 2/2] test: Make log truncation test more robust David Gibson
2024-04-24 22:01   ` Stefano Brivio [this message]
2024-04-24 22:02 ` [PATCH 0/2] Fixes for logging tests Stefano Brivio

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=20240425000100.23624505@elisabeth \
    --to=sbrivio@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=passt-dev@passt.top \
    /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.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).