From: Avinesh Kumar <akumar@suse.de>
To: Cyril Hrubis <chrubis@suse.cz>
Cc: valgrind-developers@lists.sourceforge.net, ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v2] lib: tst_test: Add reproducible output.
Date: Mon, 12 May 2025 11:47:14 +0200 [thread overview]
Message-ID: <4984431.GXAFRqVoOG@thinkpad> (raw)
In-Reply-To: <20250509092813.12860-1-chrubis@suse.cz>
Hi,
Reviewed-by: Avinesh Kumar <akumar@suse.de>
On Friday, May 9, 2025 11:28:13 AM CEST Cyril Hrubis wrote:
> This commit adds an environment variable LTP_REPRODUCIBLE_OUTPUT that
> when set skips printing parts of the test messages that may contain data
> that differ on subsequent runs (e.g. pids).
>
> With this you can run a test twice under a different conditions and
> check if the test codeflow was identical by simply doing diff of the
> outputs from the two runs.
>
> Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
> Suggested-by: Martin Doucha <mdoucha@suse.cz>
> CC: valgrind-developers@lists.sourceforge.net
> ---
> lib/tst_test.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/lib/tst_test.c b/lib/tst_test.c
> index 2bb4519dd..f14627544 100644
> --- a/lib/tst_test.c
> +++ b/lib/tst_test.c
> @@ -64,6 +64,7 @@ static int mntpoint_mounted;
> static int ovl_mounted;
> static struct timespec tst_start_time; /* valid only for test pid */
> static int tdebug;
> +static int reproducible_output;
>
> struct results {
> int passed;
> @@ -312,6 +313,9 @@ static void print_result(const char *file, const int lineno, int ttype,
> str += ret;
> size -= ret;
>
> + if (reproducible_output)
> + goto print;
> +
> ssize = size - 2;
> ret = vsnprintf(str, size, fmt, va);
> str += MIN(ret, ssize);
> @@ -329,6 +333,7 @@ static void print_result(const char *file, const int lineno, int ttype,
> "Next message is too long and truncated:");
> }
>
> +print:
> snprintf(str, size, "\n");
>
> /* we might be called from signal handler, so use write() */
> @@ -1312,6 +1317,8 @@ static void do_setup(int argc, char *argv[])
> if (tst_test->supported_archs && !tst_is_on_arch(tst_test->supported_archs))
> tst_brk(TCONF, "This arch '%s' is not supported for test!", tst_arch.name);
>
> + reproducible_output = !!getenv("LTP_REPRODUCIBLE_OUTPUT");
> +
> assert_test_fn();
>
> TCID = tid = get_tid(argv);
>
Regards,
Avinesh
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2025-05-12 9:47 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-09 9:28 [LTP] [PATCH v2] lib: tst_test: Add reproducible output Cyril Hrubis
2025-05-09 9:36 ` Martin Doucha
2025-05-12 9:47 ` Avinesh Kumar [this message]
2025-05-12 18:06 ` Petr Vorel
2025-05-15 10:34 ` Cyril Hrubis
2025-05-16 20:29 ` Martin Cermak via ltp
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=4984431.GXAFRqVoOG@thinkpad \
--to=akumar@suse.de \
--cc=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
--cc=valgrind-developers@lists.sourceforge.net \
/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