<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/tools/testing/selftests/lib.mk, branch v4.11</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v4.11</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v4.11'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2017-03-02T14:53:01Z</updated>
<entry>
<title>selftests: lib.mk Fix individual test builds</title>
<updated>2017-03-02T14:53:01Z</updated>
<author>
<name>Shuah Khan</name>
<email>shuahkh@osg.samsung.com</email>
</author>
<published>2017-03-01T22:15:07Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=e53aff45c490ea04aa5d9e3cffa65b6b54397455'/>
<id>urn:sha1:e53aff45c490ea04aa5d9e3cffa65b6b54397455</id>
<content type='text'>
In commit a8ba798bc8ec ("selftests: enable O and KBUILD_OUTPUT"), added
support to generate compile targets in a user specified directory. OUTPUT
variable controls the location which is undefined when tests are built in
the test directory or with "make -C tools/testing/selftests/x86".

make -C tools/testing/selftests/x86/
make: Entering directory '/lkml/linux_4.11/tools/testing/selftests/x86'
Makefile:44: warning: overriding recipe for target 'clean'
../lib.mk:51: warning: ignoring old recipe for target 'clean'
gcc -m64 -o /single_step_syscall_64 -O2 -g -std=gnu99 -pthread -Wall  single_step_syscall.c -lrt -ldl
/usr/bin/ld: cannot open output file /single_step_syscall_64: Permission denied
collect2: error: ld returned 1 exit status
Makefile:50: recipe for target '/single_step_syscall_64' failed
make: *** [/single_step_syscall_64] Error 1
make: Leaving directory '/lkml/linux_4.11/tools/testing/selftests/x86'

Same failure with "cd tools/testing/selftests/x86/;make" run.

Fix this with a change to lib.mk to define OUTPUT to be the pwd when
MAKELEVEL is 0. This covers both cases mentioned above.

Reported-by: Ingo Molnar &lt;mingo@kernel.org&gt;
Signed-off-by: Shuah Khan &lt;shuahkh@osg.samsung.com&gt;
</content>
</entry>
<entry>
<title>selftests: Fix the .S and .S -&gt; .o rules</title>
<updated>2017-02-14T15:02:01Z</updated>
<author>
<name>Michael Ellerman</name>
<email>mpe@ellerman.id.au</email>
</author>
<published>2017-02-09T08:56:28Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=634ce97cdfa94a0c5444489b656a662fcc344536'/>
<id>urn:sha1:634ce97cdfa94a0c5444489b656a662fcc344536</id>
<content type='text'>
Both these rules incorrectly use $&lt; (first prerequisite) rather than
$^ (all prerequisites), meaning they don't work if we're using more than
one .S file as input. Switch them to using $^.

They also don't include $(CPPFLAGS) and other variables used in the
default rules, which breaks targets that require those. Fix that by
using the builtin $(COMPILE.S) and $(LINK.S) rules.

Fixes: a8ba798bc8ec ("selftests: enable O and KBUILD_OUTPUT")
Signed-off-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
Tested by: Bamvor Jian Zhang &lt;bamvor.zhangjian@linaro.org&gt;
Signed-off-by: Shuah Khan &lt;shuahkh@osg.samsung.com&gt;
</content>
</entry>
<entry>
<title>selftests: Fix the .c linking rule</title>
<updated>2017-02-14T15:01:55Z</updated>
<author>
<name>Michael Ellerman</name>
<email>mpe@ellerman.id.au</email>
</author>
<published>2017-02-09T08:56:27Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=2047f1d8ba287d208272b6e26360d1a53f7ebf7d'/>
<id>urn:sha1:2047f1d8ba287d208272b6e26360d1a53f7ebf7d</id>
<content type='text'>
Currently we can't build some tests, for example:

  $ make -C tools/testing/selftests/ TARGETS=vm
  ...
  gcc -Wall -I ../../../../usr/include   -lrt -lpthread ../../../../usr/include/linux/kernel.h userfaultfd.c -o tools/testing/selftests/vm/userfaultfd
  /tmp/ccmOkQSM.o: In function `stress':
  userfaultfd.c:(.text+0xc60): undefined reference to `pthread_create'
  userfaultfd.c:(.text+0xca5): undefined reference to `pthread_create'
  userfaultfd.c:(.text+0xcee): undefined reference to `pthread_create'
  userfaultfd.c:(.text+0xd30): undefined reference to `pthread_create'
  userfaultfd.c:(.text+0xd77): undefined reference to `pthread_join'
  userfaultfd.c:(.text+0xe7d): undefined reference to `pthread_join'
  userfaultfd.c:(.text+0xe9f): undefined reference to `pthread_cancel'
  userfaultfd.c:(.text+0xec6): undefined reference to `pthread_join'
  userfaultfd.c:(.text+0xf14): undefined reference to `pthread_join'
  /tmp/ccmOkQSM.o: In function `userfaultfd_stress':
  userfaultfd.c:(.text+0x13e2): undefined reference to `pthread_attr_setstacksize'
  collect2: error: ld returned 1 exit status

This is because the rule for linking .c files to binaries is incorrect.

The first bug is that it uses $&lt; (first prerequisite) instead of $^ (all
preqrequisites), fix it by using ^$.

Secondly the ordering of the prerequisites vs $(LDLIBS) is wrong,
meaning on toolchains that use --as-needed we fail to link (as above).
Fix that by placing $(LDLIBS) *after* ^$.

Finally switch to using the default rule $(LINK.c), so that we get
$(CPPFLAGS) etc. included.

Fixes: a8ba798bc8ec ("selftests: enable O and KBUILD_OUTPUT")
Signed-off-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
Tested by: Bamvor Jian Zhang &lt;bamvor.zhangjian@linaro.org&gt;
Signed-off-by: Shuah Khan &lt;shuahkh@osg.samsung.com&gt;
</content>
</entry>
<entry>
<title>selftests: Fix selftests build to just build, not run tests</title>
<updated>2017-02-14T15:01:44Z</updated>
<author>
<name>Michael Ellerman</name>
<email>mpe@ellerman.id.au</email>
</author>
<published>2017-02-09T08:56:26Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=d83c3ba0b9263592d1314df924b6c568f7683d29'/>
<id>urn:sha1:d83c3ba0b9263592d1314df924b6c568f7683d29</id>
<content type='text'>
In commit 88baa78d1f31 ("selftests: remove duplicated all and clean
target"), the "all" target was removed from individual Makefiles and
added to lib.mk.

However the "all" target was added to lib.mk *after* the existing
"runtests" target. This means "runtests" becomes the first (default)
target for most of our Makefiles.

This has the effect of causing a plain "make" to build *and run* the
tests. Which is at best rude, but depending on which tests are run could
oops someone's build machine.

  $ make -C tools/testing/selftests/
  ...
  make[1]: Entering directory 'tools/testing/selftests/bpf'
  gcc -Wall -O2 -I../../../../usr/include   test_verifier.c -o tools/testing/selftests/bpf/test_verifier
  gcc -Wall -O2 -I../../../../usr/include   test_maps.c -o tools/testing/selftests/bpf/test_maps
  gcc -Wall -O2 -I../../../../usr/include   test_lru_map.c -o tools/testing/selftests/bpf/test_lru_map
  #0 add+sub+mul FAIL
  Failed to load prog 'Function not implemented'!
  #1 unreachable FAIL
  Unexpected error message!
  #2 unreachable2 FAIL
  ...

Fix it by moving the "all" target to the start of lib.mk, making it the
default target.

Fixes: 88baa78d1f31 ("selftests: remove duplicated all and clean target")
Signed-off-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
Tested by: Bamvor Jian Zhang &lt;bamvor.zhangjian@linaro.org&gt;
Signed-off-by: Shuah Khan &lt;shuahkh@osg.samsung.com&gt;
</content>
</entry>
<entry>
<title>selftests: enable O and KBUILD_OUTPUT</title>
<updated>2017-01-05T20:42:22Z</updated>
<author>
<name>bamvor.zhangjian@huawei.com</name>
<email>bamvor.zhangjian@huawei.com</email>
</author>
<published>2016-11-29T11:55:52Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=a8ba798bc8ec663cf02e80b0dd770324de9bafd9'/>
<id>urn:sha1:a8ba798bc8ec663cf02e80b0dd770324de9bafd9</id>
<content type='text'>
Enable O and KBUILD_OUTPUT for kselftest. User could compile kselftest
to another directory by passing O or KBUILD_OUTPUT. And O is high
priority than KBUILD_OUTPUT.

Signed-off-by: Bamvor Jian Zhang &lt;bamvor.zhangjian@linaro.org&gt;
Signed-off-by: Shuah Khan &lt;shuahkh@osg.samsung.com&gt;
</content>
</entry>
<entry>
<title>selftests: add EXTRA_CLEAN for clean target</title>
<updated>2017-01-05T20:42:17Z</updated>
<author>
<name>bamvor.zhangjian@huawei.com</name>
<email>bamvor.zhangjian@huawei.com</email>
</author>
<published>2016-11-29T11:55:51Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=80d443e8876602be2c130f79c4de81e12e2a700d'/>
<id>urn:sha1:80d443e8876602be2c130f79c4de81e12e2a700d</id>
<content type='text'>
Some testcases need the clean extra data after running. This patch
introduce the "EXTRA_CLEAN" variable to address this requirement.

After KBUILD_OUTPUT is enabled in later patch, it will be easy to
decide to if we need do the cleanup in the KBUILD_OUTPUT path(if the
testcase ran immediately after compiled).

Signed-off-by: Bamvor Jian Zhang &lt;bamvor.zhangjian@linaro.org&gt;
Signed-off-by: Shuah Khan &lt;shuahkh@osg.samsung.com&gt;
</content>
</entry>
<entry>
<title>selftests: add default rules for c source file</title>
<updated>2017-01-05T20:42:01Z</updated>
<author>
<name>bamvor.zhangjian@huawei.com</name>
<email>bamvor.zhangjian@huawei.com</email>
</author>
<published>2016-11-29T11:55:49Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=7d758af257bc40a8a599a0aaa4768b30fb463e9c'/>
<id>urn:sha1:7d758af257bc40a8a599a0aaa4768b30fb463e9c</id>
<content type='text'>
There are difference rules for compiling c source file in different
testcases. In order to enable KBUILD_OUTPUT support in later patch,
this patch introduce the default rules in
"tools/testing/selftest/lib.mk" and remove the existing rules in each
testcase.

Acked-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
Signed-off-by: Bamvor Jian Zhang &lt;bamvor.zhangjian@linaro.org&gt;
Signed-off-by: Shuah Khan &lt;shuahkh@osg.samsung.com&gt;
</content>
</entry>
<entry>
<title>selftests: remove useless TEST_DIRS</title>
<updated>2017-01-05T20:41:56Z</updated>
<author>
<name>bamvor.zhangjian@huawei.com</name>
<email>bamvor.zhangjian@huawei.com</email>
</author>
<published>2016-11-29T11:55:48Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=5fe59799352b2e2e2dfcf84585c6d780d6effb0e'/>
<id>urn:sha1:5fe59799352b2e2e2dfcf84585c6d780d6effb0e</id>
<content type='text'>
The TEST_DIRS was introduced in Commit e8c1d7cdf137 ("selftests: copy
TEST_DIRS to INSTALL_PATH") for coping a whole directory in ftrace.

After rsync(with -a) is introduced by Commit 900d65ee11aa ("selftests:
change install command to rsync"). Rsync could handle the directory
without the definition of TEST_DIRS.

This patch simply replace TEST_DIRS with TEST_FILES in ftrace and remove
the TEST_DIRS in tools/testing/selftest/lib.mk

Acked-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
Signed-off-by: Bamvor Jian Zhang &lt;bamvor.zhangjian@linaro.org&gt;
Signed-off-by: Shuah Khan &lt;shuahkh@osg.samsung.com&gt;
</content>
</entry>
<entry>
<title>selftests: remove duplicated all and clean target</title>
<updated>2017-01-05T20:41:35Z</updated>
<author>
<name>bamvor.zhangjian@huawei.com</name>
<email>bamvor.zhangjian@huawei.com</email>
</author>
<published>2016-11-29T11:55:47Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=88baa78d1f318e57c7cccbfe55d485befd1ce696'/>
<id>urn:sha1:88baa78d1f318e57c7cccbfe55d485befd1ce696</id>
<content type='text'>
Currently, kselftest use TEST_PROGS, TEST_PROGS_EXTENDED, TEST_FILES to
indicate the test program, extended test program and test files. It is
easy to understand the purpose of these files. But mix of compiled and
uncompiled files lead to duplicated "all" and "clean" targets.

In order to remove the duplicated targets, introduce TEST_GEN_PROGS,
TEST_GEN_PROGS_EXTENDED, TEST_GEN_FILES to indicate the compiled
objects.

Also, the later patch will make use of TEST_GEN_XXX to redirect these
files to output directory indicated by KBUILD_OUTPUT or O.

And add this changes to "Contributing new tests(details)" of
Documentation/kselftest.txt.

Signed-off-by: Bamvor Jian Zhang &lt;bamvor.zhangjian@linaro.org&gt;
Signed-off-by: Shuah Khan &lt;shuahkh@osg.samsung.com&gt;
</content>
</entry>
<entry>
<title>selftests: change install command to rsync</title>
<updated>2015-09-14T22:43:51Z</updated>
<author>
<name>Bamvor Jian Zhang</name>
<email>bamvor.zhangjian@linaro.org</email>
</author>
<published>2015-09-09T13:06:28Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=900d65ee11aae3a23cb963f484b65eb3e269dd9c'/>
<id>urn:sha1:900d65ee11aae3a23cb963f484b65eb3e269dd9c</id>
<content type='text'>
The command of install could not handle the special files in exec
testcases, change the default rule to rsync to fix this.

The installation is unchanged after this commit.

Suggested-by: Michael Ellerman &lt;mpe@ellerman.id.au&gt;
Signed-off-by: Bamvor Jian Zhang &lt;bamvor.zhangjian@linaro.org&gt;
Signed-off-by: Shuah Khan &lt;shuahkh@osg.samsung.com&gt;
</content>
</entry>
</feed>
