[LTP] [PATCH v2] Check for maximum available pids in dio_sparse.c
Cyril Hrubis
chrubis@suse.cz
Mon Mar 7 10:31:09 CET 2022
Hi!
> Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.de>
> ---
> In v2 setup message for children has been moved from TCONF to TINFO.
> And other small fixes.
Please send the small fixes in a separate patch.
> testcases/kernel/io/ltp-aiodio/dio_sparse.c | 26 +++++++++++++++++----
> 1 file changed, 21 insertions(+), 5 deletions(-)
>
> diff --git a/testcases/kernel/io/ltp-aiodio/dio_sparse.c b/testcases/kernel/io/ltp-aiodio/dio_sparse.c
> index 0039daa8d..1da1ae37f 100644
> --- a/testcases/kernel/io/ltp-aiodio/dio_sparse.c
> +++ b/testcases/kernel/io/ltp-aiodio/dio_sparse.c
> @@ -54,14 +54,29 @@ static void dio_sparse(int fd, int align, long long fs, int ws, long long off)
> w = SAFE_WRITE(0, fd, bufptr, ws);
> i += w;
> }
> +
> + free(bufptr);
> }
>
> static void setup(void)
> {
> struct stat sb;
> + int max_pids;
> +
> + if (tst_parse_int(str_numchildren, &numchildren, 1, INT_MAX)) {
> + tst_brk(TBROK, "Invalid number of children '%s'",
> + str_numchildren);
> + }
>
> - if (tst_parse_int(str_numchildren, &numchildren, 1, INT_MAX))
> - tst_brk(TBROK, "Invalid number of children '%s'", str_numchildren);
> + max_pids = tst_get_free_pids();
> + if (numchildren > max_pids) {
> + numchildren = max_pids;
> +
> + tst_res(TINFO,
> + "Number of children reduced to %d due to system "
> + "limitations",
> + numchildren);
> + }
Can we put this piece of code into a some common place and use it in all
the I/O tests?
I guess that we can as well add a function parse_numchildren() into
common.h that would call tst_parse_int() and then apply the limits and
use that in all the tests...
--
Cyril Hrubis
chrubis@suse.cz
More information about the ltp
mailing list