Commit 47e0de1a authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'kselftest-3.18-updates-1' of...

Merge tag 'kselftest-3.18-updates-1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest

Pull kselftest updates from Shuah Khan:
 - fix for missing arguments to printf
 - fix to build failures on 32-bit systems.
 - enhancement to run memfd_test run on all architectures as most
   architectures support __NR_memfd_create

* tag 'kselftest-3.18-updates-1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
  selftests/memfd: Run test on all architectures
  memfd_test: Add missing argument to printf()
  memfd_test: Make it work on 32-bit systems
parents 90eac7ee ce6a144a
uname_M := $(shell uname -m 2>/dev/null || echo not)
ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/)
ifeq ($(ARCH),i386)
ARCH := x86
endif
ifeq ($(ARCH),x86_64)
ARCH := x86
endif
CFLAGS += -D_FILE_OFFSET_BITS=64 CFLAGS += -D_FILE_OFFSET_BITS=64
CFLAGS += -I../../../../arch/x86/include/generated/uapi/
CFLAGS += -I../../../../arch/x86/include/uapi/
CFLAGS += -I../../../../include/uapi/ CFLAGS += -I../../../../include/uapi/
CFLAGS += -I../../../../include/ CFLAGS += -I../../../../include/
all: all:
ifeq ($(ARCH),x86)
gcc $(CFLAGS) memfd_test.c -o memfd_test gcc $(CFLAGS) memfd_test.c -o memfd_test
else
echo "Not an x86 target, can't build memfd selftest"
endif
run_tests: all run_tests: all
ifeq ($(ARCH),x86)
gcc $(CFLAGS) memfd_test.c -o memfd_test gcc $(CFLAGS) memfd_test.c -o memfd_test
endif
@./memfd_test || echo "memfd_test: [FAIL]" @./memfd_test || echo "memfd_test: [FAIL]"
build_fuse: build_fuse:
ifeq ($(ARCH),x86)
gcc $(CFLAGS) fuse_mnt.c `pkg-config fuse --cflags --libs` -o fuse_mnt gcc $(CFLAGS) fuse_mnt.c `pkg-config fuse --cflags --libs` -o fuse_mnt
gcc $(CFLAGS) fuse_test.c -o fuse_test gcc $(CFLAGS) fuse_test.c -o fuse_test
else
echo "Not an x86 target, can't build memfd selftest"
endif
run_fuse: build_fuse run_fuse: build_fuse
@./run_fuse_test.sh || echo "fuse_test: [FAIL]" @./run_fuse_test.sh || echo "fuse_test: [FAIL]"
......
...@@ -59,9 +59,9 @@ static void mfd_fail_new(const char *name, unsigned int flags) ...@@ -59,9 +59,9 @@ static void mfd_fail_new(const char *name, unsigned int flags)
} }
} }
static __u64 mfd_assert_get_seals(int fd) static unsigned int mfd_assert_get_seals(int fd)
{ {
long r; int r;
r = fcntl(fd, F_GET_SEALS); r = fcntl(fd, F_GET_SEALS);
if (r < 0) { if (r < 0) {
...@@ -69,50 +69,48 @@ static __u64 mfd_assert_get_seals(int fd) ...@@ -69,50 +69,48 @@ static __u64 mfd_assert_get_seals(int fd)
abort(); abort();
} }
return r; return (unsigned int)r;
} }
static void mfd_assert_has_seals(int fd, __u64 seals) static void mfd_assert_has_seals(int fd, unsigned int seals)
{ {
__u64 s; unsigned int s;
s = mfd_assert_get_seals(fd); s = mfd_assert_get_seals(fd);
if (s != seals) { if (s != seals) {
printf("%llu != %llu = GET_SEALS(%d)\n", printf("%u != %u = GET_SEALS(%d)\n", seals, s, fd);
(unsigned long long)seals, (unsigned long long)s, fd);
abort(); abort();
} }
} }
static void mfd_assert_add_seals(int fd, __u64 seals) static void mfd_assert_add_seals(int fd, unsigned int seals)
{ {
long r; int r;
__u64 s; unsigned int s;
s = mfd_assert_get_seals(fd); s = mfd_assert_get_seals(fd);
r = fcntl(fd, F_ADD_SEALS, seals); r = fcntl(fd, F_ADD_SEALS, seals);
if (r < 0) { if (r < 0) {
printf("ADD_SEALS(%d, %llu -> %llu) failed: %m\n", printf("ADD_SEALS(%d, %u -> %u) failed: %m\n", fd, s, seals);
fd, (unsigned long long)s, (unsigned long long)seals);
abort(); abort();
} }
} }
static void mfd_fail_add_seals(int fd, __u64 seals) static void mfd_fail_add_seals(int fd, unsigned int seals)
{ {
long r; int r;
__u64 s; unsigned int s;
r = fcntl(fd, F_GET_SEALS); r = fcntl(fd, F_GET_SEALS);
if (r < 0) if (r < 0)
s = 0; s = 0;
else else
s = r; s = (unsigned int)r;
r = fcntl(fd, F_ADD_SEALS, seals); r = fcntl(fd, F_ADD_SEALS, seals);
if (r >= 0) { if (r >= 0) {
printf("ADD_SEALS(%d, %llu -> %llu) didn't fail as expected\n", printf("ADD_SEALS(%d, %u -> %u) didn't fail as expected\n",
fd, (unsigned long long)s, (unsigned long long)seals); fd, s, seals);
abort(); abort();
} }
} }
...@@ -205,7 +203,7 @@ static void mfd_fail_open(int fd, int flags, mode_t mode) ...@@ -205,7 +203,7 @@ static void mfd_fail_open(int fd, int flags, mode_t mode)
sprintf(buf, "/proc/self/fd/%d", fd); sprintf(buf, "/proc/self/fd/%d", fd);
r = open(buf, flags, mode); r = open(buf, flags, mode);
if (r >= 0) { if (r >= 0) {
printf("open(%s) didn't fail as expected\n"); printf("open(%s) didn't fail as expected\n", buf);
abort(); abort();
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment