From 65177e47d3035c083cff034ffbfc7ab750a4675c Mon Sep 17 00:00:00 2001 From: Jakub Kicinski Date: Wed, 25 Jan 2023 15:13:56 -0800 Subject: testing: kselftest_harness: add filtering and enumerating tests As the number of test cases and length of execution grows it's useful to select only a subset of tests. In TLS for instance we have a matrix of variants for different crypto protocols and during development mostly care about testing a handful. This is quicker and makes reading output easier. This patch adds argument parsing to kselftest_harness. It supports a couple of ways to filter things, I could not come up with one way which will cover all cases. The first and simplest switch is -r which takes the name of a test to run (can be specified multiple times). For example: $ ./my_test -r some.test.name -r some.other.name will run tests some.test.name and some.other.name (where "some" is the fixture, "test" and "other" and "name is the test.) Then there is a handful of group filtering options. f/v/t for filtering by fixture/variant/test. They have both positive (match -> run) and negative versions (match -> skip). If user specifies any positive option we assume the default is not to run the tests. If only negative options are set we assume the tests are supposed to be run by default. Usage: ./tools/testing/selftests/net/tls [-h|-l] [-t|-T|-v|-V|-f|-F|-r name] -h print help -l list all tests -t name include test -T name exclude test -v name include variant -V name exclude variant -f name include fixture -F name exclude fixture -r name run specified test Test filter options can be specified multiple times. The filtering stops at the first match. For example to include all tests from variant 'bla' but not test 'foo' specify '-T foo -v bla'. Here we can request for example all tests from fixture "foo" to run: ./my_test -f foo or to skip variants var1 and var2: ./my_test -V var1 -V var2 Signed-off-by: Jakub Kicinski Signed-off-by: Shuah Khan --- tools/testing/selftests/kselftest_harness.h | 142 +++++++++++++++++++++++++++- 1 file changed, 137 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h index 25f4d54067c0..d8bff2005dfc 100644 --- a/tools/testing/selftests/kselftest_harness.h +++ b/tools/testing/selftests/kselftest_harness.h @@ -54,6 +54,7 @@ #define _GNU_SOURCE #endif #include +#include #include #include #include @@ -985,6 +986,127 @@ void __wait_for_test(struct __test_metadata *t) } } +static void test_harness_list_tests(void) +{ + struct __fixture_variant_metadata *v; + struct __fixture_metadata *f; + struct __test_metadata *t; + + for (f = __fixture_list; f; f = f->next) { + v = f->variant; + t = f->tests; + + if (f == __fixture_list) + fprintf(stderr, "%-20s %-25s %s\n", + "# FIXTURE", "VARIANT", "TEST"); + else + fprintf(stderr, "--------------------------------------------------------------------------------\n"); + + do { + fprintf(stderr, "%-20s %-25s %s\n", + t == f->tests ? f->name : "", + v ? v->name : "", + t ? t->name : ""); + + v = v ? v->next : NULL; + t = t ? t->next : NULL; + } while (v || t); + } +} + +static int test_harness_argv_check(int argc, char **argv) +{ + int opt; + + while ((opt = getopt(argc, argv, "hlF:f:V:v:t:T:r:")) != -1) { + switch (opt) { + case 'f': + case 'F': + case 'v': + case 'V': + case 't': + case 'T': + case 'r': + break; + case 'l': + test_harness_list_tests(); + return KSFT_SKIP; + case 'h': + default: + fprintf(stderr, + "Usage: %s [-h|-l] [-t|-T|-v|-V|-f|-F|-r name]\n" + "\t-h print help\n" + "\t-l list all tests\n" + "\n" + "\t-t name include test\n" + "\t-T name exclude test\n" + "\t-v name include variant\n" + "\t-V name exclude variant\n" + "\t-f name include fixture\n" + "\t-F name exclude fixture\n" + "\t-r name run specified test\n" + "\n" + "Test filter options can be specified " + "multiple times. The filtering stops\n" + "at the first match. For example to " + "include all tests from variant 'bla'\n" + "but not test 'foo' specify '-T foo -v bla'.\n" + "", argv[0]); + return opt == 'h' ? KSFT_SKIP : KSFT_FAIL; + } + } + + return KSFT_PASS; +} + +static bool test_enabled(int argc, char **argv, + struct __fixture_metadata *f, + struct __fixture_variant_metadata *v, + struct __test_metadata *t) +{ + unsigned int flen = 0, vlen = 0, tlen = 0; + bool has_positive = false; + int opt; + + optind = 1; + while ((opt = getopt(argc, argv, "F:f:V:v:t:T:r:")) != -1) { + has_positive |= islower(opt); + + switch (tolower(opt)) { + case 't': + if (!strcmp(t->name, optarg)) + return islower(opt); + break; + case 'f': + if (!strcmp(f->name, optarg)) + return islower(opt); + break; + case 'v': + if (!strcmp(v->name, optarg)) + return islower(opt); + break; + case 'r': + if (!tlen) { + flen = strlen(f->name); + vlen = strlen(v->name); + tlen = strlen(t->name); + } + if (strlen(optarg) == flen + 1 + vlen + !!vlen + tlen && + !strncmp(f->name, &optarg[0], flen) && + !strncmp(v->name, &optarg[flen + 1], vlen) && + !strncmp(t->name, &optarg[flen + 1 + vlen + !!vlen], tlen)) + return true; + break; + } + } + + /* + * If there are no positive tests then we assume user just wants + * exclusions and everything else is a pass. + */ + return !has_positive; +} + void __run_test(struct __fixture_metadata *f, struct __fixture_variant_metadata *variant, struct __test_metadata *t) @@ -1032,24 +1154,32 @@ void __run_test(struct __fixture_metadata *f, f->name, variant->name[0] ? "." : "", variant->name, t->name); } -static int test_harness_run(int __attribute__((unused)) argc, - char __attribute__((unused)) **argv) +static int test_harness_run(int argc, char **argv) { struct __fixture_variant_metadata no_variant = { .name = "", }; struct __fixture_variant_metadata *v; struct __fixture_metadata *f; struct __test_results *results; struct __test_metadata *t; - int ret = 0; + int ret; unsigned int case_count = 0, test_count = 0; unsigned int count = 0; unsigned int pass_count = 0; + ret = test_harness_argv_check(argc, argv); + if (ret != KSFT_PASS) + return ret; + for (f = __fixture_list; f; f = f->next) { for (v = f->variant ?: &no_variant; v; v = v->next) { - case_count++; + unsigned int old_tests = test_count; + for (t = f->tests; t; t = t->next) - test_count++; + if (test_enabled(argc, argv, f, v, t)) + test_count++; + + if (old_tests != test_count) + case_count++; } } @@ -1063,6 +1193,8 @@ static int test_harness_run(int __attribute__((unused)) argc, for (f = __fixture_list; f; f = f->next) { for (v = f->variant ?: &no_variant; v; v = v->next) { for (t = f->tests; t; t = t->next) { + if (!test_enabled(argc, argv, f, v, t)) + continue; count++; t->results = results; __run_test(f, v, t); -- cgit v1.2.3 From 7482c19173b7eb044d476b3444d7ee55bc669d03 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 27 Jan 2023 08:57:22 -0500 Subject: selftests: arm64: Fix incorrect kernel headers search path Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...). Signed-off-by: Mathieu Desnoyers Cc: Shuah Khan Cc: linux-kselftest@vger.kernel.org Cc: Ingo Molnar Cc: # 5.18+ Acked-by: Shuah Khan Acked-by: Catalin Marinas Signed-off-by: Shuah Khan --- tools/testing/selftests/arm64/fp/Makefile | 2 +- tools/testing/selftests/arm64/tags/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/arm64/fp/Makefile b/tools/testing/selftests/arm64/fp/Makefile index 36db61358ed5..932ec8792316 100644 --- a/tools/testing/selftests/arm64/fp/Makefile +++ b/tools/testing/selftests/arm64/fp/Makefile @@ -3,7 +3,7 @@ # A proper top_srcdir is needed by KSFT(lib.mk) top_srcdir = $(realpath ../../../../../) -CFLAGS += -I$(top_srcdir)/usr/include/ +CFLAGS += $(KHDR_INCLUDES) TEST_GEN_PROGS := fp-stress \ sve-ptrace sve-probe-vls \ diff --git a/tools/testing/selftests/arm64/tags/Makefile b/tools/testing/selftests/arm64/tags/Makefile index 41cb75070511..6d29cfde43a2 100644 --- a/tools/testing/selftests/arm64/tags/Makefile +++ b/tools/testing/selftests/arm64/tags/Makefile @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 -CFLAGS += -I../../../../../usr/include/ +CFLAGS += $(KHDR_INCLUDES) TEST_GEN_PROGS := tags_test TEST_PROGS := run_tags_test.sh -- cgit v1.2.3 From 612cf4d283414a5ee2733db6608d917deb45fa46 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 27 Jan 2023 08:57:24 -0500 Subject: selftests: clone3: Fix incorrect kernel headers search path Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...). Signed-off-by: Mathieu Desnoyers Cc: Shuah Khan Cc: linux-kselftest@vger.kernel.org Cc: Ingo Molnar Cc: # 5.18+ Acked-by: Shuah Khan Acked-by: Christian Brauner Signed-off-by: Shuah Khan --- tools/testing/selftests/clone3/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/clone3/Makefile b/tools/testing/selftests/clone3/Makefile index 79b19a2863a0..84832c369a2e 100644 --- a/tools/testing/selftests/clone3/Makefile +++ b/tools/testing/selftests/clone3/Makefile @@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -CFLAGS += -g -std=gnu99 -I../../../../usr/include/ +CFLAGS += -g -std=gnu99 $(KHDR_INCLUDES) LDLIBS += -lcap TEST_GEN_PROGS := clone3 clone3_clear_sighand clone3_set_tid \ -- cgit v1.2.3 From 145df2fdc38f24b3e52e4c2a59b02d874a074fbd Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 27 Jan 2023 08:57:25 -0500 Subject: selftests: core: Fix incorrect kernel headers search path Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...). Signed-off-by: Mathieu Desnoyers Cc: Shuah Khan Cc: linux-kselftest@vger.kernel.org Cc: Ingo Molnar Cc: # 5.18+ Signed-off-by: Shuah Khan --- tools/testing/selftests/core/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/core/Makefile b/tools/testing/selftests/core/Makefile index f6f2d6f473c6..ce262d097269 100644 --- a/tools/testing/selftests/core/Makefile +++ b/tools/testing/selftests/core/Makefile @@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only -CFLAGS += -g -I../../../../usr/include/ +CFLAGS += -g $(KHDR_INCLUDES) TEST_GEN_PROGS := close_range_test -- cgit v1.2.3 From f80f09b59fdd45753dd80ac623981ad00ece4c2d Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 27 Jan 2023 08:57:27 -0500 Subject: selftests: dmabuf-heaps: Fix incorrect kernel headers search path Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...). Signed-off-by: Mathieu Desnoyers Cc: Shuah Khan Cc: linux-kselftest@vger.kernel.org Cc: Ingo Molnar Cc: # 5.18+ Signed-off-by: Shuah Khan --- tools/testing/selftests/dmabuf-heaps/Makefile | 2 +- tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/dmabuf-heaps/Makefile b/tools/testing/selftests/dmabuf-heaps/Makefile index 604b43ece15f..9e7e158d5fa3 100644 --- a/tools/testing/selftests/dmabuf-heaps/Makefile +++ b/tools/testing/selftests/dmabuf-heaps/Makefile @@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -CFLAGS += -static -O3 -Wl,-no-as-needed -Wall +CFLAGS += -static -O3 -Wl,-no-as-needed -Wall $(KHDR_INCLUDES) TEST_GEN_PROGS = dmabuf-heap diff --git a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c index 29af27acd40e..890a8236a8ba 100644 --- a/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c +++ b/tools/testing/selftests/dmabuf-heaps/dmabuf-heap.c @@ -13,10 +13,9 @@ #include #include +#include #include -#include "../../../../include/uapi/linux/dma-heap.h" - #define DEVPATH "/dev/dma_heap" static int check_vgem(int fd) -- cgit v1.2.3 From 07f0148aafe8c95a3a76cd59e9e75b4d78d1d31d Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 27 Jan 2023 08:57:28 -0500 Subject: selftests: drivers: Fix incorrect kernel headers search path Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...). Signed-off-by: Mathieu Desnoyers Cc: Shuah Khan Cc: linux-kselftest@vger.kernel.org Cc: Ingo Molnar Cc: # 5.18+ Signed-off-by: Shuah Khan --- tools/testing/selftests/drivers/dma-buf/Makefile | 2 +- tools/testing/selftests/drivers/s390x/uvdevice/Makefile | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/drivers/dma-buf/Makefile b/tools/testing/selftests/drivers/dma-buf/Makefile index 79cb16b4e01a..441407bb0e80 100644 --- a/tools/testing/selftests/drivers/dma-buf/Makefile +++ b/tools/testing/selftests/drivers/dma-buf/Makefile @@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only -CFLAGS += -I../../../../../usr/include/ +CFLAGS += $(KHDR_INCLUDES) TEST_GEN_PROGS := udmabuf diff --git a/tools/testing/selftests/drivers/s390x/uvdevice/Makefile b/tools/testing/selftests/drivers/s390x/uvdevice/Makefile index 891215a7dc8a..755d164384c4 100644 --- a/tools/testing/selftests/drivers/s390x/uvdevice/Makefile +++ b/tools/testing/selftests/drivers/s390x/uvdevice/Makefile @@ -11,10 +11,9 @@ else TEST_GEN_PROGS := test_uvdevice top_srcdir ?= ../../../../../.. -khdr_dir = $(top_srcdir)/usr/include LINUX_TOOL_ARCH_INCLUDE = $(top_srcdir)/tools/arch/$(ARCH)/include -CFLAGS += -Wall -Werror -static -I$(khdr_dir) -I$(LINUX_TOOL_ARCH_INCLUDE) +CFLAGS += -Wall -Werror -static $(KHDR_INCLUDES) -I$(LINUX_TOOL_ARCH_INCLUDE) include ../../../lib.mk -- cgit v1.2.3 From c2d3cf3653a8ff6e4b402d55e7f84790ac08a8ad Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 27 Jan 2023 08:57:29 -0500 Subject: selftests: filesystems: Fix incorrect kernel headers search path Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...). Signed-off-by: Mathieu Desnoyers Cc: Shuah Khan Cc: linux-kselftest@vger.kernel.org Cc: Ingo Molnar Cc: # 5.18+ Signed-off-by: Shuah Khan --- tools/testing/selftests/filesystems/Makefile | 2 +- tools/testing/selftests/filesystems/binderfs/Makefile | 2 +- tools/testing/selftests/filesystems/epoll/Makefile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/filesystems/Makefile b/tools/testing/selftests/filesystems/Makefile index 129880fb42d3..c647fd6a0446 100644 --- a/tools/testing/selftests/filesystems/Makefile +++ b/tools/testing/selftests/filesystems/Makefile @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 -CFLAGS += -I../../../../usr/include/ +CFLAGS += $(KHDR_INCLUDES) TEST_GEN_PROGS := devpts_pts TEST_GEN_PROGS_EXTENDED := dnotify_test diff --git a/tools/testing/selftests/filesystems/binderfs/Makefile b/tools/testing/selftests/filesystems/binderfs/Makefile index 8af25ae96049..c2f7cef919c0 100644 --- a/tools/testing/selftests/filesystems/binderfs/Makefile +++ b/tools/testing/selftests/filesystems/binderfs/Makefile @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 -CFLAGS += -I../../../../../usr/include/ -pthread +CFLAGS += $(KHDR_INCLUDES) -pthread TEST_GEN_PROGS := binderfs_test binderfs_test: binderfs_test.c ../../kselftest.h ../../kselftest_harness.h diff --git a/tools/testing/selftests/filesystems/epoll/Makefile b/tools/testing/selftests/filesystems/epoll/Makefile index 78ae4aaf7141..0788a7dc8004 100644 --- a/tools/testing/selftests/filesystems/epoll/Makefile +++ b/tools/testing/selftests/filesystems/epoll/Makefile @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 -CFLAGS += -I../../../../../usr/include/ +CFLAGS += $(KHDR_INCLUDES) LDLIBS += -lpthread TEST_GEN_PROGS := epoll_wakeup_test -- cgit v1.2.3 From 24c55275ba0d538def2b1220002d0e808a85d50f Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 27 Jan 2023 08:57:30 -0500 Subject: selftests: futex: Fix incorrect kernel headers search path Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...). Signed-off-by: Mathieu Desnoyers Cc: Shuah Khan Cc: linux-kselftest@vger.kernel.org Cc: Ingo Molnar Cc: # 5.18+ Signed-off-by: Shuah Khan --- tools/testing/selftests/futex/functional/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/futex/functional/Makefile b/tools/testing/selftests/futex/functional/Makefile index 5a0e0df8de9b..a392d0917b4e 100644 --- a/tools/testing/selftests/futex/functional/Makefile +++ b/tools/testing/selftests/futex/functional/Makefile @@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -INCLUDES := -I../include -I../../ -I../../../../../usr/include/ +INCLUDES := -I../include -I../../ $(KHDR_INCLUDES) CFLAGS := $(CFLAGS) -g -O2 -Wall -D_GNU_SOURCE -pthread $(INCLUDES) $(KHDR_INCLUDES) LDLIBS := -lpthread -lrt -- cgit v1.2.3 From 8bb9c1808628babcc7b99ec2439bf102379bd4ac Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 27 Jan 2023 08:57:31 -0500 Subject: selftests: gpio: Fix incorrect kernel headers search path Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...). Signed-off-by: Mathieu Desnoyers Cc: Shuah Khan Cc: linux-kselftest@vger.kernel.org Cc: Ingo Molnar Cc: # 5.18+ Signed-off-by: Shuah Khan --- tools/testing/selftests/gpio/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/gpio/Makefile b/tools/testing/selftests/gpio/Makefile index 616ed4019655..e0884390447d 100644 --- a/tools/testing/selftests/gpio/Makefile +++ b/tools/testing/selftests/gpio/Makefile @@ -3,6 +3,6 @@ TEST_PROGS := gpio-mockup.sh gpio-sim.sh TEST_FILES := gpio-mockup-sysfs.sh TEST_GEN_PROGS_EXTENDED := gpio-mockup-cdev gpio-chip-info gpio-line-name -CFLAGS += -O2 -g -Wall -I../../../../usr/include/ $(KHDR_INCLUDES) +CFLAGS += -O2 -g -Wall $(KHDR_INCLUDES) include ../lib.mk -- cgit v1.2.3 From ecf9fdb5c2a9d63c732acccb6318feb73dd1589f Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 27 Jan 2023 08:57:32 -0500 Subject: selftests: ipc: Fix incorrect kernel headers search path Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...). Signed-off-by: Mathieu Desnoyers Cc: Shuah Khan Cc: linux-kselftest@vger.kernel.org Cc: Ingo Molnar Cc: # 5.18+ Signed-off-by: Shuah Khan --- tools/testing/selftests/ipc/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/ipc/Makefile b/tools/testing/selftests/ipc/Makefile index 1c4448a843a4..50e9c299fc4a 100644 --- a/tools/testing/selftests/ipc/Makefile +++ b/tools/testing/selftests/ipc/Makefile @@ -10,7 +10,7 @@ ifeq ($(ARCH),x86_64) CFLAGS := -DCONFIG_X86_64 -D__x86_64__ endif -CFLAGS += -I../../../../usr/include/ +CFLAGS += $(KHDR_INCLUDES) TEST_GEN_PROGS := msgque -- cgit v1.2.3 From 5d74231a2caad259f6669d8d6112814cef6bcd60 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 27 Jan 2023 08:57:33 -0500 Subject: selftests: kcmp: Fix incorrect kernel headers search path Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...). Signed-off-by: Mathieu Desnoyers Cc: Shuah Khan Cc: linux-kselftest@vger.kernel.org Cc: Ingo Molnar Cc: # 5.18+ Signed-off-by: Shuah Khan --- tools/testing/selftests/kcmp/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/kcmp/Makefile b/tools/testing/selftests/kcmp/Makefile index b4d39f6b5124..59a1e5379018 100644 --- a/tools/testing/selftests/kcmp/Makefile +++ b/tools/testing/selftests/kcmp/Makefile @@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only -CFLAGS += -I../../../../usr/include/ +CFLAGS += $(KHDR_INCLUDES) TEST_GEN_PROGS := kcmp_test -- cgit v1.2.3 From f2f9592b736087f695230410fb8dc1afd3cafbbb Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 27 Jan 2023 08:57:34 -0500 Subject: selftests: media_tests: Fix incorrect kernel headers search path Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...). Signed-off-by: Mathieu Desnoyers Cc: Shuah Khan Cc: linux-kselftest@vger.kernel.org Cc: Ingo Molnar Cc: # 5.18+ Signed-off-by: Shuah Khan --- tools/testing/selftests/media_tests/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/media_tests/Makefile b/tools/testing/selftests/media_tests/Makefile index 60826d7d37d4..471d83e61d95 100644 --- a/tools/testing/selftests/media_tests/Makefile +++ b/tools/testing/selftests/media_tests/Makefile @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 # -CFLAGS += -I../ -I../../../../usr/include/ +CFLAGS += -I../ $(KHDR_INCLUDES) TEST_GEN_PROGS := media_device_test media_device_open video_device_test include ../lib.mk -- cgit v1.2.3 From 498bb027726371ba4a94686d251f9be1d437573e Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 27 Jan 2023 08:57:35 -0500 Subject: selftests: membarrier: Fix incorrect kernel headers search path Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...). Signed-off-by: Mathieu Desnoyers Cc: Shuah Khan Cc: linux-kselftest@vger.kernel.org Cc: Ingo Molnar Cc: # 5.18+ Signed-off-by: Shuah Khan --- tools/testing/selftests/membarrier/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/membarrier/Makefile b/tools/testing/selftests/membarrier/Makefile index 34d1c81a2324..fc840e06ff56 100644 --- a/tools/testing/selftests/membarrier/Makefile +++ b/tools/testing/selftests/membarrier/Makefile @@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only -CFLAGS += -g -I../../../../usr/include/ +CFLAGS += -g $(KHDR_INCLUDES) LDLIBS += -lpthread TEST_GEN_PROGS := membarrier_test_single_thread \ -- cgit v1.2.3 From 5d11f2d0eb39d2b5c5e8f05e1f650c4a4de69918 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 27 Jan 2023 08:57:36 -0500 Subject: selftests: mount_setattr: Fix incorrect kernel headers search path Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...). Signed-off-by: Mathieu Desnoyers Cc: Shuah Khan Cc: linux-kselftest@vger.kernel.org Cc: Ingo Molnar Cc: # 5.18+ Signed-off-by: Shuah Khan --- tools/testing/selftests/mount_setattr/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/mount_setattr/Makefile b/tools/testing/selftests/mount_setattr/Makefile index 2250f7dcb81e..fde72df01b11 100644 --- a/tools/testing/selftests/mount_setattr/Makefile +++ b/tools/testing/selftests/mount_setattr/Makefile @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 # Makefile for mount selftests. -CFLAGS = -g -I../../../../usr/include/ -Wall -O2 -pthread +CFLAGS = -g $(KHDR_INCLUDES) -Wall -O2 -pthread TEST_GEN_FILES += mount_setattr_test -- cgit v1.2.3 From 65c68af0131bfef8e395c325735b6c40638cb931 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 27 Jan 2023 08:57:37 -0500 Subject: selftests: move_mount_set_group: Fix incorrect kernel headers search path Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...). Signed-off-by: Mathieu Desnoyers Cc: Shuah Khan Cc: linux-kselftest@vger.kernel.org Cc: Ingo Molnar Cc: # 5.18+ Signed-off-by: Shuah Khan --- tools/testing/selftests/move_mount_set_group/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/move_mount_set_group/Makefile b/tools/testing/selftests/move_mount_set_group/Makefile index 80c2d86812b0..94235846b6f9 100644 --- a/tools/testing/selftests/move_mount_set_group/Makefile +++ b/tools/testing/selftests/move_mount_set_group/Makefile @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 # Makefile for mount selftests. -CFLAGS = -g -I../../../../usr/include/ -Wall -O2 +CFLAGS = -g $(KHDR_INCLUDES) -Wall -O2 TEST_GEN_FILES += move_mount_set_group_test -- cgit v1.2.3 From 465cbb1b9a9fd5f6907adb2d761facaf1a46bfbe Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 27 Jan 2023 08:57:39 -0500 Subject: selftests: perf_events: Fix incorrect kernel headers search path Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...). Signed-off-by: Mathieu Desnoyers Cc: Shuah Khan Cc: linux-kselftest@vger.kernel.org Cc: Ingo Molnar Cc: # 5.18+ Signed-off-by: Shuah Khan --- tools/testing/selftests/perf_events/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/perf_events/Makefile b/tools/testing/selftests/perf_events/Makefile index fcafa5f0d34c..db93c4ff081a 100644 --- a/tools/testing/selftests/perf_events/Makefile +++ b/tools/testing/selftests/perf_events/Makefile @@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -CFLAGS += -Wl,-no-as-needed -Wall -I../../../../usr/include +CFLAGS += -Wl,-no-as-needed -Wall $(KHDR_INCLUDES) LDFLAGS += -lpthread TEST_GEN_PROGS := sigtrap_threads remove_on_exec -- cgit v1.2.3 From e81ff69f66969a16a98a2e0977c1860f1c182c74 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 27 Jan 2023 08:57:40 -0500 Subject: selftests: pid_namespace: Fix incorrect kernel headers search path Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...). Signed-off-by: Mathieu Desnoyers Cc: Shuah Khan Cc: linux-kselftest@vger.kernel.org Cc: Ingo Molnar Cc: # 5.18+ Signed-off-by: Shuah Khan --- tools/testing/selftests/pid_namespace/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/pid_namespace/Makefile b/tools/testing/selftests/pid_namespace/Makefile index edafaca1aeb3..9286a1d22cd3 100644 --- a/tools/testing/selftests/pid_namespace/Makefile +++ b/tools/testing/selftests/pid_namespace/Makefile @@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -CFLAGS += -g -I../../../../usr/include/ +CFLAGS += -g $(KHDR_INCLUDES) TEST_GEN_PROGS = regression_enomem -- cgit v1.2.3 From 3f7d71768795c386019f2295c1986d00035c9f0f Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 27 Jan 2023 08:57:41 -0500 Subject: selftests: pidfd: Fix incorrect kernel headers search path Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...). Signed-off-by: Mathieu Desnoyers Cc: Shuah Khan Cc: linux-kselftest@vger.kernel.org Cc: Ingo Molnar Cc: # 5.18+ Signed-off-by: Shuah Khan --- tools/testing/selftests/pidfd/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/pidfd/Makefile b/tools/testing/selftests/pidfd/Makefile index 778b6cdc8aed..d731e3e76d5b 100644 --- a/tools/testing/selftests/pidfd/Makefile +++ b/tools/testing/selftests/pidfd/Makefile @@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only -CFLAGS += -g -I../../../../usr/include/ -pthread -Wall +CFLAGS += -g $(KHDR_INCLUDES) -pthread -Wall TEST_GEN_PROGS := pidfd_test pidfd_fdinfo_test pidfd_open_test \ pidfd_poll_test pidfd_wait pidfd_getfd_test pidfd_setns_test -- cgit v1.2.3 From 01ede99e9de16e7a1ed689c99f41022aa878f2f4 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 27 Jan 2023 08:57:43 -0500 Subject: selftests: ptp: Fix incorrect kernel headers search path Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...). Signed-off-by: Mathieu Desnoyers Cc: Shuah Khan Cc: linux-kselftest@vger.kernel.org Cc: Ingo Molnar Cc: # 5.18+ Signed-off-by: Shuah Khan --- tools/testing/selftests/ptp/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/ptp/Makefile b/tools/testing/selftests/ptp/Makefile index ef06de0898b7..eeab44cc6863 100644 --- a/tools/testing/selftests/ptp/Makefile +++ b/tools/testing/selftests/ptp/Makefile @@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -CFLAGS += -I../../../../usr/include/ +CFLAGS += $(KHDR_INCLUDES) TEST_PROGS := testptp LDLIBS += -lrt all: $(TEST_PROGS) -- cgit v1.2.3 From 2279bfc03211045c8f43a76b01889a5ca86acd5a Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 27 Jan 2023 08:57:44 -0500 Subject: selftests: rseq: Fix incorrect kernel headers search path Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...). Signed-off-by: Mathieu Desnoyers Cc: Shuah Khan Cc: linux-kselftest@vger.kernel.org Cc: Ingo Molnar Cc: # 5.18+ Signed-off-by: Shuah Khan --- tools/testing/selftests/rseq/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/rseq/Makefile b/tools/testing/selftests/rseq/Makefile index 215e1067f037..3a173e184566 100644 --- a/tools/testing/selftests/rseq/Makefile +++ b/tools/testing/selftests/rseq/Makefile @@ -4,7 +4,7 @@ ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),) CLANG_FLAGS += -no-integrated-as endif -CFLAGS += -O2 -Wall -g -I./ -I../../../../usr/include/ -L$(OUTPUT) -Wl,-rpath=./ \ +CFLAGS += -O2 -Wall -g -I./ $(KHDR_INCLUDES) -L$(OUTPUT) -Wl,-rpath=./ \ $(CLANG_FLAGS) LDLIBS += -lpthread -ldl -- cgit v1.2.3 From 0d2cace5af50806a6b32ab73d367b80e46acda0f Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 27 Jan 2023 08:57:45 -0500 Subject: selftests: sched: Fix incorrect kernel headers search path Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...). Signed-off-by: Mathieu Desnoyers Cc: Shuah Khan Cc: linux-kselftest@vger.kernel.org Cc: Ingo Molnar Cc: # 5.18+ Signed-off-by: Shuah Khan --- tools/testing/selftests/sched/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/sched/Makefile b/tools/testing/selftests/sched/Makefile index 10c72f14fea9..099ee9213557 100644 --- a/tools/testing/selftests/sched/Makefile +++ b/tools/testing/selftests/sched/Makefile @@ -4,7 +4,7 @@ ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),) CLANG_FLAGS += -no-integrated-as endif -CFLAGS += -O2 -Wall -g -I./ -I../../../../usr/include/ -Wl,-rpath=./ \ +CFLAGS += -O2 -Wall -g -I./ $(KHDR_INCLUDES) -Wl,-rpath=./ \ $(CLANG_FLAGS) LDLIBS += -lpthread -- cgit v1.2.3 From 07d42dd854446ba3177ad7a217870a5b4edee165 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 27 Jan 2023 08:57:46 -0500 Subject: selftests: seccomp: Fix incorrect kernel headers search path Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...). Signed-off-by: Mathieu Desnoyers Cc: Shuah Khan Cc: linux-kselftest@vger.kernel.org Cc: Ingo Molnar Cc: # 5.18+ Signed-off-by: Shuah Khan --- tools/testing/selftests/seccomp/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/seccomp/Makefile b/tools/testing/selftests/seccomp/Makefile index f017c382c036..584fba487037 100644 --- a/tools/testing/selftests/seccomp/Makefile +++ b/tools/testing/selftests/seccomp/Makefile @@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -CFLAGS += -Wl,-no-as-needed -Wall -isystem ../../../../usr/include/ +CFLAGS += -Wl,-no-as-needed -Wall $(KHDR_INCLUDES) LDFLAGS += -lpthread LDLIBS += -lcap -- cgit v1.2.3 From 5ad0c8e42c13623bd996e19ce76f2596e16eb0db Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 27 Jan 2023 08:57:47 -0500 Subject: selftests: sync: Fix incorrect kernel headers search path Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...). Signed-off-by: Mathieu Desnoyers Cc: Shuah Khan Cc: linux-kselftest@vger.kernel.org Cc: Ingo Molnar Cc: # 5.18+ Acked-by: Shuah Khan Signed-off-by: Shuah Khan --- tools/testing/selftests/sync/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/sync/Makefile b/tools/testing/selftests/sync/Makefile index d0121a8a3523..df0f91bf6890 100644 --- a/tools/testing/selftests/sync/Makefile +++ b/tools/testing/selftests/sync/Makefile @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 CFLAGS += -O2 -g -std=gnu89 -pthread -Wall -Wextra -CFLAGS += -I../../../../usr/include/ +CFLAGS += $(KHDR_INCLUDES) LDFLAGS += -pthread .PHONY: all clean -- cgit v1.2.3 From f3886fd28987c119a98493f625cb9940b5f1c9a0 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 27 Jan 2023 08:57:48 -0500 Subject: selftests: user_events: Fix incorrect kernel headers search path Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...). Signed-off-by: Mathieu Desnoyers Cc: Shuah Khan Cc: linux-kselftest@vger.kernel.org Cc: Ingo Molnar Cc: # 5.18+ Signed-off-by: Shuah Khan --- tools/testing/selftests/user_events/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/user_events/Makefile b/tools/testing/selftests/user_events/Makefile index c765d8635d9a..87d54c640068 100644 --- a/tools/testing/selftests/user_events/Makefile +++ b/tools/testing/selftests/user_events/Makefile @@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -CFLAGS += -Wl,-no-as-needed -Wall -I../../../../usr/include +CFLAGS += -Wl,-no-as-needed -Wall $(KHDR_INCLUDES) LDLIBS += -lrt -lpthread -lm TEST_GEN_PROGS = ftrace_test dyn_test perf_test -- cgit v1.2.3 From 8eb3751c73bec746f61fb6bada60d1074d92b8c3 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 27 Jan 2023 08:57:49 -0500 Subject: selftests: vm: Fix incorrect kernel headers search path Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...). Signed-off-by: Mathieu Desnoyers Cc: Shuah Khan Cc: linux-kselftest@vger.kernel.org Cc: Ingo Molnar Cc: # 5.18+ Signed-off-by: Shuah Khan --- tools/testing/selftests/vm/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile index 89c14e41bd43..ac9366065fd2 100644 --- a/tools/testing/selftests/vm/Makefile +++ b/tools/testing/selftests/vm/Makefile @@ -25,7 +25,7 @@ MACHINE ?= $(shell echo $(uname_M) | sed -e 's/aarch64.*/arm64/' -e 's/ppc64.*/p # LDLIBS. MAKEFLAGS += --no-builtin-rules -CFLAGS = -Wall -I $(top_srcdir) -I $(top_srcdir)/usr/include $(EXTRA_CFLAGS) $(KHDR_INCLUDES) +CFLAGS = -Wall -I $(top_srcdir) $(EXTRA_CFLAGS) $(KHDR_INCLUDES) LDLIBS = -lrt -lpthread TEST_GEN_FILES = cow TEST_GEN_FILES += compaction_test -- cgit v1.2.3 From ac5ec90e94fe8eddb4499e51398640fa6a89d657 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 27 Jan 2023 08:57:50 -0500 Subject: selftests: x86: Fix incorrect kernel headers search path Use $(KHDR_INCLUDES) as lookup path for kernel headers. This prevents building against kernel headers from the build environment in scenarios where kernel headers are installed into a specific output directory (O=...). Signed-off-by: Mathieu Desnoyers Cc: Shuah Khan Cc: linux-kselftest@vger.kernel.org Cc: Ingo Molnar Cc: # 5.18+ Signed-off-by: Shuah Khan --- tools/testing/selftests/x86/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/x86/Makefile b/tools/testing/selftests/x86/Makefile index 0388c4d60af0..ca9374b56ead 100644 --- a/tools/testing/selftests/x86/Makefile +++ b/tools/testing/selftests/x86/Makefile @@ -34,7 +34,7 @@ BINARIES_64 := $(TARGETS_C_64BIT_ALL:%=%_64) BINARIES_32 := $(patsubst %,$(OUTPUT)/%,$(BINARIES_32)) BINARIES_64 := $(patsubst %,$(OUTPUT)/%,$(BINARIES_64)) -CFLAGS := -O2 -g -std=gnu99 -pthread -Wall +CFLAGS := -O2 -g -std=gnu99 -pthread -Wall $(KHDR_INCLUDES) # call32_from_64 in thunks.S uses absolute addresses. ifeq ($(CAN_BUILD_WITH_NOPIE),1) -- cgit v1.2.3 From 0d7a91678aaacf8e2f532c3e04a276af06b42d1c Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 27 Jan 2023 08:57:52 -0500 Subject: selftests: iommu: Use installed kernel headers search path Use $(KHDR_INCLUDES) as lookup path for installed kernel headers rather than using kernel headers in include/uapi from the source kernel tree kernel headers. Remove bogus ../../../../include/ from the search path, because kernel source headers are not needed by those user-space selftests, and it causes issues because -I paths are searched before -isystem paths, and conflicts for files appearing both in kernel sources and in uapi headers with incompatible semantics (e.g. types.h). Signed-off-by: Mathieu Desnoyers Cc: Shuah Khan Cc: linux-kselftest@vger.kernel.org Cc: Ingo Molnar Signed-off-by: Shuah Khan --- tools/testing/selftests/iommu/Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/testing/selftests/iommu/Makefile b/tools/testing/selftests/iommu/Makefile index 7cb74d26f141..32c5fdfd0eef 100644 --- a/tools/testing/selftests/iommu/Makefile +++ b/tools/testing/selftests/iommu/Makefile @@ -1,7 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only CFLAGS += -Wall -O2 -Wno-unused-function -CFLAGS += -I../../../../include/uapi/ -CFLAGS += -I../../../../include/ +CFLAGS += $(KHDR_INCLUDES) CFLAGS += -D_GNU_SOURCE -- cgit v1.2.3 From a24ebb4937034e3b9459a5faf353c26af27f62be Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 27 Jan 2023 08:57:53 -0500 Subject: selftests: memfd: Use installed kernel headers search path Use $(KHDR_INCLUDES) as lookup path for installed kernel headers rather than using kernel headers in include/uapi from the source kernel tree kernel headers. Remove bogus ../../../../include/ from the search path, because kernel source headers are not needed by those user-space selftests, and it causes issues because -I paths are searched before -isystem paths, and conflicts for files appearing both in kernel sources and in uapi headers with incompatible semantics (e.g. types.h). Signed-off-by: Mathieu Desnoyers Cc: Shuah Khan Cc: linux-kselftest@vger.kernel.org Cc: Ingo Molnar Signed-off-by: Shuah Khan --- tools/testing/selftests/memfd/Makefile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tools/testing/selftests/memfd/Makefile b/tools/testing/selftests/memfd/Makefile index 4da8b565fa32..163b6f68631c 100644 --- a/tools/testing/selftests/memfd/Makefile +++ b/tools/testing/selftests/memfd/Makefile @@ -1,8 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 CFLAGS += -D_FILE_OFFSET_BITS=64 -CFLAGS += -I../../../../include/uapi/ -CFLAGS += -I../../../../include/ -CFLAGS += -I../../../../usr/include/ +CFLAGS += $(KHDR_INCLUDES) TEST_GEN_PROGS := memfd_test TEST_PROGS := run_fuse_test.sh run_hugetlbfs_test.sh -- cgit v1.2.3 From 4c983a14238d6d4e95c5783b9d93dd4d4aeccdd9 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 27 Jan 2023 08:57:54 -0500 Subject: selftests: ptrace: Use installed kernel headers search path Use $(KHDR_INCLUDES) as lookup path for installed kernel headers rather than using kernel headers in include/uapi from the source kernel tree kernel headers. Signed-off-by: Mathieu Desnoyers Cc: Shuah Khan Cc: linux-kselftest@vger.kernel.org Cc: Ingo Molnar Signed-off-by: Shuah Khan --- tools/testing/selftests/ptrace/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/ptrace/Makefile b/tools/testing/selftests/ptrace/Makefile index 2f1f532c39db..96ffa94afb91 100644 --- a/tools/testing/selftests/ptrace/Makefile +++ b/tools/testing/selftests/ptrace/Makefile @@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only -CFLAGS += -std=c99 -pthread -iquote../../../../include/uapi -Wall +CFLAGS += -std=c99 -pthread -Wall $(KHDR_INCLUDES) TEST_GEN_PROGS := get_syscall_info peeksiginfo vmaccess -- cgit v1.2.3 From 5adbe55c8ba5c2d03add62386e4722d273e5b893 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 27 Jan 2023 08:57:55 -0500 Subject: selftests: tdx: Use installed kernel headers search path Use $(KHDR_INCLUDES) as lookup path for installed kernel headers rather than using kernel headers in include/uapi from the source kernel tree kernel headers. Signed-off-by: Mathieu Desnoyers Cc: Shuah Khan Cc: linux-kselftest@vger.kernel.org Cc: Ingo Molnar Signed-off-by: Shuah Khan --- tools/testing/selftests/tdx/Makefile | 2 +- tools/testing/selftests/tdx/tdx_guest_test.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/tdx/Makefile b/tools/testing/selftests/tdx/Makefile index 8dd43517cd55..306e9c4d5ef7 100644 --- a/tools/testing/selftests/tdx/Makefile +++ b/tools/testing/selftests/tdx/Makefile @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 -CFLAGS += -O3 -Wl,-no-as-needed -Wall -static +CFLAGS += -O3 -Wl,-no-as-needed -Wall $(KHDR_INCLUDES) -static TEST_GEN_PROGS := tdx_guest_test diff --git a/tools/testing/selftests/tdx/tdx_guest_test.c b/tools/testing/selftests/tdx/tdx_guest_test.c index 2a2afd856798..81d8cb88ea1a 100644 --- a/tools/testing/selftests/tdx/tdx_guest_test.c +++ b/tools/testing/selftests/tdx/tdx_guest_test.c @@ -12,8 +12,8 @@ #include #include +#include #include "../kselftest_harness.h" -#include "../../../../include/uapi/linux/tdx-guest.h" #define TDX_GUEST_DEVNAME "/dev/tdx_guest" #define HEX_DUMP_SIZE 8 -- cgit v1.2.3 From 4b225d4f067f544b7594ce8a18216e19f0c1d692 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Thu, 2 Feb 2023 12:56:21 +0000 Subject: selftests: Fix spelling mistake "allright" -> "all right" There are two spelling mistakes in the test messages. Fix them. Signed-off-by: Colin Ian King Signed-off-by: Shuah Khan --- tools/testing/selftests/prctl/disable-tsc-ctxt-sw-stress-test.c | 2 +- tools/testing/selftests/prctl/disable-tsc-on-off-stress-test.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/prctl/disable-tsc-ctxt-sw-stress-test.c b/tools/testing/selftests/prctl/disable-tsc-ctxt-sw-stress-test.c index 62a93cc61b7c..6d1a5ee8eb28 100644 --- a/tools/testing/selftests/prctl/disable-tsc-ctxt-sw-stress-test.c +++ b/tools/testing/selftests/prctl/disable-tsc-ctxt-sw-stress-test.c @@ -79,7 +79,7 @@ int main(void) { int n_tasks = 100, i; - fprintf(stderr, "[No further output means we're allright]\n"); + fprintf(stderr, "[No further output means we're all right]\n"); for (i=0; i Date: Fri, 3 Feb 2023 16:26:03 +0100 Subject: selftests: find echo binary to use -ne options Find the actual echo binary using $(which echo) and use it for formatted output with -ne. On some systems, the default echo command doesn't handle the -e option and the output looks like this (arm64 build): -ne Emit Tests for alsa -ne Emit Tests for amd-pstate -ne Emit Tests for arm64 This is for example the case with the KernelCI Docker images e.g. kernelci/gcc-10:x86-kselftest-kernelci. With the actual echo binary (e.g. in /bin/echo), the output is formatted as expected (x86 build this time): Emit Tests for alsa Emit Tests for amd-pstate Skipping non-existent dir: arm64 Only the install target is using "echo -ne" so keep the $ECHO variable local to it. Reported-by: "kernelci.org bot" Fixes: 3297a4df805d ("kselftests: Enable the echo command to print newlines in Makefile") Signed-off-by: Guillaume Tucker Signed-off-by: Shuah Khan --- tools/testing/selftests/Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index 41b649452560..9619d0f3b2ff 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile @@ -234,10 +234,11 @@ ifdef INSTALL_PATH @# While building kselftest-list.text skip also non-existent TARGET dirs: @# they could be the result of a build failure and should NOT be @# included in the generated runlist. + ECHO=`which echo`; \ for TARGET in $(TARGETS); do \ BUILD_TARGET=$$BUILD/$$TARGET; \ - [ ! -d $(INSTALL_PATH)/$$TARGET ] && echo "Skipping non-existent dir: $$TARGET" && continue; \ - echo -ne "Emit Tests for $$TARGET\n"; \ + [ ! -d $(INSTALL_PATH)/$$TARGET ] && $$ECHO "Skipping non-existent dir: $$TARGET" && continue; \ + $$ECHO -ne "Emit Tests for $$TARGET\n"; \ $(MAKE) -s --no-print-directory OUTPUT=$$BUILD_TARGET COLLECTION=$$TARGET \ -C $$TARGET emit_tests >> $(TEST_LIST); \ done; -- cgit v1.2.3 From 787fccb321dd6c1c464bb11d952074edbde5de36 Mon Sep 17 00:00:00 2001 From: Tzung-Bi Shih Date: Fri, 3 Feb 2023 18:14:30 +0800 Subject: selftests: tpm2: remove redundant ord() When testing with FLAG_DEBUG enabled client, it emits the following error messages: File "/root/tpm2/tpm2.py", line 347, in hex_dump d = [format(ord(x), '02x') for x in d] File "/root/tpm2/tpm2.py", line 347, in d = [format(ord(x), '02x') for x in d] TypeError: ord() expected string of length 1, but int found The input of hex_dump() should be packed binary data. Remove the ord(). Signed-off-by: Tzung-Bi Shih Signed-off-by: Shuah Khan --- tools/testing/selftests/tpm2/tpm2.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/tpm2/tpm2.py b/tools/testing/selftests/tpm2/tpm2.py index c7363c6764fc..bba8cb54548e 100644 --- a/tools/testing/selftests/tpm2/tpm2.py +++ b/tools/testing/selftests/tpm2/tpm2.py @@ -344,7 +344,7 @@ def get_algorithm(name): def hex_dump(d): - d = [format(ord(x), '02x') for x in d] + d = [format(x, '02x') for x in d] d = [d[i: i + 16] for i in range(0, len(d), 16)] d = [' '.join(x) for x in d] d = os.linesep.join(d) -- cgit v1.2.3 From 1e6b485c922fbedf41d5a9f4e6449c5aeb923a32 Mon Sep 17 00:00:00 2001 From: "Masami Hiramatsu (Google)" Date: Sun, 22 Jan 2023 08:32:50 +0900 Subject: selftests/ftrace: Fix bash specific "==" operator Since commit a1d6cd88c897 ("selftests/ftrace: event_triggers: wait longer for test_event_enable") introduced bash specific "==" comparation operator, that test will fail when we run it on a posix-shell. `checkbashisms` warned it as below. possible bashism in ftrace/func_event_triggers.tc line 45 (should be 'b = a'): if [ "$e" == $val ]; then This replaces it with "=". Fixes: a1d6cd88c897 ("selftests/ftrace: event_triggers: wait longer for test_event_enable") Signed-off-by: Masami Hiramatsu (Google) Reviewed-by: Steven Rostedt (Google) Signed-off-by: Shuah Khan --- tools/testing/selftests/ftrace/test.d/ftrace/func_event_triggers.tc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/func_event_triggers.tc b/tools/testing/selftests/ftrace/test.d/ftrace/func_event_triggers.tc index 3eea2abf68f9..2ad7d4b501cc 100644 --- a/tools/testing/selftests/ftrace/test.d/ftrace/func_event_triggers.tc +++ b/tools/testing/selftests/ftrace/test.d/ftrace/func_event_triggers.tc @@ -42,7 +42,7 @@ test_event_enabled() { while [ $check_times -ne 0 ]; do e=`cat $EVENT_ENABLE` - if [ "$e" == $val ]; then + if [ "$e" = $val ]; then return 0 fi sleep $SLEEP_TIME -- cgit v1.2.3 From 9e34fad00fc889abbb99d751a4c22cf2bded10df Mon Sep 17 00:00:00 2001 From: Guillaume Tucker Date: Thu, 9 Feb 2023 09:55:36 +0100 Subject: selftests: use printf instead of echo -ne Rather than trying to guess which implementation of "echo" to run with support for "-ne" options, use "printf" instead of "echo -ne". It handles escape characters as a standard feature and it is widespread among modern shells. Reported-by: "kernelci.org bot" Suggested-by: David Laight Fixes: 3297a4df805d ("kselftests: Enable the echo command to print newlines in Makefile") Fixes: 79c16b1120fe ("selftests: find echo binary to use -ne options") Signed-off-by: Guillaume Tucker Reviewed-by: Guenter Roeck Signed-off-by: Shuah Khan --- tools/testing/selftests/Makefile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile index 9619d0f3b2ff..06578963f4f1 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile @@ -234,11 +234,10 @@ ifdef INSTALL_PATH @# While building kselftest-list.text skip also non-existent TARGET dirs: @# they could be the result of a build failure and should NOT be @# included in the generated runlist. - ECHO=`which echo`; \ for TARGET in $(TARGETS); do \ BUILD_TARGET=$$BUILD/$$TARGET; \ - [ ! -d $(INSTALL_PATH)/$$TARGET ] && $$ECHO "Skipping non-existent dir: $$TARGET" && continue; \ - $$ECHO -ne "Emit Tests for $$TARGET\n"; \ + [ ! -d $(INSTALL_PATH)/$$TARGET ] && printf "Skipping non-existent dir: $$TARGET\n" && continue; \ + printf "Emit Tests for $$TARGET\n"; \ $(MAKE) -s --no-print-directory OUTPUT=$$BUILD_TARGET COLLECTION=$$TARGET \ -C $$TARGET emit_tests >> $(TEST_LIST); \ done; -- cgit v1.2.3 From 6e81461b06b6a4a24bf97fca37d9b89f72ce8126 Mon Sep 17 00:00:00 2001 From: Shuah Khan Date: Fri, 10 Feb 2023 17:20:57 -0700 Subject: selftests/ptp: Remove clean target from Makefile Fix the following build warn removing unnecessary clean target from the Makefile. lib.mk handles clean. Makefile:10: warning: overriding recipe for target clean ../lib.mk:124: warning: ignoring old recipe for target clean In addition, fix to use TEST_GEN_PROGS for generated test executables and TES_PROGS for the shell script. Ger rid of all target as lib.mk handles it. Signed-off-by: Shuah Khan --- tools/testing/selftests/ptp/Makefile | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/ptp/Makefile b/tools/testing/selftests/ptp/Makefile index eeab44cc6863..8f57f88ecadd 100644 --- a/tools/testing/selftests/ptp/Makefile +++ b/tools/testing/selftests/ptp/Makefile @@ -1,10 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 CFLAGS += $(KHDR_INCLUDES) -TEST_PROGS := testptp +TEST_GEN_PROGS := testptp LDLIBS += -lrt -all: $(TEST_PROGS) +TEST_PROGS = phc.sh include ../lib.mk - -clean: - rm -fr $(TEST_PROGS) -- cgit v1.2.3 From a7151a8eaa292933cc934deb1dda0f5f51114c82 Mon Sep 17 00:00:00 2001 From: Shuah Khan Date: Mon, 13 Feb 2023 10:21:43 -0700 Subject: selftests/sched: fix warn_unused_result build warns MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix the following warns by adding return check and error handling. gcc -O2 -Wall -g -I./ -isystem .../tools/testing/selftests/../../../usr/include -Wl,-rpath=./ cs_prctl_test.c -lpthread -o .../tools/testing/selftests/sched/cs_prctl_test cs_prctl_test.c: In function ‘create_processes’: cs_prctl_test.c:187:17: warning: ignoring return value of ‘read’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 187 | read(proc[i].pfd[0], &proc[i].thr_tids, sizeof(int) * proc[i].num_threads); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cs_prctl_test.c: In function ‘child_func_process’: cs_prctl_test.c:159:9: warning: ignoring return value of ‘write’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 159 | write(ca->pfd[1], &ca->thr_tids, sizeof(int) * ca->num_threads); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Shuah Khan --- tools/testing/selftests/sched/cs_prctl_test.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/sched/cs_prctl_test.c b/tools/testing/selftests/sched/cs_prctl_test.c index 8109b17dc764..25e0d95d3713 100644 --- a/tools/testing/selftests/sched/cs_prctl_test.c +++ b/tools/testing/selftests/sched/cs_prctl_test.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -151,12 +152,17 @@ static void create_threads(int num_threads, int thr_tids[]) static int child_func_process(void *arg) { struct child_args *ca = (struct child_args *)arg; + int ret; close(ca->pfd[0]); create_threads(ca->num_threads, ca->thr_tids); - write(ca->pfd[1], &ca->thr_tids, sizeof(int) * ca->num_threads); + ret = write(ca->pfd[1], &ca->thr_tids, sizeof(int) * ca->num_threads); + if (ret == -1) + printf("write failed on pfd[%d] - error (%s)\n", + ca->pfd[1], strerror(errno)); + close(ca->pfd[1]); while (1) @@ -169,7 +175,7 @@ static unsigned char child_func_process_stack[STACK_SIZE]; void create_processes(int num_processes, int num_threads, struct child_args proc[]) { pid_t cpid; - int i; + int i, ret; for (i = 0; i < num_processes; ++i) { proc[i].num_threads = num_threads; @@ -184,7 +190,10 @@ void create_processes(int num_processes, int num_threads, struct child_args proc } for (i = 0; i < num_processes; ++i) { - read(proc[i].pfd[0], &proc[i].thr_tids, sizeof(int) * proc[i].num_threads); + ret = read(proc[i].pfd[0], &proc[i].thr_tids, sizeof(int) * proc[i].num_threads); + if (ret == -1) + printf("read failed on proc[%d].pfd[0] error (%s)\n", + i, strerror(errno)); close(proc[i].pfd[0]); } } -- cgit v1.2.3 From d8e45bf1aed2e5fddd8985b5bb1aaf774a97aba8 Mon Sep 17 00:00:00 2001 From: Shuah Khan Date: Mon, 13 Feb 2023 11:20:07 -0700 Subject: selftests/mount_setattr: fix redefine struct mount_attr build error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix the following build error due to redefining struct mount_attr by removing duplicate define from mount_setattr_test.c gcc -g -isystem .../tools/testing/selftests/../../../usr/include -Wall -O2 -pthread mount_setattr_test.c -o .../tools/testing/selftests/mount_setattr/mount_setattr_test mount_setattr_test.c:107:8: error: redefinition of ‘struct mount_attr’ 107 | struct mount_attr { | ^~~~~~~~~~ In file included from /usr/include/x86_64-linux-gnu/sys/mount.h:32, from mount_setattr_test.c:10: .../usr/include/linux/mount.h:129:8: note: originally defined here 129 | struct mount_attr { | ^~~~~~~~~~ make: *** [../lib.mk:145: .../tools/testing/selftests/mount_setattr/mount_setattr_test] Error 1 Signed-off-by: Shuah Khan --- tools/testing/selftests/mount_setattr/mount_setattr_test.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/tools/testing/selftests/mount_setattr/mount_setattr_test.c b/tools/testing/selftests/mount_setattr/mount_setattr_test.c index 8c5fea68ae67..582669ca38e9 100644 --- a/tools/testing/selftests/mount_setattr/mount_setattr_test.c +++ b/tools/testing/selftests/mount_setattr/mount_setattr_test.c @@ -103,13 +103,6 @@ #else #define __NR_mount_setattr 442 #endif - -struct mount_attr { - __u64 attr_set; - __u64 attr_clr; - __u64 propagation; - __u64 userns_fd; -}; #endif #ifndef __NR_open_tree -- cgit v1.2.3 From aca5a0944c309c56267b0c1d001aa999ddb2fb1e Mon Sep 17 00:00:00 2001 From: Shuah Khan Date: Mon, 13 Feb 2023 14:52:47 -0700 Subject: selftests/mount_setattr: fix to make run_tests failure make run_tests doesn't run the test. Fix Makefile to set TEST_GEN_PROGS instead of TEST_GEN_FILES to fix the problem. run_tests runs TEST_GEN_PROGS, TEST_CUSTOM_PROGS, and TEST_PROGS. TEST_GEN_FILES is for files generated by tests. Signed-off-by: Shuah Khan --- tools/testing/selftests/mount_setattr/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/mount_setattr/Makefile b/tools/testing/selftests/mount_setattr/Makefile index fde72df01b11..0c0d7b1234c1 100644 --- a/tools/testing/selftests/mount_setattr/Makefile +++ b/tools/testing/selftests/mount_setattr/Makefile @@ -2,6 +2,6 @@ # Makefile for mount selftests. CFLAGS = -g $(KHDR_INCLUDES) -Wall -O2 -pthread -TEST_GEN_FILES += mount_setattr_test +TEST_GEN_PROGS := mount_setattr_test include ../lib.mk -- cgit v1.2.3 From 0eb15a47bf437a268b69ab1a1a45fdf1f609b69f Mon Sep 17 00:00:00 2001 From: Shuah Khan Date: Tue, 14 Feb 2023 12:19:39 -0700 Subject: selftests/user_events: add a note about user_events.h dependency This test depends on exported in uapi The following commit removed user_events.h out of uapi: commit 5cfff569cab8 ("tracing: Move user_events.h temporarily out of include/uapi") This test will not compile until user_events.h is added back to uapi. Signed-off-by: Shuah Khan --- tools/testing/selftests/user_events/Makefile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/testing/selftests/user_events/Makefile b/tools/testing/selftests/user_events/Makefile index 87d54c640068..6b512b86aec3 100644 --- a/tools/testing/selftests/user_events/Makefile +++ b/tools/testing/selftests/user_events/Makefile @@ -2,6 +2,14 @@ CFLAGS += -Wl,-no-as-needed -Wall $(KHDR_INCLUDES) LDLIBS += -lrt -lpthread -lm +# Note: +# This test depends on exported in uapi +# The following commit removed user_events.h out of uapi: +# commit 5cfff569cab8bf544bab62c911c5d6efd5af5e05 +# tracing: Move user_events.h temporarily out of include/uapi +# This test will not compile until user_events.h is added +# back to uapi. + TEST_GEN_PROGS = ftrace_test dyn_test perf_test TEST_FILES := settings -- cgit v1.2.3