Rewrite utstest suite
v5 cover Rewrite utstest suite
Added new tests and removed utstest which looked broken.
Andrea Cervesato (2):
Add SAFE_SETHOSTNAME macro
Rewrite utsname testing suite
include/safe_net_fn.h | 3 + include/tst_safe_net.h | 3 + lib/safe_net.c | 17 + runtest/containers | 16 +- .../kernel/containers/utsname/.gitignore | 5 +- testcases/kernel/containers/utsname/Makefile | 23 +- .../containers/utsname/runutstests_noltp.sh | 41 -- .../kernel/containers/utsname/utsname01.c | 56 +++ .../kernel/containers/utsname/utsname02.c | 81 ++++ .../kernel/containers/utsname/utsname03.c | 118 ++++++ .../kernel/containers/utsname/utsname04.c | 52 +++ testcases/kernel/containers/utsname/utstest.c | 353 ------------------ 12 files changed, 343 insertions(+), 425 deletions(-) delete mode 100755 testcases/kernel/containers/utsname/runutstests_noltp.sh create mode 100644 testcases/kernel/containers/utsname/utsname01.c create mode 100644 testcases/kernel/containers/utsname/utsname02.c create mode 100644 testcases/kernel/containers/utsname/utsname03.c create mode 100644 testcases/kernel/containers/utsname/utsname04.c delete mode 100644 testcases/kernel/containers/utsname/utstest.c
Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v5 1/2 Add SAFE_SETHOSTNAME macro
--- include/safe_net_fn.h | 3 +++ include/tst_safe_net.h | 3 +++ lib/safe_net.c | 17 +++++++++++++++++ 3 files changed, 23 insertions(+)
include/safe_net_fn.h +3 -0
@@ -73,6 +73,9 @@ int safe_getsockname(const char *file, const int lineno,int safe_gethostname (const char *file,const int lineno,char *name,size_t size); +int safe_sethostname (const char *file,const int lineno, +const char *name,size_t size); +int tst_getsockport (const char *file,const int lineno,int sockfd); unsigned short tst_get_unused_port(const char *file, const int lineno,
include/tst_safe_net.h +3 -0
@@ -68,6 +68,9 @@#define SAFE_GETHOSTNAME (name, size) \ safe_gethostname(__FILE__, __LINE__, name, size) +#define SAFE_SETHOSTNAME (name, size) \ + safe_sethostname(__FILE__, __LINE__, name, size) +#define TST_GETSOCKPORT (sockfd) \ tst_getsockport(__FILE__, __LINE__, sockfd)
lib/safe_net.c +17 -0
@@ -469,6 +469,23 @@ int safe_gethostname(const char *file, const int lineno,return rval; } +int safe_sethostname (const char *file,const int lineno, +const char *name,size_t size) +{ +int rval =sethostname (name, size); + +if (rval ==-1 ) { +tst_brkm_ (file, lineno,TBROK |TERRNO ,NULL , +"sethostname(%p, %zu) failed" , name, size); + }else if (rval) { +tst_brkm_ (file, lineno,TBROK |TERRNO ,NULL , +"Invalid sethostname(%p, %zu) return value %d" , name, + size, rval); + } + +return rval; +} +/* * @return port in network byte order. */
Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Re: [LTP] [PATCH v5 1/2] Add SAFE_SETHOSTNAME macro
Hello,
I think you forgot my existing Reviewed-by tag on this patch.
Quoted 65 lines · Andrea Cervesato via ltp
Signed-off-by Andrea Cervesato <[email protected]>--- include/safe_net_fn.h | 3 +++ include/tst_safe_net.h | 3 +++ lib/safe_net.c | 17 +++++++++++++++++ 3 files changed, 23 insertions(+)include/safe_net_fn.h +3
-0@@ -73,6 +73,9 @@ int safe_getsockname(const char *file, const int lineno,int safe_gethostname (const char *file,const int lineno,char *name,size_t size); +int safe_sethostname (const char *file,const int lineno, +const char *name,size_t size); +int tst_getsockport (const char *file,const int lineno,int sockfd); unsigned short tst_get_unused_port(const char *file, const int lineno,include/tst_safe_net.h +3
-0@@ -68,6 +68,9 @@#define SAFE_GETHOSTNAME (name, size) \ safe_gethostname(__FILE__, __LINE__, name, size) +#define SAFE_SETHOSTNAME (name, size) \ + safe_sethostname(__FILE__, __LINE__, name, size) +#define TST_GETSOCKPORT (sockfd) \ tst_getsockport(__FILE__, __LINE__, sockfd)lib/safe_net.c +17
-0@@ -469,6 +469,23 @@ int safe_gethostname(const char *file, const int lineno,return rval; } +int safe_sethostname (const char *file,const int lineno, +const char *name,size_t size) +{ +int rval =sethostname (name, size); + +if (rval ==-1 ) { +tst_brkm_ (file, lineno,TBROK |TERRNO ,NULL , +"sethostname(%p, %zu) failed" , name, size); + }else if (rval) { +tst_brkm_ (file, lineno,TBROK |TERRNO ,NULL , +"Invalid sethostname(%p, %zu) return value %d" , name, + size, rval); + } + +return rval; +} +/* * @return port in network byte order. */ Signature · 1 line
2.35.3
Signature · 5 lines
Thank you, Richard. -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v5 2/2 Rewrite utsname testing suite
In reply to Andrea Cervesato via ltpDeleted utstest.c and created the following new tests:
- utsname01
- utsname02
- utsname03
- utsname04
---
Deleted utsname.h
Usage of tst_reap_children
Cleaner code
runtest/containers | 16 +- .../kernel/containers/utsname/.gitignore | 5 +- testcases/kernel/containers/utsname/Makefile | 23 +- .../containers/utsname/runutstests_noltp.sh | 41 -- .../kernel/containers/utsname/utsname01.c | 56 +++ .../kernel/containers/utsname/utsname02.c | 81 ++++ .../kernel/containers/utsname/utsname03.c | 118 ++++++ .../kernel/containers/utsname/utsname04.c | 52 +++ testcases/kernel/containers/utsname/utstest.c | 353 ------------------ 9 files changed, 320 insertions(+), 425 deletions(-) delete mode 100755 testcases/kernel/containers/utsname/runutstests_noltp.sh create mode 100644 testcases/kernel/containers/utsname/utsname01.c create mode 100644 testcases/kernel/containers/utsname/utsname02.c create mode 100644 testcases/kernel/containers/utsname/utsname03.c create mode 100644 testcases/kernel/containers/utsname/utsname04.c delete mode 100644 testcases/kernel/containers/utsname/utstest.c
runtest/containers +6 -10
@@ -62,16 +62,12 @@ semtest_2ns_clone semtest_2ns -m clone semtest_2ns_unshare semtest_2ns -m unshare sem_comm sem_comm -utstest_unshare_1 utstest unshare 1 -utstest_unshare_2 utstest unshare 2 -utstest_unshare_3 utstest unshare 3 -utstest_unshare_4 utstest unshare 4 -utstest_unshare_5 utstest unshare 5 -utstest_clone_1 utstest clone 1 -utstest_clone_2 utstest clone 2 -utstest_clone_3 utstest clone 3 -utstest_clone_4 utstest clone 4 -utstest_clone_5 utstest clone 5 +utsname01 utsname01 +utsname02 utsname02 +utsname03_clone utsname03 -m clone +utsname03_unshare utsname03 -m unshare +utsname04_clone utsname04 -m clone +utsname04_unshare utsname04 -m unshare mountns01 mountns01 mountns02 mountns02
testcases/kernel/containers/utsname/.gitignore +4 -1
@@ -1 +1,4 @@ -/utstest +/utsname01 +/utsname02 +/utsname03 +/utsname04
testcases/kernel/containers/utsname/Makefile +3 -20
@@ -1,28 +1,11 @@ -################################################################################ -## ## -## Copyright (c) International Business Machines Corp., 2007 ## -## ## -## 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, write to the Free Software ## -## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ## -## ## -################################################################################ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (C) 2021 SUSE LLC Andrea Cervesato <[email protected]> top_srcdir ?= ../../../.. include $(top_srcdir)/include/mk/testcases.mk include $(abs_srcdir)/../Makefile.inc -LDLIBS := -lclone -lpthread -lrt $(LDLIBS) +LDLIBS := -lclone $(LDLIBS) include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/containers/utsname/runutstests_noltp.sh deleted +0 -41
41 lines not on this page · raw message
testcases/kernel/containers/utsname/utsname01.c new file +56 -0
56 lines not on this page · raw message
testcases/kernel/containers/utsname/utsname02.c new file +81 -0
81 lines not on this page · raw message
testcases/kernel/containers/utsname/utsname03.c new file +118 -0
118 lines not on this page · raw message
testcases/kernel/containers/utsname/utsname04.c new file +52 -0
52 lines not on this page · raw message
testcases/kernel/containers/utsname/utstest.c deleted +0 -353
353 lines not on this page · raw message
Signature · 5 lines
2.35.3 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Richard Palethorpe
AppliedHello,
Merged, thanks!
Quoted 28 lines · Andrea Cervesato via ltp
Added new tests and removed utstest which looked broken.
Andrea Cervesato (2):
AddSAFE_SETHOSTNAMEmacro
Rewrite utsname testing suiteinclude/safe_net_fn.h | 3 + include/tst_safe_net.h | 3 + lib/safe_net.c | 17 + runtest/containers | 16 +- .../kernel/containers/utsname/.gitignore | 5 +- testcases/kernel/containers/utsname/Makefile | 23 +- .../containers/utsname/runutstests_noltp.sh | 41 -- .../kernel/containers/utsname/utsname01.c | 56 +++ .../kernel/containers/utsname/utsname02.c | 81 ++++ .../kernel/containers/utsname/utsname03.c | 118 ++++++ .../kernel/containers/utsname/utsname04.c | 52 +++ testcases/kernel/containers/utsname/utstest.c | 353 ------------------ 12 files changed, 343 insertions(+), 425 deletions(-) delete mode 100755 testcases/kernel/containers/utsname/runutstests_noltp.sh create mode 100644 testcases/kernel/containers/utsname/utsname01.c create mode 100644 testcases/kernel/containers/utsname/utsname02.c create mode 100644 testcases/kernel/containers/utsname/utsname03.c create mode 100644 testcases/kernel/containers/utsname/utsname04.c delete mode 100644 testcases/kernel/containers/utsname/utstest.cSignature · 1 line
2.35.3
Signature · 5 lines
Thank you, Richard. -- Mailing list info: https://lists.linux.it/listinfo/ltp