lib: add safe_gethostname()
PATCH v2 1/2 lib: add safe_gethostname()
---
v2: remove cleanup()
include/safe_net_fn.h | 3 +++ include/tst_safe_net.h | 3 +++ lib/safe_net.c | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 0 deletions(-)
include/safe_net_fn.h +3 -0
@@ -45,4 +45,7 @@ int safe_getsockname(const char *file, const int lineno, void (cleanup_fn)(void), int sockfd, struct sockaddr *addr, socklen_t *addrlen); +int safe_gethostname (const char *file,const int lineno, +char *name,size_t size); +#endif /* SAFE_NET_FN_H__ */
include/tst_safe_net.h +3 -0
@@ -43,4 +43,7 @@safe_getsockname (__FILE__, __LINE__,NULL , sockfd, addr, \ addrlen) +#define SAFE_GETHOSTNAME (name, size) \ + safe_gethostname(__FILE__, __LINE__, name, size) +#endif /* TST_SAFE_NET_H__ */
lib/safe_net.c +14 -0
@@ -183,3 +183,17 @@ int safe_getsockname(const char *file, const int lineno,return rval; } + +int safe_gethostname (const char *file,const int lineno, +char *name,size_t size) +{ +int rval =gethostname (name, size); + +if (rval <0 ) { +tst_brkm (TBROK |TERRNO ,NULL , +"%s:%d: gethostname(%p, %zu) failed" , + file, lineno, name, size); + } + +return rval; +}
Signature · 1 line
1.7.1
PATCH v2 2/2 network/nfs05: rewrite the test, make use of new library
* remove dynamic allocation of memory, use asprintf in few places;
* run built binaries and check that they print correct message;
* run tst_run_cmd() to call make/make clean;
* clean directories with tst_rmdir library.
---
v2: * added run_targets() to run built binaries and check their output
* correct generated C files and Makefiles
* fix makefile: include testcases.mk
* added check for gcc and make commands
testcases/network/nfs/nfs_stress/Makefile | 2 +- testcases/network/nfs/nfs_stress/nfs05 | 10 +- testcases/network/nfs/nfs_stress/nfs05_make_tree.c | 934 ++++---------------- 3 files changed, 194 insertions(+), 752 deletions(-)
testcases/network/nfs/nfs_stress/Makefile +1 -1
@@ -16,7 +16,7 @@ top_srcdir ?= ../../../.. -include $(top_srcdir)/include/mk/env_pre.mk +include $(top_srcdir)/include/mk/testcases.mk nfs04_create_file: CPPFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE nfs05_make_tree: LDLIBS += -lpthread
testcases/network/nfs/nfs_stress/nfs05 +8 -2
@@ -31,11 +31,17 @@ THREAD_NUM=${THREAD_NUM:-"8"} . nfs_lib.sh . test_net.sh +tst_check_cmds make gcc + nfs_setup tst_resm TINFO "start nfs05_make_tree -d $DIR_NUM -f $FILE_NUM -t $THREAD_NUM" -ROD nfs05_make_tree -d $DIR_NUM -f $FILE_NUM -t $THREAD_NUM +TMPDIR=$(pwd) nfs05_make_tree -d $DIR_NUM -f $FILE_NUM -t $THREAD_NUM -tst_resm TPASS "test finished" +if [ $? -ne 0 ]; then + tst_resm TFAIL "'make' test failed" +else + tst_resm TPASS "'make' test finished" +fi tst_exit
testcases/network/nfs/nfs_stress/nfs05_make_tree.c +185 -749
973 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v2 2/2 network/nfs05: rewrite the test, make use of new library
Hi!
testcases/network/nfs/nfs_stress/nfs05 THREAD_NUM=${THREAD_NUM:-"8"} · line 39
Quoted 3 lines
tst_resmTINFO "startnfs05_make_tree-d $DIR_NUM -f $FILE_NUM -t $THREAD_NUM"testcases/network/nfs/nfs_stress/nfs05 +1
-1-ROD nfs05_make_tree -d $DIR_NUM -f $FILE_NUM -t $THREAD_NUM +TMPDIR=$(pwd) nfs05_make_tree -d $DIR_NUM -f $FILE_NUM -t $THREAD_NUM
Hmm, the tst_tmpdir is created and mounted in the nfs_setup right?
Why can't we just let the nfs05_make_tree work with current directory and omit the needs_tmpdir = 1 from it's source? It's not like the nfs05_make_tree binary is supposed to be executed directly, so it's OK if it starts to create files in PWD.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v2 2/2 network/nfs05: rewrite the test, make use of new library
Hi,
Quoted 10 lines · Cyril Hrubis
Hi!
testcases/network/nfs/nfs_stress/nfs05 THREAD_NUM=${THREAD_NUM:-"8"} · line 39
Quoted 3 lines
tst_resmTINFO "startnfs05_make_tree-d $DIR_NUM -f $FILE_NUM -t $THREAD_NUM"testcases/network/nfs/nfs_stress/nfs05 +1
-1-ROD nfs05_make_tree -d $DIR_NUM -f $FILE_NUM -t $THREAD_NUM +TMPDIR=$(pwd) nfs05_make_tree -d $DIR_NUM -f $FILE_NUM -t $THREAD_NUMHmm, the
tst_tmpdiris created and mounted in thenfs_setupright?Why can't we just let the
nfs05_make_treework with current directory and omit theneeds_tmpdir= 1 from it's source? It's not like thenfs05_make_treebinary is supposed to be executed directly, so it's OK if it starts to create files in PWD.
You are right, it's not used other than inside nfs05 script so the flag can be
safely removed along with "TMPDIR=$(pwd)".
Thanks,
Alexey
PATCH v2 2/2 network/nfs05: rewrite the test, make use of new library
Hi,
Both patches applied.
Thanks,
Alexey