From: Petr Vorel <pvorel@suse.cz>
To: Cyril Hrubis <chrubis@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] lib: TST_EXP_FAIL: Add array variants
Date: Thu, 4 Jan 2024 13:53:34 +0100 [thread overview]
Message-ID: <20240104125334.GA1159015@pevik> (raw)
In-Reply-To: <20240103115700.14585-1-chrubis@suse.cz>
Hi Cyril,
> For certain cases there is a possibility of a failure with more than one
> errno, for instance testcases with invalid fd may return either EINVAL
> or EBADFD and in many cases either one is fine, at least that was the
> feedback from kernel devs.
> This change also adds a tst_errno_in_set() function that is now the
> single place to validate errno for all TST_EXP_FAIL*() variants. That is
> intentional since this allows us to implement code to relax the
> conditions if needed, e.g. we had requests to allow additional errnos
> for systems with SELinux where failures may be caused by the SELinux
> policies and the errors may differ.
+1, this should be merged before release.
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Also thanks for starting docs in tst_test_macros.h (I wanted to add more but
haven't done it yet).
> Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
> ---
> include/tst_test_macros.h | 65 ++++++++++++++++++++++++++------
> lib/newlib_tests/test_macros02.c | 11 ++++++
> lib/tst_test_macros.c | 36 ++++++++++++++++++
> 3 files changed, 101 insertions(+), 11 deletions(-)
> create mode 100644 lib/tst_test_macros.c
> diff --git a/include/tst_test_macros.h b/include/tst_test_macros.h
> index bd0c491c1..5687d0904 100644
> --- a/include/tst_test_macros.h
> +++ b/include/tst_test_macros.h
> @@ -186,7 +186,18 @@ extern void *TST_RET_PTR;
> TST_MSG_(TPASS, " passed", #SCALL, ##__VA_ARGS__); \
> } while (0) \
> -#define TST_EXP_FAIL_SILENT_(PASS_COND, SCALL, SSCALL, ERRNO, ...) \
> +/*
> + * Returns true if err is in the exp_err array.
> + */
> +int tst_errno_in_set(int err, const int *exp_errs, int exp_errs_cnt);
nit: we already use bool in fuzzy sync header and tst_af_alg.h. We could use it
here as well (it's immediately obvious it's true/false, not e.g. count).
...
> diff --git a/lib/tst_test_macros.c b/lib/tst_test_macros.c
> new file mode 100644
> index 000000000..a36abbea3
> --- /dev/null
> +++ b/lib/tst_test_macros.c
> @@ -0,0 +1,36 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (c) 2020 Cyril Hrubis <chrubis@suse.cz>
nit: maybe 2024?
> + */
> +
> +#include <stdio.h>
> +#define TST_NO_DEFAULT_MAIN
> +#include "tst_test.h"
> +#include "tst_test_macros.h"
> +
> +int tst_errno_in_set(int err, const int *exp_errs, int exp_errs_cnt)
> +{
> + int i;
> +
> + for (i = 0; i < exp_errs_cnt; i++) {
> + if (err == exp_errs[i])
> + return 1;
> + }
> +
> + return 0;
> +}
> +
> +const char *tst_errno_names(char *buf, const int *exp_errs, int exp_errs_cnt)
> +{
> + int i;
> + char *cb = buf;
> +
> + for (i = 0; i < exp_errs_cnt-1; i++)
> + cb += sprintf(cb, "%s, ", tst_strerrno(exp_errs[i]));
> +
> + cb += sprintf(cb, "%s", tst_strerrno(exp_errs[i]));
> +
> + *cb = 0;
very nit: \0 is for me more readable.
Kind regards,
Petr
> +
> + return buf;
> +}
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2024-01-04 12:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-03 11:57 [LTP] [PATCH] lib: TST_EXP_FAIL: Add array variants Cyril Hrubis
2024-01-04 12:53 ` Petr Vorel [this message]
2024-01-15 11:05 ` Cyril Hrubis
2024-01-04 22:57 ` Petr Vorel
2024-01-15 11:05 ` Cyril Hrubis
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=20240104125334.GA1159015@pevik \
--to=pvorel@suse.cz \
--cc=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
/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