Commit d6296cb6 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'linux-kselftest-next-6.3-rc1' of...

Merge tag 'linux-kselftest-next-6.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest

Pull Kselftest update from Shuah Khan:

 - several patches to fix incorrect kernel headers search path from
   Mathieu Desnoyers

 - a few follow-on fixes found during testing the above change

 - miscellaneous fixes

 - support for filtering and enumerating tests

* tag 'linux-kselftest-next-6.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: (40 commits)
  selftests/user_events: add a note about user_events.h dependency
  selftests/mount_setattr: fix to make run_tests failure
  selftests/mount_setattr: fix redefine struct mount_attr build error
  selftests/sched: fix warn_unused_result build warns
  selftests/ptp: Remove clean target from Makefile
  selftests: use printf instead of echo -ne
  selftests/ftrace: Fix bash specific "==" operator
  selftests: tpm2: remove redundant ord()
  selftests: find echo binary to use -ne options
  selftests: Fix spelling mistake "allright" -> "all right"
  selftests: tdx: Use installed kernel headers search path
  selftests: ptrace: Use installed kernel headers search path
  selftests: memfd: Use installed kernel headers search path
  selftests: iommu: Use installed kernel headers search path
  selftests: x86: Fix incorrect kernel headers search path
  selftests: vm: Fix incorrect kernel headers search path
  selftests: user_events: Fix incorrect kernel headers search path
  selftests: sync: Fix incorrect kernel headers search path
  selftests: seccomp: Fix incorrect kernel headers search path
  selftests: sched: Fix incorrect kernel headers search path
  ...
parents f01d4c8a 0eb15a47
......@@ -237,8 +237,8 @@ ifdef INSTALL_PATH
@# included in the generated runlist.
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;
......
......@@ -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 \
......
# SPDX-License-Identifier: GPL-2.0
CFLAGS += -I../../../../../usr/include/
CFLAGS += $(KHDR_INCLUDES)
TEST_GEN_PROGS := tags_test
TEST_PROGS := run_tags_test.sh
......
# 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 \
......
# SPDX-License-Identifier: GPL-2.0-only
CFLAGS += -g -I../../../../usr/include/
CFLAGS += -g $(KHDR_INCLUDES)
TEST_GEN_PROGS := close_range_test
......
# 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
......
......@@ -13,10 +13,9 @@
#include <sys/types.h>
#include <linux/dma-buf.h>
#include <linux/dma-heap.h>
#include <drm/drm.h>
#include "../../../../include/uapi/linux/dma-heap.h"
#define DEVPATH "/dev/dma_heap"
static int check_vgem(int fd)
......
# SPDX-License-Identifier: GPL-2.0-only
CFLAGS += -I../../../../../usr/include/
CFLAGS += $(KHDR_INCLUDES)
TEST_GEN_PROGS := udmabuf
......
......@@ -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
......
# SPDX-License-Identifier: GPL-2.0
CFLAGS += -I../../../../usr/include/
CFLAGS += $(KHDR_INCLUDES)
TEST_GEN_PROGS := devpts_pts
TEST_GEN_PROGS_EXTENDED := dnotify_test
......
# 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
......
# SPDX-License-Identifier: GPL-2.0
CFLAGS += -I../../../../../usr/include/
CFLAGS += $(KHDR_INCLUDES)
LDLIBS += -lpthread
TEST_GEN_PROGS := epoll_wakeup_test
......
......@@ -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
......
# 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
......
......@@ -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
# 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
......
......@@ -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
......
# SPDX-License-Identifier: GPL-2.0-only
CFLAGS += -I../../../../usr/include/
CFLAGS += $(KHDR_INCLUDES)
TEST_GEN_PROGS := kcmp_test
......
......@@ -54,6 +54,7 @@
#define _GNU_SOURCE
#endif
#include <asm/types.h>
#include <ctype.h>
#include <errno.h>
#include <stdbool.h>
#include <stdint.h>
......@@ -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)
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);
......
# 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
# 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 \
......
# 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
......
# 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
TEST_GEN_PROGS := mount_setattr_test
include ../lib.mk
......@@ -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
......
# 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
......
# 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
......
# SPDX-License-Identifier: GPL-2.0
CFLAGS += -g -I../../../../usr/include/
CFLAGS += -g $(KHDR_INCLUDES)
TEST_GEN_PROGS = regression_enomem
......
# 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
......
......@@ -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<n_tasks; i++)
if (fork() == 0)
......
......@@ -83,7 +83,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<n_tasks; i++)
if (fork() == 0)
......
# SPDX-License-Identifier: GPL-2.0
CFLAGS += -I../../../../usr/include/
TEST_PROGS := testptp
CFLAGS += $(KHDR_INCLUDES)
TEST_GEN_PROGS := testptp
LDLIBS += -lrt
all: $(TEST_PROGS)
TEST_PROGS = phc.sh
include ../lib.mk
clean:
rm -fr $(TEST_PROGS)
# 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
......
......@@ -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
......
......@@ -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
......
......@@ -27,6 +27,7 @@
#include <sys/prctl.h>
#include <unistd.h>
#include <time.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......@@ -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]);
}
}
......
# 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
......
# 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
......
# 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
......
......@@ -12,8 +12,8 @@
#include <errno.h>
#include <fcntl.h>
#include <linux/tdx-guest.h>
#include "../kselftest_harness.h"
#include "../../../../include/uapi/linux/tdx-guest.h"
#define TDX_GUEST_DEVNAME "/dev/tdx_guest"
#define HEX_DUMP_SIZE 8
......
......@@ -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)
......
# 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
# Note:
# This test depends on <linux/user_events.h> 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
......
......@@ -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
......
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment