Message ID | 20200318153801.3529-4-chrubis@suse.cz |
---|---|
State | Accepted |
Headers | show |
Series | Add basic time namespace testcases | expand |
Hi Cyril, ... > diff --git a/lib/tst_safe_macros.c b/lib/tst_safe_macros.c > index f5413a18e..353ef5b1d 100644 > --- a/lib/tst_safe_macros.c > +++ b/lib/tst_safe_macros.c > @@ -6,6 +6,7 @@ > #define _GNU_SOURCE > #include <unistd.h> > #include <errno.h> > +#include "lapi/setns.h" One more fix needed: lapi file needs to be loaded later: diff --git lib/tst_safe_macros.c lib/tst_safe_macros.c index 353ef5b1d..7d33f2b79 100644 --- lib/tst_safe_macros.c +++ lib/tst_safe_macros.c @@ -6,7 +6,6 @@ #define _GNU_SOURCE #include <unistd.h> #include <errno.h> -#include "lapi/setns.h" #include <sched.h> #include "config.h" #ifdef HAVE_SYS_FANOTIFY_H @@ -14,6 +13,7 @@ #endif #define TST_NO_DEFAULT_MAIN #include "tst_test.h" +#include "lapi/setns.h" #include "tst_safe_macros.h" #include "lapi/personality.h" to prevent failure: In file included from /usr/src/ltp/lib/tst_safe_macros.c:9: /usr/src/ltp/include/lapi/setns.h: In function 'setns': /usr/src/ltp/include/lapi/setns.h:16: error: implicit declaration of function 'tst_brk' /usr/src/ltp/include/lapi/setns.h:16: error: 'TCONF' undeclared (first use in this function) /usr/src/ltp/include/lapi/setns.h:16: error: (Each undeclared identifier is reported only once The rest of the patchset looks ok to me: Reviewed-by: Petr Vorel <pvorel@suse.cz> Kind regards, Petr
Hi! I've fixed up problems pointed out by you and Li and pushed. Peter, Li thanks a lot for the review.
diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h index 80c4d9cb9..291f2a722 100644 --- a/include/tst_safe_macros.h +++ b/include/tst_safe_macros.h @@ -547,4 +547,8 @@ int safe_personality(const char *filename, unsigned int lineno, void safe_unshare(const char *file, const int lineno, int flags); #define SAFE_UNSHARE(flags) safe_unshare(__FILE__, __LINE__, (flags)) + +void safe_setns(const char *file, const int lineno, int fd, int nstype); +#define SAFE_SETNS(fd, nstype) safe_setns(__FILE__, __LINE__, (fd), (nstype)); + #endif /* SAFE_MACROS_H__ */ diff --git a/lib/tst_safe_macros.c b/lib/tst_safe_macros.c index f5413a18e..353ef5b1d 100644 --- a/lib/tst_safe_macros.c +++ b/lib/tst_safe_macros.c @@ -6,6 +6,7 @@ #define _GNU_SOURCE #include <unistd.h> #include <errno.h> +#include "lapi/setns.h" #include <sched.h> #include "config.h" #ifdef HAVE_SYS_FANOTIFY_H @@ -202,3 +203,14 @@ void safe_unshare(const char *file, const int lineno, int flags) } } } + +void safe_setns(const char *file, const int lineno, int fd, int nstype) +{ + int ret; + + ret = setns(fd, nstype); + if (ret == -1) { + tst_brk_(file, lineno, TBROK | TERRNO, "setns(%i, %i) failed", + fd, nstype); + } +}