[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8736kzqpdm.fsf@concordia.ellerman.id.au>
Date: Tue, 28 May 2019 12:33:41 +1000
From: Michael Ellerman <mpe@...erman.id.au>
To: Christian Brauner <christian@...uner.io>, viro@...iv.linux.org.uk,
linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org,
linux-api@...r.kernel.org, torvalds@...ux-foundation.org,
fweimer@...hat.com
Cc: jannh@...gle.com, oleg@...hat.com, tglx@...utronix.de,
arnd@...db.de, shuah@...nel.org, dhowells@...hat.com,
tkjos@...roid.com, ldv@...linux.org, miklos@...redi.hu,
linux-alpha@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-ia64@...r.kernel.org, linux-m68k@...ts.linux-m68k.org,
linux-mips@...r.kernel.org, linux-parisc@...r.kernel.org,
linuxppc-dev@...ts.ozlabs.org, linux-s390@...r.kernel.org,
linux-sh@...r.kernel.org, sparclinux@...r.kernel.org,
linux-xtensa@...ux-xtensa.org, linux-arch@...r.kernel.org,
linux-kselftest@...r.kernel.org, x86@...nel.org,
Christian Brauner <christian@...uner.io>
Subject: Re: [PATCH v2 2/2] tests: add close_range() tests
Christian Brauner <christian@...uner.io> writes:
> This adds basic tests for the new close_range() syscall.
> - test that no invalid flags can be passed
> - test that a range of file descriptors is correctly closed
> - test that a range of file descriptors is correctly closed if there there
> are already closed file descriptors in the range
> - test that max_fd is correctly capped to the current fdtable maximum
>
> Signed-off-by: Christian Brauner <christian@...uner.io>
> Cc: Arnd Bergmann <arnd@...db.de>
> Cc: Jann Horn <jannh@...gle.com>
> Cc: David Howells <dhowells@...hat.com>
> Cc: Dmitry V. Levin <ldv@...linux.org>
> Cc: Oleg Nesterov <oleg@...hat.com>
> Cc: Linus Torvalds <torvalds@...ux-foundation.org>
> Cc: Florian Weimer <fweimer@...hat.com>
> Cc: linux-api@...r.kernel.org
> ---
> v1: unchanged
> v2:
> - Christian Brauner <christian@...uner.io>:
> - verify that close_range() correctly closes a single file descriptor
> ---
> tools/testing/selftests/Makefile | 1 +
> tools/testing/selftests/core/.gitignore | 1 +
> tools/testing/selftests/core/Makefile | 6 +
> .../testing/selftests/core/close_range_test.c | 142 ++++++++++++++++++
> 4 files changed, 150 insertions(+)
> create mode 100644 tools/testing/selftests/core/.gitignore
> create mode 100644 tools/testing/selftests/core/Makefile
> create mode 100644 tools/testing/selftests/core/close_range_test.c
>
> diff --git a/tools/testing/selftests/core/.gitignore b/tools/testing/selftests/core/.gitignore
> new file mode 100644
> index 000000000000..6e6712ce5817
> --- /dev/null
> +++ b/tools/testing/selftests/core/.gitignore
> @@ -0,0 +1 @@
> +close_range_test
> diff --git a/tools/testing/selftests/core/Makefile b/tools/testing/selftests/core/Makefile
> new file mode 100644
> index 000000000000..de3ae68aa345
> --- /dev/null
> +++ b/tools/testing/selftests/core/Makefile
> @@ -0,0 +1,6 @@
> +CFLAGS += -g -I../../../../usr/include/ -I../../../../include
Your second -I pulls the unexported kernel headers in, userspace
programs shouldn't include unexported kernel headers.
It breaks the build on powerpc with eg:
powerpc64le-linux-gnu-gcc -g -I../../../../usr/include/ -I../../../../include close_range_test.c -o /output/kselftest/core/close_range_test
In file included from /usr/powerpc64le-linux-gnu/include/bits/fcntl-linux.h:346,
from /usr/powerpc64le-linux-gnu/include/bits/fcntl.h:62,
from /usr/powerpc64le-linux-gnu/include/fcntl.h:35,
from close_range_test.c:5:
../../../../include/linux/falloc.h:13:2: error: unknown type name '__s16'
__s16 l_type;
^~~~~
Did you do that on purpose or just copy it from one of the other
Makefiles? :)
If you're just wanting to get the syscall number when the headers
haven't been exported, I think the best solution is to do eg:
diff --git a/tools/testing/selftests/core/close_range_test.c b/tools/testing/selftests/core/close_range_test.c
index d6e6079d3d53..34c6f02f25de 100644
--- a/tools/testing/selftests/core/close_range_test.c
+++ b/tools/testing/selftests/core/close_range_test.c
@@ -14,6 +14,10 @@
#include "../kselftest.h"
+#ifndef __NR_close_range
+#define __NR_close_range 435
+#endif
+
static inline int sys_close_range(unsigned int fd, unsigned int max_fd,
unsigned int flags)
{
cheers
Powered by blists - more mailing lists