* [PATCH] selftests/exec: Check if the syscall exists and bail if not @ 2015-01-21 7:41 Michael Ellerman [not found] ` <1421826060-2237-1-git-send-email-mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org> 0 siblings, 1 reply; 3+ messages in thread From: Michael Ellerman @ 2015-01-21 7:41 UTC (permalink / raw) To: linux-kernel-u79uwXL29TY76Z2rM5mHXA Cc: linux-api-u79uwXL29TY76Z2rM5mHXA, geert-Td1EMuHUCqxL1ZNQvxDV9g, drysdale-hpIqsD4AKlfQT0dZR+AlfA, shuahkh-JPH+aEBZ4P+UEJcrhfAQsw, davej-rdkfGonbjUTCLXcRTR1eJlpr/1R2p/CL On systems which don't implement sys_execveat(), this test produces a lot of output. Add a check at the beginning to see if the syscall is present, and if not just note one error and return. Signed-off-by: Michael Ellerman <mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org> --- tools/testing/selftests/exec/execveat.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/testing/selftests/exec/execveat.c b/tools/testing/selftests/exec/execveat.c index e238c9559caf..b87e4a843bea 100644 --- a/tools/testing/selftests/exec/execveat.c +++ b/tools/testing/selftests/exec/execveat.c @@ -234,6 +234,14 @@ static int run_tests(void) int fd_cloexec = open_or_die("execveat", O_RDONLY|O_CLOEXEC); int fd_script_cloexec = open_or_die("script", O_RDONLY|O_CLOEXEC); + /* Check if we have execveat at all, and bail early if not */ + errno = 0; + execveat_(-1, NULL, NULL, NULL, 0); + if (errno == -ENOSYS) { + printf("[FAIL] ENOSYS calling execveat - no kernel support?\n"); + return 1; + } + /* Change file position to confirm it doesn't affect anything */ lseek(fd, 10, SEEK_SET); -- 2.1.0 ^ permalink raw reply related [flat|nested] 3+ messages in thread
[parent not found: <1421826060-2237-1-git-send-email-mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org>]
* Re: [PATCH] selftests/exec: Check if the syscall exists and bail if not [not found] ` <1421826060-2237-1-git-send-email-mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org> @ 2015-01-21 10:22 ` David Drysdale [not found] ` <CAHse=S_AWuY4YG7DJeU+Rma-kPuQLGZH2oqVV27RvF4unu61Aw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 0 siblings, 1 reply; 3+ messages in thread From: David Drysdale @ 2015-01-21 10:22 UTC (permalink / raw) To: Michael Ellerman Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Linux API, Geert Uytterhoeven, Shuah Khan, davej-rdkfGonbjUTCLXcRTR1eJlpr/1R2p/CL On Wed, Jan 21, 2015 at 7:41 AM, Michael Ellerman <mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org> wrote: > On systems which don't implement sys_execveat(), this test produces a > lot of output. > > Add a check at the beginning to see if the syscall is present, and if > not just note one error and return. Good point, thanks. > Signed-off-by: Michael Ellerman <mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org> > --- > tools/testing/selftests/exec/execveat.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/tools/testing/selftests/exec/execveat.c b/tools/testing/selftests/exec/execveat.c > index e238c9559caf..b87e4a843bea 100644 > --- a/tools/testing/selftests/exec/execveat.c > +++ b/tools/testing/selftests/exec/execveat.c > @@ -234,6 +234,14 @@ static int run_tests(void) > int fd_cloexec = open_or_die("execveat", O_RDONLY|O_CLOEXEC); > int fd_script_cloexec = open_or_die("script", O_RDONLY|O_CLOEXEC); > > + /* Check if we have execveat at all, and bail early if not */ > + errno = 0; > + execveat_(-1, NULL, NULL, NULL, 0); > + if (errno == -ENOSYS) { Could we change this to ENOSYS (no minus) and also change the execveat_() function similarly, so that a binary built where __NR_execveat is available but running where it isn't also exits early? (My bad for having the minus sign in execveat_() in the first place -- fingers too used to kernel mode.) Thanks! > + printf("[FAIL] ENOSYS calling execveat - no kernel support?\n"); > + return 1; > + } > + > /* Change file position to confirm it doesn't affect anything */ > lseek(fd, 10, SEEK_SET); > > -- > 2.1.0 > ^ permalink raw reply [flat|nested] 3+ messages in thread
[parent not found: <CAHse=S_AWuY4YG7DJeU+Rma-kPuQLGZH2oqVV27RvF4unu61Aw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: [PATCH] selftests/exec: Check if the syscall exists and bail if not [not found] ` <CAHse=S_AWuY4YG7DJeU+Rma-kPuQLGZH2oqVV27RvF4unu61Aw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> @ 2015-01-23 6:01 ` Michael Ellerman 0 siblings, 0 replies; 3+ messages in thread From: Michael Ellerman @ 2015-01-23 6:01 UTC (permalink / raw) To: David Drysdale Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Linux API, Geert Uytterhoeven, Shuah Khan, davej-rdkfGonbjUTCLXcRTR1eJlpr/1R2p/CL On Wed, 2015-01-21 at 10:22 +0000, David Drysdale wrote: > On Wed, Jan 21, 2015 at 7:41 AM, Michael Ellerman <mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org> wrote: > > On systems which don't implement sys_execveat(), this test produces a > > lot of output. > > > > Add a check at the beginning to see if the syscall is present, and if > > not just note one error and return. > > Good point, thanks. > > > diff --git a/tools/testing/selftests/exec/execveat.c b/tools/testing/selftests/exec/execveat.c > > index e238c9559caf..b87e4a843bea 100644 > > --- a/tools/testing/selftests/exec/execveat.c > > +++ b/tools/testing/selftests/exec/execveat.c > > @@ -234,6 +234,14 @@ static int run_tests(void) > > int fd_cloexec = open_or_die("execveat", O_RDONLY|O_CLOEXEC); > > int fd_script_cloexec = open_or_die("script", O_RDONLY|O_CLOEXEC); > > > > + /* Check if we have execveat at all, and bail early if not */ > > + errno = 0; > > + execveat_(-1, NULL, NULL, NULL, 0); > > + if (errno == -ENOSYS) { > > Could we change this to ENOSYS (no minus) and also change > the execveat_() function similarly, so that a binary built where > __NR_execveat is available but running where it isn't also exits > early? (My bad for having the minus sign in execveat_() in the > first place -- fingers too used to kernel mode.) Ah yeah, me too, -ENOSYS just came naturally. Will fix up and retest and resend. cheers ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-01-23 6:01 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-01-21 7:41 [PATCH] selftests/exec: Check if the syscall exists and bail if not Michael Ellerman [not found] ` <1421826060-2237-1-git-send-email-mpe-Gsx/Oe8HsFggBc27wqDAHg@public.gmane.org> 2015-01-21 10:22 ` David Drysdale [not found] ` <CAHse=S_AWuY4YG7DJeU+Rma-kPuQLGZH2oqVV27RvF4unu61Aw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2015-01-23 6:01 ` Michael Ellerman
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).