[LTP] [PATCH v2 4/5] readahead02: Add max_runtime

Petr Vorel pvorel@suse.cz
Wed Sep 14 22:33:26 CEST 2022


Hi Martin,

> Also calculate max_runtime dynamically if the test gets called with
> non-default filesize.

> Changes since v1:
> - Added dynamic runtime calculation for non-default filesize

LGTM, thanks!
Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr

>  testcases/kernel/syscalls/readahead/readahead02.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)

> diff --git a/testcases/kernel/syscalls/readahead/readahead02.c b/testcases/kernel/syscalls/readahead/readahead02.c
> index 4fa8cfaf8..02e866e82 100644
> --- a/testcases/kernel/syscalls/readahead/readahead02.c
> +++ b/testcases/kernel/syscalls/readahead/readahead02.c
> @@ -38,7 +38,9 @@ static char testfile[PATH_MAX] = "testfile";
>  #define DROP_CACHES_FNAME "/proc/sys/vm/drop_caches"
>  #define MEMINFO_FNAME "/proc/meminfo"
>  #define PROC_IO_FNAME "/proc/self/io"
> -static size_t testfile_size = 64 * 1024 * 1024;
> +#define DEFAULT_FILESIZE (64 * 1024 * 1024)
> +
> +static size_t testfile_size = DEFAULT_FILESIZE;
>  static char *opt_fsizestr;
>  static int pagesize;
>  static unsigned long cached_max;
> @@ -365,8 +367,10 @@ static void setup_readahead_length(void)

>  static void setup(void)
>  {
> -	if (opt_fsizestr)
> +	if (opt_fsizestr) {
>  		testfile_size = SAFE_STRTOL(opt_fsizestr, 1, INT_MAX);
> +		tst_set_max_runtime(1 + testfile_size / (DEFAULT_FILESIZE/32));
> +	}

>  	if (access(PROC_IO_FNAME, F_OK))
>  		tst_brk(TCONF, "Requires " PROC_IO_FNAME);
> @@ -406,6 +410,7 @@ static struct tst_test test = {
>  	},
>  	.test = test_readahead,
>  	.tcnt = ARRAY_SIZE(tcases),
> +	.max_runtime = 30,
>  	.tags = (const struct tst_tag[]) {
>  		{"linux-git", "b833a3660394"},
>  		{"linux-git", "5b910bd615ba"},


More information about the ltp mailing list