From 57e67900d4c7949ad646a5f43a8ca5180170d2a0 Mon Sep 17 00:00:00 2001 From: Pranith Kumar Date: Wed, 3 Sep 2014 10:31:16 -0400 Subject: memfd_test: Make it work on 32-bit systems This test currently fails on 32-bit systems since we use u64 type to pass the flags to fcntl. This commit changes this to use 'unsigned int' type for flags to fcntl making it work on 32-bit systems. Signed-off-by: Pranith Kumar Reviewed-by: David Herrmann Signed-off-by: Shuah Khan --- tools/testing/selftests/memfd/memfd_test.c | 34 ++++++++++++++---------------- 1 file changed, 16 insertions(+), 18 deletions(-) (limited to 'tools/testing/selftests') diff --git a/tools/testing/selftests/memfd/memfd_test.c b/tools/testing/selftests/memfd/memfd_test.c index 3634c909b1b0..cb5001bfa5e3 100644 --- a/tools/testing/selftests/memfd/memfd_test.c +++ b/tools/testing/selftests/memfd/memfd_test.c @@ -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); if (r < 0) { @@ -69,50 +69,48 @@ static __u64 mfd_assert_get_seals(int fd) 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); if (s != seals) { - printf("%llu != %llu = GET_SEALS(%d)\n", - (unsigned long long)seals, (unsigned long long)s, fd); + printf("%u != %u = GET_SEALS(%d)\n", seals, s, fd); abort(); } } -static void mfd_assert_add_seals(int fd, __u64 seals) +static void mfd_assert_add_seals(int fd, unsigned int seals) { - long r; - __u64 s; + int r; + unsigned int s; s = mfd_assert_get_seals(fd); r = fcntl(fd, F_ADD_SEALS, seals); if (r < 0) { - printf("ADD_SEALS(%d, %llu -> %llu) failed: %m\n", - fd, (unsigned long long)s, (unsigned long long)seals); + printf("ADD_SEALS(%d, %u -> %u) failed: %m\n", fd, s, seals); abort(); } } -static void mfd_fail_add_seals(int fd, __u64 seals) +static void mfd_fail_add_seals(int fd, unsigned int seals) { - long r; - __u64 s; + int r; + unsigned int s; r = fcntl(fd, F_GET_SEALS); if (r < 0) s = 0; else - s = r; + s = (unsigned int)r; r = fcntl(fd, F_ADD_SEALS, seals); if (r >= 0) { - printf("ADD_SEALS(%d, %llu -> %llu) didn't fail as expected\n", - fd, (unsigned long long)s, (unsigned long long)seals); + printf("ADD_SEALS(%d, %u -> %u) didn't fail as expected\n", + fd, s, seals); abort(); } } -- cgit v1.2.3-59-g8ed1b From 2ed36928373cc3dfb20a4d17042e9a6e05538e41 Mon Sep 17 00:00:00 2001 From: Pranith Kumar Date: Thu, 4 Sep 2014 11:58:19 -0400 Subject: memfd_test: Add missing argument to printf() Add a missing path argument buf to printf() Signed-off-by: Pranith Kumar Reviewed-by: David Herrmann Signed-off-by: Shuah Khan --- tools/testing/selftests/memfd/memfd_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools/testing/selftests') diff --git a/tools/testing/selftests/memfd/memfd_test.c b/tools/testing/selftests/memfd/memfd_test.c index cb5001bfa5e3..0b9eafb7ab7b 100644 --- a/tools/testing/selftests/memfd/memfd_test.c +++ b/tools/testing/selftests/memfd/memfd_test.c @@ -203,7 +203,7 @@ static void mfd_fail_open(int fd, int flags, mode_t mode) sprintf(buf, "/proc/self/fd/%d", fd); r = open(buf, flags, mode); if (r >= 0) { - printf("open(%s) didn't fail as expected\n"); + printf("open(%s) didn't fail as expected\n", buf); abort(); } } -- cgit v1.2.3-59-g8ed1b From ce6a144a0d01c6628496e4c0d18fbf3a0362cc67 Mon Sep 17 00:00:00 2001 From: Pranith Kumar Date: Mon, 15 Sep 2014 18:59:42 -0400 Subject: selftests/memfd: Run test on all architectures Remove the dependence on x86 to run the memfd test. Verfied on 32-bit powerpc. Signed-off-by: Pranith Kumar Reviewed-by: David Herrmann Signed-off-by: Shuah Khan --- tools/testing/selftests/memfd/Makefile | 21 --------------------- 1 file changed, 21 deletions(-) (limited to 'tools/testing/selftests') diff --git a/tools/testing/selftests/memfd/Makefile b/tools/testing/selftests/memfd/Makefile index ad4ab01cd28f..b80cd10d53ba 100644 --- a/tools/testing/selftests/memfd/Makefile +++ b/tools/testing/selftests/memfd/Makefile @@ -1,38 +1,17 @@ -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 += -I../../../../arch/x86/include/generated/uapi/ -CFLAGS += -I../../../../arch/x86/include/uapi/ CFLAGS += -I../../../../include/uapi/ CFLAGS += -I../../../../include/ all: -ifeq ($(ARCH),x86) gcc $(CFLAGS) memfd_test.c -o memfd_test -else - echo "Not an x86 target, can't build memfd selftest" -endif run_tests: all -ifeq ($(ARCH),x86) gcc $(CFLAGS) memfd_test.c -o memfd_test -endif @./memfd_test || echo "memfd_test: [FAIL]" build_fuse: -ifeq ($(ARCH),x86) gcc $(CFLAGS) fuse_mnt.c `pkg-config fuse --cflags --libs` -o fuse_mnt 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_test.sh || echo "fuse_test: [FAIL]" -- cgit v1.2.3-59-g8ed1b