syscalls/copy_file_range02: Improve error message
PATCH 1/2 syscalls/copy_file_range02: Improve error message
Changing error message as 255 exit code occurs on some systems not only for "command not find" (usual ENOENT from execve()) but also for swapon failure:
swapon: /tmp/5Q4kqc/file_swap: swapon failed: Invalid argument copy_file_range02.c:89: CONF: swapon binary not installed
+ improve info message for syscall tests
--- testcases/kernel/syscalls/copy_file_range/copy_file_range.h | 2 +- testcases/kernel/syscalls/copy_file_range/copy_file_range02.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
testcases/kernel/syscalls/copy_file_range/copy_file_range.h +1 -1
@@ -41,7 +41,7 @@ static void syscall_info(void)tst_res (TINFO ,"Testing libc copy_file_range()" );break ;case 1 : -tst_res (TINFO ,"Testing tst copy_file_range()" ); +tst_res (TINFO ,"Testing __NR_copy_file_range syscall" ); } }
testcases/kernel/syscalls/copy_file_range/copy_file_range02.c +1 -1
@@ -86,7 +86,7 @@ static int run_command(char *command, char *option, char *file)case 0 :return 0 ;case 255 : -tst_res (TCONF ,"%s binary not installed" , command); +tst_res (TCONF ,"%s binary not installed or failed" , command);return 1 ;default :tst_res (TCONF ,"%s exited with %i" , command, ret);
Signature · 1 line
2.22.0
PATCH 2/2 syscalls/copy_file_range02: Add test description
to increase readability as all_filesystems flag prolonged output a lot.
--- .../copy_file_range/copy_file_range02.c | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-)
testcases/kernel/syscalls/copy_file_range/copy_file_range02.c +18 -15
@@ -13,14 +13,14 @@* 2) Try to copy contents to directory -> EISDIR * 3) Try to copy contents to a file opened with the * O_APPEND flag -> EBADF -* 4) Try to copy contents to closed filedescriptor +* 4) Try to copy contents to closed file descriptor * -> EBADF * 5) Try to copy contents with invalid 'flags' value * -> EINVAL * 6) Try to copy contents to a file chattred with +i * flag -> EPERM * 7) Try to copy contents to a swapfile ->ETXTBSY -* 8) Try to copy contents to the samefile with overlapping +* 8) Try to copy contents to the same file with overlapping * ->EINVAL * 9) Try to copy contents to a blkdev ->EINVAL * 10) Try to copy contents to a chardev ->EINVAL
@@ -60,20 +60,21 @@ static struct tcase {int exp_err;loff_t dst;loff_t len; +const char *tname; } tcases[] = { - {&fd_rdonly, 0, EBADF, 0, CONTSIZE}, - {&fd_dir, 0, EISDIR, 0, CONTSIZE}, - {&fd_append, 0, EBADF, 0, CONTSIZE}, - {&fd_closed, 0, EBADF, 0, CONTSIZE}, - {&fd_dest, -1, EINVAL, 0, CONTSIZE}, - {&fd_immutable, 0, EPERM, 0, CONTSIZE}, - {&fd_swapfile, 0, ETXTBSY, 0, CONTSIZE}, - {&fd_dup, 0, EINVAL, 0, CONTSIZE/2}, - {&fd_blkdev, 0, EINVAL, 0, CONTSIZE}, - {&fd_chrdev, 0, EINVAL, 0, CONTSIZE}, - {&fd_fifo, 0, EINVAL, 0, CONTSIZE}, - {&fd_copy, 0, EOVERFLOW, MAX_OFF, ULLONG_MAX}, - {&fd_copy, 0, EFBIG, MAX_OFF, MIN_OFF}, + {&fd_rdonly, 0, EBADF, 0, CONTSIZE, "readonly file"}, + {&fd_dir, 0, EISDIR, 0, CONTSIZE, "directory"}, + {&fd_append, 0, EBADF, 0, CONTSIZE, "append to file"}, + {&fd_closed, 0, EBADF, 0, CONTSIZE, "closed file descriptor"}, + {&fd_dest, -1, EINVAL, 0, CONTSIZE, "invalid flags"}, + {&fd_immutable, 0, EPERM, 0, CONTSIZE, "immutable file"}, + {&fd_swapfile, 0, ETXTBSY, 0, CONTSIZE, "swap file"}, + {&fd_dup, 0, EINVAL, 0, CONTSIZE/2, "overlaping"}, + {&fd_blkdev, 0, EINVAL, 0, CONTSIZE, "block device"}, + {&fd_chrdev, 0, EINVAL, 0, CONTSIZE, "charr device"}, + {&fd_fifo, 0, EINVAL, 0, CONTSIZE, "fifo"}, + {&fd_copy, 0, EOVERFLOW, MAX_OFF, ULLONG_MAX, "max length lenght"}, + {&fd_copy, 0, EFBIG, MAX_OFF, MIN_OFF, "max file size"}, }; static int run_command(char *command, char *option, char *file)
@@ -97,6 +98,8 @@ static int run_command(char *command, char *option, char *file)static void verify_copy_file_range (unsigned int n) {struct tcase *tc = &tcases[n]; +tst_res (TINFO ,"Test #%d: %s" , n, tc->tname); +if (tc->copy_to_fd == &fd_immutable && chattr_i_nsup) {tst_res (TCONF ,"filesystem doesn't support chattr +i, skip it" );return ;
Signature · 1 line
2.22.0
PATCH 2/2 syscalls/copy_file_range02: Add test description
Hi
Quoted 45 lines
to increase readability as
all_filesystemsflag prolonged output a lot.Signed-off-by Petr Vorel <[email protected]>--- .../copy_file_range/copy_file_range02.c | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-)testcases/kernel/syscalls/copy_file_range/copy_file_range02.c +3
-13@@ -13,14 +13,14 @@* 2) Try to copy contents to directory -> EISDIR * 3) Try to copy contents to a file opened with the * O_APPEND flag -> EBADF -* 4) Try to copy contents to closed filedescriptor +* 4) Try to copy contents to closed file descriptor * -> EBADF * 5) Try to copy contents with invalid 'flags' value * -> EINVAL * 6) Try to copy contents to a file chattred with +i * flag -> EPERM * 7) Try to copy contents to a swapfile ->ETXTBSY -* 8) Try to copy contents to the samefile with overlapping +* 8) Try to copy contents to the same file with overlapping * ->EINVAL * 9) Try to copy contents to a blkdev ->EINVAL * 10) Try to copy contents to a chardev ->EINVAL @@ -60,20 +60,21 @@ static struct tcase {int exp_err;loff_t dst;loff_t len; +const char *tname; } tcases[] = { - {&fd_rdonly, 0, EBADF, 0, CONTSIZE}, - {&fd_dir, 0, EISDIR, 0, CONTSIZE}, - {&fd_append, 0, EBADF, 0, CONTSIZE}, - {&fd_closed, 0, EBADF, 0, CONTSIZE}, - {&fd_dest, -1, EINVAL, 0, CONTSIZE}, - {&fd_immutable, 0, EPERM, 0, CONTSIZE}, - {&fd_swapfile, 0, ETXTBSY, 0, CONTSIZE}, - {&fd_dup, 0, EINVAL, 0, CONTSIZE/2}, - {&fd_blkdev, 0, EINVAL, 0, CONTSIZE}, - {&fd_chrdev, 0, EINVAL, 0, CONTSIZE}, - {&fd_fifo, 0, EINVAL, 0, CONTSIZE},
testcases/kernel/syscalls/copy_file_range/copy_file_range02.c static struct tcase { · line 72
Quoted 10 lines
testcases/kernel/syscalls/copy_file_range/copy_file_range02.c +8
-2- {&fd_copy, 0, EOVERFLOW, MAX_OFF, ULLONG_MAX}, - {&fd_copy, 0, EFBIG, MAX_OFF, MIN_OFF}, + {&fd_rdonly, 0, EBADF, 0, CONTSIZE, "readonly file"}, + {&fd_dir, 0, EISDIR, 0, CONTSIZE, "directory"}, + {&fd_append, 0, EBADF, 0, CONTSIZE, "append to file"}, + {&fd_closed, 0, EBADF, 0, CONTSIZE, "closed file descriptor"}, + {&fd_dest, -1, EINVAL, 0, CONTSIZE, "invalid flags"}, + {&fd_immutable, 0, EPERM, 0, CONTSIZE, "immutable file"}, + {&fd_swapfile, 0, ETXTBSY, 0, CONTSIZE, "swap file"}, + {&fd_dup, 0, EINVAL, 0, CONTSIZE/2, "overlaping"},
overlaping range
testcases/kernel/syscalls/copy_file_range/copy_file_range02.c static struct tcase { · line 74
Quoted 2 lines
testcases/kernel/syscalls/copy_file_range/copy_file_range02.c +2
-0+ {&fd_blkdev, 0, EINVAL, 0, CONTSIZE, "block device"}, + {&fd_chrdev, 0, EINVAL, 0, CONTSIZE, "charr device"},
char device
Quoted 7 lines
testcases/kernel/syscalls/copy_file_range/copy_file_range02.c +3
-0+ {&fd_fifo, 0, EINVAL, 0, CONTSIZE, "fifo"}, + {&fd_copy, 0, EOVERFLOW, MAX_OFF, ULLONG_MAX, "max length lenght"}, + {&fd_copy, 0, EFBIG, MAX_OFF, MIN_OFF, "max file size"}, };static int run_command (char *command,char *option,char *file)
testcases/kernel/syscalls/copy_file_range/copy_file_range02.c static int run_command(char *command, char *option, char *file) · line 105
Quoted 8 lines
testcases/kernel/syscalls/copy_file_range/copy_file_range02.c +2
-0@@ -97,6 +98,8 @@ static int run_command(char *command, char *option, char *file)static void verify_copy_file_range (unsigned int n) {struct tcase *tc = &tcases[n]; +tst_res (TINFO ,"Test #%d: %s" , n, tc->tname); +if (tc->copy_to_fd == &fd_immutable && chattr_i_nsup) {tst_res (TCONF ,"filesystem doesn't support chattr +i, skip it" );return ;
Other than typos, this patchset looks good to me.
PATCH 2/2 syscalls/copy_file_range02: Add test description
Hi Xu, Murphy,
...
Quoted 5 lines
testcases/kernel/syscalls/copy_file_range/copy_file_range02.c static struct tcase { · line 72
Quoted 1 line
testcases/kernel/syscalls/copy_file_range/copy_file_range02.c +1
-0+ {&fd_dup, 0, EINVAL, 0, CONTSIZE/2, "overlaping"},overlaping range
testcases/kernel/syscalls/copy_file_range/copy_file_range02.c static struct tcase { · line 74
Quoted 2 lines
testcases/kernel/syscalls/copy_file_range/copy_file_range02.c +2
-0+ {&fd_blkdev, 0, EINVAL, 0, CONTSIZE, "block device"}, + {&fd_chrdev, 0, EINVAL, 0, CONTSIZE, "charr device"},char device
Thanks for your review. Fixed and merged with your ack.
Kind regards,
Petr
PATCH 2/2 syscalls/copy_file_range02: Add test description
In reply to Petr VorelQuoted 1 line · Petr Vorel
to increase readability as
all_filesystemsflag prolonged output a lot.
Test ok. Ack.
Thanks,
M
Quoted 74 lines
Signed-off-by Petr Vorel <[email protected]>--- .../copy_file_range/copy_file_range02.c | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-)testcases/kernel/syscalls/copy_file_range/copy_file_range02.c +18
-15@@ -13,14 +13,14 @@* 2) Try to copy contents to directory -> EISDIR * 3) Try to copy contents to a file opened with the * O_APPEND flag -> EBADF -* 4) Try to copy contents to closed filedescriptor +* 4) Try to copy contents to closed file descriptor * -> EBADF * 5) Try to copy contents with invalid 'flags' value * -> EINVAL * 6) Try to copy contents to a file chattred with +i * flag -> EPERM * 7) Try to copy contents to a swapfile ->ETXTBSY -* 8) Try to copy contents to the samefile with overlapping +* 8) Try to copy contents to the same file with overlapping * ->EINVAL * 9) Try to copy contents to a blkdev ->EINVAL * 10) Try to copy contents to a chardev ->EINVAL @@ -60,20 +60,21 @@ static struct tcase {int exp_err;loff_t dst;loff_t len; +const char *tname; } tcases[] = { - {&fd_rdonly, 0, EBADF, 0, CONTSIZE}, - {&fd_dir, 0, EISDIR, 0, CONTSIZE}, - {&fd_append, 0, EBADF, 0, CONTSIZE}, - {&fd_closed, 0, EBADF, 0, CONTSIZE}, - {&fd_dest, -1, EINVAL, 0, CONTSIZE}, - {&fd_immutable, 0, EPERM, 0, CONTSIZE}, - {&fd_swapfile, 0, ETXTBSY, 0, CONTSIZE}, - {&fd_dup, 0, EINVAL, 0, CONTSIZE/2}, - {&fd_blkdev, 0, EINVAL, 0, CONTSIZE}, - {&fd_chrdev, 0, EINVAL, 0, CONTSIZE}, - {&fd_fifo, 0, EINVAL, 0, CONTSIZE}, - {&fd_copy, 0, EOVERFLOW, MAX_OFF, ULLONG_MAX}, - {&fd_copy, 0, EFBIG, MAX_OFF, MIN_OFF}, + {&fd_rdonly, 0, EBADF, 0, CONTSIZE, "readonly file"}, + {&fd_dir, 0, EISDIR, 0, CONTSIZE, "directory"}, + {&fd_append, 0, EBADF, 0, CONTSIZE, "append to file"}, + {&fd_closed, 0, EBADF, 0, CONTSIZE, "closed file descriptor"}, + {&fd_dest, -1, EINVAL, 0, CONTSIZE, "invalid flags"}, + {&fd_immutable, 0, EPERM, 0, CONTSIZE, "immutable file"}, + {&fd_swapfile, 0, ETXTBSY, 0, CONTSIZE, "swap file"}, + {&fd_dup, 0, EINVAL, 0, CONTSIZE/2, "overlaping"}, + {&fd_blkdev, 0, EINVAL, 0, CONTSIZE, "block device"}, + {&fd_chrdev, 0, EINVAL, 0, CONTSIZE, "charr device"}, + {&fd_fifo, 0, EINVAL, 0, CONTSIZE, "fifo"}, + {&fd_copy, 0, EOVERFLOW, MAX_OFF, ULLONG_MAX, "max length lenght"}, + {&fd_copy, 0, EFBIG, MAX_OFF, MIN_OFF, "max file size"}, }; static int run_command(char *command, char *option, char *file)@@ -97,6 +98,8 @@ static int run_command(char *command, char *option, char *file)static void verify_copy_file_range (unsigned int n) {struct tcase *tc = &tcases[n]; +tst_res (TINFO ,"Test #%d: %s" , n, tc->tname); +if (tc->copy_to_fd == &fd_immutable && chattr_i_nsup) {tst_res (TCONF ,"filesystem doesn't support chattr +i, skip it" );return ;Signature · 1 line
2.22.0