2015-08-14 13:47:05

by Bamvor Zhang Jian

[permalink] [raw]
Subject: [PATCH 0/7] Improvement kselftest support for arm and arm64

This is my first attempt for improving the kselftest for arm/arm64
architecture. Eventually, we hope we could build(in an cross compile
environment) and run all the kselftest cases automatically(successful
of courses).

I realize that there are lots of improvement for kselftest after the
lastest pull request for kselftest. So, All my work is based on the
lastest linux-next tree ("30b42f4 Add linux-next specific files for
20150813").

In this series, I try to make all the testcases compiling and
installation successful.

Patch 1 rename jumplabel target to static_keys in the Makefile.

Patch 2 add CFLAGS_EXTRA to fix the cross comiling failure.

Patch 3 fix the running the installation issue for exec testcase.

Patch 4 check if there are files need to be installed. This is
useful when such testcase is not built for specific architecture.
E.g. x86 testcases for arm/arm64.

Patch 5, 6 and 7 check the architecture before build and install.

Bamvor Jian Zhang (7):
selftests: rename jump label to static_keys
selftests: add CFLAGS_EXTRA
selftests: exec: fix for running and installing
selftests: check before install
selftests: disable seccomp for arm64
selftests: only compile userfaultfd for x86 and powperpc
selftests: breakpoints: fix installing error on the architecture
except x86

tools/testing/selftests/Makefile | 3 +--
tools/testing/selftests/breakpoints/Makefile | 16 +++-------------
tools/testing/selftests/exec/Makefile | 14 +++++++++++---
tools/testing/selftests/lib.mk | 15 ++++++++++-----
tools/testing/selftests/seccomp/Makefile | 6 ++++++
tools/testing/selftests/vm/Makefile | 12 ++++++++++++
6 files changed, 43 insertions(+), 23 deletions(-)

--
2.1.4


2015-08-14 13:47:20

by Bamvor Zhang Jian

[permalink] [raw]
Subject: [PATCH 1/7] selftests: rename jump label to static_keys

commit "2bf9e0a locking/static_keys: Provide a selftest" rename
jump_label directory to static_keys.

Signed-off-by: Bamvor Jian Zhang <[email protected]>
---
tools/testing/selftests/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index 2cb20b7..5f1d643 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -16,12 +16,12 @@ TARGETS += powerpc
TARGETS += ptrace
TARGETS += seccomp
TARGETS += size
+TARGETS += static_keys
TARGETS += sysctl
ifneq (1, $(quicktest))
TARGETS += timers
endif
TARGETS += user
-TARGETS += jumplabel
TARGETS += vm
TARGETS += x86
#Please keep the TARGETS list alphabetically sorted
--
2.1.4

2015-08-14 13:47:30

by Bamvor Zhang Jian

[permalink] [raw]
Subject: [PATCH 2/7] selftests: add CFLAGS_EXTRA

One may pass the "-I /path/to/headers -L /path/to/lib" through
CFLAGS_EXTRA for cross compiling. mqueue could compile pass
in this way when we provide the popt.h and libpopt.so. And kdbus
could compile pass with sys/capability and libcap.so

Sed-off-by: Bamvor Jian Zhang <[email protected]>

--
Originally, I want to add something like --sysroot to the compile
which mean the user need to provide the full filesystem including
headers and library for compiler. With CFLAGS_EXTRA, the user only
need to provide the minimal headers and/or librarys for building.
---
tools/testing/selftests/lib.mk | 2 ++
1 file changed, 2 insertions(+)

diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index ee412ba..1acfd02 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -2,6 +2,8 @@
# Makefile can operate with or without the kbuild infrastructure.
CC := $(CROSS_COMPILE)gcc

+CFLAGS += $(CFLAGS_EXTRA)
+
define RUN_TESTS
@for TEST in $(TEST_PROGS); do \
(./$$TEST && echo "selftests: $$TEST [PASS]") || echo "selftests: $$TEST [FAIL]"; \
--
2.1.4

2015-08-14 13:47:46

by Bamvor Zhang Jian

[permalink] [raw]
Subject: [PATCH 3/7] selftests: exec: fix for running and installing

Fix three issues in exec testcase:

Add RUN_TESTS rules in order to running the testcases in the build
directory through "make TARGETS=exec kselftest"

Copy symbol link and non-executable file instead of install it,
otherwise this test will fail after installation.

Exec testcases need a "Makefile" in line 346, otherwise it will
be ENOENT instead of EACCES.

Signed-off-by: Bamvor Jian Zhang <[email protected]>
---
tools/testing/selftests/exec/Makefile | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/exec/Makefile b/tools/testing/selftests/exec/Makefile
index 6b76bfd..34966a0 100644
--- a/tools/testing/selftests/exec/Makefile
+++ b/tools/testing/selftests/exec/Makefile
@@ -1,4 +1,4 @@
-CFLAGS = -Wall
+CFLAGS = -Wall -g
BINARIES = execveat
DEPS = execveat.symlink execveat.denatured script
all: $(BINARIES) $(DEPS)
@@ -18,11 +18,19 @@ execveat.denatured: execveat
$(CC) $(CFLAGS) -o $@ $^

TEST_PROGS := execveat
-TEST_FILES := $(DEPS)
+TEST_FILES := script

include ../lib.mk

-override EMIT_TESTS := echo "mkdir -p subdir; (./execveat && echo \"selftests: execveat [PASS]\") || echo \"selftests: execveat [FAIL]\""
+override RUN_TESTS := mkdir -p subdir; (./execveat && echo "selftests: execveat [PASS]") || echo "selftests: execveat [FAIL]"
+
+override EMIT_TESTS := echo "mkdir -p subdir; touch Makefile; (./execveat && echo \"selftests: execveat [PASS]\") || echo \"selftests: execveat [FAIL]\""
+
+override define INSTALL_RULE
+ mkdir -p $(INSTALL_PATH)
+ install -t $(INSTALL_PATH) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES)
+ cp -a execveat.symlink execveat.denatured $(INSTALL_PATH)
+endef

clean:
rm -rf $(BINARIES) $(DEPS) subdir.moved execveat.moved xxxxx*
--
2.1.4

2015-08-14 13:48:05

by Bamvor Zhang Jian

[permalink] [raw]
Subject: [PATCH 4/7] selftests: check before install

When the test cases is not supported by the current architecture
the install files(TEST_PROGS, TEST_PROGS_EXTENDED and TEST_FILES)
will be empty. Check it before installation to dismiss a failure
reported by install program.

Signed-off-by: Bamvor Jian Zhang <[email protected]>
---
tools/testing/selftests/Makefile | 1 -
tools/testing/selftests/lib.mk | 13 ++++++++-----
2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index 5f1d643..1d4a29a 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -73,7 +73,6 @@ ifdef INSTALL_PATH
@# Ask all targets to install their files
mkdir -p $(INSTALL_PATH)
for TARGET in $(TARGETS); do \
- mkdir -p $(INSTALL_PATH)/$$TARGET ; \
make -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install; \
done;

diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index 1acfd02..4e14665 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -14,11 +14,14 @@ run_tests: all
$(RUN_TESTS)

define INSTALL_RULE
- mkdir -p $(INSTALL_PATH)
- @for TEST_DIR in $(TEST_DIRS); do\
- cp -r $$TEST_DIR $(INSTALL_PATH); \
- done;
- install -t $(INSTALL_PATH) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES)
+ @if [ "X$(TEST_PROGS)$(TEST_PROGS_EXTENDED)$(TEST_FILES)" != "X" ]; then \
+ mkdir -p $(INSTALL_PATH); \
+ for TEST_DIR in $(TEST_DIRS); do \
+ cp -r $$TEST_DIR $(INSTALL_PATH); \
+ done; \
+ echo "install -t $(INSTALL_PATH) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES)"; \
+ install -t $(INSTALL_PATH) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES); \
+ fi
endef

install: all
--
2.1.4

2015-08-14 13:48:17

by Bamvor Zhang Jian

[permalink] [raw]
Subject: [PATCH 5/7] selftests: disable seccomp for arm64

Currently, seccomp need the __NR_poll which is not supported
by arm64(There is only __NR_ppoll). I am not sure we should
skip this test testcase or update the seccomp without __NR_poll.

Signed-off-by: Bamvor Jian Zhang <[email protected]>
---
tools/testing/selftests/seccomp/Makefile | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/tools/testing/selftests/seccomp/Makefile b/tools/testing/selftests/seccomp/Makefile
index 8401e87..ea2793a 100644
--- a/tools/testing/selftests/seccomp/Makefile
+++ b/tools/testing/selftests/seccomp/Makefile
@@ -1,4 +1,10 @@
+
+uname_M := $(shell uname -m 2>/dev/null || echo not)
+ARCH ?= $(shell echo $(uname_M) | sed -e s/aarch64.*/arm64/)
+
+ifneq ($(ARCH),arm64)
TEST_PROGS := seccomp_bpf
+endif
CFLAGS += -Wl,-no-as-needed -Wall
LDFLAGS += -lpthread

--
2.1.4

2015-08-14 13:48:25

by Bamvor Zhang Jian

[permalink] [raw]
Subject: [PATCH 6/7] selftests: only compile userfaultfd for x86 and powperpc

Signed-off-by: Bamvor Jian Zhang <[email protected]>
---
tools/testing/selftests/vm/Makefile | 12 ++++++++++++
1 file changed, 12 insertions(+)

diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile
index bb888c6..4dd6e4f 100644
--- a/tools/testing/selftests/vm/Makefile
+++ b/tools/testing/selftests/vm/Makefile
@@ -1,5 +1,15 @@
# Makefile for vm selftests

+uname_M := $(shell uname -m 2>/dev/null || echo not)
+ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/ppc.*/powerpc/)
+
+ifeq ($(ARCH),powerpc)
+support_userfaultfd = yes
+endif
+ifeq ($(ARCH),x86)
+support_userfaultfd = yes
+endif
+
CFLAGS = -Wall
BINARIES = compaction_test
BINARIES += hugepage-mmap
@@ -9,7 +19,9 @@ BINARIES += mlock2-tests
BINARIES += on-fault-limit
BINARIES += thuge-gen
BINARIES += transhuge-stress
+ifdef support_userfaultfd
BINARIES += userfaultfd
+endif

all: $(BINARIES)
%: %.c
--
2.1.4

2015-08-14 13:48:39

by Bamvor Zhang Jian

[permalink] [raw]
Subject: [PATCH 7/7] selftests: breakpoints: fix installing error on the architecture except x86

Signed-off-by: Bamvor Jian Zhang <[email protected]>
---
tools/testing/selftests/breakpoints/Makefile | 16 +++-------------
1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/tools/testing/selftests/breakpoints/Makefile b/tools/testing/selftests/breakpoints/Makefile
index 1822356..d27108b 100644
--- a/tools/testing/selftests/breakpoints/Makefile
+++ b/tools/testing/selftests/breakpoints/Makefile
@@ -1,22 +1,12 @@
# Taken from perf makefile
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
+ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/x86/ -e s/x86_64/x86/)

-
-all:
ifeq ($(ARCH),x86)
- gcc breakpoint_test.c -o breakpoint_test
-else
- echo "Not an x86 target, can't build breakpoints selftests"
+TEST_PROGS := breakpoint_test
endif

-TEST_PROGS := breakpoint_test
+all:

include ../lib.mk

--
2.1.4

2015-08-24 03:48:04

by Michael Ellerman

[permalink] [raw]
Subject: Re: [PATCH 2/7] selftests: add CFLAGS_EXTRA

On Fri, 2015-08-14 at 21:43 +0800, Bamvor Jian Zhang wrote:
> One may pass the "-I /path/to/headers -L /path/to/lib" through
> CFLAGS_EXTRA for cross compiling. mqueue could compile pass
> in this way when we provide the popt.h and libpopt.so. And kdbus
> could compile pass with sys/capability and libcap.so

There should be no need to define a new variable.

You should just update the relevant Makefiles to use CFLAGS += rather than
CFLAGS =. And then you can just specifiy CFLAGS on the command line.

cheers

2015-08-24 03:48:06

by Michael Ellerman

[permalink] [raw]
Subject: Re: [PATCH 5/7] selftests: disable seccomp for arm64

On Fri, 2015-08-14 at 21:43 +0800, Bamvor Jian Zhang wrote:
> Currently, seccomp need the __NR_poll which is not supported
> by arm64(There is only __NR_ppoll). I am not sure we should
> skip this test testcase or update the seccomp without __NR_poll.

You should fix or skip the test that needs __NR_poll, not skip the entire test
suite.

You should also CC the author of the tests, they might be able to help you.

cheers


2015-08-25 12:52:22

by Bamvor Zhang Jian

[permalink] [raw]
Subject: Re: [PATCH 2/7] selftests: add CFLAGS_EXTRA



On 08/24/2015 11:48 AM, Michael Ellerman wrote:
> On Fri, 2015-08-14 at 21:43 +0800, Bamvor Jian Zhang wrote:
>> One may pass the "-I /path/to/headers -L /path/to/lib" through
>> CFLAGS_EXTRA for cross compiling. mqueue could compile pass
>> in this way when we provide the popt.h and libpopt.so. And kdbus
>> could compile pass with sys/capability and libcap.so
>
> There should be no need to define a new variable.
>
> You should just update the relevant Makefiles to use CFLAGS += rather than
> CFLAGS =. And then you can just specifiy CFLAGS on the command line.
yeap, it works for me. There is only one line need to be changed:
diff --git a/tools/testing/selftests/mqueue/Makefile b/tools/testing/selftests/mqueue/Makefile
index 0e3b41e..ca8327f 100644
--- a/tools/testing/selftests/mqueue/Makefile
+++ b/tools/testing/selftests/mqueue/Makefile
@@ -1,4 +1,4 @@
-CFLAGS = -O2
+CFLAGS += -O2

all:
$(CC) $(CFLAGS) mq_open_tests.c -o mq_open_tests -lrt

regards

bamvor
>
> cheers
>
>

2015-08-25 12:53:31

by Bamvor Zhang Jian

[permalink] [raw]
Subject: Re: [PATCH 5/7] selftests: disable seccomp for arm64

Hi, Michael

On 08/24/2015 11:48 AM, Michael Ellerman wrote:
> On Fri, 2015-08-14 at 21:43 +0800, Bamvor Jian Zhang wrote:
>> Currently, seccomp need the __NR_poll which is not supported
>> by arm64(There is only __NR_ppoll). I am not sure we should
>> skip this test testcase or update the seccomp without __NR_poll.
>
> You should fix or skip the test that needs __NR_poll, not skip the entire test
> suite.
>
> You should also CC the author of the tests, they might be able to help you.
Thanks you suggestion. I am trying to do this.

regards

bamvor
>
> cheers
>
>
>

2015-08-27 10:23:14

by Michael Ellerman

[permalink] [raw]
Subject: Re: [PATCH 2/7] selftests: add CFLAGS_EXTRA

On Tue, 2015-08-25 at 20:49 +0800, Bamvor Zhang Jian wrote:
>
> On 08/24/2015 11:48 AM, Michael Ellerman wrote:
> > On Fri, 2015-08-14 at 21:43 +0800, Bamvor Jian Zhang wrote:
> >> One may pass the "-I /path/to/headers -L /path/to/lib" through
> >> CFLAGS_EXTRA for cross compiling. mqueue could compile pass
> >> in this way when we provide the popt.h and libpopt.so. And kdbus
> >> could compile pass with sys/capability and libcap.so
> >
> > There should be no need to define a new variable.
> >
> > You should just update the relevant Makefiles to use CFLAGS += rather than
> > CFLAGS =. And then you can just specifiy CFLAGS on the command line.

> yeap, it works for me. There is only one line need to be changed:

OK, so please send a patch to update that Makefile.

> diff --git a/tools/testing/selftests/mqueue/Makefile b/tools/testing/selftests/mqueue/Makefile
> index 0e3b41e..ca8327f 100644
> --- a/tools/testing/selftests/mqueue/Makefile
> +++ b/tools/testing/selftests/mqueue/Makefile
> @@ -1,4 +1,4 @@
> -CFLAGS = -O2
> +CFLAGS += -O2
>
> all:
> $(CC) $(CFLAGS) mq_open_tests.c -o mq_open_tests -lrt

And this can be simplified to:

LDLIBS = -lrt

all: mq_open_tests

cheers

2015-08-27 10:55:21

by Michael Ellerman

[permalink] [raw]
Subject: Re: [PATCH 3/7] selftests: exec: fix for running and installing

On Fri, 2015-08-14 at 21:43 +0800, Bamvor Jian Zhang wrote:
> Fix three issues in exec testcase:

In future please describe the issues you're trying to fix. Below you describe
only the *fixes*, which means I have to work backward to work out what the
issues were.

> Add RUN_TESTS rules in order to running the testcases in the build
> directory through "make TARGETS=exec kselftest"

OK so the problem here is that subdir isn't created when we're *not*
installing. It looks like we actually broke that in commit 84cbd9e4c457
("selftests/exec: do not install subdir as it is already created").

If so I think the fix is just to add subdir as a dependency of all isn't it?

> Copy symbol link and non-executable file instead of install it,
> otherwise this test will fail after installation.

And the problem here is that install wrecks the permissions, right?

> Exec testcases need a "Makefile" in line 346, otherwise it will
> be ENOENT instead of EACCES.

OK. It seems it would be cleaner to have the test create a specific test file,
rather than relying on the presence of the Makefile.


I've been wondering if we should just be using rsync to install the files,
rather than the current method. That way if the Makefile creates the correct
files, they should then appear exactly the same in the installed directory.

I had a quick look at it a while back, but didn't have time to test it 100%.
Does the patch below fix it for you?

cheers


diff --git a/tools/testing/selftests/ftrace/Makefile b/tools/testing/selftests/ftrace/Makefile
index 0acbeca47225..4e6ed13e7f66 100644
--- a/tools/testing/selftests/ftrace/Makefile
+++ b/tools/testing/selftests/ftrace/Makefile
@@ -1,7 +1,7 @@
all:

TEST_PROGS := ftracetest
-TEST_DIRS := test.d/
+TEST_DIRS := test.d

include ../lib.mk

diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index ee412bab7ed4..7082b7e8a2ee 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -13,10 +13,7 @@ run_tests: all

define INSTALL_RULE
mkdir -p $(INSTALL_PATH)
- @for TEST_DIR in $(TEST_DIRS); do\
- cp -r $$TEST_DIR $(INSTALL_PATH); \
- done;
- install -t $(INSTALL_PATH) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES)
+ rsync -a $(TEST_DIRS) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/
endef

install: all




2015-08-27 14:16:48

by Shuah Khan

[permalink] [raw]
Subject: Re: [PATCH 7/7] selftests: breakpoints: fix installing error on the architecture except x86

On 08/14/2015 07:43 AM, Bamvor Jian Zhang wrote:
> Signed-off-by: Bamvor Jian Zhang <[email protected]>

Hi Bamvor,

Could you please add commit log with more details on the error you
are seeing. I would like to get this patch into kselftest next for
4.3 soon

thanks,
-- Shuah
> ---
> tools/testing/selftests/breakpoints/Makefile | 16 +++-------------
> 1 file changed, 3 insertions(+), 13 deletions(-)
>
> diff --git a/tools/testing/selftests/breakpoints/Makefile b/tools/testing/selftests/breakpoints/Makefile
> index 1822356..d27108b 100644
> --- a/tools/testing/selftests/breakpoints/Makefile
> +++ b/tools/testing/selftests/breakpoints/Makefile
> @@ -1,22 +1,12 @@
> # Taken from perf makefile
> 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
> +ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/x86/ -e s/x86_64/x86/)
>
> -
> -all:
> ifeq ($(ARCH),x86)
> - gcc breakpoint_test.c -o breakpoint_test
> -else
> - echo "Not an x86 target, can't build breakpoints selftests"
> +TEST_PROGS := breakpoint_test
> endif
>
> -TEST_PROGS := breakpoint_test
> +all:
>
> include ../lib.mk
>
>


--
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
[email protected] | (970) 217-8978

2015-08-27 20:10:55

by Shuah Khan

[permalink] [raw]
Subject: Re: [PATCH 4/7] selftests: check before install

On 08/14/2015 07:43 AM, Bamvor Jian Zhang wrote:
> When the test cases is not supported by the current architecture
> the install files(TEST_PROGS, TEST_PROGS_EXTENDED and TEST_FILES)
> will be empty. Check it before installation to dismiss a failure
> reported by install program.
>
> Signed-off-by: Bamvor Jian Zhang <[email protected]>
> ---
> tools/testing/selftests/Makefile | 1 -
> tools/testing/selftests/lib.mk | 13 ++++++++-----
> 2 files changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
> index 5f1d643..1d4a29a 100644
> --- a/tools/testing/selftests/Makefile
> +++ b/tools/testing/selftests/Makefile
> @@ -73,7 +73,6 @@ ifdef INSTALL_PATH
> @# Ask all targets to install their files
> mkdir -p $(INSTALL_PATH)
> for TARGET in $(TARGETS); do \
> - mkdir -p $(INSTALL_PATH)/$$TARGET ; \
> make -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install; \
> done;
>
> diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
> index 1acfd02..4e14665 100644
> --- a/tools/testing/selftests/lib.mk
> +++ b/tools/testing/selftests/lib.mk
> @@ -14,11 +14,14 @@ run_tests: all
> $(RUN_TESTS)
>
> define INSTALL_RULE
> - mkdir -p $(INSTALL_PATH)
> - @for TEST_DIR in $(TEST_DIRS); do\
> - cp -r $$TEST_DIR $(INSTALL_PATH); \
> - done;
> - install -t $(INSTALL_PATH) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES)
> + @if [ "X$(TEST_PROGS)$(TEST_PROGS_EXTENDED)$(TEST_FILES)" != "X" ]; then \
> + mkdir -p $(INSTALL_PATH); \
> + for TEST_DIR in $(TEST_DIRS); do \
> + cp -r $$TEST_DIR $(INSTALL_PATH); \
> + done; \
> + echo "install -t $(INSTALL_PATH) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES)"; \
> + install -t $(INSTALL_PATH) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES); \
> + fi
> endef
>
> install: all
>

Hi Bamvor,

This patch works as intended for tests that use the default
INSTALL_RULE. In the cases where INSTALL_RULE is overridden
as in the case of powerpc, powerpc directory still gets created
during install.

It would be nice if we can fix it for the override cases as well.
I will get this into 4.3 for now. Would you like to send a patch
to fix the override cases as well??

thanks,
-- Shuah

--
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
[email protected] | (970) 217-8978

2015-08-27 22:13:45

by Shuah Khan

[permalink] [raw]
Subject: Re: [PATCH 4/7] selftests: check before install

On 08/27/2015 02:10 PM, Shuah Khan wrote:
> On 08/14/2015 07:43 AM, Bamvor Jian Zhang wrote:
>> When the test cases is not supported by the current architecture
>> the install files(TEST_PROGS, TEST_PROGS_EXTENDED and TEST_FILES)
>> will be empty. Check it before installation to dismiss a failure
>> reported by install program.
>>
>> Signed-off-by: Bamvor Jian Zhang <[email protected]>
>> ---
>> tools/testing/selftests/Makefile | 1 -
>> tools/testing/selftests/lib.mk | 13 ++++++++-----
>> 2 files changed, 8 insertions(+), 6 deletions(-)
>>
>> diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
>> index 5f1d643..1d4a29a 100644
>> --- a/tools/testing/selftests/Makefile
>> +++ b/tools/testing/selftests/Makefile
>> @@ -73,7 +73,6 @@ ifdef INSTALL_PATH
>> @# Ask all targets to install their files
>> mkdir -p $(INSTALL_PATH)
>> for TARGET in $(TARGETS); do \
>> - mkdir -p $(INSTALL_PATH)/$$TARGET ; \
>> make -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install; \
>> done;
>>
>> diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
>> index 1acfd02..4e14665 100644
>> --- a/tools/testing/selftests/lib.mk
>> +++ b/tools/testing/selftests/lib.mk
>> @@ -14,11 +14,14 @@ run_tests: all
>> $(RUN_TESTS)
>>
>> define INSTALL_RULE
>> - mkdir -p $(INSTALL_PATH)
>> - @for TEST_DIR in $(TEST_DIRS); do\
>> - cp -r $$TEST_DIR $(INSTALL_PATH); \
>> - done;
>> - install -t $(INSTALL_PATH) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES)
>> + @if [ "X$(TEST_PROGS)$(TEST_PROGS_EXTENDED)$(TEST_FILES)" != "X" ]; then \
>> + mkdir -p $(INSTALL_PATH); \
>> + for TEST_DIR in $(TEST_DIRS); do \
>> + cp -r $$TEST_DIR $(INSTALL_PATH); \
>> + done; \
>> + echo "install -t $(INSTALL_PATH) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES)"; \
>> + install -t $(INSTALL_PATH) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES); \
>> + fi
>> endef
>>
>> install: all
>>
>
> Hi Bamvor,
>
> This patch works as intended for tests that use the default
> INSTALL_RULE. In the cases where INSTALL_RULE is overridden
> as in the case of powerpc, powerpc directory still gets created
> during install.
>
> It would be nice if we can fix it for the override cases as well.
> I will get this into 4.3 for now. Would you like to send a patch
> to fix the override cases as well??
>

Applied to linux-kselftest next for 4.3-rc1.

thanks,
-- Shuah


--
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
[email protected] | (970) 217-8978

2015-08-27 22:14:48

by Shuah Khan

[permalink] [raw]
Subject: Re: [PATCH 7/7] selftests: breakpoints: fix installing error on the architecture except x86

On 08/27/2015 08:16 AM, Shuah Khan wrote:
> On 08/14/2015 07:43 AM, Bamvor Jian Zhang wrote:
>> Signed-off-by: Bamvor Jian Zhang <[email protected]>
>
> Hi Bamvor,
>
> Could you please add commit log with more details on the error you
> are seeing. I would like to get this patch into kselftest next for
> 4.3 soon
>
> thanks,
> -- Shuah

Never mind. I applied the patch to linux-kselftest next for 4.3-rc1

thanks,
-- Shuah


--
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
[email protected] | (970) 217-8978

2015-08-27 22:17:40

by Shuah Khan

[permalink] [raw]
Subject: Re: [PATCH 1/7] selftests: rename jump label to static_keys

On 08/14/2015 07:43 AM, Bamvor Jian Zhang wrote:
> commit "2bf9e0a locking/static_keys: Provide a selftest" rename
> jump_label directory to static_keys.
>
> Signed-off-by: Bamvor Jian Zhang <[email protected]>
> ---
> tools/testing/selftests/Makefile | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>

I will get this into 4.3-rc2, once the jump_label patch gets
into 4.3-rc1

thanks for the fix.
-- Shuah

--
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
[email protected] | (970) 217-8978

2015-08-27 22:20:47

by Shuah Khan

[permalink] [raw]
Subject: Re: [PATCH 6/7] selftests: only compile userfaultfd for x86 and powperpc

On 08/14/2015 07:43 AM, Bamvor Jian Zhang wrote:
> Signed-off-by: Bamvor Jian Zhang <[email protected]>
> ---
> tools/testing/selftests/vm/Makefile | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile
> index bb888c6..4dd6e4f 100644
> --- a/tools/testing/selftests/vm/Makefile
> +++ b/tools/testing/selftests/vm/Makefile
> @@ -1,5 +1,15 @@
> # Makefile for vm selftests
>
> +uname_M := $(shell uname -m 2>/dev/null || echo not)
> +ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/ppc.*/powerpc/)
> +
> +ifeq ($(ARCH),powerpc)
> +support_userfaultfd = yes
> +endif
> +ifeq ($(ARCH),x86)
> +support_userfaultfd = yes
> +endif
> +
> CFLAGS = -Wall
> BINARIES = compaction_test
> BINARIES += hugepage-mmap
> @@ -9,7 +19,9 @@ BINARIES += mlock2-tests
> BINARIES += on-fault-limit
> BINARIES += thuge-gen
> BINARIES += transhuge-stress
> +ifdef support_userfaultfd
> BINARIES += userfaultfd
> +endif
>
> all: $(BINARIES)
> %: %.c
>

I will get this into 4.3-rc2 once the userfaultfd gets into
4.3-rc1. Thanks for the fix.

thanks,
-- Shuah

--
Shuah Khan
Sr. Linux Kernel Developer
Open Source Innovation Group
Samsung Research America (Silicon Valley)
[email protected] | (970) 217-8978

2015-08-31 03:26:23

by Michael Ellerman

[permalink] [raw]
Subject: Re: [PATCH 6/7] selftests: only compile userfaultfd for x86 and powperpc

On Fri, 2015-08-14 at 21:43 +0800, Bamvor Jian Zhang wrote:
> Signed-off-by: Bamvor Jian Zhang <[email protected]>
> ---
> tools/testing/selftests/vm/Makefile | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile
> index bb888c6..4dd6e4f 100644
> --- a/tools/testing/selftests/vm/Makefile
> +++ b/tools/testing/selftests/vm/Makefile
> @@ -1,5 +1,15 @@
> # Makefile for vm selftests
>
> +uname_M := $(shell uname -m 2>/dev/null || echo not)
> +ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/ -e s/ppc.*/powerpc/)
> +
> +ifeq ($(ARCH),powerpc)
> +support_userfaultfd = yes
> +endif
> +ifeq ($(ARCH),x86)
> +support_userfaultfd = yes
> +endif
> +
> CFLAGS = -Wall
> BINARIES = compaction_test
> BINARIES += hugepage-mmap
> @@ -9,7 +19,9 @@ BINARIES += mlock2-tests
> BINARIES += on-fault-limit
> BINARIES += thuge-gen
> BINARIES += transhuge-stress
> +ifdef support_userfaultfd
> BINARIES += userfaultfd
> +endif
>
> all: $(BINARIES)
> %: %.c


This is nasty. It means when userfaultfd gets implemented for other arches
someone has to remember to update the logic here, which they won't.

Instead the C program should just do nothing when __NR_userfaultfd is not defined, eg:

#ifdef __NR_userfaultfd

int main(int argc, char **argv)
{
...
}

#else

int main(void)
{
printf("skip: Skipping userfaultfd test\n");
return 0;
}
#endif


This way when the syscall is implemented for other arches the test will just
start working.

cheers