mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH RFC 0/6] enable O and KBUILD_OUTPUT for kselftest
@ 2016-10-21 11:01 bamvor.zhangjian
  2016-10-21 11:01 ` [PATCH RFC 1/6] selftests: remove duplicated all and clean target bamvor.zhangjian
                   ` (7 more replies)
  0 siblings, 8 replies; 22+ messages in thread
From: bamvor.zhangjian @ 2016-10-21 11:01 UTC (permalink / raw)
  To: shuahkh; +Cc: linux-api, linux-kernel, khilman, broonie, mpe

From: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>

Here is my first version for enabling the KBUILD_OUTPUT for kselftest.
I fix and test all the TARGET in tools/testing/selftest/Makefile. For
ppc, I test through fake target.

There are six patches in these series. And five of them clean up the
existing code. I split the clean up patches into five, hope it is easy
to review.

selftests: remove duplicated all and clean target
selftests: remove useless TEST_DIRS
selftests: add pattern rules
selftests: remove CROSS_COMPILE in dedicated Makefile
selftests: add EXTRA_CLEAN for clean target
selftests: enable O and KBUILD_OUTPUT

In the first patch, I split the test files into two types:
TEST_GEN_XXX means such file is generated during compiling. TEST_XXX
means there is no need to compile before use. The main reason of this
is the enablement of KBUILD_OUTPUT only need to care about TEST_GEN_XXX.
I wanted to copy all the TEST_XXX with TEST_GEN_XXX, but I give up this
idea in the end. Because people may puzzle why copy the file before
installation.

Because of the introducing of TEST_GEN_XXX, I update the top-level
Makefile and lib.mk selftests directory. After introduce TEST_GEN_XXX I
could remove all the unnecessary all and clean targets.

The second patch remove TEST_DIRS variable. And third patch add the
pattern for compiling the c sourc code. The fourth patch remove the
useless CROSS_COMPILE variable as it aleady exists in
"tools/testing/selftests/lib.mk".

Further more, The fifth patch add the EXTRA_CLEAN variable to clean up
the duplicated clean target

The last patch introduces the KBUILD_OUTPUT and O for kselftest instead
using the existing kbuild system because user may compile kselftest
directly (make -C tools/testing/selftests).

Bamvor Jian Zhang (6):
  selftests: remove duplicated all and clean target
  selftests: remove useless TEST_DIRS
  selftests: add default rules for c source file
  selftests: remove CROSS_COMPILE in dedicated Makefile
  selftests: add EXTRA_CLEAN for clean target
  selftests: enable O and KBUILD_OUTPUT

 Documentation/kselftest.txt                        | 13 ++++++++
 tools/testing/selftests/Makefile                   | 39 +++++++++++++++++-----
 tools/testing/selftests/breakpoints/Makefile       |  8 ++---
 tools/testing/selftests/capabilities/Makefile      | 11 ++----
 tools/testing/selftests/efivarfs/Makefile          |  8 +----
 tools/testing/selftests/exec/Makefile              | 32 ++++++++----------
 tools/testing/selftests/ftrace/Makefile            |  6 ++--
 tools/testing/selftests/futex/Makefile             | 21 +++++++++---
 tools/testing/selftests/futex/functional/Makefile  | 12 ++-----
 tools/testing/selftests/ipc/Makefile               |  7 +---
 tools/testing/selftests/kcmp/Makefile              |  6 ++--
 tools/testing/selftests/lib.mk                     | 36 ++++++++++++++++----
 tools/testing/selftests/membarrier/Makefile        |  6 +---
 tools/testing/selftests/memfd/Makefile             | 15 ++-------
 tools/testing/selftests/mount/Makefile             |  7 +---
 tools/testing/selftests/mqueue/Makefile            |  6 +---
 tools/testing/selftests/net/Makefile               | 10 +-----
 tools/testing/selftests/powerpc/Makefile           | 14 +++++---
 tools/testing/selftests/powerpc/alignment/Makefile |  9 ++---
 .../testing/selftests/powerpc/benchmarks/Makefile  | 15 ++++-----
 .../selftests/powerpc/context_switch/Makefile      |  9 ++---
 tools/testing/selftests/powerpc/copyloops/Makefile | 19 +++++------
 tools/testing/selftests/powerpc/dscr/Makefile      | 13 +++-----
 tools/testing/selftests/powerpc/math/Makefile      | 27 +++++++--------
 tools/testing/selftests/powerpc/mm/Makefile        | 18 ++++------
 tools/testing/selftests/powerpc/pmu/Makefile       | 26 +++++++--------
 tools/testing/selftests/powerpc/pmu/ebb/Makefile   | 15 +++------
 .../testing/selftests/powerpc/primitives/Makefile  |  9 ++---
 .../testing/selftests/powerpc/stringloops/Makefile |  9 ++---
 .../selftests/powerpc/switch_endian/Makefile       | 17 ++++------
 tools/testing/selftests/powerpc/syscalls/Makefile  |  9 ++---
 tools/testing/selftests/powerpc/tm/Makefile        | 19 +++++------
 tools/testing/selftests/powerpc/vphn/Makefile      | 10 ++----
 tools/testing/selftests/pstore/Makefile            |  4 +--
 tools/testing/selftests/ptrace/Makefile            |  8 +----
 tools/testing/selftests/seccomp/Makefile           |  6 +---
 tools/testing/selftests/sigaltstack/Makefile       |  5 +--
 tools/testing/selftests/size/Makefile              | 10 ++----
 tools/testing/selftests/timers/Makefile            | 10 ++----
 tools/testing/selftests/vm/Makefile                | 29 +++++++---------
 tools/testing/selftests/x86/Makefile               | 17 ++++++----
 tools/testing/selftests/zram/Makefile              |  3 +-
 42 files changed, 250 insertions(+), 323 deletions(-)

-- 
1.8.4.5

^ permalink raw reply	[flat|nested] 22+ messages in thread
* Re: [PATCH RFC 5/6] selftests: add EXTRA_CLEAN for clean target
@ 2016-10-21 11:17 Bamvor Zhang Jian
  0 siblings, 0 replies; 22+ messages in thread
From: Bamvor Zhang Jian @ 2016-10-21 11:17 UTC (permalink / raw)
  To: Zhang Jian(Bamvor)
  Cc: Shuah Khan, linux-api, lkml, Mark Brown, Michael Ellerman, Kevin Hilman

Fix the wrong email address of kevin hilman to khilman@kernel.org.
Sorry for inconvenience.

On 21 October 2016 at 19:01,  <bamvor.zhangjian@huawei.com> wrote:
> From: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>
>
> Some testcases need the clean extra data after running. This patch
> introduce the "EXTRA_CLEAN" variable to address this requirement.
>
> After KOUTPUT_BUILD is enabled in later patch, it will be easy to
> decide to if we need do the cleanup in the KOUTPUT_BUILD path, if the
> testcase ran immediately after compiled.
>
> Signed-off-by: Bamvor Jian Zhang <bamvor.zhangjian@linaro.org>
> ---
>  tools/testing/selftests/exec/Makefile                 | 19 +++++++++----------
>  tools/testing/selftests/ftrace/Makefile               |  4 +---
>  tools/testing/selftests/kcmp/Makefile                 |  4 ++--
>  tools/testing/selftests/lib.mk                        |  2 +-
>  tools/testing/selftests/powerpc/benchmarks/Makefile   |  5 ++---
>  tools/testing/selftests/powerpc/copyloops/Makefile    |  3 +--
>  tools/testing/selftests/powerpc/dscr/Makefile         |  4 ++--
>  tools/testing/selftests/powerpc/math/Makefile         |  5 ++---
>  tools/testing/selftests/powerpc/primitives/Makefile   |  5 ++---
>  tools/testing/selftests/powerpc/stringloops/Makefile  |  5 ++---
>  .../testing/selftests/powerpc/switch_endian/Makefile  |  5 ++---
>  tools/testing/selftests/powerpc/syscalls/Makefile     |  5 ++---
>  tools/testing/selftests/powerpc/tm/Makefile           |  5 ++---
>  tools/testing/selftests/pstore/Makefile               |  4 +---
>  tools/testing/selftests/zram/Makefile                 |  3 +--
>  15 files changed, 32 insertions(+), 46 deletions(-)
>
> diff --git a/tools/testing/selftests/exec/Makefile b/tools/testing/selftests/exec/Makefile
> index 9eb1c3e..48d1f86 100644
> --- a/tools/testing/selftests/exec/Makefile
> +++ b/tools/testing/selftests/exec/Makefile
> @@ -1,5 +1,14 @@
>  CFLAGS = -Wall
>
> +TEST_GEN_PROGS := execveat
> +TEST_GEN_FILES := execveat.symlink execveat.denatured script subdir
> +# Makefile is a run-time dependency, since it's accessed by the execveat test
> +TEST_FILES := Makefile
> +
> +EXTRA_CLEAN := subdir.moved execveat.moved xxxxx*
> +
> +include ../lib.mk
> +
>  subdir:
>         mkdir -p $@
>  script:
> @@ -11,13 +20,3 @@ execveat.symlink: execveat
>  execveat.denatured: execveat
>         cp $< $@
>         chmod -x $@
> -
> -TEST_GEN_PROGS := execveat
> -TEST_GEN_FILES := execveat.symlink execveat.denatured script subdir
> -# Makefile is a run-time dependency, since it's accessed by the execveat test
> -TEST_FILES := Makefile
> -
> -include ../lib.mk
> -
> -clean:
> -       rm -rf $(TEST_GEN_PROGS) $(TEST_GEN_FILES) subdir.moved execveat.moved xxxxx*
> diff --git a/tools/testing/selftests/ftrace/Makefile b/tools/testing/selftests/ftrace/Makefile
> index a715300..6c64b42 100644
> --- a/tools/testing/selftests/ftrace/Makefile
> +++ b/tools/testing/selftests/ftrace/Makefile
> @@ -2,8 +2,6 @@ all:
>
>  TEST_PROGS := ftracetest
>  TEST_FILES := test.d
> +EXTRA_CLEAN := logs/*
>
>  include ../lib.mk
> -
> -clean:
> -       rm -rf logs/*
> diff --git a/tools/testing/selftests/kcmp/Makefile b/tools/testing/selftests/kcmp/Makefile
> index 9e8b673..74a8add 100644
> --- a/tools/testing/selftests/kcmp/Makefile
> +++ b/tools/testing/selftests/kcmp/Makefile
> @@ -2,7 +2,7 @@ CFLAGS += -I../../../../usr/include/
>
>  TEST_GEN_PROGS := kcmp_test
>
> +EXTRA_CLEAN := kcmp-test-file
> +
>  include ../lib.mk
>
> -clean:
> -       $(RM) $(TEST_GEN_PROGS) kcmp-test-file
> diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
> index 9ccec4b..0f7a371 100644
> --- a/tools/testing/selftests/lib.mk
> +++ b/tools/testing/selftests/lib.mk
> @@ -43,7 +43,7 @@ emit_tests:
>  all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
>
>  clean:
> -       $(RM) -fr $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)
> +       $(RM) -r $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(EXTRA_CLEAN)
>
>  %: %.c
>         $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ $^
> diff --git a/tools/testing/selftests/powerpc/benchmarks/Makefile b/tools/testing/selftests/powerpc/benchmarks/Makefile
> index 985a77c..1f94b31 100644
> --- a/tools/testing/selftests/powerpc/benchmarks/Makefile
> +++ b/tools/testing/selftests/powerpc/benchmarks/Makefile
> @@ -4,11 +4,10 @@ CFLAGS += -O2
>
>  $(TEST_GEN_PROGS): ../harness.c
>
> +EXTRA_CLEAN = *.o
> +
>  include ../../lib.mk
>
>  context_switch: ../utils.c
>  context_switch: CFLAGS += -maltivec -mvsx -mabi=altivec
>  context_switch: LDLIBS += -lpthread
> -
> -clean:
> -       $(RM) $(TEST_GEN_PROGS) *.o
> diff --git a/tools/testing/selftests/powerpc/copyloops/Makefile b/tools/testing/selftests/powerpc/copyloops/Makefile
> index eff1034..a768179 100644
> --- a/tools/testing/selftests/powerpc/copyloops/Makefile
> +++ b/tools/testing/selftests/powerpc/copyloops/Makefile
> @@ -9,6 +9,7 @@ ASFLAGS = $(CFLAGS)
>
>  TEST_GEN_PROGS := copyuser_64 copyuser_power7 memcpy_64 memcpy_power7
>  EXTRA_SOURCES := validate.c ../harness.c
> +EXTRA_CLEAN := *.o
>
>  include ../../lib.mk
>
> @@ -19,5 +20,3 @@ memcpy_power7:   CPPFLAGS += -D COPY_LOOP=test_memcpy_power7
>
>  $(TEST_GEN_PROGS): $(EXTRA_SOURCES)
>
> -clean:
> -       $(RM) $(TEST_GEN_PROGS) *.o
> diff --git a/tools/testing/selftests/powerpc/dscr/Makefile b/tools/testing/selftests/powerpc/dscr/Makefile
> index 96e0de0..7b43ac3 100644
> --- a/tools/testing/selftests/powerpc/dscr/Makefile
> +++ b/tools/testing/selftests/powerpc/dscr/Makefile
> @@ -2,11 +2,11 @@ TEST_GEN_PROGS := dscr_default_test dscr_explicit_test dscr_user_test \
>               dscr_inherit_test dscr_inherit_exec_test dscr_sysfs_test  \
>               dscr_sysfs_thread_test
>
> +EXTRA_CLEAN := *.o
> +
>  include ../../lib.mk
>
>  dscr_default_test: LDLIBS += -lpthread
>
>  $(TEST_GEN_PROGS): ../harness.c
>
> -clean:
> -       $(RM) $(TEST_GEN_PROGS) *.o
> diff --git a/tools/testing/selftests/powerpc/math/Makefile b/tools/testing/selftests/powerpc/math/Makefile
> index 8a5dde5..9aa9b22 100644
> --- a/tools/testing/selftests/powerpc/math/Makefile
> +++ b/tools/testing/selftests/powerpc/math/Makefile
> @@ -1,5 +1,7 @@
>  TEST_GEN_PROGS := fpu_syscall fpu_preempt fpu_signal vmx_syscall vmx_preempt vmx_signal vsx_preempt
>
> +EXTRA_CLEAN = *.o
> +
>  include ../../lib.mk
>
>  $(TEST_GEN_PROGS): ../harness.c
> @@ -15,6 +17,3 @@ vmx_signal: vmx_asm.S
>
>  vsx_preempt: CFLAGS += -mvsx
>  vsx_preempt: vsx_asm.S
> -
> -clean:
> -       $(RM) $(TEST_GEN_PROGS) *.o
> diff --git a/tools/testing/selftests/powerpc/primitives/Makefile b/tools/testing/selftests/powerpc/primitives/Makefile
> index 32cd56c..681627d 100644
> --- a/tools/testing/selftests/powerpc/primitives/Makefile
> +++ b/tools/testing/selftests/powerpc/primitives/Makefile
> @@ -2,9 +2,8 @@ CFLAGS += -I$(CURDIR)
>
>  TEST_GEN_PROGS := load_unaligned_zeropad
>
> +EXTRA_CLEAN = *.o
> +
>  include ../../lib.mk
>
>  $(TEST_GEN_PROGS): ../harness.c
> -
> -clean:
> -       $(RM) $(TEST_GEN_PROGS) *.o
> diff --git a/tools/testing/selftests/powerpc/stringloops/Makefile b/tools/testing/selftests/powerpc/stringloops/Makefile
> index c0ce663..166fdb8 100644
> --- a/tools/testing/selftests/powerpc/stringloops/Makefile
> +++ b/tools/testing/selftests/powerpc/stringloops/Makefile
> @@ -5,9 +5,8 @@ CFLAGS += -I$(CURDIR)
>  TEST_GEN_PROGS := memcmp
>  EXTRA_SOURCES := memcmp_64.S ../harness.c
>
> +EXTRA_CLEAN = *.o
> +
>  include ../../lib.mk
>
>  $(TEST_GEN_PROGS): $(EXTRA_SOURCES)
> -
> -clean:
> -       $(RM) $(TEST_GEN_PROGS) *.o
> diff --git a/tools/testing/selftests/powerpc/switch_endian/Makefile b/tools/testing/selftests/powerpc/switch_endian/Makefile
> index bd01223..dbd05ac 100644
> --- a/tools/testing/selftests/powerpc/switch_endian/Makefile
> +++ b/tools/testing/selftests/powerpc/switch_endian/Makefile
> @@ -2,6 +2,8 @@ TEST_GEN_PROGS := switch_endian_test
>
>  ASFLAGS += -O2 -Wall -g -nostdlib -m64
>
> +EXTRA_CLEAN = *.o check-reversed.S
> +
>  include ../../lib.mk
>
>  switch_endian_test: check-reversed.S
> @@ -11,6 +13,3 @@ check-reversed.o: check.o
>
>  check-reversed.S: check-reversed.o
>         hexdump -v -e '/1 ".byte 0x%02X\n"' $< > $@
> -
> -clean:
> -       $(RM) $(TEST_GEN_PROGS) *.o check-reversed.S
> diff --git a/tools/testing/selftests/powerpc/syscalls/Makefile b/tools/testing/selftests/powerpc/syscalls/Makefile
> index 5bea391..1590938 100644
> --- a/tools/testing/selftests/powerpc/syscalls/Makefile
> +++ b/tools/testing/selftests/powerpc/syscalls/Makefile
> @@ -2,9 +2,8 @@ TEST_GEN_PROGS := ipc_unmuxed
>
>  CFLAGS += -I../../../../../usr/include
>
> +EXTRAN_CLEAN = *.o
> +
>  include ../../lib.mk
>
>  $(TEST_GEN_PROGS): ../harness.c
> -
> -clean:
> -       $(RM) $(TEST_GEN_PROGS) *.o
> diff --git a/tools/testing/selftests/powerpc/tm/Makefile b/tools/testing/selftests/powerpc/tm/Makefile
> index cad0821..0ad4674 100644
> --- a/tools/testing/selftests/powerpc/tm/Makefile
> +++ b/tools/testing/selftests/powerpc/tm/Makefile
> @@ -4,6 +4,8 @@ SIGNAL_CONTEXT_CHK_TESTS := tm-signal-context-chk-gpr tm-signal-context-chk-fpu
>  TEST_GEN_PROGS := tm-resched-dscr tm-syscall tm-signal-msr-resv tm-signal-stack \
>         tm-vmxcopy tm-fork tm-tar tm-tmspr $(SIGNAL_CONTEXT_CHK_TESTS)
>
> +EXTRA_CLEAN = *.o
> +
>  include ../../lib.mk
>
>  $(TEST_GEN_PROGS): ../harness.c ../utils.c
> @@ -16,6 +18,3 @@ tm-tmspr: CFLAGS += -pthread
>
>  $(SIGNAL_CONTEXT_CHK_TESTS): tm-signal.S
>  $(SIGNAL_CONTEXT_CHK_TESTS): CFLAGS += -mhtm -m64 -mvsx
> -
> -clean:
> -       $(RM) $(TEST_GEN_PROGS) *.o
> diff --git a/tools/testing/selftests/pstore/Makefile b/tools/testing/selftests/pstore/Makefile
> index bd7abe2..c5f2440 100644
> --- a/tools/testing/selftests/pstore/Makefile
> +++ b/tools/testing/selftests/pstore/Makefile
> @@ -5,11 +5,9 @@ all:
>
>  TEST_PROGS := pstore_tests pstore_post_reboot_tests
>  TEST_FILES := common_tests pstore_crash_test
> +EXTRA_CLEAN := logs/* *uuid
>
>  include ../lib.mk
>
>  run_crash:
>         @sh pstore_crash_test || { echo "pstore_crash_test: [FAIL]"; exit 1; }
> -
> -clean:
> -       rm -rf logs/* *uuid
> diff --git a/tools/testing/selftests/zram/Makefile b/tools/testing/selftests/zram/Makefile
> index 29d8034..c3a87e5 100644
> --- a/tools/testing/selftests/zram/Makefile
> +++ b/tools/testing/selftests/zram/Makefile
> @@ -2,8 +2,7 @@ all:
>
>  TEST_PROGS := zram.sh
>  TEST_FILES := zram01.sh zram02.sh zram_lib.sh
> +EXTRA_CLEAN := err.log
>
>  include ../lib.mk
>
> -clean:
> -       $(RM) err.log
> --
> 1.8.4.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-api" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2016-11-21  8:54 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-21 11:01 [PATCH RFC 0/6] enable O and KBUILD_OUTPUT for kselftest bamvor.zhangjian
2016-10-21 11:01 ` [PATCH RFC 1/6] selftests: remove duplicated all and clean target bamvor.zhangjian
2016-11-18 10:31   ` Michael Ellerman
2016-11-18 12:59     ` Zhangjian (Bamvor)
2016-11-21  8:53       ` Michael Ellerman
2016-10-21 11:01 ` [PATCH RFC 2/6] selftests: remove useless TEST_DIRS bamvor.zhangjian
2016-11-18 10:31   ` Michael Ellerman
2016-10-21 11:01 ` [PATCH RFC 3/6] selftests: add default rules for c source file bamvor.zhangjian
2016-11-18 10:57   ` Michael Ellerman
2016-10-21 11:01 ` [PATCH RFC 4/6] selftests: remove CROSS_COMPILE in dedicated Makefile bamvor.zhangjian
2016-11-18 10:58   ` Michael Ellerman
2016-10-21 11:01 ` [PATCH RFC 5/6] selftests: add EXTRA_CLEAN for clean target bamvor.zhangjian
2016-11-18 11:01   ` Michael Ellerman
2016-11-18 12:51     ` Zhangjian (Bamvor)
2016-10-21 11:01 ` [PATCH RFC 6/6] selftests: enable O and KBUILD_OUTPUT bamvor.zhangjian
2016-11-18 11:29   ` Michael Ellerman
2016-11-18 13:03     ` Zhangjian (Bamvor)
2016-10-21 11:11 ` [PATCH RFC 0/6] enable O and KBUILD_OUTPUT for kselftest Bamvor Zhang Jian
2016-11-16 23:57 ` Shuah Khan
2016-11-18  0:15   ` Michael Ellerman
2016-11-18  0:18     ` Shuah Khan
2016-10-21 11:17 [PATCH RFC 5/6] selftests: add EXTRA_CLEAN for clean target Bamvor Zhang Jian

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®