All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: Amir Goldstein <amir73il@gmail.com>
Cc: ltp@lists.linux.it, Jan Stancek <jstancek@redhat.com>,
	Miklos Szeredi <miklos@szeredi.hu>,
	linux-unionfs@vger.kernel.org
Subject: Re: [PATCH v3 3/6] syscalls/readahead02: abort test if readahead syscall fails
Date: Tue, 20 Nov 2018 17:30:31 +0100	[thread overview]
Message-ID: <20181120161811.GB18182@rei.lan> (raw)
In-Reply-To: <20181010233441.5337-4-amir73il@gmail.com>

Hi!
> There is no reason to continue the test if readahead syscall fails
> and we can also check and report TCONF if filesystem does not support
> readahead.

This looks good, but I would like to get rid of the check_ret function
as I said in the first case.

So maybe we can leave it in the cleanup but move the actuall code in
this patch. Does that sounds good to you?

> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> ---
>  .../kernel/syscalls/readahead/readahead02.c   | 21 +++++++++++--------
>  1 file changed, 12 insertions(+), 9 deletions(-)
> 
> diff --git a/testcases/kernel/syscalls/readahead/readahead02.c b/testcases/kernel/syscalls/readahead/readahead02.c
> index c739d3ba2..f77e7c66c 100644
> --- a/testcases/kernel/syscalls/readahead/readahead02.c
> +++ b/testcases/kernel/syscalls/readahead/readahead02.c
> @@ -45,16 +45,17 @@ static struct tst_option options[] = {
>  	{NULL, NULL, NULL}
>  };
>  
> -static int check_ret(long expected_ret)
> +static int check_ret(void)
>  {
> -	if (expected_ret == TST_RET) {
> -		tst_res(TPASS, "expected ret success - "
> -			"returned value = %ld", TST_RET);
> +	if (TST_RET == 0)
>  		return 0;
> +	if (TST_ERR == EINVAL) {
> +		tst_res(TCONF, "readahead not supported on %s",
> +			tst_device->fs_type);
> +	} else {
> +		tst_res(TFAIL | TTERRNO, "readahead failed on %s",
> +			tst_device->fs_type);
>  	}
> -	tst_res(TFAIL | TTERRNO, "unexpected failure - "
> -		"returned value = %ld, expected: %ld",
> -		TST_RET, expected_ret);
>  	return 1;
>  }
>  
> @@ -163,8 +164,8 @@ static void read_testfile(int do_readahead, const char *fname, size_t fsize,
>  		do {
>  			TEST(readahead(fd, offset, fsize - offset));
>  			if (TST_RET != 0) {
> -				check_ret(0);
> -				break;
> +				SAFE_CLOSE(fd);
> +				return;
>  			}
>  
>  			/* estimate max readahead size based on first call */
> @@ -252,6 +253,8 @@ static void test_readahead(void)
>  	tst_res(TINFO, "read_testfile(1)");
>  	read_testfile(1, testfile, testfile_size, &read_bytes_ra,
>  		      &usec_ra, &cached_ra);
> +	if (check_ret())
> +		return;
>  	if (cached_ra > cached_low)
>  		cached_ra = cached_ra - cached_low;
>  	else
> -- 
> 2.17.1
> 

-- 
Cyril Hrubis
chrubis@suse.cz

WARNING: multiple messages have this Message-ID (diff)
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v3 3/6] syscalls/readahead02: abort test if readahead syscall fails
Date: Tue, 20 Nov 2018 17:30:31 +0100	[thread overview]
Message-ID: <20181120161811.GB18182@rei.lan> (raw)
In-Reply-To: <20181010233441.5337-4-amir73il@gmail.com>

Hi!
> There is no reason to continue the test if readahead syscall fails
> and we can also check and report TCONF if filesystem does not support
> readahead.

This looks good, but I would like to get rid of the check_ret function
as I said in the first case.

So maybe we can leave it in the cleanup but move the actuall code in
this patch. Does that sounds good to you?

> Signed-off-by: Amir Goldstein <amir73il@gmail.com>
> ---
>  .../kernel/syscalls/readahead/readahead02.c   | 21 +++++++++++--------
>  1 file changed, 12 insertions(+), 9 deletions(-)
> 
> diff --git a/testcases/kernel/syscalls/readahead/readahead02.c b/testcases/kernel/syscalls/readahead/readahead02.c
> index c739d3ba2..f77e7c66c 100644
> --- a/testcases/kernel/syscalls/readahead/readahead02.c
> +++ b/testcases/kernel/syscalls/readahead/readahead02.c
> @@ -45,16 +45,17 @@ static struct tst_option options[] = {
>  	{NULL, NULL, NULL}
>  };
>  
> -static int check_ret(long expected_ret)
> +static int check_ret(void)
>  {
> -	if (expected_ret == TST_RET) {
> -		tst_res(TPASS, "expected ret success - "
> -			"returned value = %ld", TST_RET);
> +	if (TST_RET == 0)
>  		return 0;
> +	if (TST_ERR == EINVAL) {
> +		tst_res(TCONF, "readahead not supported on %s",
> +			tst_device->fs_type);
> +	} else {
> +		tst_res(TFAIL | TTERRNO, "readahead failed on %s",
> +			tst_device->fs_type);
>  	}
> -	tst_res(TFAIL | TTERRNO, "unexpected failure - "
> -		"returned value = %ld, expected: %ld",
> -		TST_RET, expected_ret);
>  	return 1;
>  }
>  
> @@ -163,8 +164,8 @@ static void read_testfile(int do_readahead, const char *fname, size_t fsize,
>  		do {
>  			TEST(readahead(fd, offset, fsize - offset));
>  			if (TST_RET != 0) {
> -				check_ret(0);
> -				break;
> +				SAFE_CLOSE(fd);
> +				return;
>  			}
>  
>  			/* estimate max readahead size based on first call */
> @@ -252,6 +253,8 @@ static void test_readahead(void)
>  	tst_res(TINFO, "read_testfile(1)");
>  	read_testfile(1, testfile, testfile_size, &read_bytes_ra,
>  		      &usec_ra, &cached_ra);
> +	if (check_ret())
> +		return;
>  	if (cached_ra > cached_low)
>  		cached_ra = cached_ra - cached_low;
>  	else
> -- 
> 2.17.1
> 

-- 
Cyril Hrubis
chrubis@suse.cz

  reply	other threads:[~2018-11-20 16:30 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-10 23:34 [PATCH v3 0/6] Tests for readahead() and fadvise() on overlayfs Amir Goldstein
2018-10-10 23:34 ` [LTP] " Amir Goldstein
2018-10-10 23:34 ` [PATCH v3 1/6] syscalls/readahead01: Convert to newlib Amir Goldstein
2018-10-10 23:34   ` [LTP] " Amir Goldstein
2018-11-02 15:34   ` Cyril Hrubis
2018-11-02 15:34     ` [LTP] " Cyril Hrubis
2018-10-10 23:34 ` [PATCH v3 2/6] syscalls/readahead02: Convert to newlib and cleanup Amir Goldstein
2018-10-10 23:34   ` [LTP] " Amir Goldstein
2018-11-20 16:07   ` Cyril Hrubis
2018-11-20 16:07     ` [LTP] " Cyril Hrubis
2018-11-20 16:42     ` Cyril Hrubis
2018-11-20 16:42       ` Cyril Hrubis
2018-11-28 16:50     ` Amir Goldstein
2018-11-28 16:50       ` [LTP] " Amir Goldstein
2018-10-10 23:34 ` [PATCH v3 3/6] syscalls/readahead02: abort test if readahead syscall fails Amir Goldstein
2018-10-10 23:34   ` [LTP] " Amir Goldstein
2018-11-20 16:30   ` Cyril Hrubis [this message]
2018-11-20 16:30     ` Cyril Hrubis
2018-11-28  9:52     ` Amir Goldstein
2018-11-28  9:52       ` [LTP] " Amir Goldstein
2018-10-10 23:34 ` [PATCH v3 4/6] syscalls/readahead02: test readahead() on an overlayfs file Amir Goldstein
2018-10-10 23:34   ` [LTP] " Amir Goldstein
2018-10-10 23:34 ` [PATCH v3 5/6] syscalls/readahead02: test readahead using posix_fadvise() Amir Goldstein
2018-10-10 23:34   ` [LTP] " Amir Goldstein
2018-10-10 23:34 ` [PATCH v3 6/6] syscalls/readahead02: fail test if readahead did not use any cache Amir Goldstein
2018-10-10 23:34   ` [LTP] " Amir Goldstein
2018-11-02 10:32 ` [PATCH v3 0/6] Tests for readahead() and fadvise() on overlayfs Amir Goldstein
2018-11-02 10:32   ` [LTP] " Amir Goldstein

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=20181120161811.GB18182@rei.lan \
    --to=chrubis@suse.cz \
    --cc=amir73il@gmail.com \
    --cc=jstancek@redhat.com \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=ltp@lists.linux.it \
    --cc=miklos@szeredi.hu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.