Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752203AbdI0PKc (ORCPT ); Wed, 27 Sep 2017 11:10:32 -0400 Received: from ec2-52-27-115-49.us-west-2.compute.amazonaws.com ([52.27.115.49]:60139 "EHLO osg.samsung.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751907AbdI0PK3 (ORCPT ); Wed, 27 Sep 2017 11:10:29 -0400 To: torvalds@linux-foundation.org Cc: Shuah Khan , linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Shuah Khan From: Shuah Khan Subject: [GIT PULL] Kselftest update for 4.14-rc3 fixes Message-ID: Date: Wed, 27 Sep 2017 09:10:03 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------11B375788EEF2F3BDDE70657" Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 28323 Lines: 883 This is a multi-part message in MIME format. --------------11B375788EEF2F3BDDE70657 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Hi Linus, Please pull the following kselftest update for 4.14-rc3 fixes This update consists of: - fixes to several existing tests - a test for regression introduced by b9470c27607b ("inet: kill smallest_size and smallest_port") - seccomp support for glibc 2.26 siginfo_t.h - fixes to kselftest framework and tests to run make O=dir use-case - fixes to silence unnecessary test output to de-clutter test results Diff for the update attached. This is a larger set of fixes than I anticipated. Several fixes and the test for regression came in/ready very close to the end of 4.13 release and soon after during the merge window. thanks, -- Shuah ----------------------------------------------------------------------------------- The following changes since commit 2bd6bf03f4c1c59381d62c61d03f6cc3fe71f66e: Linux 4.14-rc1 (2017-09-16 15:47:51 -0700) are available in the git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest tags/linux-kselftest-4.14-rc3-fixes for you to fetch changes up to eefd95e1f3d47b90dc768e9ebc77d390c4f34809: selftests: timers: set-timer-lat: Fix hang when testing unsupported alarms (2017-09-25 10:09:07 -0600) ---------------------------------------------------------------- linux-kselftest-4.14-rc3-fixes This update consists of: - fixes to several existing tests - a test for regression introduced by b9470c27607b ("inet: kill smallest_size and smallest_port") - seccomp support for glibc 2.26 siginfo_t.h - fixes to kselftest framework and tests to run make O=dir use-case - fixes to silence unnecessary test output to de-clutter test results ---------------------------------------------------------------- Daniel Díaz (2): selftests: net: More graceful finding of `ip'. selftests: intel_pstate: build only on x86 Fathi Boudra (1): selftests: breakpoints: re-order TEST_GEN_PROGS targets Josef Bacik (3): selftests: silence test output by default selftest: add a reuseaddr test selftests: actually run the various net selftests Kees Cook (1): selftests/seccomp: Support glibc 2.26 siginfo_t.h Li Zhijian (1): selftests/memfd: correct run_tests.sh permission Shuah Khan (15): Makefile: kselftest and kselftest-clean fail for make O=dir case selftests: lib.mk: kselftest and kselftest-clean fail for make O=dir case selftests: Makefile: clear LDFLAGS for make O=dir use-case selftests: lib.mk: fix test executable status check to use full path selftests: watchdog: fix to use TEST_GEN_PROGS and remove clean selftests: lib.mk: add TEST_CUSTOM_PROGS to allow custom test run/install selftests: sync: use TEST_CUSTOM_PROGS instead of TEST_PROGS selftests: sync: kselftest and kselftest-clean fail for make O=dir case selftests: lib.mk: copy test scripts and test files for make O=dir run selftests: futex: copy sub-dir test scripts for make O=dir run selftests: mqueue: Use full path to run tests from Makefile selftests: Makefile: fix for loops in targets to run silently selftests: futex: Makefile: fix for loops in targets to run silently selftests: timers: set-timer-lat: fix hang when std out/err are redirected selftests: timers: set-timer-lat: Fix hang when testing unsupported alarms Thomas Meyer (4): selftests/intel_pstate: No need to compile test progs in the run script selftests/bpf: Make bpf_util work on uniprocessor systems selftests/ftrace: multiple_kprobes: Also check for support selftests/net: msg_zerocopy enable build with older kernel headers Thomas Richter (1): tools: fix testing/selftests/sigaltstack for s390x Makefile | 4 +- tools/testing/selftests/Makefile | 18 ++-- tools/testing/selftests/bpf/bpf_util.h | 17 +-- tools/testing/selftests/breakpoints/Makefile | 8 +- .../ftrace/test.d/kprobe/multiple_kprobes.tc | 2 + tools/testing/selftests/futex/Makefile | 9 +- tools/testing/selftests/intel_pstate/Makefile | 2 + tools/testing/selftests/intel_pstate/run.sh | 11 +- tools/testing/selftests/lib.mk | 48 +++++++-- tools/testing/selftests/memfd/run_tests.sh | 0 tools/testing/selftests/mqueue/Makefile | 4 +- tools/testing/selftests/net/.gitignore | 1 + tools/testing/selftests/net/Makefile | 6 +- tools/testing/selftests/net/msg_zerocopy.c | 2 +- tools/testing/selftests/net/netdevice.sh | 2 +- tools/testing/selftests/net/reuseaddr_conflict.c | 114 +++++++++++++++++++++ tools/testing/selftests/seccomp/seccomp_bpf.c | 18 +++- tools/testing/selftests/sigaltstack/sas.c | 4 + tools/testing/selftests/sync/Makefile | 24 ++++- tools/testing/selftests/timers/set-timer-lat.c | 13 +-- tools/testing/selftests/watchdog/Makefile | 7 +- 21 files changed, 247 insertions(+), 67 deletions(-) mode change 100644 => 100755 tools/testing/selftests/memfd/run_tests.sh create mode 100644 tools/testing/selftests/net/reuseaddr_conflict.c ----------------------------------------------------------------------------------- -- Shuah Khan Sr. Linux Kernel Developer Open Source Innovation Group Samsung Research America (Silicon Valley) shuahkh@osg.samsung.com --------------11B375788EEF2F3BDDE70657 Content-Type: text/x-patch; name="linux-kselftest-4.14-rc3-fixes.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="linux-kselftest-4.14-rc3-fixes.diff" diff --git a/Makefile b/Makefile index 64cbc66cebca..9a70578922d3 100644 --- a/Makefile +++ b/Makefile @@ -1172,11 +1172,11 @@ headers_check: headers_install =20 PHONY +=3D kselftest kselftest: - $(Q)$(MAKE) -C tools/testing/selftests run_tests + $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests run_tests =20 PHONY +=3D kselftest-clean kselftest-clean: - $(Q)$(MAKE) -C tools/testing/selftests clean + $(Q)$(MAKE) -C $(srctree)/tools/testing/selftests clean =20 PHONY +=3D kselftest-merge kselftest-merge: diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/M= akefile index 26ce4f7168be..ff805643b5f7 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile @@ -52,6 +52,10 @@ override LDFLAGS =3D override MAKEFLAGS =3D endif =20 +ifneq ($(KBUILD_SRC),) +override LDFLAGS =3D +endif + BUILD :=3D $(O) ifndef BUILD BUILD :=3D $(KBUILD_OUTPUT) @@ -62,32 +66,32 @@ endif =20 export BUILD all: - for TARGET in $(TARGETS); do \ + @for TARGET in $(TARGETS); do \ BUILD_TARGET=3D$$BUILD/$$TARGET; \ mkdir $$BUILD_TARGET -p; \ make OUTPUT=3D$$BUILD_TARGET -C $$TARGET;\ done; =20 run_tests: all - for TARGET in $(TARGETS); do \ + @for TARGET in $(TARGETS); do \ BUILD_TARGET=3D$$BUILD/$$TARGET; \ make OUTPUT=3D$$BUILD_TARGET -C $$TARGET run_tests;\ done; =20 hotplug: - for TARGET in $(TARGETS_HOTPLUG); do \ + @for TARGET in $(TARGETS_HOTPLUG); do \ BUILD_TARGET=3D$$BUILD/$$TARGET; \ make OUTPUT=3D$$BUILD_TARGET -C $$TARGET;\ done; =20 run_hotplug: hotplug - for TARGET in $(TARGETS_HOTPLUG); do \ + @for TARGET in $(TARGETS_HOTPLUG); do \ BUILD_TARGET=3D$$BUILD/$$TARGET; \ make OUTPUT=3D$$BUILD_TARGET -C $$TARGET run_full_test;\ done; =20 clean_hotplug: - for TARGET in $(TARGETS_HOTPLUG); do \ + @for TARGET in $(TARGETS_HOTPLUG); do \ BUILD_TARGET=3D$$BUILD/$$TARGET; \ make OUTPUT=3D$$BUILD_TARGET -C $$TARGET clean;\ done; @@ -103,7 +107,7 @@ install: ifdef INSTALL_PATH @# Ask all targets to install their files mkdir -p $(INSTALL_PATH) - for TARGET in $(TARGETS); do \ + @for TARGET in $(TARGETS); do \ BUILD_TARGET=3D$$BUILD/$$TARGET; \ make OUTPUT=3D$$BUILD_TARGET -C $$TARGET INSTALL_PATH=3D$(INSTALL_PATH= )/$$TARGET install; \ done; @@ -128,7 +132,7 @@ else endif =20 clean: - for TARGET in $(TARGETS); do \ + @for TARGET in $(TARGETS); do \ BUILD_TARGET=3D$$BUILD/$$TARGET; \ make OUTPUT=3D$$BUILD_TARGET -C $$TARGET clean;\ done; diff --git a/tools/testing/selftests/bpf/bpf_util.h b/tools/testing/selft= ests/bpf/bpf_util.h index 20ecbaa0d85d..6c53a8906eff 100644 --- a/tools/testing/selftests/bpf/bpf_util.h +++ b/tools/testing/selftests/bpf/bpf_util.h @@ -12,6 +12,7 @@ static inline unsigned int bpf_num_possible_cpus(void) unsigned int start, end, possible_cpus =3D 0; char buff[128]; FILE *fp; + int n; =20 fp =3D fopen(fcpu, "r"); if (!fp) { @@ -20,17 +21,17 @@ static inline unsigned int bpf_num_possible_cpus(void= ) } =20 while (fgets(buff, sizeof(buff), fp)) { - if (sscanf(buff, "%u-%u", &start, &end) =3D=3D 2) { - possible_cpus =3D start =3D=3D 0 ? end + 1 : 0; - break; + n =3D sscanf(buff, "%u-%u", &start, &end); + if (n =3D=3D 0) { + printf("Failed to retrieve # possible CPUs!\n"); + exit(1); + } else if (n =3D=3D 1) { + end =3D start; } + possible_cpus =3D start =3D=3D 0 ? end + 1 : 0; + break; } - fclose(fp); - if (!possible_cpus) { - printf("Failed to retrieve # possible CPUs!\n"); - exit(1); - } =20 return possible_cpus; } diff --git a/tools/testing/selftests/breakpoints/Makefile b/tools/testing= /selftests/breakpoints/Makefile index 6b214b7b10fb..247b0a1899d7 100644 --- a/tools/testing/selftests/breakpoints/Makefile +++ b/tools/testing/selftests/breakpoints/Makefile @@ -2,14 +2,14 @@ uname_M :=3D $(shell uname -m 2>/dev/null || echo not) ARCH ?=3D $(shell echo $(uname_M) | sed -e s/i.86/x86/ -e s/x86_64/x86/)= =20 +TEST_GEN_PROGS :=3D step_after_suspend_test + ifeq ($(ARCH),x86) -TEST_GEN_PROGS :=3D breakpoint_test +TEST_GEN_PROGS +=3D breakpoint_test endif ifneq (,$(filter $(ARCH),aarch64 arm64)) -TEST_GEN_PROGS :=3D breakpoint_test_arm64 +TEST_GEN_PROGS +=3D breakpoint_test_arm64 endif =20 -TEST_GEN_PROGS +=3D step_after_suspend_test - include ../lib.mk =20 diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/multiple_kprobe= s.tc b/tools/testing/selftests/ftrace/test.d/kprobe/multiple_kprobes.tc index 2a1cb9908746..a4fd4c851a5b 100644 --- a/tools/testing/selftests/ftrace/test.d/kprobe/multiple_kprobes.tc +++ b/tools/testing/selftests/ftrace/test.d/kprobe/multiple_kprobes.tc @@ -1,6 +1,8 @@ #!/bin/sh # description: Register/unregister many kprobe events =20 +[ -f kprobe_events ] || exit_unsupported # this is configurable + # ftrace fentry skip size depends on the machine architecture. # Currently HAVE_KPROBES_ON_FTRACE defined on x86 and powerpc64le case `uname -m` in diff --git a/tools/testing/selftests/futex/Makefile b/tools/testing/selft= ests/futex/Makefile index 7c647f619d63..f0c0369ccb79 100644 --- a/tools/testing/selftests/futex/Makefile +++ b/tools/testing/selftests/futex/Makefile @@ -7,14 +7,17 @@ TEST_PROGS :=3D run.sh include ../lib.mk =20 all: - for DIR in $(SUBDIRS); do \ + @for DIR in $(SUBDIRS); do \ BUILD_TARGET=3D$(OUTPUT)/$$DIR; \ mkdir $$BUILD_TARGET -p; \ make OUTPUT=3D$$BUILD_TARGET -C $$DIR $@;\ + if [ -e $$DIR/$(TEST_PROGS) ]; then + rsync -a $$DIR/$(TEST_PROGS) $$BUILD_TARGET/; + fi done =20 override define RUN_TESTS - $(OUTPUT)/run.sh + @cd $(OUTPUT); ./run.sh endef =20 override define INSTALL_RULE @@ -33,7 +36,7 @@ override define EMIT_TESTS endef =20 override define CLEAN - for DIR in $(SUBDIRS); do \ + @for DIR in $(SUBDIRS); do \ BUILD_TARGET=3D$(OUTPUT)/$$DIR; \ mkdir $$BUILD_TARGET -p; \ make OUTPUT=3D$$BUILD_TARGET -C $$DIR $@;\ diff --git a/tools/testing/selftests/intel_pstate/Makefile b/tools/testin= g/selftests/intel_pstate/Makefile index 849a90ffe8dd..a97e24edde39 100644 --- a/tools/testing/selftests/intel_pstate/Makefile +++ b/tools/testing/selftests/intel_pstate/Makefile @@ -1,7 +1,9 @@ CFLAGS :=3D $(CFLAGS) -Wall -D_GNU_SOURCE LDLIBS :=3D $(LDLIBS) -lm =20 +ifeq (,$(filter $(ARCH),x86)) TEST_GEN_FILES :=3D msr aperf +endif =20 TEST_PROGS :=3D run.sh =20 diff --git a/tools/testing/selftests/intel_pstate/run.sh b/tools/testing/= selftests/intel_pstate/run.sh index 7868c106b8b1..d3ab48f91cd6 100755 --- a/tools/testing/selftests/intel_pstate/run.sh +++ b/tools/testing/selftests/intel_pstate/run.sh @@ -29,13 +29,12 @@ =20 EVALUATE_ONLY=3D0 =20 -max_cpus=3D$(($(nproc)-1)) +if ! uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ | grep -q x86; then + echo "$0 # Skipped: Test can only run on x86 architectures." + exit 0 +fi =20 -# compile programs -gcc aperf.c -Wall -D_GNU_SOURCE -o aperf -lm -[ $? -ne 0 ] && echo "Problem compiling aperf.c." && exit 1 -gcc -o msr msr.c -lm -[ $? -ne 0 ] && echo "Problem compiling msr.c." && exit 1 +max_cpus=3D$(($(nproc)-1)) =20 function run_test () { =20 diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib= =2Emk index 693616651da5..f65886af7c0c 100644 --- a/tools/testing/selftests/lib.mk +++ b/tools/testing/selftests/lib.mk @@ -6,7 +6,14 @@ ifeq (0,$(MAKELEVEL)) OUTPUT :=3D $(shell pwd) endif =20 +# The following are built by lib.mk common compile rules. +# TEST_CUSTOM_PROGS should be used by tests that require +# custom build rule and prevent common build rule use. +# TEST_PROGS are for test shell scripts. +# TEST_CUSTOM_PROGS and TEST_PROGS will be run by common run_tests +# and install targets. Common clean doesn't touch them. TEST_GEN_PROGS :=3D $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS)) +TEST_GEN_PROGS_EXTENDED :=3D $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS_E= XTENDED)) TEST_GEN_FILES :=3D $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_FILES)) =20 all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) @@ -20,17 +27,28 @@ define RUN_TESTS test_num=3D`echo $$test_num+1 | bc`; \ echo "selftests: $$BASENAME_TEST"; \ echo "=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D"; \ - if [ ! -x $$BASENAME_TEST ]; then \ + if [ ! -x $$TEST ]; then \ echo "selftests: Warning: file $$BASENAME_TEST is not executable, cor= rect this.";\ echo "not ok 1..$$test_num selftests: $$BASENAME_TEST [FAIL]"; \ else \ - cd `dirname $$TEST` > /dev/null; (./$$BASENAME_TEST && echo "ok 1..$$= test_num selftests: $$BASENAME_TEST [PASS]") || echo "not ok 1..$$test_nu= m selftests: $$BASENAME_TEST [FAIL]"; cd - > /dev/null;\ + cd `dirname $$TEST` > /dev/null; (./$$BASENAME_TEST > /tmp/$$BASENAME= _TEST 2>&1 && echo "ok 1..$$test_num selftests: $$BASENAME_TEST [PASS]") = || echo "not ok 1..$$test_num selftests: $$BASENAME_TEST [FAIL]"; cd - >= /dev/null;\ fi; \ done; endef =20 run_tests: all - $(call RUN_TESTS, $(TEST_GEN_PROGS) $(TEST_PROGS)) +ifneq ($(KBUILD_SRC),) + @if [ "X$(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES)" !=3D "X" ];= then + @rsync -aq $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(OUTPUT= ) + fi + @if [ "X$(TEST_PROGS)" !=3D "X" ]; then + $(call RUN_TESTS, $(TEST_GEN_PROGS) $(TEST_CUSTOM_PROGS) $(OUTPUT)/$(T= EST_PROGS)) + else + $(call RUN_TESTS, $(TEST_GEN_PROGS) $(TEST_CUSTOM_PROGS)) + fi +else + $(call RUN_TESTS, $(TEST_GEN_PROGS) $(TEST_CUSTOM_PROGS) $(TEST_PROGS))= +endif =20 define INSTALL_RULE @if [ "X$(TEST_PROGS)$(TEST_PROGS_EXTENDED)$(TEST_FILES)" !=3D "X" ]; t= hen \ @@ -38,10 +56,10 @@ define INSTALL_RULE echo "rsync -a $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(IN= STALL_PATH)/"; \ rsync -a $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_= PATH)/; \ fi - @if [ "X$(TEST_GEN_PROGS)$(TEST_GEN_PROGS_EXTENDED)$(TEST_GEN_FILES)" != =3D "X" ]; then \ + @if [ "X$(TEST_GEN_PROGS)$(TEST_CUSTOM_PROGS)$(TEST_GEN_PROGS_EXTENDED)= $(TEST_GEN_FILES)" !=3D "X" ]; then \ mkdir -p ${INSTALL_PATH}; \ - echo "rsync -a $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN= _FILES) $(INSTALL_PATH)/"; \ - rsync -a $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES= ) $(INSTALL_PATH)/; \ + echo "rsync -a $(TEST_GEN_PROGS) $(TEST_CUSTOM_PROGS) $(TEST_GEN_PROGS= _EXTENDED) $(TEST_GEN_FILES) $(INSTALL_PATH)/"; \ + rsync -a $(TEST_GEN_PROGS) $(TEST_CUSTOM_PROGS) $(TEST_GEN_PROGS_EXTEN= DED) $(TEST_GEN_FILES) $(INSTALL_PATH)/; \ fi endef =20 @@ -53,15 +71,20 @@ else endif =20 define EMIT_TESTS - @for TEST in $(TEST_GEN_PROGS) $(TEST_PROGS); do \ + @for TEST in $(TEST_GEN_PROGS) $(TEST_CUSTOM_PROGS) $(TEST_PROGS); do \= BASENAME_TEST=3D`basename $$TEST`; \ - echo "(./$$BASENAME_TEST && echo \"selftests: $$BASENAME_TEST [PASS]\"= ) || echo \"selftests: $$BASENAME_TEST [FAIL]\""; \ + echo "(./$$BASENAME_TEST > /tmp/$$BASENAME_TEST 2>&1 && echo \"selftes= ts: $$BASENAME_TEST [PASS]\") || echo \"selftests: $$BASENAME_TEST [FAIL]= \""; \ done; endef =20 emit_tests: $(EMIT_TESTS) =20 +# define if isn't already. It is undefined in make O=3D case. +ifeq ($(RM),) +RM :=3D rm -f +endif + define CLEAN $(RM) -r $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)= $(EXTRA_CLEAN) endef @@ -69,6 +92,15 @@ endef clean: $(CLEAN) =20 +# When make O=3D with kselftest target from main level +# the following aren't defined. +# +ifneq ($(KBUILD_SRC),) +LINK.c =3D $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH) +COMPILE.S =3D $(CC) $(ASFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c +LINK.S =3D $(CC) $(ASFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH) +endif + $(OUTPUT)/%:%.c $(LINK.c) $^ $(LDLIBS) -o $@ =20 diff --git a/tools/testing/selftests/memfd/run_tests.sh b/tools/testing/s= elftests/memfd/run_tests.sh old mode 100644 new mode 100755 diff --git a/tools/testing/selftests/mqueue/Makefile b/tools/testing/self= tests/mqueue/Makefile index 79a664aeb8d7..0f5e347b068d 100644 --- a/tools/testing/selftests/mqueue/Makefile +++ b/tools/testing/selftests/mqueue/Makefile @@ -5,8 +5,8 @@ TEST_GEN_PROGS :=3D mq_open_tests mq_perf_tests include ../lib.mk =20 override define RUN_TESTS - @./mq_open_tests /test1 || echo "selftests: mq_open_tests [FAIL]" - @./mq_perf_tests || echo "selftests: mq_perf_tests [FAIL]" + $(OUTPUT)/mq_open_tests /test1 || echo "selftests: mq_open_tests [FAIL]= " + $(OUTPUT)//mq_perf_tests || echo "selftests: mq_perf_tests [FAIL]" endef =20 override define EMIT_TESTS diff --git a/tools/testing/selftests/net/.gitignore b/tools/testing/selft= ests/net/.gitignore index 9801253e4802..c612d6e38c62 100644 --- a/tools/testing/selftests/net/.gitignore +++ b/tools/testing/selftests/net/.gitignore @@ -6,3 +6,4 @@ reuseport_bpf reuseport_bpf_cpu reuseport_bpf_numa reuseport_dualstack +reuseaddr_conflict diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftes= ts/net/Makefile index de1f5772b878..d86bca991f45 100644 --- a/tools/testing/selftests/net/Makefile +++ b/tools/testing/selftests/net/Makefile @@ -5,9 +5,9 @@ CFLAGS +=3D -I../../../../usr/include/ =20 TEST_PROGS :=3D run_netsocktests run_afpackettests test_bpf.sh netdevice= =2Esh rtnetlink.sh TEST_GEN_FILES =3D socket -TEST_GEN_FILES +=3D psock_fanout psock_tpacket -TEST_GEN_FILES +=3D reuseport_bpf reuseport_bpf_cpu reuseport_bpf_numa -TEST_GEN_FILES +=3D reuseport_dualstack msg_zerocopy +TEST_GEN_FILES +=3D psock_fanout psock_tpacket msg_zerocopy +TEST_GEN_PROGS =3D reuseport_bpf reuseport_bpf_cpu reuseport_bpf_numa +TEST_GEN_PROGS +=3D reuseport_dualstack reuseaddr_conflict =20 include ../lib.mk =20 diff --git a/tools/testing/selftests/net/msg_zerocopy.c b/tools/testing/s= elftests/net/msg_zerocopy.c index 40232af5b023..3ab6ec403905 100644 --- a/tools/testing/selftests/net/msg_zerocopy.c +++ b/tools/testing/selftests/net/msg_zerocopy.c @@ -55,7 +55,7 @@ #include =20 #ifndef SO_EE_ORIGIN_ZEROCOPY -#define SO_EE_ORIGIN_ZEROCOPY SO_EE_ORIGIN_UPAGE +#define SO_EE_ORIGIN_ZEROCOPY 5 #endif =20 #ifndef SO_ZEROCOPY diff --git a/tools/testing/selftests/net/netdevice.sh b/tools/testing/sel= ftests/net/netdevice.sh index 4e00568d70c2..90cb903c3381 100755 --- a/tools/testing/selftests/net/netdevice.sh +++ b/tools/testing/selftests/net/netdevice.sh @@ -178,7 +178,7 @@ if [ "$(id -u)" -ne 0 ];then exit 0 fi =20 -ip -Version 2>/dev/null >/dev/null +ip link show 2>/dev/null >/dev/null if [ $? -ne 0 ];then echo "SKIP: Could not run test without the ip tool" exit 0 diff --git a/tools/testing/selftests/net/reuseaddr_conflict.c b/tools/tes= ting/selftests/net/reuseaddr_conflict.c new file mode 100644 index 000000000000..7c5b12664b03 --- /dev/null +++ b/tools/testing/selftests/net/reuseaddr_conflict.c @@ -0,0 +1,114 @@ +/* + * Test for the regression introduced by + * + * b9470c27607b ("inet: kill smallest_size and smallest_port") + * + * If we open an ipv4 socket on a port with reuseaddr we shouldn't reset= the tb + * when we open the ipv6 conterpart, which is what was happening previou= sly. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define PORT 9999 + +int open_port(int ipv6, int any) +{ + int fd =3D -1; + int reuseaddr =3D 1; + int v6only =3D 1; + int addrlen; + int ret =3D -1; + struct sockaddr *addr; + int family =3D ipv6 ? AF_INET6 : AF_INET; + + struct sockaddr_in6 addr6 =3D { + .sin6_family =3D AF_INET6, + .sin6_port =3D htons(PORT), + .sin6_addr =3D in6addr_any + }; + struct sockaddr_in addr4 =3D { + .sin_family =3D AF_INET, + .sin_port =3D htons(PORT), + .sin_addr.s_addr =3D any ? htonl(INADDR_ANY) : inet_addr("127.0.0.1"),= + }; + + + if (ipv6) { + addr =3D (struct sockaddr*)&addr6; + addrlen =3D sizeof(addr6); + } else { + addr =3D (struct sockaddr*)&addr4; + addrlen =3D sizeof(addr4); + } + + if ((fd =3D socket(family, SOCK_STREAM, IPPROTO_TCP)) < 0) { + perror("socket"); + goto out; + } + + if (ipv6 && setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, (void*)&v6only, + sizeof(v6only)) < 0) { + perror("setsockopt IPV6_V6ONLY"); + goto out; + } + + if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &reuseaddr, + sizeof(reuseaddr)) < 0) { + perror("setsockopt SO_REUSEADDR"); + goto out; + } + + if (bind(fd, addr, addrlen) < 0) { + perror("bind"); + goto out; + } + + if (any) + return fd; + + if (listen(fd, 1) < 0) { + perror("listen"); + goto out; + } + return fd; +out: + close(fd); + return ret; +} + +int main(void) +{ + int listenfd; + int fd1, fd2; + + fprintf(stderr, "Opening 127.0.0.1:%d\n", PORT); + listenfd =3D open_port(0, 0); + if (listenfd < 0) + error(1, errno, "Couldn't open listen socket"); + fprintf(stderr, "Opening INADDR_ANY:%d\n", PORT); + fd1 =3D open_port(0, 1); + if (fd1 >=3D 0) + error(1, 0, "Was allowed to create an ipv4 reuseport on a already boun= d non-reuseport socket"); + fprintf(stderr, "Opening in6addr_any:%d\n", PORT); + fd1 =3D open_port(1, 1); + if (fd1 < 0) + error(1, errno, "Couldn't open ipv6 reuseport"); + fprintf(stderr, "Opening INADDR_ANY:%d\n", PORT); + fd2 =3D open_port(0, 1); + if (fd2 >=3D 0) + error(1, 0, "Was allowed to create an ipv4 reuseport on a already boun= d non-reuseport socket"); + close(fd1); + fprintf(stderr, "Opening INADDR_ANY:%d after closing ipv6 socket\n", PO= RT); + fd1 =3D open_port(0, 1); + if (fd1 >=3D 0) + error(1, 0, "Was allowed to create an ipv4 reuseport on an already bou= nd non-reuseport socket with no ipv6"); + fprintf(stderr, "Success"); + return 0; +} diff --git a/tools/testing/selftests/seccomp/seccomp_bpf.c b/tools/testin= g/selftests/seccomp/seccomp_bpf.c index 4d6f92a9df6b..19cd272c234d 100644 --- a/tools/testing/selftests/seccomp/seccomp_bpf.c +++ b/tools/testing/selftests/seccomp/seccomp_bpf.c @@ -6,10 +6,18 @@ */ =20 #include -#include -#define __have_siginfo_t 1 -#define __have_sigval_t 1 -#define __have_sigevent_t 1 + +/* + * glibc 2.26 and later have SIGSYS in siginfo_t. Before that, + * we need to use the kernel's siginfo.h file and trick glibc + * into accepting it. + */ +#if !__GLIBC_PREREQ(2, 26) +# include +# define __have_siginfo_t 1 +# define __have_sigval_t 1 +# define __have_sigevent_t 1 +#endif =20 #include #include @@ -676,7 +684,7 @@ TEST_F_SIGNAL(TRAP, ign, SIGSYS) syscall(__NR_getpid); } =20 -static struct siginfo TRAP_info; +static siginfo_t TRAP_info; static volatile int TRAP_nr; static void TRAP_action(int nr, siginfo_t *info, void *void_context) { diff --git a/tools/testing/selftests/sigaltstack/sas.c b/tools/testing/se= lftests/sigaltstack/sas.c index 7d406c3973ba..97bb150837df 100644 --- a/tools/testing/selftests/sigaltstack/sas.c +++ b/tools/testing/selftests/sigaltstack/sas.c @@ -39,7 +39,11 @@ void my_usr1(int sig, siginfo_t *si, void *u) stack_t stk; struct stk_data *p; =20 +#if __s390x__ + register unsigned long sp asm("%15"); +#else register unsigned long sp asm("sp"); +#endif =20 if (sp < (unsigned long)sstack || sp >=3D (unsigned long)sstack + SIGSTKSZ) { diff --git a/tools/testing/selftests/sync/Makefile b/tools/testing/selfte= sts/sync/Makefile index 4981c6b6d050..8e04d0afcbd7 100644 --- a/tools/testing/selftests/sync/Makefile +++ b/tools/testing/selftests/sync/Makefile @@ -2,12 +2,16 @@ CFLAGS +=3D -O2 -g -std=3Dgnu89 -pthread -Wall -Wextra CFLAGS +=3D -I../../../../usr/include/ LDFLAGS +=3D -pthread =20 -TEST_PROGS =3D sync_test - -all: $(TEST_PROGS) +.PHONY: all clean =20 include ../lib.mk =20 +# lib.mk TEST_CUSTOM_PROGS var is for custom tests that need special +# build rules. lib.mk will run and install them. + +TEST_CUSTOM_PROGS :=3D $(OUTPUT)/sync_test +all: $(TEST_CUSTOM_PROGS) + OBJS =3D sync_test.o sync.o =20 TESTS +=3D sync_alloc.o @@ -18,6 +22,16 @@ TESTS +=3D sync_stress_parallelism.o TESTS +=3D sync_stress_consumer.o TESTS +=3D sync_stress_merge.o =20 -sync_test: $(OBJS) $(TESTS) +OBJS :=3D $(patsubst %,$(OUTPUT)/%,$(OBJS)) +TESTS :=3D $(patsubst %,$(OUTPUT)/%,$(TESTS)) + +$(TEST_CUSTOM_PROGS): $(TESTS) $(OBJS) + $(CC) -o $(TEST_CUSTOM_PROGS) $(OBJS) $(TESTS) $(CFLAGS) $(LDFLAGS) + +$(OBJS): $(OUTPUT)/%.o: %.c + $(CC) -c $^ -o $@ + +$(TESTS): $(OUTPUT)/%.o: %.c + $(CC) -c $^ -o $@ =20 -EXTRA_CLEAN :=3D sync_test $(OBJS) $(TESTS) +EXTRA_CLEAN :=3D $(TEST_CUSTOM_PROGS) $(OBJS) $(TESTS) diff --git a/tools/testing/selftests/timers/set-timer-lat.c b/tools/testi= ng/selftests/timers/set-timer-lat.c index 9c92b7bd5641..50da45437daa 100644 --- a/tools/testing/selftests/timers/set-timer-lat.c +++ b/tools/testing/selftests/timers/set-timer-lat.c @@ -143,7 +143,8 @@ int setup_timer(int clock_id, int flags, int interval= , timer_t *tm1) printf("%-22s %s missing CAP_WAKE_ALARM? : [UNSUPPORTED]\n", clockstring(clock_id), flags ? "ABSTIME":"RELTIME"); - return 0; + /* Indicate timer isn't set, so caller doesn't wait */ + return 1; } printf("%s - timer_create() failed\n", clockstring(clock_id)); return -1; @@ -213,8 +214,9 @@ int do_timer(int clock_id, int flags) int err; =20 err =3D setup_timer(clock_id, flags, interval, &tm1); + /* Unsupported case - return 0 to not fail the test */ if (err) - return err; + return err =3D=3D 1 ? 0 : err; =20 while (alarmcount < 5) sleep(1); @@ -228,18 +230,17 @@ int do_timer_oneshot(int clock_id, int flags) timer_t tm1; const int interval =3D 0; struct timeval timeout; - fd_set fds; int err; =20 err =3D setup_timer(clock_id, flags, interval, &tm1); + /* Unsupported case - return 0 to not fail the test */ if (err) - return err; + return err =3D=3D 1 ? 0 : err; =20 memset(&timeout, 0, sizeof(timeout)); timeout.tv_sec =3D 5; - FD_ZERO(&fds); do { - err =3D select(FD_SETSIZE, &fds, NULL, NULL, &timeout); + err =3D select(0, NULL, NULL, NULL, &timeout); } while (err =3D=3D -1 && errno =3D=3D EINTR); =20 timer_delete(tm1); diff --git a/tools/testing/selftests/watchdog/Makefile b/tools/testing/se= lftests/watchdog/Makefile index f863c664e3d1..ee068511fd0b 100644 --- a/tools/testing/selftests/watchdog/Makefile +++ b/tools/testing/selftests/watchdog/Makefile @@ -1,8 +1,3 @@ -TEST_PROGS :=3D watchdog-test - -all: $(TEST_PROGS) +TEST_GEN_PROGS :=3D watchdog-test =20 include ../lib.mk - -clean: - rm -fr $(TEST_PROGS) --------------11B375788EEF2F3BDDE70657--