<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, May 31, 2019 at 6:15 PM Xiao Yang <<a href="mailto:yangx.jy@cn.fujitsu.com" target="_blank">yangx.jy@cn.fujitsu.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 2019/05/31 16:44, Jinhui huang wrote:<br>
> On new kernels, copy_file_range() returned EISDIR when copyed contents<br>
> to directory, but on old kernels, it returned EBADF, we should accept<br>
> EBADF to be compatible with new and old kernels.<br>
><br>
> The patch as follows:<br>
> commit 11cbfb10775a ("vfs: deny copy_file_range() for non regular files")<br>
Hi,<br>
<br>
>From description of commit, I wonder if we can add more tests for some<br>
non regular files(e.g. block, pipe)?<br></blockquote><div><br></div><div class="gmail_default" style="font-size:small">I have no objection on this. But, is there really make sense to test some more non regular files which not being mentioned by Linux Manual Page?</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">The copy_file_range02 test errors are all extract from manual page, I commented that in Christian's first patch version. And I don't think it's necessary to test undefined behavior in syscall using, because how do we know what error return is the expected?</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
I just want to increase coverage and fix all similar issues as you did. :-)<br>
<br>
Best Regards,<br>
Xiao Yang<br>
> Signed-off-by: Jinhui huang <<a href="mailto:huangjh.jy@cn.fujitsu.com" target="_blank">huangjh.jy@cn.fujitsu.com</a>><br>
> ---<br>
>  .../syscalls/copy_file_range/copy_file_range02.c   | 33 +++++++++++++++-------<br>
>  1 file changed, 23 insertions(+), 10 deletions(-)<br>
><br>
> diff --git a/testcases/kernel/syscalls/copy_file_range/copy_file_range02.c b/testcases/kernel/syscalls/copy_file_range/copy_file_range02.c<br>
> index 07c0207..9e6356c 100644<br>
> --- a/testcases/kernel/syscalls/copy_file_range/copy_file_range02.c<br>
> +++ b/testcases/kernel/syscalls/copy_file_range/copy_file_range02.c<br>
> @@ -54,19 +54,32 @@ static void verify_copy_file_range(unsigned int n)<br>
>       TEST(sys_copy_file_range(fd_src, 0, *tc->copy_to_fd,<br>
>                               0, CONTSIZE, tc->flags));<br>
>  <br>
> -     if (TST_RET == -1) {<br>
> -             if (tc->exp_err == TST_ERR) {<br>
> +     if (TST_RET != -1) {<br>
> +             tst_res(TFAIL,<br>
> +                     "copy_file_range returned wrong value: %ld", TST_RET);<br>
> +             return;<br>
> +     }<br>
> +<br>
> +     if (tc->exp_err == TST_ERR) {<br>
> +             tst_res(TPASS | TTERRNO,<br>
> +                     "copy_file_range failed as expected");<br>
> +     } else {<br>
> +             /* copy_file_range() returned EISDIR when copyed contents to<br>
> +              * directory on new kernels, but on old kernels, it returned<br>
> +              * EBADF.<br>
> +              *<br>
> +              * the patch as follws:<br>
> +              * commit 11cbfb10775a ("vfs: deny copy_file_range() for non regular files")<br>
> +              */<br>
> +             if (tc->exp_err == EISDIR && TST_ERR == EBADF) {<br>
>                       tst_res(TPASS | TTERRNO,<br>
> -                                     "copy_file_range failed as expected");<br>
> -             } else {<br>
> -                     tst_res(TFAIL | TTERRNO,<br>
> -                             "copy_file_range failed unexpectedly; expected %s, but got",<br>
> -                             tst_strerrno(tc->exp_err));<br>
> +                             "copy_file_range failed as expected");<br>
>                       return;<br>
>               }<br>
> -     } else {<br>
> -             tst_res(TFAIL,<br>
> -                     "copy_file_range returned wrong value: %ld", TST_RET);<br>
> +<br>
> +             tst_res(TFAIL | TTERRNO,<br>
> +                     "copy_file_range failed unexpectedly; expected %s, but got",<br>
> +                     tst_strerrno(tc->exp_err));<br>
>       }<br>
>  }<br>
>  <br>
<br>
<br>
<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="m_1781087082608906626gmail_signature"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>