cleanup: Modify incorrect use of test macros and annotation style
cover cleanup: Modify incorrect use of test macros and annotation style
- modify incorrect use of test macros;
- unify the annotation style and remove Redundant code.
Xie Ziyao (2):
Modify incorrect use of TERRNO and replace functions with safe_macros Unify the annotation style and remove Redundant code
testcases/kernel/syscalls/bpf/bpf_map01.c | 2 +- .../syscalls/clock_gettime/clock_gettime03.c | 20 +++++++------------ .../clock_nanosleep/clock_nanosleep01.c | 2 +- .../clock_nanosleep/clock_nanosleep03.c | 18 +++++++---------- testcases/kernel/syscalls/clone3/clone301.c | 5 +++++ testcases/kernel/syscalls/clone3/clone302.c | 5 +++++ .../copy_file_range/copy_file_range02.c | 2 +- .../copy_file_range/copy_file_range03.c | 2 +- testcases/kernel/syscalls/dup/dup03.c | 4 ++-- testcases/kernel/syscalls/execle/Makefile | 19 +++--------------- testcases/kernel/syscalls/execlp/Makefile | 19 +++--------------- testcases/kernel/syscalls/execve/execve02.c | 4 ++-- testcases/kernel/syscalls/execvp/Makefile | 20 +++---------------- .../kernel/syscalls/fallocate/fallocate04.c | 2 +- testcases/kernel/syscalls/getcwd/getcwd01.c | 4 ++-- testcases/kernel/syscalls/getcwd/getcwd02.c | 2 +- .../syscalls/init_module/init_module01.c | 2 +- .../syscalls/init_module/init_module02.c | 2 +- .../kernel/syscalls/io_uring/io_uring02.c | 10 +++++----- testcases/kernel/syscalls/ioctl/ioctl04.c | 4 ++-- testcases/kernel/syscalls/ioperm/ioperm01.c | 2 +- testcases/kernel/syscalls/lgetxattr/Makefile | 16 +-------------- 22 files changed, 56 insertions(+), 110 deletions(-)
--
2.17.1
PATCH 1/2 kernel/syscalls: Modify incorrect use of TERRNO and replace functions with safe_macros
- modify some incorrect use of TERRNO/TTERRNO in kernel/syscalls;
- replace functions with safe_macros to check the return value in kernel/syscalls.
--- testcases/kernel/syscalls/bpf/bpf_map01.c | 2 +- .../syscalls/clock_nanosleep/clock_nanosleep01.c | 2 +- .../syscalls/copy_file_range/copy_file_range02.c | 2 +- .../syscalls/copy_file_range/copy_file_range03.c | 2 +- testcases/kernel/syscalls/dup/dup03.c | 4 ++-- testcases/kernel/syscalls/execve/execve02.c | 4 ++-- testcases/kernel/syscalls/fallocate/fallocate04.c | 2 +- testcases/kernel/syscalls/getcwd/getcwd01.c | 4 ++-- testcases/kernel/syscalls/getcwd/getcwd02.c | 2 +- testcases/kernel/syscalls/init_module/init_module01.c | 2 +- testcases/kernel/syscalls/init_module/init_module02.c | 2 +- testcases/kernel/syscalls/io_uring/io_uring02.c | 10 +++++----- testcases/kernel/syscalls/ioctl/ioctl04.c | 4 ++-- testcases/kernel/syscalls/ioperm/ioperm01.c | 2 +- 14 files changed, 22 insertions(+), 22 deletions(-)
testcases/kernel/syscalls/bpf/bpf_map01.c +1 -1
@@ -83,7 +83,7 @@ void run(unsigned int n)if (i <VAL_SZ )tst_res (TPASS ,"Preallocated array map lookup" ); }else { -tst_res (TFAIL |TERRNO ,"Prellocated array map lookup" ); +tst_res (TFAIL |TTERRNO ,"Prellocated array map lookup" ); }break ; }
testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep01.c +1 -1
@@ -208,7 +208,7 @@ static void do_test(unsigned int i)return ; } -tst_res (TPASS |TERRNO ,"clock_nanosleep() failed with" ); +tst_res (TPASS |TTERRNO ,"clock_nanosleep() failed with" ); }static struct tst_test test = {
testcases/kernel/syscalls/copy_file_range/copy_file_range02.c +1 -1
@@ -221,7 +221,7 @@ static void setup(void)SAFE_PIPE (fd_pipe);SAFE_WRITE (1 , fd_src,CONTENT ,CONTSIZE ); -close (fd_src); +SAFE_CLOSE (fd_src); fd_src =SAFE_OPEN (FILE_SRC_PATH ,O_RDONLY ,0664 ); fd_dup =SAFE_OPEN (FILE_SRC_PATH ,O_WRONLY |O_CREAT ,0666 );
testcases/kernel/syscalls/copy_file_range/copy_file_range03.c +1 -1
@@ -21,7 +21,7 @@ unsigned long get_timestamp(int fd) {struct stat filestat; -fstat (fd, &filestat); +SAFE_FSTAT (fd, &filestat);return filestat.st_mtime; }
testcases/kernel/syscalls/dup/dup03.c +2 -2
@@ -30,9 +30,9 @@ static void run(void)if (TST_RET ==-1 ) {if (TST_ERR ==EMFILE ) -tst_res (TPASS |TERRNO ,"dup() failed as expected" ); +tst_res (TPASS |TTERRNO ,"dup() failed as expected" );else -tst_res (TFAIL |TERRNO ,"dup() failed unexpectedly" ); +tst_res (TFAIL |TTERRNO ,"dup() failed unexpectedly" );return ; }
testcases/kernel/syscalls/execve/execve02.c +2 -2
@@ -49,9 +49,9 @@ static void do_child(void)tst_brk (TFAIL ,"execve() passed unexpectedly" );if (TST_ERR !=EACCES ) -tst_brk (TFAIL |TERRNO ,"execve() failed unexpectedly" ); +tst_brk (TFAIL |TTERRNO ,"execve() failed unexpectedly" ); -tst_res (TPASS |TERRNO ,"execve() failed expectedly" ); +tst_res (TPASS |TTERRNO ,"execve() failed expectedly" );exit (0 ); }
testcases/kernel/syscalls/fallocate/fallocate04.c +1 -1
@@ -43,7 +43,7 @@ static size_t get_allocsize(void) {struct stat file_stat; -fsync (fd); +SAFE_FSYNC (fd);SAFE_FSTAT (fd, &file_stat);
testcases/kernel/syscalls/getcwd/getcwd01.c +2 -2
@@ -54,12 +54,12 @@ static void verify_getcwd(unsigned int n) }if (TST_ERR != tc->exp_err) { -tst_res (TFAIL |TTERRNO ,"getcwd() failed unexpectedly, expected %s" , +tst_res (TFAIL |TERRNO ,"getcwd() failed unexpectedly, expected %s" ,tst_strerrno (tc->exp_err));return ; } -tst_res (TPASS |TTERRNO ,"getcwd() failed as expected" ); +tst_res (TPASS |TERRNO ,"getcwd() failed as expected" ); }static struct tst_test test = {
testcases/kernel/syscalls/getcwd/getcwd02.c +1 -1
@@ -73,7 +73,7 @@ static void verify_getcwd(unsigned int n) res =getcwd (tc->buf, tc->size);TST_ERR = errno;if (!res) { -tst_res (TFAIL |TTERRNO ,"getcwd() failed" ); +tst_res (TFAIL |TERRNO ,"getcwd() failed" ); goto end; }
testcases/kernel/syscalls/init_module/init_module01.c +1 -1
@@ -45,7 +45,7 @@ static void run(void)static void cleanup (void ) { -munmap (buf, sb.st_size); +SAFE_MUNMAP (buf, sb.st_size); }static struct tst_test test = {
testcases/kernel/syscalls/init_module/init_module02.c +1 -1
@@ -86,7 +86,7 @@ static void run(unsigned int n)static void cleanup (void ) { -munmap (buf, size); +SAFE_MUNMAP (buf, size); }static struct tst_test test = {
testcases/kernel/syscalls/io_uring/io_uring02.c +5 -5
@@ -134,7 +134,7 @@ static void drain_fallback(void)if (cqe_ptr->res >=0 || cqe_ptr->res == -EAGAIN )continue ; -tst_res (TFAIL |TTERRNO , +tst_res (TFAIL |TERRNO ,"Spam request failed unexpectedly" );continue ; }
@@ -150,10 +150,10 @@ static void drain_fallback(void)if (cqe_ptr->res >=0 ) {tst_res (TFAIL ,"Write outside chroot succeeded." ); }else if (cqe_ptr->res != -ENOENT ) { -tst_res (TFAIL |TTERRNO , +tst_res (TFAIL |TERRNO ,"Write outside chroot failed unexpectedly" ); }else { -tst_res (TPASS |TTERRNO , +tst_res (TPASS |TERRNO ,"Write outside chroot failed as expected" ); } }
@@ -197,12 +197,12 @@ static void check_result(void) }if (cqe_ptr->res != -ENOENT ) { -tst_res (TFAIL |TTERRNO , +tst_res (TFAIL |TERRNO ,"Write outside chroot failed unexpectedly" );return ; } -tst_res (TPASS |TTERRNO ,"Write outside chroot failed as expected" ); +tst_res (TPASS |TERRNO ,"Write outside chroot failed as expected" ); }static void run (void )
testcases/kernel/syscalls/ioctl/ioctl04.c +2 -2
@@ -47,11 +47,11 @@ static void verify_ioctl(void) }if (TST_ERR ==EACCES ) { -tst_res (TPASS |TERRNO ,"Mounting RO device RW failed" ); +tst_res (TPASS |TTERRNO ,"Mounting RO device RW failed" ); goto next; } -tst_res (TFAIL |TERRNO , +tst_res (TFAIL |TTERRNO ,"Mounting RO device RW failed unexpectedly expected EACCES" ); next:
testcases/kernel/syscalls/ioperm/ioperm01.c +1 -1
@@ -64,7 +64,7 @@ static void cleanup(void)* Reset I/O privileges for the specified port. */ if ((ioperm (io_addr,NUM_BYTES ,0 )) ==-1 ) -tst_brk (TBROK |TTERRNO ,"ioperm() cleanup failed" ); +tst_brk (TBROK |TERRNO ,"ioperm() cleanup failed" ); }static struct tst_test test = {
--
2.17.1
PATCH 1/2 kernel/syscalls: Modify incorrect use of TERRNO and replace functions with safe_macros
Quoted 2 lines
- modify some incorrect use of TERRNO/TTERRNO in kernel/syscalls;
- replace functions withsafe_macrosto check the return value in kernel/syscalls.
These two would be really better to put 2 commits.
Kind regards,
Petr
PATCH 1/2 kernel/syscalls: Modify incorrect use of TERRNO and replace functions with safe_macros
Hi, Petr,
Quoted 1 line
Quoted 1 line
- modify some incorrect use of TERRNO/TTERRNO in kernel/syscalls;
I just re-checked the latest code and submit the v2 version.
Please see:
https://patchwork.ozlabs.org/project/ltp/patch/[email protected]/
Quoted 1 line
Quoted 1 line
- replace functions with
safe_macrosto check the return value in kernel/syscalls.
As for this type of modification, I'll try to use script to replace all of them.
Quoted 6 lines
These two would be really better to put 2 commits.
Kind regards,
Petr
.
Thanks for your review.
Kind Regards,
Ziyao
PATCH 2/2 kernel/syscalls: Unify the annotation style and remove Redundant code
In reply to Xie ZiyaoChange License for Makefile and remove some unnecessary annotation in kernel/syscalls.
--- .../syscalls/clock_gettime/clock_gettime03.c | 20 +++++++------------ .../clock_nanosleep/clock_nanosleep03.c | 18 +++++++---------- testcases/kernel/syscalls/clone3/clone301.c | 5 +++++ testcases/kernel/syscalls/clone3/clone302.c | 5 +++++ testcases/kernel/syscalls/execle/Makefile | 19 +++--------------- testcases/kernel/syscalls/execlp/Makefile | 19 +++--------------- testcases/kernel/syscalls/execvp/Makefile | 20 +++---------------- testcases/kernel/syscalls/lgetxattr/Makefile | 16 +-------------- 8 files changed, 34 insertions(+), 88 deletions(-)
testcases/kernel/syscalls/clock_gettime/clock_gettime03.c +7 -13
@@ -1,20 +1,14 @@// SPDX-License-Identifier: GPL-2.0-or-later /* - -Copyright (c) 2020 Cyril Hrubis <[email protected]> - +* Copyright (c) 2020 Cyril Hrubis <[email protected]> */ /* - -Basic test for timer namespaces. - -After a call to unshare(CLONE_NEWTIME) a new timer namespace is created, the -process that has called the unshare() can adjust offsets for CLOCK_MONOTONIC -and CLOCK_BOOTTIME for its children by writing to the '/proc/self/timens_offsets'. - -The child processes also switch to the initial parent namespace and checks -that the offset is set to 0. - +* After a call to unshare(CLONE_NEWTIME) a new timer namespace is created, the +* process that has called the unshare() can adjust offsets for CLOCK_MONOTONIC +* and CLOCK_BOOTTIME for its children by writing to the '/proc/self/timens_offsets'. +* +* The child processes also switch to the initial parent namespace and checks +* that the offset is set to 0. */ #define _GNU_SOURCE
testcases/kernel/syscalls/clock_nanosleep/clock_nanosleep03.c +7 -11
@@ -1,18 +1,14 @@// SPDX-License-Identifier: GPL-2.0-or-later /* - -Copyright (c) 2020 Cyril Hrubis <[email protected]> - +* Copyright (c) 2020 Cyril Hrubis <[email protected]> */ -/* - -Test that clock_nanosleep() adds correctly an offset with absolute timeout -and CLOCK_MONOTONIC inside of a timer namespace. - -After a call to unshare(CLONE_NEWTIME) a new timer namespace is created, the -process that has called the unshare() can adjust offsets for CLOCK_MONOTONIC -and CLOCK_BOOTTIME for its children by writing to the '/proc/self/timens_offsets'. +/* +* Test that clock_nanosleep() adds correctly an offset with absolute timeout +* and CLOCK_MONOTONIC inside of a timer namespace. +* After a call to unshare(CLONE_NEWTIME) a new timer namespace is created, the +* process that has called the unshare() can adjust offsets for CLOCK_MONOTONIC +* and CLOCK_BOOTTIME for its children by writing to the '/proc/self/timens_offsets'. */ #include <stdlib.h>
testcases/kernel/syscalls/clone3/clone301.c +5 -0
@@ -1,9 +1,14 @@// SPDX-License-Identifier: GPL-2.0-or-later /* * Copyright (c) 2020 Viresh Kumar <[email protected]> +*/ + +/*\ +* [Description] * * Basic clone3() test. */ +#define _GNU_SOURCE#include <stdlib.h>
testcases/kernel/syscalls/clone3/clone302.c +5 -0
@@ -1,9 +1,14 @@// SPDX-License-Identifier: GPL-2.0-or-later /* * Copyright (c) 2020 Viresh Kumar <[email protected]> +*/ + +/*\ +* [Description] * * Basic clone3() test to check various failures. */ +#define _GNU_SOURCE#include <stdlib.h>
testcases/kernel/syscalls/execle/Makefile +3 -16
@@ -1,20 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0-or-later # -# Copyright (c) Linux Test Project, 2018 -# Copyright (c) International Business Machines Corp., 2001 -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# +# Copyright (c) Linux Test Project, 2018 +# Copyright (c) International Business Machines Corp., 2001 top_srcdir ?= ../../../..
testcases/kernel/syscalls/execlp/Makefile +3 -16
@@ -1,20 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0-or-later # -# Copyright (c) Linux Test Project, 2018 -# Copyright (c) International Business Machines Corp., 2001 -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# +# Copyright (c) Linux Test Project, 2018 +# Copyright (c) International Business Machines Corp., 2001 top_srcdir ?= ../../../..
testcases/kernel/syscalls/execvp/Makefile +3 -17
@@ -1,20 +1,6 @@ -# -# Copyright (c) Linux Test Project, 2018 -# Copyright (c) International Business Machines Corp., 2001 -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) Linux Test Project, 2018 +# Copyright (c) International Business Machines Corp., 2001 top_srcdir ?= ../../../..
testcases/kernel/syscalls/lgetxattr/Makefile +1 -15
@@ -1,20 +1,6 @@ -# +# SPDX-License-Identifier: GPL-2.0-or-later # Copyright (c) 2016 Fujitsu Ltd. # Author: Jinbao Huang <[email protected]> -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -# the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. -# top_srcdir ?= ../../../..
--
2.17.1
PATCH 2/2 kernel/syscalls: Unify the annotation style and remove Redundant code
Hi Ziyao,
Quoted 2 lines
Change License for
Makefileand remove some unnecessary annotation in kernel/syscalls.
Thanks, merged!
I slightly modified C code changes - put docparse into clock_nanosleep03.c and clock_gettime03.c and modified the commit message.
Next time it'd be better to separate these changes - put Makefile changes into separate commit and ideally use script to replace all of them.
Kind regards,
Petr
PATCH 2/2 kernel/syscalls: Unify the annotation style and remove Redundant code
Hi, Petr,
Quoted 2 lines
Next time it'd be better to separate these changes - put
Makefilechanges into separate commit and ideally use script to replace all of them.
For all the testsuite that has used SPDX, I've also used script and shell commands to modify its Makefile to use SPDX.
Please take a look at this patch:
https://patchwork.ozlabs.org/project/ltp/patch/[email protected]/
Kind Regards,
Ziyao