From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751520AbdBXVTx (ORCPT ); Fri, 24 Feb 2017 16:19:53 -0500 Received: from ec2-52-27-115-49.us-west-2.compute.amazonaws.com ([52.27.115.49]:56682 "EHLO osg.samsung.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751219AbdBXVTt (ORCPT ); Fri, 24 Feb 2017 16:19:49 -0500 To: torvalds@linux-foundation.org, Stephen Rothwell Cc: linux-kselftest@vger.kernel.org, LKML , "davem@davemloft.net" , Shuah Khan From: Shuah Khan Subject: [GIT PULL] Kselftest update for 4.11-rc1 Message-ID: <5355691a-e765-51d9-d6ab-cc5310fa30f0@osg.samsung.com> Date: Fri, 24 Feb 2017 14:09:04 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------CCC865A8D9E631AA5C057686" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is a multi-part message in MIME format. --------------CCC865A8D9E631AA5C057686 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Hi Linus, Please pull the Kselftest update for 4.11-rc1 This update consists of: -- fixes to several existing tests from Stafford Horne -- cpufreq tests from Viresh Kumar -- Selftest build and install fixes from Bamvor Jian Zhang and Michael Ellerman -- Fixes to protection-keys tests from Dave Hansen -- Warning fixes from Shuah Khan Stephen saw a conflict during kselftest merge with next between commit: d498f8719a09 ("bpf: Rebuild bpf.o for any dependency update") from the net-next tree and commit: 88baa78d1f31 ("selftests: remove duplicated all and clean target") Stephen fixed this up in linux-next and volunteered to carry forward the fix - fix diff attached. Please let me know if this isn't acceptable. Sorry for the inconvenience. Diff for the update attached. thanks, -- Shuah -------------------------------------------------------------------------------------------- The following changes since commit 7ce7d89f48834cefece7804d38fc5d85382edf77: Linux 4.10-rc1 (2016-12-25 16:13:08 -0800) are available in the git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest tags/linux-kselftest-4.11-rc1 for you to fetch changes up to 68bd42d97c30d51217b8c3b2b22fede577d8371c: selftests/powerpc: Fix remaining fallout from recent changes (2017-02-14 08:02:27 -0700) ---------------------------------------------------------------- linux-kselftest-4.11-rc1 This update consists of: -- fixes to several existing tests from Stafford Horne -- cpufreq tests from Viresh Kumar -- Selftest build and install fixes from Bamvor Jian Zhang and Michael Ellerman -- Fixes to protection-keys tests from Dave Hansen -- Warning fixes from Shuah Khan ---------------------------------------------------------------- Dave Hansen (2): selftests, x86, protection_keys: fix uninitialized variable warning selftests, x86, protection_keys: fix wrong offset in siginfo Michael Ellerman (5): selftests: Fix selftests build to just build, not run tests selftests: Fix the .c linking rule selftests: Fix the .S and .S -> .o rules selftests/powerpc: Fix the clean rule since recent changes selftests/powerpc: Fix remaining fallout from recent changes Shuah Khan (4): selftests: gpio add .gitignore for generated files selftests: ipc add missing generated file to .gitignore selftests: x86 protection_keys fix unused variable compile warnings selftests: x86 protection_keys remove dead code Stafford Horne (6): selftests/futex: Add stdio used for logging selftests/futex: Add headers to makefile dependencies cpupower: Restore format of frequency-info limit selftests/intel_pstate: Fix warning on loop index overflow selftests/intel_pstate: Update makefile to match new style selftests: Add intel_pstate to TARGETS Viresh Kumar (5): selftest: cpufreq: Add support for cpufreq tests selftest: cpufreq: Add suspend/resume/hibernate support selftest: cpufreq: Add support to test cpufreq modules selftest: cpufreq: Add special tests selftest: cpufreq: Update MAINTAINERS file bamvor.zhangjian@huawei.com (6): selftests: remove duplicated all and clean target selftests: remove useless TEST_DIRS selftests: add default rules for c source file selftests: remove CROSS_COMPILE in dedicated Makefile selftests: add EXTRA_CLEAN for clean target selftests: enable O and KBUILD_OUTPUT Documentation/kselftest.txt | 12 + MAINTAINERS | 1 + tools/power/cpupower/utils/cpufreq-info.c | 21 +- tools/testing/selftests/Makefile | 38 +++- tools/testing/selftests/bpf/Makefile | 10 +- tools/testing/selftests/breakpoints/Makefile | 10 +- tools/testing/selftests/capabilities/Makefile | 11 +- tools/testing/selftests/cpufreq/Makefile | 8 + tools/testing/selftests/cpufreq/cpu.sh | 84 +++++++ tools/testing/selftests/cpufreq/cpufreq.sh | 241 ++++++++++++++++++++ tools/testing/selftests/cpufreq/governor.sh | 153 +++++++++++++ tools/testing/selftests/cpufreq/main.sh | 194 ++++++++++++++++ tools/testing/selftests/cpufreq/module.sh | 243 +++++++++++++++++++++ tools/testing/selftests/cpufreq/special-tests.sh | 115 ++++++++++ tools/testing/selftests/efivarfs/Makefile | 8 +- tools/testing/selftests/exec/Makefile | 32 ++- tools/testing/selftests/ftrace/Makefile | 6 +- tools/testing/selftests/futex/Makefile | 21 +- tools/testing/selftests/futex/functional/Makefile | 17 +- tools/testing/selftests/futex/include/logging.h | 1 + tools/testing/selftests/gpio/.gitignore | 1 + tools/testing/selftests/intel_pstate/Makefile | 13 +- tools/testing/selftests/intel_pstate/aperf.c | 2 +- tools/testing/selftests/ipc/.gitignore | 1 + tools/testing/selftests/ipc/Makefile | 7 +- tools/testing/selftests/kcmp/Makefile | 6 +- tools/testing/selftests/lib.mk | 36 ++- tools/testing/selftests/membarrier/Makefile | 6 +- tools/testing/selftests/memfd/Makefile | 15 +- tools/testing/selftests/mount/Makefile | 7 +- tools/testing/selftests/mqueue/Makefile | 6 +- tools/testing/selftests/net/Makefile | 15 +- tools/testing/selftests/nsfs/Makefile | 9 +- tools/testing/selftests/powerpc/Makefile | 14 +- tools/testing/selftests/powerpc/alignment/Makefile | 9 +- .../testing/selftests/powerpc/benchmarks/Makefile | 17 +- .../selftests/powerpc/context_switch/Makefile | 9 +- tools/testing/selftests/powerpc/copyloops/Makefile | 19 +- tools/testing/selftests/powerpc/dscr/Makefile | 13 +- tools/testing/selftests/powerpc/math/Makefile | 29 +-- tools/testing/selftests/powerpc/mm/Makefile | 18 +- tools/testing/selftests/powerpc/pmu/Makefile | 26 +-- tools/testing/selftests/powerpc/pmu/ebb/Makefile | 15 +- .../testing/selftests/powerpc/primitives/Makefile | 9 +- .../testing/selftests/powerpc/stringloops/Makefile | 9 +- .../selftests/powerpc/switch_endian/Makefile | 17 +- tools/testing/selftests/powerpc/syscalls/Makefile | 9 +- tools/testing/selftests/powerpc/tm/Makefile | 18 +- tools/testing/selftests/powerpc/vphn/Makefile | 10 +- tools/testing/selftests/pstore/Makefile | 4 +- tools/testing/selftests/ptrace/Makefile | 8 +- tools/testing/selftests/seccomp/Makefile | 6 +- tools/testing/selftests/sigaltstack/Makefile | 5 +- tools/testing/selftests/size/Makefile | 10 +- tools/testing/selftests/timers/Makefile | 10 +- tools/testing/selftests/vm/Makefile | 41 ++-- tools/testing/selftests/x86/Makefile | 17 +- tools/testing/selftests/x86/protection_keys.c | 19 +- tools/testing/selftests/zram/Makefile | 3 +- 59 files changed, 1318 insertions(+), 396 deletions(-) create mode 100644 tools/testing/selftests/cpufreq/Makefile create mode 100755 tools/testing/selftests/cpufreq/cpu.sh create mode 100755 tools/testing/selftests/cpufreq/cpufreq.sh create mode 100755 tools/testing/selftests/cpufreq/governor.sh create mode 100755 tools/testing/selftests/cpufreq/main.sh create mode 100755 tools/testing/selftests/cpufreq/module.sh create mode 100755 tools/testing/selftests/cpufreq/special-tests.sh create mode 100644 tools/testing/selftests/gpio/.gitignore ------------------------------------------------------------------------------------------ -- Shuah Khan Sr. Linux Kernel Developer Open Source Innovation Group Samsung Research America (Silicon Valley) shuahkh@osg.samsung.com --------------CCC865A8D9E631AA5C057686 Content-Type: text/x-patch; name="linux-kselftest-4.11-rc1.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="linux-kselftest-4.11-rc1.diff" diff --git a/Documentation/kselftest.txt b/Documentation/kselftest.txt index e5c7254..d431dc8 100644 --- a/Documentation/kselftest.txt +++ b/Documentation/kselftest.txt @@ -95,3 +95,15 @@ In general, the rules for selftests are =20 * Don't cause the top-level "make run_tests" to fail if your feature is= unconfigured. + +Contributing new tests(details) +=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 + + * Use TEST_GEN_XXX if such binaries or files are generated during + compiling. + TEST_PROGS, TEST_GEN_PROGS mean it is the excutable tested by + default. + TEST_PROGS_EXTENDED, TEST_GEN_PROGS_EXTENDED mean it is the + executable which is not tested by default. + TEST_FILES, TEST_GEN_FILES mean it is the file which is used by + test. diff --git a/MAINTAINERS b/MAINTAINERS index cfff2c9..c258cb7 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -3390,6 +3390,7 @@ B: https://bugzilla.kernel.org F: Documentation/cpu-freq/ F: drivers/cpufreq/ F: include/linux/cpufreq.h +F: tools/testing/selftests/cpufreq/ =20 CPU FREQUENCY DRIVERS - ARM BIG LITTLE M: Viresh Kumar diff --git a/tools/power/cpupower/utils/cpufreq-info.c b/tools/power/cpup= ower/utils/cpufreq-info.c index 590d12a..3e701f0 100644 --- a/tools/power/cpupower/utils/cpufreq-info.c +++ b/tools/power/cpupower/utils/cpufreq-info.c @@ -285,20 +285,24 @@ static int get_freq_hardware(unsigned int cpu, unsi= gned int human) =20 /* --hwlimits / -l */ =20 -static int get_hardware_limits(unsigned int cpu) +static int get_hardware_limits(unsigned int cpu, unsigned int human) { unsigned long min, max; =20 - printf(_(" hardware limits: ")); if (cpufreq_get_hardware_limits(cpu, &min, &max)) { printf(_("Not Available\n")); return -EINVAL; } =20 - print_speed(min); - printf(" - "); - print_speed(max); - printf("\n"); + if (human) { + printf(_(" hardware limits: ")); + print_speed(min); + printf(" - "); + print_speed(max); + printf("\n"); + } else { + printf("%lu %lu\n", min, max); + } return 0; } =20 @@ -456,7 +460,7 @@ static void debug_output_one(unsigned int cpu) get_related_cpus(cpu); get_affected_cpus(cpu); get_latency(cpu, 1); - get_hardware_limits(cpu); + get_hardware_limits(cpu, 1); =20 freqs =3D cpufreq_get_available_frequencies(cpu); if (freqs) { @@ -622,7 +626,7 @@ int cmd_freq_info(int argc, char **argv) ret =3D get_driver(cpu); break; case 'l': - ret =3D get_hardware_limits(cpu); + ret =3D get_hardware_limits(cpu, human); break; case 'w': ret =3D get_freq_hardware(cpu, human); @@ -639,7 +643,6 @@ int cmd_freq_info(int argc, char **argv) } if (ret) return ret; - printf("\n"); } return ret; } diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/M= akefile index 71b0589..e23bed2 100644 --- a/tools/testing/selftests/Makefile +++ b/tools/testing/selftests/Makefile @@ -1,6 +1,7 @@ TARGETS =3D bpf TARGETS +=3D breakpoints TARGETS +=3D capabilities +TARGETS +=3D cpufreq TARGETS +=3D cpu-hotplug TARGETS +=3D efivarfs TARGETS +=3D exec @@ -8,6 +9,7 @@ TARGETS +=3D firmware TARGETS +=3D ftrace TARGETS +=3D futex TARGETS +=3D gpio +TARGETS +=3D intel_pstate TARGETS +=3D ipc TARGETS +=3D kcmp TARGETS +=3D lib @@ -49,29 +51,44 @@ override LDFLAGS =3D override MAKEFLAGS =3D endif =20 +BUILD :=3D $(O) +ifndef BUILD + BUILD :=3D $(KBUILD_OUTPUT) +endif +ifndef BUILD + BUILD :=3D $(shell pwd) +endif + +export BUILD all: - for TARGET in $(TARGETS); do \ - make -C $$TARGET; \ + 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 \ - make -C $$TARGET run_tests; \ + BUILD_TARGET=3D$$BUILD/$$TARGET; \ + make OUTPUT=3D$$BUILD_TARGET -C $$TARGET run_tests;\ done; =20 hotplug: for TARGET in $(TARGETS_HOTPLUG); do \ - make -C $$TARGET; \ + BUILD_TARGET=3D$$BUILD/$$TARGET; \ + make OUTPUT=3D$$BUILD_TARGET -C $$TARGET;\ done; =20 run_hotplug: hotplug for TARGET in $(TARGETS_HOTPLUG); do \ - make -C $$TARGET run_full_test; \ + 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 \ - make -C $$TARGET clean; \ + BUILD_TARGET=3D$$BUILD/$$TARGET; \ + make OUTPUT=3D$$BUILD_TARGET -C $$TARGET clean;\ done; =20 run_pstore_crash: @@ -86,7 +103,8 @@ ifdef INSTALL_PATH @# Ask all targets to install their files mkdir -p $(INSTALL_PATH) for TARGET in $(TARGETS); do \ - make -C $$TARGET INSTALL_PATH=3D$(INSTALL_PATH)/$$TARGET install; \ + BUILD_TARGET=3D$$BUILD/$$TARGET; \ + make OUTPUT=3D$$BUILD_TARGET -C $$TARGET INSTALL_PATH=3D$(INSTALL_PATH= )/$$TARGET install; \ done; =20 @# Ask all targets to emit their test scripts @@ -95,10 +113,11 @@ ifdef INSTALL_PATH echo "ROOT=3D\$$PWD" >> $(ALL_SCRIPT) =20 for TARGET in $(TARGETS); do \ + BUILD_TARGET=3D$$BUILD/$$TARGET; \ echo "echo ; echo Running tests in $$TARGET" >> $(ALL_SCRIPT); \ echo "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" >> $(ALL_SC= RIPT); \ echo "cd $$TARGET" >> $(ALL_SCRIPT); \ - make -s --no-print-directory -C $$TARGET emit_tests >> $(ALL_SCRIPT); = \ + make -s --no-print-directory OUTPUT=3D$$BUILD_TARGET -C $$TARGET emit_= tests >> $(ALL_SCRIPT); \ echo "cd \$$ROOT" >> $(ALL_SCRIPT); \ done; =20 @@ -109,7 +128,8 @@ endif =20 clean: for TARGET in $(TARGETS); do \ - make -C $$TARGET clean; \ + BUILD_TARGET=3D$$BUILD/$$TARGET; \ + make OUTPUT=3D$$BUILD_TARGET -C $$TARGET clean;\ done; =20 .PHONY: install diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftes= ts/bpf/Makefile index 7a5f245..058351b 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -1,13 +1,7 @@ CFLAGS +=3D -Wall -O2 -I../../../../usr/include =20 -test_objs =3D test_verifier test_maps test_lru_map +TEST_GEN_PROGS =3D test_verifier test_maps test_lru_map =20 -TEST_PROGS :=3D test_verifier test_maps test_lru_map test_kmod.sh -TEST_FILES :=3D $(test_objs) - -all: $(test_objs) +TEST_PROGS :=3D test_kmod.sh =20 include ../lib.mk - -clean: - $(RM) $(test_objs) diff --git a/tools/testing/selftests/breakpoints/Makefile b/tools/testing= /selftests/breakpoints/Makefile index 61b79e8..72aa103 100644 --- a/tools/testing/selftests/breakpoints/Makefile +++ b/tools/testing/selftests/breakpoints/Makefile @@ -3,17 +3,13 @@ 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 ifeq ($(ARCH),x86) -TEST_PROGS :=3D breakpoint_test +TEST_GEN_PROGS :=3D breakpoint_test endif ifeq ($(ARCH),aarch64) -TEST_PROGS :=3D breakpoint_test_arm64 +TEST_GEN_PROGS :=3D breakpoint_test_arm64 endif =20 -TEST_PROGS +=3D step_after_suspend_test - -all: $(TEST_PROGS) +TEST_GEN_PROGS +=3D step_after_suspend_test =20 include ../lib.mk =20 -clean: - rm -fr breakpoint_test breakpoint_test_arm64 step_after_suspend_test diff --git a/tools/testing/selftests/capabilities/Makefile b/tools/testin= g/selftests/capabilities/Makefile index 008602a..29b8adf 100644 --- a/tools/testing/selftests/capabilities/Makefile +++ b/tools/testing/selftests/capabilities/Makefile @@ -1,15 +1,8 @@ -TEST_FILES :=3D validate_cap -TEST_PROGS :=3D test_execve - -BINARIES :=3D $(TEST_FILES) $(TEST_PROGS) +TEST_GEN_FILES :=3D validate_cap +TEST_GEN_PROGS :=3D test_execve =20 CFLAGS +=3D -O2 -g -std=3Dgnu99 -Wall LDLIBS +=3D -lcap-ng -lrt -ldl =20 -all: $(BINARIES) - -clean: - $(RM) $(BINARIES) - include ../lib.mk =20 diff --git a/tools/testing/selftests/cpufreq/Makefile b/tools/testing/sel= ftests/cpufreq/Makefile new file mode 100644 index 0000000..3955cd9 --- /dev/null +++ b/tools/testing/selftests/cpufreq/Makefile @@ -0,0 +1,8 @@ +all: + +TEST_PROGS :=3D main.sh +TEST_FILES :=3D cpu.sh cpufreq.sh governor.sh module.sh special-tests.sh= + +include ../lib.mk + +clean: diff --git a/tools/testing/selftests/cpufreq/cpu.sh b/tools/testing/selft= ests/cpufreq/cpu.sh new file mode 100755 index 0000000..8e08a83 --- /dev/null +++ b/tools/testing/selftests/cpufreq/cpu.sh @@ -0,0 +1,84 @@ +#!/bin/bash +# +# CPU helpers + +# protect against multiple inclusion +if [ $FILE_CPU ]; then + return 0 +else + FILE_CPU=3DDONE +fi + +source cpufreq.sh + +for_each_cpu() +{ + cpus=3D$(ls $CPUROOT | grep "cpu[0-9].*") + for cpu in $cpus; do + $@ $cpu + done +} + +for_each_non_boot_cpu() +{ + cpus=3D$(ls $CPUROOT | grep "cpu[1-9].*") + for cpu in $cpus; do + $@ $cpu + done +} + +#$1: cpu +offline_cpu() +{ + printf "Offline $1\n" + echo 0 > $CPUROOT/$1/online +} + +#$1: cpu +online_cpu() +{ + printf "Online $1\n" + echo 1 > $CPUROOT/$1/online +} + +#$1: cpu +reboot_cpu() +{ + offline_cpu $1 + online_cpu $1 +} + +# Reboot CPUs +# param: number of times we want to run the loop +reboot_cpus() +{ + printf "** Test: Running ${FUNCNAME[0]} for $1 loops **\n\n" + + for i in `seq 1 $1`; do + for_each_non_boot_cpu offline_cpu + for_each_non_boot_cpu online_cpu + printf "\n" + done + + printf "\n%s\n\n" "------------------------------------------------" +} + +# Prints warning for all CPUs with missing cpufreq directory +print_unmanaged_cpus() +{ + for_each_cpu cpu_should_have_cpufreq_directory +} + +# Counts CPUs with cpufreq directories +count_cpufreq_managed_cpus() +{ + count=3D0; + + for cpu in `ls $CPUROOT | grep "cpu[0-9].*"`; do + if [ -d $CPUROOT/$cpu/cpufreq ]; then + let count=3Dcount+1; + fi + done + + echo $count; +} diff --git a/tools/testing/selftests/cpufreq/cpufreq.sh b/tools/testing/s= elftests/cpufreq/cpufreq.sh new file mode 100755 index 0000000..1ed3832 --- /dev/null +++ b/tools/testing/selftests/cpufreq/cpufreq.sh @@ -0,0 +1,241 @@ +#!/bin/bash + +# protect against multiple inclusion +if [ $FILE_CPUFREQ ]; then + return 0 +else + FILE_CPUFREQ=3DDONE +fi + +source cpu.sh + + +# $1: cpu +cpu_should_have_cpufreq_directory() +{ + if [ ! -d $CPUROOT/$1/cpufreq ]; then + printf "Warning: No cpufreq directory present for $1\n" + fi +} + +cpu_should_not_have_cpufreq_directory() +{ + if [ -d $CPUROOT/$1/cpufreq ]; then + printf "Warning: cpufreq directory present for $1\n" + fi +} + +for_each_policy() +{ + policies=3D$(ls $CPUFREQROOT| grep "policy[0-9].*") + for policy in $policies; do + $@ $policy + done +} + +for_each_policy_concurrent() +{ + policies=3D$(ls $CPUFREQROOT| grep "policy[0-9].*") + for policy in $policies; do + $@ $policy & + done +} + +# $1: Path +read_cpufreq_files_in_dir() +{ + local files=3D`ls $1` + + printf "Printing directory: $1\n\n" + + for file in $files; do + if [ -f $1/$file ]; then + printf "$file:" + cat $1/$file + else + printf "\n" + read_cpufreq_files_in_dir "$1/$file" + fi + done + printf "\n" +} + + +read_all_cpufreq_files() +{ + printf "** Test: Running ${FUNCNAME[0]} **\n\n" + + read_cpufreq_files_in_dir $CPUFREQROOT + + printf "%s\n\n" "------------------------------------------------" +} + + +# UPDATE CPUFREQ FILES + +# $1: directory path +update_cpufreq_files_in_dir() +{ + local files=3D`ls $1` + + printf "Updating directory: $1\n\n" + + for file in $files; do + if [ -f $1/$file ]; then + # file is writable ? + local wfile=3D$(ls -l $1/$file | awk '$1 ~ /^.*w.*/ { print $NF; }') + + if [ ! -z $wfile ]; then + # scaling_setspeed is a special file and we + # should skip updating it + if [ $file !=3D "scaling_setspeed" ]; then + local val=3D$(cat $1/$file) + printf "Writing $val to: $file\n" + echo $val > $1/$file + fi + fi + else + printf "\n" + update_cpufreq_files_in_dir "$1/$file" + fi + done + + printf "\n" +} + +# Update all writable files with their existing values +update_all_cpufreq_files() +{ + printf "** Test: Running ${FUNCNAME[0]} **\n\n" + + update_cpufreq_files_in_dir $CPUFREQROOT + + printf "%s\n\n" "------------------------------------------------" +} + + +# CHANGE CPU FREQUENCIES + +# $1: policy +find_current_freq() +{ + cat $CPUFREQROOT/$1/scaling_cur_freq +} + +# $1: policy +# $2: frequency +set_cpu_frequency() +{ + printf "Change frequency for $1 to $2\n" + echo $2 > $CPUFREQROOT/$1/scaling_setspeed +} + +# $1: policy +test_all_frequencies() +{ + local filepath=3D"$CPUFREQROOT/$1" + + backup_governor $1 + + local found=3D$(switch_governor $1 "userspace") + if [ $found =3D 1 ]; then + printf "${FUNCNAME[0]}: userspace governor not available for: $1\n" + return; + fi + + printf "Switched governor for $1 to userspace\n\n" + + local freqs=3D$(cat $filepath/scaling_available_frequencies) + printf "Available frequencies for $1: $freqs\n\n" + + # Set all frequencies one-by-one + for freq in $freqs; do + set_cpu_frequency $1 $freq + done + + printf "\n" + + restore_governor $1 +} + +# $1: loop count +shuffle_frequency_for_all_cpus() +{ + printf "** Test: Running ${FUNCNAME[0]} for $1 loops **\n\n" + + for i in `seq 1 $1`; do + for_each_policy test_all_frequencies + done + printf "\n%s\n\n" "------------------------------------------------" +} + +# Basic cpufreq tests +cpufreq_basic_tests() +{ + printf "*** RUNNING CPUFREQ SANITY TESTS ***\n" + printf "=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\n\n" + + count=3D$(count_cpufreq_managed_cpus) + if [ $count =3D 0 ]; then + printf "No cpu is managed by cpufreq core, exiting\n" + exit; + else + printf "CPUFreq manages: $count CPUs\n\n" + fi + + # Detect & print which CPUs are not managed by cpufreq + print_unmanaged_cpus + + # read/update all cpufreq files + read_all_cpufreq_files + update_all_cpufreq_files + + # hotplug cpus + reboot_cpus 5 + + # Test all frequencies + shuffle_frequency_for_all_cpus 2 + + # Test all governors + shuffle_governors_for_all_cpus 1 +} + +# Suspend/resume +# $1: "suspend" or "hibernate", $2: loop count +do_suspend() +{ + printf "** Test: Running ${FUNCNAME[0]}: Trying $1 for $2 loops **\n\n"= + + # Is the directory available + if [ ! -d $SYSFS/power/ -o ! -f $SYSFS/power/state ]; then + printf "$SYSFS/power/state not available\n" + return 1 + fi + + if [ $1 =3D "suspend" ]; then + filename=3D"mem" + elif [ $1 =3D "hibernate" ]; then + filename=3D"disk" + else + printf "$1 is not a valid option\n" + return 1 + fi + + if [ -n $filename ]; then + present=3D$(cat $SYSFS/power/state | grep $filename) + + if [ -z "$present" ]; then + printf "Tried to $1 but $filename isn't present in $SYSFS/power/state= \n" + return 1; + fi + + for i in `seq 1 $2`; do + printf "Starting $1\n" + echo $filename > $SYSFS/power/state + printf "Came out of $1\n" + + printf "Do basic tests after finishing $1 to verify cpufreq state\n\n= " + cpufreq_basic_tests + done + fi +} diff --git a/tools/testing/selftests/cpufreq/governor.sh b/tools/testing/= selftests/cpufreq/governor.sh new file mode 100755 index 0000000..def6451 --- /dev/null +++ b/tools/testing/selftests/cpufreq/governor.sh @@ -0,0 +1,153 @@ +#!/bin/bash +# +# Test governors + +# protect against multiple inclusion +if [ $FILE_GOVERNOR ]; then + return 0 +else + FILE_GOVERNOR=3DDONE +fi + +source cpu.sh +source cpufreq.sh + +CUR_GOV=3D +CUR_FREQ=3D + +# Find governor's directory path +# $1: policy, $2: governor +find_gov_directory() +{ + if [ -d $CPUFREQROOT/$2 ]; then + printf "$CPUFREQROOT/$2\n" + elif [ -d $CPUFREQROOT/$1/$2 ]; then + printf "$CPUFREQROOT/$1/$2\n" + else + printf "INVALID\n" + fi +} + +# $1: policy +find_current_governor() +{ + cat $CPUFREQROOT/$1/scaling_governor +} + +# $1: policy +backup_governor() +{ + CUR_GOV=3D$(find_current_governor $1) + + printf "Governor backup done for $1: $CUR_GOV\n" + + if [ $CUR_GOV =3D=3D "userspace" ]; then + CUR_FREQ=3D$(find_current_freq $1) + printf "Governor frequency backup done for $1: $CUR_FREQ\n" + fi + + printf "\n" +} + +# $1: policy +restore_governor() +{ + __switch_governor $1 $CUR_GOV + + printf "Governor restored for $1 to $CUR_GOV\n" + + if [ $CUR_GOV =3D=3D "userspace" ]; then + set_cpu_frequency $1 $CUR_FREQ + printf "Governor frequency restored for $1: $CUR_FREQ\n" + fi + + printf "\n" +} + +# param: +# $1: policy, $2: governor +__switch_governor() +{ + echo $2 > $CPUFREQROOT/$1/scaling_governor +} + +# param: +# $1: cpu, $2: governor +__switch_governor_for_cpu() +{ + echo $2 > $CPUROOT/$1/cpufreq/scaling_governor +} + +# SWITCH GOVERNORS + +# $1: cpu, $2: governor +switch_governor() +{ + local filepath=3D$CPUFREQROOT/$1/scaling_available_governors + + # check if governor is available + local found=3D$(cat $filepath | grep $2 | wc -l) + if [ $found =3D 0 ]; then + echo 1; + return + fi + + __switch_governor $1 $2 + echo 0; +} + +# $1: policy, $2: governor +switch_show_governor() +{ + cur_gov=3Dfind_current_governor + if [ $cur_gov =3D=3D "userspace" ]; then + cur_freq=3Dfind_current_freq + fi + + # switch governor + __switch_governor $1 $2 + + printf "\nSwitched governor for $1 to $2\n\n" + + if [ $2 =3D=3D "userspace" -o $2 =3D=3D "powersave" -o $2 =3D=3D "perfo= rmance" ]; then + printf "No files to read for $2 governor\n\n" + return + fi + + # show governor files + local govpath=3D$(find_gov_directory $1 $2) + read_cpufreq_files_in_dir $govpath +} + +# $1: function to be called, $2: policy +call_for_each_governor() +{ + local filepath=3D$CPUFREQROOT/$2/scaling_available_governors + + # Exit if cpu isn't managed by cpufreq core + if [ ! -f $filepath ]; then + return; + fi + + backup_governor $2 + + local governors=3D$(cat $filepath) + printf "Available governors for $2: $governors\n" + + for governor in $governors; do + $1 $2 $governor + done + + restore_governor $2 +} + +# $1: loop count +shuffle_governors_for_all_cpus() +{ + printf "** Test: Running ${FUNCNAME[0]} for $1 loops **\n\n" + + for i in `seq 1 $1`; do + for_each_policy call_for_each_governor switch_show_governor + done + printf "%s\n\n" "------------------------------------------------" +} diff --git a/tools/testing/selftests/cpufreq/main.sh b/tools/testing/self= tests/cpufreq/main.sh new file mode 100755 index 0000000..01bac76 --- /dev/null +++ b/tools/testing/selftests/cpufreq/main.sh @@ -0,0 +1,194 @@ +#!/bin/bash + +source cpu.sh +source cpufreq.sh +source governor.sh +source module.sh +source special-tests.sh + +FUNC=3Dbasic # do basic tests by default +OUTFILE=3Dcpufreq_selftest +SYSFS=3D +CPUROOT=3D +CPUFREQROOT=3D + +helpme() +{ + printf "Usage: $0 [-h] [-todg args] + [-h ] + [-o ] + [-t ] + [-d \"] + [-g \"] + \n" + exit 2 +} + +prerequisite() +{ + msg=3D"skip all tests:" + + if [ $UID !=3D 0 ]; then + echo $msg must be run as root >&2 + exit 2 + fi + + taskset -p 01 $$ + + SYSFS=3D`mount -t sysfs | head -1 | awk '{ print $3 }'` + + if [ ! -d "$SYSFS" ]; then + echo $msg sysfs is not mounted >&2 + exit 2 + fi + + CPUROOT=3D$SYSFS/devices/system/cpu + CPUFREQROOT=3D"$CPUROOT/cpufreq" + + if ! ls $CPUROOT/cpu* > /dev/null 2>&1; then + echo $msg cpus not available in sysfs >&2 + exit 2 + fi + + if ! ls $CPUROOT/cpufreq > /dev/null 2>&1; then + echo $msg cpufreq directory not available in sysfs >&2 + exit 2 + fi +} + +parse_arguments() +{ + while getopts ht:o:d:g: arg + do + case $arg in + h) # --help + helpme + ;; + + t) # --func_type (Function to perform: basic, suspend, hibernate, mod= test, sptest1/2/3/4 (default: basic)) + FUNC=3D$OPTARG + ;; + + o) # --output-file (Output file to store dumps) + OUTFILE=3D$OPTARG + ;; + + d) # --driver-mod-name (Name of the driver module) + DRIVER_MOD=3D$OPTARG + ;; + + g) # --governor-mod-name (Name of the governor module) + GOVERNOR_MOD=3D$OPTARG + ;; + + \?) + helpme + ;; + esac + done +} + +do_test() +{ + # Check if CPUs are managed by cpufreq or not + count=3D$(count_cpufreq_managed_cpus) + + if [ $count =3D 0 -a $FUNC !=3D "modtest" ]; then + echo "No cpu is managed by cpufreq core, exiting" + exit 2; + fi + + case "$FUNC" in + "basic") + cpufreq_basic_tests + ;; + + "suspend") + do_suspend "suspend" 1 + ;; + + "hibernate") + do_suspend "hibernate" 1 + ;; + + "modtest") + # Do we have modules in place? + if [ -z $DRIVER_MOD ] && [ -z $GOVERNOR_MOD ]; then + echo "No driver or governor module passed with -d or -g" + exit 2; + fi + + if [ $DRIVER_MOD ]; then + if [ $GOVERNOR_MOD ]; then + module_test $DRIVER_MOD $GOVERNOR_MOD + else + module_driver_test $DRIVER_MOD + fi + else + if [ $count =3D 0 ]; then + echo "No cpu is managed by cpufreq core, exiting" + exit 2; + fi + + module_governor_test $GOVERNOR_MOD + fi + ;; + + "sptest1") + simple_lockdep + ;; + + "sptest2") + concurrent_lockdep + ;; + + "sptest3") + governor_race + ;; + + "sptest4") + hotplug_with_updates + ;; + + *) + echo "Invalid [-f] function type" + helpme + ;; + esac +} + +# clear dumps +# $1: file name +clear_dumps() +{ + echo "" > $1.txt + echo "" > $1.dmesg_cpufreq.txt + echo "" > $1.dmesg_full.txt +} + +# $1: output file name +dmesg_dumps() +{ + dmesg | grep cpufreq >> $1.dmesg_cpufreq.txt + + # We may need the full logs as well + dmesg >> $1.dmesg_full.txt +} + +# Parse arguments +parse_arguments $@ + +# Make sure all requirements are met +prerequisite + +# Run requested functions +clear_dumps $OUTFILE +do_test >> $OUTFILE.txt +dmesg_dumps $OUTFILE diff --git a/tools/testing/selftests/cpufreq/module.sh b/tools/testing/se= lftests/cpufreq/module.sh new file mode 100755 index 0000000..8ff2244 --- /dev/null +++ b/tools/testing/selftests/cpufreq/module.sh @@ -0,0 +1,243 @@ +#!/bin/bash +# +# Modules specific tests cases + +# protect against multiple inclusion +if [ $FILE_MODULE ]; then + return 0 +else + FILE_MODULE=3DDONE +fi + +source cpu.sh +source cpufreq.sh +source governor.sh + +# Check basic insmod/rmmod +# $1: module +test_basic_insmod_rmmod() +{ + printf "** Test: Running ${FUNCNAME[0]} **\n\n" + + printf "Inserting $1 module\n" + # insert module + insmod $1 + if [ $? !=3D 0 ]; then + printf "Insmod $1 failed\n" + exit; + fi + + printf "Removing $1 module\n" + # remove module + rmmod $1 + if [ $? !=3D 0 ]; then + printf "rmmod $1 failed\n" + exit; + fi + + printf "\n" +} + +# Insert cpufreq driver module and perform basic tests +# $1: cpufreq-driver module to insert +# $2: If we want to play with CPUs (1) or not (0) +module_driver_test_single() +{ + printf "** Test: Running ${FUNCNAME[0]} for driver $1 and cpus_hotplug=3D= $2 **\n\n" + + if [ $2 -eq 1 ]; then + # offline all non-boot CPUs + for_each_non_boot_cpu offline_cpu + printf "\n" + fi + + # insert module + printf "Inserting $1 module\n\n" + insmod $1 + if [ $? !=3D 0 ]; then + printf "Insmod $1 failed\n" + return; + fi + + if [ $2 -eq 1 ]; then + # online all non-boot CPUs + for_each_non_boot_cpu online_cpu + printf "\n" + fi + + # run basic tests + cpufreq_basic_tests + + # remove module + printf "Removing $1 module\n\n" + rmmod $1 + if [ $? !=3D 0 ]; then + printf "rmmod $1 failed\n" + return; + fi + + # There shouldn't be any cpufreq directories now. + for_each_cpu cpu_should_not_have_cpufreq_directory + printf "\n" +} + +# $1: cpufreq-driver module to insert +module_driver_test() +{ + printf "** Test: Running ${FUNCNAME[0]} **\n\n" + + # check if module is present or not + ls $1 > /dev/null + if [ $? !=3D 0 ]; then + printf "$1: not present in `pwd` folder\n" + return; + fi + + # test basic module tests + test_basic_insmod_rmmod $1 + + # Do simple module test + module_driver_test_single $1 0 + + # Remove CPUs before inserting module and then bring them back + module_driver_test_single $1 1 + printf "\n" +} + +# find governor name based on governor module name +# $1: governor module name +find_gov_name() +{ + if [ $1 =3D "cpufreq_ondemand.ko" ]; then + printf "ondemand" + elif [ $1 =3D "cpufreq_conservative.ko" ]; then + printf "conservative" + elif [ $1 =3D "cpufreq_userspace.ko" ]; then + printf "userspace" + elif [ $1 =3D "cpufreq_performance.ko" ]; then + printf "performance" + elif [ $1 =3D "cpufreq_powersave.ko" ]; then + printf "powersave" + elif [ $1 =3D "cpufreq_schedutil.ko" ]; then + printf "schedutil" + fi +} + +# $1: governor string, $2: governor module, $3: policy +# example: module_governor_test_single "ondemand" "cpufreq_ondemand.ko" = 2 +module_governor_test_single() +{ + printf "** Test: Running ${FUNCNAME[0]} for $3 **\n\n" + + backup_governor $3 + + # switch to new governor + printf "Switch from $CUR_GOV to $1\n" + switch_show_governor $3 $1 + + # try removing module, it should fail as governor is used + printf "Removing $2 module\n\n" + rmmod $2 + if [ $? =3D 0 ]; then + printf "WARN: rmmod $2 succeeded even if governor is used\n" + insmod $2 + else + printf "Pass: unable to remove $2 while it is being used\n\n" + fi + + # switch back to old governor + printf "Switchback to $CUR_GOV from $1\n" + restore_governor $3 + printf "\n" +} + +# Insert cpufreq governor module and perform basic tests +# $1: cpufreq-governor module to insert +module_governor_test() +{ + printf "** Test: Running ${FUNCNAME[0]} **\n\n" + + # check if module is present or not + ls $1 > /dev/null + if [ $? !=3D 0 ]; then + printf "$1: not present in `pwd` folder\n" + return; + fi + + # test basic module tests + test_basic_insmod_rmmod $1 + + # insert module + printf "Inserting $1 module\n\n" + insmod $1 + if [ $? !=3D 0 ]; then + printf "Insmod $1 failed\n" + return; + fi + + # switch to new governor for each cpu + for_each_policy module_governor_test_single $(find_gov_name $1) $1 + + # remove module + printf "Removing $1 module\n\n" + rmmod $1 + if [ $? !=3D 0 ]; then + printf "rmmod $1 failed\n" + return; + fi + printf "\n" +} + +# test modules: driver and governor +# $1: driver module, $2: governor module +module_test() +{ + printf "** Test: Running ${FUNCNAME[0]} **\n\n" + + # check if modules are present or not + ls $1 $2 > /dev/null + if [ $? !=3D 0 ]; then + printf "$1 or $2: is not present in `pwd` folder\n" + return; + fi + + # TEST1: Insert gov after driver + # insert driver module + printf "Inserting $1 module\n\n" + insmod $1 + if [ $? !=3D 0 ]; then + printf "Insmod $1 failed\n" + return; + fi + + # run governor tests + module_governor_test $2 + + # remove driver module + printf "Removing $1 module\n\n" + rmmod $1 + if [ $? !=3D 0 ]; then + printf "rmmod $1 failed\n" + return; + fi + + # TEST2: Insert driver after governor + # insert governor module + printf "Inserting $2 module\n\n" + insmod $2 + if [ $? !=3D 0 ]; then + printf "Insmod $2 failed\n" + return; + fi + + # run governor tests + module_driver_test $1 + + # remove driver module + printf "Removing $2 module\n\n" + rmmod $2 + if [ $? !=3D 0 ]; then + printf "rmmod $2 failed\n" + return; + fi +} diff --git a/tools/testing/selftests/cpufreq/special-tests.sh b/tools/tes= ting/selftests/cpufreq/special-tests.sh new file mode 100755 index 0000000..58b730f --- /dev/null +++ b/tools/testing/selftests/cpufreq/special-tests.sh @@ -0,0 +1,115 @@ +#!/bin/bash +# +# Special test cases reported by people + +# Testcase 1: Reported here: http://marc.info/?l=3Dlinux-pm&m=3D14061859= 2709858&w=3D2 + +# protect against multiple inclusion +if [ $FILE_SPECIAL ]; then + return 0 +else + FILE_SPECIAL=3DDONE +fi + +source cpu.sh +source cpufreq.sh +source governor.sh + +# Test 1 +# $1: policy +__simple_lockdep() +{ + # switch to ondemand + __switch_governor $1 "ondemand" + + # cat ondemand files + local ondir=3D$(find_gov_directory $1 "ondemand") + if [ -z $ondir ]; then + printf "${FUNCNAME[0]}Ondemand directory not created, quit" + return + fi + + cat $ondir/* + + # switch to conservative + __switch_governor $1 "conservative" +} + +simple_lockdep() +{ + printf "** Test: Running ${FUNCNAME[0]} **\n" + + for_each_policy __simple_lockdep +} + +# Test 2 +# $1: policy +__concurrent_lockdep() +{ + for i in `seq 0 100`; do + __simple_lockdep $1 + done +} + +concurrent_lockdep() +{ + printf "** Test: Running ${FUNCNAME[0]} **\n" + + for_each_policy_concurrent __concurrent_lockdep +} + +# Test 3 +quick_shuffle() +{ + # this is called concurrently from governor_race + for I in `seq 1000` + do + echo ondemand | sudo tee $CPUFREQROOT/policy*/scaling_governor & + echo userspace | sudo tee $CPUFREQROOT/policy*/scaling_governor & + done +} + +governor_race() +{ + printf "** Test: Running ${FUNCNAME[0]} **\n" + + # run 8 concurrent instances + for I in `seq 8` + do + quick_shuffle & + done +} + +# Test 4 +# $1: cpu +hotplug_with_updates_cpu() +{ + local filepath=3D"$CPUROOT/$1/cpufreq" + + # switch to ondemand + __switch_governor_for_cpu $1 "ondemand" + + for i in `seq 1 5000` + do + reboot_cpu $1 + done & + + local freqs=3D$(cat $filepath/scaling_available_frequencies) + local oldfreq=3D$(cat $filepath/scaling_min_freq) + + for j in `seq 1 5000` + do + # Set all frequencies one-by-one + for freq in $freqs; do + echo $freq > $filepath/scaling_min_freq + done + done + + # restore old freq + echo $oldfreq > $filepath/scaling_min_freq +} + +hotplug_with_updates() +{ + for_each_non_boot_cpu hotplug_with_updates_cpu +} diff --git a/tools/testing/selftests/efivarfs/Makefile b/tools/testing/se= lftests/efivarfs/Makefile index 736c3dd..c49dcea 100644 --- a/tools/testing/selftests/efivarfs/Makefile +++ b/tools/testing/selftests/efivarfs/Makefile @@ -1,13 +1,7 @@ CFLAGS =3D -Wall =20 -test_objs =3D open-unlink create-read - -all: $(test_objs) - +TEST_GEN_FILES :=3D open-unlink create-read TEST_PROGS :=3D efivarfs.sh -TEST_FILES :=3D $(test_objs) =20 include ../lib.mk =20 -clean: - rm -f $(test_objs) diff --git a/tools/testing/selftests/exec/Makefile b/tools/testing/selfte= sts/exec/Makefile index d430060..2e13035 100644 --- a/tools/testing/selftests/exec/Makefile +++ b/tools/testing/selftests/exec/Makefile @@ -1,27 +1,23 @@ CFLAGS =3D -Wall -BINARIES =3D execveat -DEPS =3D execveat.symlink execveat.denatured script subdir -all: $(BINARIES) $(DEPS) =20 -subdir: +TEST_GEN_PROGS :=3D execveat +TEST_GEN_FILES :=3D execveat.symlink execveat.denatured script subdir +# Makefile is a run-time dependency, since it's accessed by the execveat= test +TEST_FILES :=3D Makefile + +EXTRA_CLEAN :=3D $(OUTPUT)/subdir.moved $(OUTPUT)/execveat.moved $(OUTPU= T)/xxxxx* + +include ../lib.mk + +$(OUTPUT)/subdir: mkdir -p $@ -script: +$(OUTPUT)/script: echo '#!/bin/sh' > $@ echo 'exit $$*' >> $@ chmod +x $@ -execveat.symlink: execveat - ln -s -f $< $@ -execveat.denatured: execveat +$(OUTPUT)/execveat.symlink: $(OUTPUT)/execveat + cd $(OUTPUT) && ln -s -f $(shell basename $<) $(shell basename $@) +$(OUTPUT)/execveat.denatured: $(OUTPUT)/execveat cp $< $@ chmod -x $@ -%: %.c - $(CC) $(CFLAGS) -o $@ $^ - -TEST_PROGS :=3D execveat -# Makefile is a run-time dependency, since it's accessed by the execveat= test -TEST_FILES :=3D $(DEPS) Makefile - -include ../lib.mk =20 -clean: - rm -rf $(BINARIES) $(DEPS) subdir.moved execveat.moved xxxxx* diff --git a/tools/testing/selftests/ftrace/Makefile b/tools/testing/self= tests/ftrace/Makefile index 4e6ed13..a8a5e21 100644 --- a/tools/testing/selftests/ftrace/Makefile +++ b/tools/testing/selftests/ftrace/Makefile @@ -1,9 +1,7 @@ all: =20 TEST_PROGS :=3D ftracetest -TEST_DIRS :=3D test.d +TEST_FILES :=3D test.d +EXTRA_CLEAN :=3D $(OUTPUT)/logs/* =20 include ../lib.mk - -clean: - rm -rf logs/* diff --git a/tools/testing/selftests/futex/Makefile b/tools/testing/selft= ests/futex/Makefile index 6a17529..653c5cd 100644 --- a/tools/testing/selftests/futex/Makefile +++ b/tools/testing/selftests/futex/Makefile @@ -3,13 +3,18 @@ SUBDIRS :=3D functional TEST_PROGS :=3D run.sh =20 .PHONY: all clean -all: - for DIR in $(SUBDIRS); do $(MAKE) -C $$DIR $@ ; done =20 include ../lib.mk =20 +all: + for DIR in $(SUBDIRS); do \ + BUILD_TARGET=3D$$OUTPUT/$$DIR; \ + mkdir $$BUILD_TARGET -p; \ + make OUTPUT=3D$$BUILD_TARGET -C $$DIR $@;\ + done + override define RUN_TESTS - ./run.sh + @if [ `dirname $(OUTPUT)` =3D $(PWD) ]; then ./run.sh; fi endef =20 override define INSTALL_RULE @@ -17,7 +22,9 @@ override define INSTALL_RULE install -t $(INSTALL_PATH) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_= FILES) =20 @for SUBDIR in $(SUBDIRS); do \ - $(MAKE) -C $$SUBDIR INSTALL_PATH=3D$(INSTALL_PATH)/$$SUBDIR install; \= + BUILD_TARGET=3D$$OUTPUT/$$SUBDIR; \ + mkdir $$BUILD_TARGET -p; \ + $(MAKE) OUTPUT=3D$$BUILD_TARGET -C $$SUBDIR INSTALL_PATH=3D$(INSTALL_P= ATH)/$$SUBDIR install; \ done; endef =20 @@ -26,4 +33,8 @@ override define EMIT_TESTS endef =20 clean: - for DIR in $(SUBDIRS); do $(MAKE) -C $$DIR $@ ; done + for DIR in $(SUBDIRS); do \ + BUILD_TARGET=3D$$OUTPUT/$$DIR; \ + mkdir $$BUILD_TARGET -p; \ + make OUTPUT=3D$$BUILD_TARGET -C $$DIR $@;\ + done diff --git a/tools/testing/selftests/futex/functional/Makefile b/tools/te= sting/selftests/futex/functional/Makefile index 9d6b75e..a648e7a 100644 --- a/tools/testing/selftests/futex/functional/Makefile +++ b/tools/testing/selftests/futex/functional/Makefile @@ -2,8 +2,11 @@ INCLUDES :=3D -I../include -I../../ CFLAGS :=3D $(CFLAGS) -g -O2 -Wall -D_GNU_SOURCE -pthread $(INCLUDES) LDFLAGS :=3D $(LDFLAGS) -pthread -lrt =20 -HEADERS :=3D ../include/futextest.h -TARGETS :=3D \ +HEADERS :=3D \ + ../include/futextest.h \ + ../include/atomic.h \ + ../include/logging.h +TEST_GEN_FILES :=3D \ futex_wait_timeout \ futex_wait_wouldblock \ futex_requeue_pi \ @@ -12,14 +15,8 @@ TARGETS :=3D \ futex_wait_uninitialized_heap \ futex_wait_private_mapped_file =20 -TEST_PROGS :=3D $(TARGETS) run.sh - -.PHONY: all clean -all: $(TARGETS) - -$(TARGETS): $(HEADERS) +TEST_PROGS :=3D run.sh =20 include ../../lib.mk =20 -clean: - rm -f $(TARGETS) +$(TEST_GEN_FILES): $(HEADERS) diff --git a/tools/testing/selftests/futex/include/logging.h b/tools/test= ing/selftests/futex/include/logging.h index 014aa01..e144691 100644 --- a/tools/testing/selftests/futex/include/logging.h +++ b/tools/testing/selftests/futex/include/logging.h @@ -21,6 +21,7 @@ #ifndef _LOGGING_H #define _LOGGING_H =20 +#include #include #include #include diff --git a/tools/testing/selftests/gpio/.gitignore b/tools/testing/self= tests/gpio/.gitignore new file mode 100644 index 0000000..7d14f74 --- /dev/null +++ b/tools/testing/selftests/gpio/.gitignore @@ -0,0 +1 @@ +gpio-mockup-chardev diff --git a/tools/testing/selftests/intel_pstate/Makefile b/tools/testin= g/selftests/intel_pstate/Makefile index f5f1a28..19678e9 100644 --- a/tools/testing/selftests/intel_pstate/Makefile +++ b/tools/testing/selftests/intel_pstate/Makefile @@ -1,15 +1,10 @@ -CC :=3D $(CROSS_COMPILE)gcc CFLAGS :=3D $(CFLAGS) -Wall -D_GNU_SOURCE LDFLAGS :=3D $(LDFLAGS) -lm =20 -TARGETS :=3D msr aperf +TEST_GEN_FILES :=3D msr aperf =20 -TEST_PROGS :=3D $(TARGETS) run.sh +TEST_PROGS :=3D run.sh =20 -.PHONY: all clean -all: $(TARGETS) +include ../lib.mk =20 -$(TARGETS): $(HEADERS) - -clean: - rm -f $(TARGETS) +$(TEST_GEN_FILES): $(HEADERS) diff --git a/tools/testing/selftests/intel_pstate/aperf.c b/tools/testing= /selftests/intel_pstate/aperf.c index 6046e18..cd72f3d 100644 --- a/tools/testing/selftests/intel_pstate/aperf.c +++ b/tools/testing/selftests/intel_pstate/aperf.c @@ -14,7 +14,7 @@ void usage(char *name) { } =20 int main(int argc, char **argv) { - int i, cpu, fd; + unsigned int i, cpu, fd; char msr_file_name[64]; long long tsc, old_tsc, new_tsc; long long aperf, old_aperf, new_aperf; diff --git a/tools/testing/selftests/ipc/.gitignore b/tools/testing/selft= ests/ipc/.gitignore index 84b66a3..9af04c9 100644 --- a/tools/testing/selftests/ipc/.gitignore +++ b/tools/testing/selftests/ipc/.gitignore @@ -1 +1,2 @@ msgque_test +msgque diff --git a/tools/testing/selftests/ipc/Makefile b/tools/testing/selftes= ts/ipc/Makefile index 25d2e70..30ef4c7 100644 --- a/tools/testing/selftests/ipc/Makefile +++ b/tools/testing/selftests/ipc/Makefile @@ -11,12 +11,7 @@ endif =20 CFLAGS +=3D -I../../../../usr/include/ =20 -all: - $(CC) $(CFLAGS) msgque.c -o msgque_test - -TEST_PROGS :=3D msgque_test +TEST_GEN_PROGS :=3D msgque =20 include ../lib.mk =20 -clean: - rm -fr ./msgque_test diff --git a/tools/testing/selftests/kcmp/Makefile b/tools/testing/selfte= sts/kcmp/Makefile index 2ae7450..47aa988 100644 --- a/tools/testing/selftests/kcmp/Makefile +++ b/tools/testing/selftests/kcmp/Makefile @@ -1,10 +1,8 @@ CFLAGS +=3D -I../../../../usr/include/ =20 -all: kcmp_test +TEST_GEN_PROGS :=3D kcmp_test =20 -TEST_PROGS :=3D kcmp_test +EXTRA_CLEAN :=3D $(OUTPUT)/kcmp-test-file =20 include ../lib.mk =20 -clean: - $(RM) kcmp_test kcmp-test-file diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib= =2Emk index 50a93f5..ce96d80 100644 --- a/tools/testing/selftests/lib.mk +++ b/tools/testing/selftests/lib.mk @@ -2,9 +2,15 @@ # Makefile can operate with or without the kbuild infrastructure. CC :=3D $(CROSS_COMPILE)gcc =20 +TEST_GEN_PROGS :=3D $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS)) +TEST_GEN_FILES :=3D $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_FILES)) + +all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) + define RUN_TESTS - @for TEST in $(TEST_PROGS); do \ - (./$$TEST && echo "selftests: $$TEST [PASS]") || echo "selftests: $$TE= ST [FAIL]"; \ + @for TEST in $(TEST_GEN_PROGS) $(TEST_PROGS); do \ + BASENAME_TEST=3D`basename $$TEST`; \ + cd `dirname $$TEST`; (./$$BASENAME_TEST && echo "selftests: $$BASENAME= _TEST [PASS]") || echo "selftests: $$BASENAME_TEST [FAIL]"; cd -;\ done; endef =20 @@ -14,8 +20,13 @@ run_tests: all define INSTALL_RULE @if [ "X$(TEST_PROGS)$(TEST_PROGS_EXTENDED)$(TEST_FILES)" !=3D "X" ]; t= hen \ mkdir -p ${INSTALL_PATH}; \ - echo "rsync -a $(TEST_DIRS) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TES= T_FILES) $(INSTALL_PATH)/"; \ - rsync -a $(TEST_DIRS) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILE= S) $(INSTALL_PATH)/; \ + 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 \ + 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)/; \ fi endef =20 @@ -27,12 +38,25 @@ else endif =20 define EMIT_TESTS - @for TEST in $(TEST_PROGS); do \ - echo "(./$$TEST && echo \"selftests: $$TEST [PASS]\") || echo \"selfte= sts: $$TEST [FAIL]\""; \ + @for TEST in $(TEST_GEN_PROGS) $(TEST_PROGS); do \ + BASENAME_TEST=3D`basename $$TEST`; \ + echo "(./$$BASENAME_TEST && echo \"selftests: $$BASENAME_TEST [PASS]\"= ) || echo \"selftests: $$BASENAME_TEST [FAIL]\""; \ done; endef =20 emit_tests: $(EMIT_TESTS) =20 +clean: + $(RM) -r $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES)= $(EXTRA_CLEAN) + +$(OUTPUT)/%:%.c + $(LINK.c) $^ $(LDLIBS) -o $@ + +$(OUTPUT)/%.o:%.S + $(COMPILE.S) $^ -o $@ + +$(OUTPUT)/%:%.S + $(LINK.S) $^ $(LDLIBS) -o $@ + .PHONY: run_tests all clean install emit_tests diff --git a/tools/testing/selftests/membarrier/Makefile b/tools/testing/= selftests/membarrier/Makefile index a1a9708..0284553 100644 --- a/tools/testing/selftests/membarrier/Makefile +++ b/tools/testing/selftests/membarrier/Makefile @@ -1,10 +1,6 @@ CFLAGS +=3D -g -I../../../../usr/include/ =20 -TEST_PROGS :=3D membarrier_test - -all: $(TEST_PROGS) +TEST_GEN_PROGS :=3D membarrier_test =20 include ../lib.mk =20 -clean: - $(RM) $(TEST_PROGS) diff --git a/tools/testing/selftests/memfd/Makefile b/tools/testing/selft= ests/memfd/Makefile index fd396ac..79891d0 100644 --- a/tools/testing/selftests/memfd/Makefile +++ b/tools/testing/selftests/memfd/Makefile @@ -1,22 +1,13 @@ -CC =3D $(CROSS_COMPILE)gcc CFLAGS +=3D -D_FILE_OFFSET_BITS=3D64 CFLAGS +=3D -I../../../../include/uapi/ CFLAGS +=3D -I../../../../include/ CFLAGS +=3D -I../../../../usr/include/ =20 -TEST_PROGS :=3D memfd_test - -all: $(TEST_PROGS) - -include ../lib.mk - -build_fuse: fuse_mnt fuse_test +TEST_PROGS :=3D run_fuse_test.sh +TEST_GEN_FILES :=3D memfd_test fuse_mnt fuse_test =20 fuse_mnt.o: CFLAGS +=3D $(shell pkg-config fuse --cflags) fuse_mnt: LDFLAGS +=3D $(shell pkg-config fuse --libs) =20 -run_fuse: build_fuse - @./run_fuse_test.sh || echo "fuse_test: [FAIL]" +include ../lib.mk =20 -clean: - $(RM) memfd_test fuse_test diff --git a/tools/testing/selftests/mount/Makefile b/tools/testing/selft= ests/mount/Makefile index 5e35c9c..9093d7f 100644 --- a/tools/testing/selftests/mount/Makefile +++ b/tools/testing/selftests/mount/Makefile @@ -1,14 +1,11 @@ # Makefile for mount selftests. CFLAGS =3D -Wall \ -O2 -all: unprivileged-remount-test =20 -unprivileged-remount-test: unprivileged-remount-test.c - $(CC) $(CFLAGS) unprivileged-remount-test.c -o unprivileged-remount-tes= t +TEST_GEN_PROGS :=3D unprivileged-remount-test =20 include ../lib.mk =20 -TEST_PROGS :=3D unprivileged-remount-test override RUN_TESTS :=3D if [ -f /proc/self/uid_map ] ; \ then \ ./unprivileged-remount-test ; \ @@ -17,5 +14,3 @@ override RUN_TESTS :=3D if [ -f /proc/self/uid_map ] ; = \ fi override EMIT_TESTS :=3D echo "$(RUN_TESTS)" =20 -clean: - rm -f unprivileged-remount-test diff --git a/tools/testing/selftests/mqueue/Makefile b/tools/testing/self= tests/mqueue/Makefile index eebac29..79a664a 100644 --- a/tools/testing/selftests/mqueue/Makefile +++ b/tools/testing/selftests/mqueue/Makefile @@ -1,8 +1,6 @@ CFLAGS +=3D -O2 LDLIBS =3D -lrt -lpthread -lpopt -TEST_PROGS :=3D mq_open_tests mq_perf_tests - -all: $(TEST_PROGS) +TEST_GEN_PROGS :=3D mq_open_tests mq_perf_tests =20 include ../lib.mk =20 @@ -16,5 +14,3 @@ override define EMIT_TESTS echo "./mq_perf_tests || echo \"selftests: mq_perf_tests [FAIL]\"" endef =20 -clean: - rm -f mq_open_tests mq_perf_tests diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftes= ts/net/Makefile index e24e4c8..fbfe5d0 100644 --- a/tools/testing/selftests/net/Makefile +++ b/tools/testing/selftests/net/Makefile @@ -3,20 +3,13 @@ CFLAGS =3D -Wall -Wl,--no-as-needed -O2 -g CFLAGS +=3D -I../../../../usr/include/ =20 -NET_PROGS =3D socket -NET_PROGS +=3D psock_fanout psock_tpacket -NET_PROGS +=3D reuseport_bpf reuseport_bpf_cpu reuseport_bpf_numa -NET_PROGS +=3D reuseport_dualstack - -all: $(NET_PROGS) reuseport_bpf_numa: LDFLAGS +=3D -lnuma -%: %.c - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ =20 TEST_PROGS :=3D run_netsocktests run_afpackettests test_bpf.sh -TEST_FILES :=3D $(NET_PROGS) +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 =20 include ../lib.mk =20 -clean: - $(RM) $(NET_PROGS) diff --git a/tools/testing/selftests/nsfs/Makefile b/tools/testing/selfte= sts/nsfs/Makefile index 2306054..9ff7c7f 100644 --- a/tools/testing/selftests/nsfs/Makefile +++ b/tools/testing/selftests/nsfs/Makefile @@ -1,12 +1,5 @@ -TEST_PROGS :=3D owner pidns +TEST_GEN_PROGS :=3D owner pidns =20 CFLAGS :=3D -Wall -Werror =20 -all: owner pidns -owner: owner.c -pidns: pidns.c - -clean: - $(RM) owner pidns - include ../lib.mk diff --git a/tools/testing/selftests/powerpc/Makefile b/tools/testing/sel= ftests/powerpc/Makefile index c2c4211..1c5d057 100644 --- a/tools/testing/selftests/powerpc/Makefile +++ b/tools/testing/selftests/powerpc/Makefile @@ -34,31 +34,35 @@ endif all: $(SUB_DIRS) =20 $(SUB_DIRS): - $(MAKE) -k -C $@ all + BUILD_TARGET=3D$$OUTPUT/$@; mkdir -p $$BUILD_TARGET; $(MAKE) OUTPUT=3D$= $BUILD_TARGET -k -C $@ all =20 include ../lib.mk =20 override define RUN_TESTS @for TARGET in $(SUB_DIRS); do \ - $(MAKE) -C $$TARGET run_tests; \ + BUILD_TARGET=3D$$OUTPUT/$$TARGET; \ + $(MAKE) OUTPUT=3D$$BUILD_TARGET -C $$TARGET run_tests;\ done; endef =20 override define INSTALL_RULE @for TARGET in $(SUB_DIRS); do \ - $(MAKE) -C $$TARGET install; \ + BUILD_TARGET=3D$$OUTPUT/$$TARGET; \ + $(MAKE) OUTPUT=3D$$BUILD_TARGET -C $$TARGET install;\ done; endef =20 override define EMIT_TESTS @for TARGET in $(SUB_DIRS); do \ - $(MAKE) -s -C $$TARGET emit_tests; \ + BUILD_TARGET=3D$$OUTPUT/$$TARGET; \ + $(MAKE) OUTPUT=3D$$BUILD_TARGET -s -C $$TARGET emit_tests;\ done; endef =20 clean: @for TARGET in $(SUB_DIRS); do \ - $(MAKE) -C $$TARGET clean; \ + BUILD_TARGET=3D$$OUTPUT/$$TARGET; \ + $(MAKE) OUTPUT=3D$$BUILD_TARGET -C $$TARGET clean; \ done; rm -f tags =20 diff --git a/tools/testing/selftests/powerpc/alignment/Makefile b/tools/t= esting/selftests/powerpc/alignment/Makefile index ad6a4e4..16b2200 100644 --- a/tools/testing/selftests/powerpc/alignment/Makefile +++ b/tools/testing/selftests/powerpc/alignment/Makefile @@ -1,10 +1,5 @@ -TEST_PROGS :=3D copy_unaligned copy_first_unaligned paste_unaligned past= e_last_unaligned - -all: $(TEST_PROGS) - -$(TEST_PROGS): ../harness.c ../utils.c copy_paste_unaligned_common.c +TEST_GEN_PROGS :=3D copy_unaligned copy_first_unaligned paste_unaligned = paste_last_unaligned =20 include ../../lib.mk =20 -clean: - rm -f $(TEST_PROGS) +$(TEST_GEN_PROGS): ../harness.c ../utils.c copy_paste_unaligned_common.c= diff --git a/tools/testing/selftests/powerpc/benchmarks/Makefile b/tools/= testing/selftests/powerpc/benchmarks/Makefile index 545077f..fb96a89 100644 --- a/tools/testing/selftests/powerpc/benchmarks/Makefile +++ b/tools/testing/selftests/powerpc/benchmarks/Makefile @@ -1,16 +1,11 @@ -TEST_PROGS :=3D gettimeofday context_switch mmap_bench futex_bench null_= syscall +TEST_GEN_PROGS :=3D gettimeofday context_switch mmap_bench futex_bench n= ull_syscall =20 CFLAGS +=3D -O2 =20 -all: $(TEST_PROGS) - -$(TEST_PROGS): ../harness.c - -context_switch: ../utils.c -context_switch: CFLAGS +=3D -maltivec -mvsx -mabi=3Daltivec -context_switch: LDLIBS +=3D -lpthread - include ../../lib.mk =20 -clean: - rm -f $(TEST_PROGS) *.o +$(TEST_GEN_PROGS): ../harness.c + +$(OUTPUT)/context_switch: ../utils.c +$(OUTPUT)/context_switch: CFLAGS +=3D -maltivec -mvsx -mabi=3Daltivec +$(OUTPUT)/context_switch: LDLIBS +=3D -lpthread diff --git a/tools/testing/selftests/powerpc/context_switch/Makefile b/to= ols/testing/selftests/powerpc/context_switch/Makefile index e164d14..e9351bb 100644 --- a/tools/testing/selftests/powerpc/context_switch/Makefile +++ b/tools/testing/selftests/powerpc/context_switch/Makefile @@ -1,10 +1,5 @@ -TEST_PROGS :=3D cp_abort - -all: $(TEST_PROGS) - -$(TEST_PROGS): ../harness.c ../utils.c +TEST_GEN_PROGS :=3D cp_abort =20 include ../../lib.mk =20 -clean: - rm -f $(TEST_PROGS) +$(TEST_GEN_PROGS): ../harness.c ../utils.c diff --git a/tools/testing/selftests/powerpc/copyloops/Makefile b/tools/t= esting/selftests/powerpc/copyloops/Makefile index 384843e..681ab19 100644 --- a/tools/testing/selftests/powerpc/copyloops/Makefile +++ b/tools/testing/selftests/powerpc/copyloops/Makefile @@ -7,19 +7,14 @@ CFLAGS +=3D -maltivec # Use our CFLAGS for the implicit .S rule ASFLAGS =3D $(CFLAGS) =20 -TEST_PROGS :=3D copyuser_64 copyuser_power7 memcpy_64 memcpy_power7 +TEST_GEN_PROGS :=3D copyuser_64 copyuser_power7 memcpy_64 memcpy_power7 EXTRA_SOURCES :=3D validate.c ../harness.c =20 -all: $(TEST_PROGS) - -copyuser_64: CPPFLAGS +=3D -D COPY_LOOP=3Dtest___copy_tofrom_user_ba= se -copyuser_power7: CPPFLAGS +=3D -D COPY_LOOP=3Dtest___copy_tofrom_user_po= wer7 -memcpy_64: CPPFLAGS +=3D -D COPY_LOOP=3Dtest_memcpy -memcpy_power7: CPPFLAGS +=3D -D COPY_LOOP=3Dtest_memcpy_power7 - -$(TEST_PROGS): $(EXTRA_SOURCES) - include ../../lib.mk =20 -clean: - rm -f $(TEST_PROGS) *.o +$(OUTPUT)/copyuser_64: CPPFLAGS +=3D -D COPY_LOOP=3Dtest___copy_tofr= om_user_base +$(OUTPUT)/copyuser_power7: CPPFLAGS +=3D -D COPY_LOOP=3Dtest___copy_tofr= om_user_power7 +$(OUTPUT)/memcpy_64: CPPFLAGS +=3D -D COPY_LOOP=3Dtest_memcpy +$(OUTPUT)/memcpy_power7: CPPFLAGS +=3D -D COPY_LOOP=3Dtest_memcpy_powe= r7 + +$(TEST_GEN_PROGS): $(EXTRA_SOURCES) diff --git a/tools/testing/selftests/powerpc/dscr/Makefile b/tools/testin= g/selftests/powerpc/dscr/Makefile index 49327ee..c5639de 100644 --- a/tools/testing/selftests/powerpc/dscr/Makefile +++ b/tools/testing/selftests/powerpc/dscr/Makefile @@ -1,14 +1,9 @@ -TEST_PROGS :=3D dscr_default_test dscr_explicit_test dscr_user_test \ +TEST_GEN_PROGS :=3D dscr_default_test dscr_explicit_test dscr_user_test = \ dscr_inherit_test dscr_inherit_exec_test dscr_sysfs_test \ dscr_sysfs_thread_test =20 -dscr_default_test: LDLIBS +=3D -lpthread - -all: $(TEST_PROGS) - -$(TEST_PROGS): ../harness.c - include ../../lib.mk =20 -clean: - rm -f $(TEST_PROGS) *.o +$(OUTPUT)/dscr_default_test: LDLIBS +=3D -lpthread + +$(TEST_GEN_PROGS): ../harness.c diff --git a/tools/testing/selftests/powerpc/math/Makefile b/tools/testin= g/selftests/powerpc/math/Makefile index a505b66..fa8bae9 100644 --- a/tools/testing/selftests/powerpc/math/Makefile +++ b/tools/testing/selftests/powerpc/math/Makefile @@ -1,22 +1,17 @@ -TEST_PROGS :=3D fpu_syscall fpu_preempt fpu_signal vmx_syscall vmx_preem= pt vmx_signal vsx_preempt +TEST_GEN_PROGS :=3D fpu_syscall fpu_preempt fpu_signal vmx_syscall vmx_p= reempt vmx_signal vsx_preempt =20 -all: $(TEST_PROGS) - -$(TEST_PROGS): ../harness.c -$(TEST_PROGS): CFLAGS +=3D -O2 -g -pthread -m64 -maltivec - -fpu_syscall: fpu_asm.S -fpu_preempt: fpu_asm.S -fpu_signal: fpu_asm.S +include ../../lib.mk =20 -vmx_syscall: vmx_asm.S -vmx_preempt: vmx_asm.S -vmx_signal: vmx_asm.S +$(TEST_GEN_PROGS): ../harness.c +$(TEST_GEN_PROGS): CFLAGS +=3D -O2 -g -pthread -m64 -maltivec =20 -vsx_preempt: CFLAGS +=3D -mvsx -vsx_preempt: vsx_asm.S +$(OUTPUT)/fpu_syscall: fpu_asm.S +$(OUTPUT)/fpu_preempt: fpu_asm.S +$(OUTPUT)/fpu_signal: fpu_asm.S =20 -include ../../lib.mk +$(OUTPUT)/vmx_syscall: vmx_asm.S +$(OUTPUT)/vmx_preempt: vmx_asm.S +$(OUTPUT)/vmx_signal: vmx_asm.S =20 -clean: - rm -f $(TEST_PROGS) *.o +$(OUTPUT)/vsx_preempt: CFLAGS +=3D -mvsx +$(OUTPUT)/vsx_preempt: vsx_asm.S diff --git a/tools/testing/selftests/powerpc/mm/Makefile b/tools/testing/= selftests/powerpc/mm/Makefile index 3bdb96e..1cffe54 100644 --- a/tools/testing/selftests/powerpc/mm/Makefile +++ b/tools/testing/selftests/powerpc/mm/Makefile @@ -1,19 +1,15 @@ noarg: $(MAKE) -C ../ =20 -TEST_PROGS :=3D hugetlb_vs_thp_test subpage_prot prot_sao -TEST_FILES :=3D tempfile +TEST_GEN_PROGS :=3D hugetlb_vs_thp_test subpage_prot prot_sao +TEST_GEN_FILES :=3D tempfile =20 -all: $(TEST_PROGS) $(TEST_FILES) - -$(TEST_PROGS): ../harness.c +include ../../lib.mk =20 -prot_sao: ../utils.c +$(TEST_GEN_PROGS): ../harness.c =20 -include ../../lib.mk +$(OUTPUT)/prot_sao: ../utils.c =20 -tempfile: - dd if=3D/dev/zero of=3Dtempfile bs=3D64k count=3D1 +$(OUTPUT)/tempfile: + dd if=3D/dev/zero of=3D$@ bs=3D64k count=3D1 =20 -clean: - rm -f $(TEST_PROGS) tempfile diff --git a/tools/testing/selftests/powerpc/pmu/Makefile b/tools/testing= /selftests/powerpc/pmu/Makefile index ac41a71..e4e55d1 100644 --- a/tools/testing/selftests/powerpc/pmu/Makefile +++ b/tools/testing/selftests/powerpc/pmu/Makefile @@ -1,44 +1,44 @@ noarg: $(MAKE) -C ../ =20 -TEST_PROGS :=3D count_instructions l3_bank_test per_event_excludes +TEST_GEN_PROGS :=3D count_instructions l3_bank_test per_event_excludes EXTRA_SOURCES :=3D ../harness.c event.c lib.c ../utils.c =20 -all: $(TEST_PROGS) ebb +include ../../lib.mk + +all: $(TEST_GEN_PROGS) ebb =20 -$(TEST_PROGS): $(EXTRA_SOURCES) +$(TEST_GEN_PROGS): $(EXTRA_SOURCES) =20 # loop.S can only be built 64-bit -count_instructions: loop.S count_instructions.c $(EXTRA_SOURCES) +$(OUTPUT)/count_instructions: loop.S count_instructions.c $(EXTRA_SOURCE= S) $(CC) $(CFLAGS) -m64 -o $@ $^ =20 -per_event_excludes: ../utils.c - -include ../../lib.mk +$(OUTPUT)/per_event_excludes: ../utils.c =20 DEFAULT_RUN_TESTS :=3D $(RUN_TESTS) override define RUN_TESTS $(DEFAULT_RUN_TESTS) - $(MAKE) -C ebb run_tests + TARGET=3Debb; BUILD_TARGET=3D$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=3D$$BUIL= D_TARGET -C $$TARGET run_tests endef =20 DEFAULT_EMIT_TESTS :=3D $(EMIT_TESTS) override define EMIT_TESTS $(DEFAULT_EMIT_TESTS) - $(MAKE) -s -C ebb emit_tests + TARGET=3Debb; BUILD_TARGET=3D$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=3D$$BUIL= D_TARGET -s -C $$TARGET emit_tests endef =20 DEFAULT_INSTALL_RULE :=3D $(INSTALL_RULE) override define INSTALL_RULE $(DEFAULT_INSTALL_RULE) - $(MAKE) -C ebb install + TARGET=3Debb; BUILD_TARGET=3D$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=3D$$BUIL= D_TARGET -C $$TARGET install endef =20 clean: - rm -f $(TEST_PROGS) loop.o - $(MAKE) -C ebb clean + $(RM) $(TEST_GEN_PROGS) $(OUTPUT)/loop.o + TARGET=3Debb; BUILD_TARGET=3D$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=3D$$BUIL= D_TARGET -C $$TARGET clean =20 ebb: - $(MAKE) -k -C $@ all + TARGET=3D$@; BUILD_TARGET=3D$$OUTPUT/$$TARGET; mkdir -p $$BUILD_TARGET;= $(MAKE) OUTPUT=3D$$BUILD_TARGET -k -C $$TARGET all =20 .PHONY: all run_tests clean ebb diff --git a/tools/testing/selftests/powerpc/pmu/ebb/Makefile b/tools/tes= ting/selftests/powerpc/pmu/ebb/Makefile index 8d2279c4..6001fb0 100644 --- a/tools/testing/selftests/powerpc/pmu/ebb/Makefile +++ b/tools/testing/selftests/powerpc/pmu/ebb/Makefile @@ -4,7 +4,7 @@ noarg: # The EBB handler is 64-bit code and everything links against it CFLAGS +=3D -m64 =20 -TEST_PROGS :=3D reg_access_test event_attributes_test cycles_test \ +TEST_GEN_PROGS :=3D reg_access_test event_attributes_test cycles_test \ cycles_with_freeze_test pmc56_overflow_test \ ebb_vs_cpu_event_test cpu_event_vs_ebb_test \ cpu_event_pinned_vs_ebb_test task_event_vs_ebb_test \ @@ -16,16 +16,11 @@ TEST_PROGS :=3D reg_access_test event_attributes_test= cycles_test \ lost_exception_test no_handler_test \ cycles_with_mmcr2_test =20 -all: $(TEST_PROGS) +include ../../../lib.mk =20 -$(TEST_PROGS): ../../harness.c ../../utils.c ../event.c ../lib.c \ +$(TEST_GEN_PROGS): ../../harness.c ../../utils.c ../event.c ../lib.c \ ebb.c ebb_handler.S trace.c busy_loop.S =20 -instruction_count_test: ../loop.S - -lost_exception_test: ../lib.c - -include ../../../lib.mk +$(OUTPUT)/instruction_count_test: ../loop.S =20 -clean: - rm -f $(TEST_PROGS) +$(OUTPUT)/lost_exception_test: ../lib.c diff --git a/tools/testing/selftests/powerpc/primitives/Makefile b/tools/= testing/selftests/powerpc/primitives/Makefile index b68c622..175366d 100644 --- a/tools/testing/selftests/powerpc/primitives/Makefile +++ b/tools/testing/selftests/powerpc/primitives/Makefile @@ -1,12 +1,7 @@ CFLAGS +=3D -I$(CURDIR) =20 -TEST_PROGS :=3D load_unaligned_zeropad - -all: $(TEST_PROGS) - -$(TEST_PROGS): ../harness.c +TEST_GEN_PROGS :=3D load_unaligned_zeropad =20 include ../../lib.mk =20 -clean: - rm -f $(TEST_PROGS) *.o +$(TEST_GEN_PROGS): ../harness.c diff --git a/tools/testing/selftests/powerpc/stringloops/Makefile b/tools= /testing/selftests/powerpc/stringloops/Makefile index 2a728f4..557b937 100644 --- a/tools/testing/selftests/powerpc/stringloops/Makefile +++ b/tools/testing/selftests/powerpc/stringloops/Makefile @@ -2,14 +2,9 @@ CFLAGS +=3D -m64 CFLAGS +=3D -I$(CURDIR) =20 -TEST_PROGS :=3D memcmp +TEST_GEN_PROGS :=3D memcmp EXTRA_SOURCES :=3D memcmp_64.S ../harness.c =20 -all: $(TEST_PROGS) - -$(TEST_PROGS): $(EXTRA_SOURCES) - include ../../lib.mk =20 -clean: - rm -f $(TEST_PROGS) *.o +$(TEST_GEN_PROGS): $(EXTRA_SOURCES) diff --git a/tools/testing/selftests/powerpc/switch_endian/Makefile b/too= ls/testing/selftests/powerpc/switch_endian/Makefile index e21d106..b92c2a1 100644 --- a/tools/testing/selftests/powerpc/switch_endian/Makefile +++ b/tools/testing/selftests/powerpc/switch_endian/Makefile @@ -1,18 +1,15 @@ -TEST_PROGS :=3D switch_endian_test +TEST_GEN_PROGS :=3D switch_endian_test =20 ASFLAGS +=3D -O2 -Wall -g -nostdlib -m64 =20 -all: $(TEST_PROGS) +EXTRA_CLEAN =3D $(OUTPUT)/*.o $(OUTPUT)/check-reversed.S =20 -switch_endian_test: check-reversed.S +include ../../lib.mk + +$(OUTPUT)/switch_endian_test: $(OUTPUT)/check-reversed.S =20 -check-reversed.o: check.o +$(OUTPUT)/check-reversed.o: $(OUTPUT)/check.o $(CROSS_COMPILE)objcopy -j .text --reverse-bytes=3D4 -O binary $< $@ =20 -check-reversed.S: check-reversed.o +$(OUTPUT)/check-reversed.S: $(OUTPUT)/check-reversed.o hexdump -v -e '/1 ".byte 0x%02X\n"' $< > $@ - -include ../../lib.mk - -clean: - rm -f $(TEST_PROGS) *.o check-reversed.S diff --git a/tools/testing/selftests/powerpc/syscalls/Makefile b/tools/te= sting/selftests/powerpc/syscalls/Makefile index b35c794..da22ca7 100644 --- a/tools/testing/selftests/powerpc/syscalls/Makefile +++ b/tools/testing/selftests/powerpc/syscalls/Makefile @@ -1,12 +1,7 @@ -TEST_PROGS :=3D ipc_unmuxed +TEST_GEN_PROGS :=3D ipc_unmuxed =20 CFLAGS +=3D -I../../../../../usr/include =20 -all: $(TEST_PROGS) - -$(TEST_PROGS): ../harness.c - include ../../lib.mk =20 -clean: - rm -f $(TEST_PROGS) *.o +$(TEST_GEN_PROGS): ../harness.c diff --git a/tools/testing/selftests/powerpc/tm/Makefile b/tools/testing/= selftests/powerpc/tm/Makefile index c6c53c8..5576ee6 100644 --- a/tools/testing/selftests/powerpc/tm/Makefile +++ b/tools/testing/selftests/powerpc/tm/Makefile @@ -1,23 +1,19 @@ SIGNAL_CONTEXT_CHK_TESTS :=3D tm-signal-context-chk-gpr tm-signal-contex= t-chk-fpu \ tm-signal-context-chk-vmx tm-signal-context-chk-vsx =20 -TEST_PROGS :=3D tm-resched-dscr tm-syscall tm-signal-msr-resv tm-signal-= stack \ +TEST_GEN_PROGS :=3D tm-resched-dscr tm-syscall tm-signal-msr-resv tm-sig= nal-stack \ tm-vmxcopy tm-fork tm-tar tm-tmspr $(SIGNAL_CONTEXT_CHK_TESTS) =20 -all: $(TEST_PROGS) +include ../../lib.mk =20 -$(TEST_PROGS): ../harness.c ../utils.c +$(TEST_GEN_PROGS): ../harness.c ../utils.c =20 CFLAGS +=3D -mhtm =20 -tm-syscall: tm-syscall-asm.S -tm-syscall: CFLAGS +=3D -I../../../../../usr/include -tm-tmspr: CFLAGS +=3D -pthread +$(OUTPUT)/tm-syscall: tm-syscall-asm.S +$(OUTPUT)/tm-syscall: CFLAGS +=3D -I../../../../../usr/include +$(OUTPUT)/tm-tmspr: CFLAGS +=3D -pthread =20 +SIGNAL_CONTEXT_CHK_TESTS :=3D $(patsubst %,$(OUTPUT)/%,$(SIGNAL_CONTEXT_= CHK_TESTS)) $(SIGNAL_CONTEXT_CHK_TESTS): tm-signal.S $(SIGNAL_CONTEXT_CHK_TESTS): CFLAGS +=3D -mhtm -m64 -mvsx - -include ../../lib.mk - -clean: - rm -f $(TEST_PROGS) *.o diff --git a/tools/testing/selftests/powerpc/vphn/Makefile b/tools/testin= g/selftests/powerpc/vphn/Makefile index a485f2e..f8ced26 100644 --- a/tools/testing/selftests/powerpc/vphn/Makefile +++ b/tools/testing/selftests/powerpc/vphn/Makefile @@ -1,12 +1,8 @@ -TEST_PROGS :=3D test-vphn +TEST_GEN_PROGS :=3D test-vphn =20 CFLAGS +=3D -m64 =20 -all: $(TEST_PROGS) - -$(TEST_PROGS): ../harness.c - include ../../lib.mk =20 -clean: - rm -f $(TEST_PROGS) +$(TEST_GEN_PROGS): ../harness.c + diff --git a/tools/testing/selftests/pstore/Makefile b/tools/testing/self= tests/pstore/Makefile index bd7abe2..c5f2440 100644 --- a/tools/testing/selftests/pstore/Makefile +++ b/tools/testing/selftests/pstore/Makefile @@ -5,11 +5,9 @@ all: =20 TEST_PROGS :=3D pstore_tests pstore_post_reboot_tests TEST_FILES :=3D common_tests pstore_crash_test +EXTRA_CLEAN :=3D logs/* *uuid =20 include ../lib.mk =20 run_crash: @sh pstore_crash_test || { echo "pstore_crash_test: [FAIL]"; exit 1; } - -clean: - rm -rf logs/* *uuid diff --git a/tools/testing/selftests/ptrace/Makefile b/tools/testing/self= tests/ptrace/Makefile index 453927f..8a2bc55 100644 --- a/tools/testing/selftests/ptrace/Makefile +++ b/tools/testing/selftests/ptrace/Makefile @@ -1,11 +1,5 @@ CFLAGS +=3D -iquote../../../../include/uapi -Wall -peeksiginfo: peeksiginfo.c =20 -all: peeksiginfo - -clean: - rm -f peeksiginfo - -TEST_PROGS :=3D peeksiginfo +TEST_GEN_PROGS :=3D peeksiginfo =20 include ../lib.mk diff --git a/tools/testing/selftests/seccomp/Makefile b/tools/testing/sel= ftests/seccomp/Makefile index 8401e87..5fa6fd2 100644 --- a/tools/testing/selftests/seccomp/Makefile +++ b/tools/testing/selftests/seccomp/Makefile @@ -1,10 +1,6 @@ -TEST_PROGS :=3D seccomp_bpf +TEST_GEN_PROGS :=3D seccomp_bpf CFLAGS +=3D -Wl,-no-as-needed -Wall LDFLAGS +=3D -lpthread =20 -all: $(TEST_PROGS) - include ../lib.mk =20 -clean: - $(RM) $(TEST_PROGS) diff --git a/tools/testing/selftests/sigaltstack/Makefile b/tools/testing= /selftests/sigaltstack/Makefile index 56af56e..f68fbf8 100644 --- a/tools/testing/selftests/sigaltstack/Makefile +++ b/tools/testing/selftests/sigaltstack/Makefile @@ -1,8 +1,5 @@ CFLAGS =3D -Wall -BINARIES =3D sas -all: $(BINARIES) +TEST_GEN_PROGS =3D sas =20 include ../lib.mk =20 -clean: - rm -rf $(BINARIES) diff --git a/tools/testing/selftests/size/Makefile b/tools/testing/selfte= sts/size/Makefile index bbd0b53..4685b3e 100644 --- a/tools/testing/selftests/size/Makefile +++ b/tools/testing/selftests/size/Makefile @@ -1,11 +1,5 @@ -all: get_size +CFLAGS :=3D -static -ffreestanding -nostartfiles -s =20 -get_size: get_size.c - $(CC) -static -ffreestanding -nostartfiles -s $< -o $@ - -TEST_PROGS :=3D get_size +TEST_GEN_PROGS :=3D get_size =20 include ../lib.mk - -clean: - $(RM) get_size diff --git a/tools/testing/selftests/timers/Makefile b/tools/testing/self= tests/timers/Makefile index 1d55568..b90e50c 100644 --- a/tools/testing/selftests/timers/Makefile +++ b/tools/testing/selftests/timers/Makefile @@ -1,20 +1,16 @@ -CC =3D $(CROSS_COMPILE)gcc BUILD_FLAGS =3D -DKTEST CFLAGS +=3D -O3 -Wl,-no-as-needed -Wall $(BUILD_FLAGS) LDFLAGS +=3D -lrt -lpthread =20 # these are all "safe" tests that don't modify # system time or require escalated privledges -TEST_PROGS =3D posix_timers nanosleep nsleep-lat set-timer-lat mqueue-la= t \ +TEST_GEN_PROGS =3D posix_timers nanosleep nsleep-lat set-timer-lat mqueu= e-lat \ inconsistency-check raw_skew threadtest rtctest =20 -TEST_PROGS_EXTENDED =3D alarmtimer-suspend valid-adjtimex adjtick change= _skew \ +TEST_GEN_PROGS_EXTENDED =3D alarmtimer-suspend valid-adjtimex adjtick ch= ange_skew \ skew_consistency clocksource-switch leap-a-day \ leapcrash set-tai set-2038 set-tz =20 -bins =3D $(TEST_PROGS) $(TEST_PROGS_EXTENDED) - -all: ${bins} =20 include ../lib.mk =20 @@ -34,5 +30,3 @@ run_destructive_tests: run_tests ./set-tai ./set-2038 =20 -clean: - rm -f ${bins} diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftest= s/vm/Makefile index bbab7f4..983140e 100644 --- a/tools/testing/selftests/vm/Makefile +++ b/tools/testing/selftests/vm/Makefile @@ -1,33 +1,24 @@ # Makefile for vm selftests =20 CFLAGS =3D -Wall -I ../../../../usr/include $(EXTRA_CFLAGS) -BINARIES =3D compaction_test -BINARIES +=3D hugepage-mmap -BINARIES +=3D hugepage-shm -BINARIES +=3D map_hugetlb -BINARIES +=3D mlock2-tests -BINARIES +=3D on-fault-limit -BINARIES +=3D thuge-gen -BINARIES +=3D transhuge-stress -BINARIES +=3D userfaultfd -BINARIES +=3D mlock-random-test - -all: $(BINARIES) -%: %.c - $(CC) $(CFLAGS) -o $@ $^ -lrt -userfaultfd: userfaultfd.c ../../../../usr/include/linux/kernel.h - $(CC) $(CFLAGS) -O2 -o $@ $< -lpthread - -mlock-random-test: mlock-random-test.c - $(CC) $(CFLAGS) -o $@ $< -lcap - -../../../../usr/include/linux/kernel.h: - make -C ../../../.. headers_install +LDLIBS =3D -lrt +TEST_GEN_FILES =3D compaction_test +TEST_GEN_FILES +=3D hugepage-mmap +TEST_GEN_FILES +=3D hugepage-shm +TEST_GEN_FILES +=3D map_hugetlb +TEST_GEN_FILES +=3D mlock2-tests +TEST_GEN_FILES +=3D on-fault-limit +TEST_GEN_FILES +=3D thuge-gen +TEST_GEN_FILES +=3D transhuge-stress +TEST_GEN_FILES +=3D userfaultfd +TEST_GEN_FILES +=3D mlock-random-test =20 TEST_PROGS :=3D run_vmtests -TEST_FILES :=3D $(BINARIES) =20 include ../lib.mk =20 -clean: - $(RM) $(BINARIES) +$(OUTPUT)/userfaultfd: LDLIBS +=3D -lpthread ../../../../usr/include/lin= ux/kernel.h +$(OUTPUT)/mlock-random-test: LDLIBS +=3D -lcap + +../../../../usr/include/linux/kernel.h: + make -C ../../../.. headers_install diff --git a/tools/testing/selftests/x86/Makefile b/tools/testing/selftes= ts/x86/Makefile index 8c1cb42..f251cf9 100644 --- a/tools/testing/selftests/x86/Makefile +++ b/tools/testing/selftests/x86/Makefile @@ -17,6 +17,9 @@ TARGETS_C_64BIT_ALL :=3D $(TARGETS_C_BOTHBITS) $(TARGET= S_C_64BIT_ONLY) BINARIES_32 :=3D $(TARGETS_C_32BIT_ALL:%=3D%_32) BINARIES_64 :=3D $(TARGETS_C_64BIT_ALL:%=3D%_64) =20 +BINARIES_32 :=3D $(patsubst %,$(OUTPUT)/%,$(BINARIES_32)) +BINARIES_64 :=3D $(patsubst %,$(OUTPUT)/%,$(BINARIES_64)) + CFLAGS :=3D -O2 -g -std=3Dgnu99 -pthread -Wall =20 UNAME_M :=3D $(shell uname -m) @@ -40,10 +43,10 @@ all_64: $(BINARIES_64) clean: $(RM) $(BINARIES_32) $(BINARIES_64) =20 -$(TARGETS_C_32BIT_ALL:%=3D%_32): %_32: %.c +$(BINARIES_32): $(OUTPUT)/%_32: %.c $(CC) -m32 -o $@ $(CFLAGS) $(EXTRA_CFLAGS) $^ -lrt -ldl -lm =20 -$(TARGETS_C_64BIT_ALL:%=3D%_64): %_64: %.c +$(BINARIES_64): $(OUTPUT)/%_64: %.c $(CC) -m64 -o $@ $(CFLAGS) $(EXTRA_CFLAGS) $^ -lrt -ldl =20 # x86_64 users should be encouraged to install 32-bit libraries @@ -65,12 +68,12 @@ warn_32bit_failure: endif =20 # Some tests have additional dependencies. -sysret_ss_attrs_64: thunks.S -ptrace_syscall_32: raw_syscall_helper_32.S -test_syscall_vdso_32: thunks_32.S +$(OUTPUT)/sysret_ss_attrs_64: thunks.S +$(OUTPUT)/ptrace_syscall_32: raw_syscall_helper_32.S +$(OUTPUT)/test_syscall_vdso_32: thunks_32.S =20 # check_initial_reg_state is special: it needs a custom entry, and it # needs to be static so that its interpreter doesn't destroy its initial= # state. -check_initial_reg_state_32: CFLAGS +=3D -Wl,-ereal_start -static -check_initial_reg_state_64: CFLAGS +=3D -Wl,-ereal_start -static +$(OUTPUT)/check_initial_reg_state_32: CFLAGS +=3D -Wl,-ereal_start -stat= ic +$(OUTPUT)/check_initial_reg_state_64: CFLAGS +=3D -Wl,-ereal_start -stat= ic diff --git a/tools/testing/selftests/x86/protection_keys.c b/tools/testin= g/selftests/x86/protection_keys.c index bdd58c7..f39c5bc 100644 --- a/tools/testing/selftests/x86/protection_keys.c +++ b/tools/testing/selftests/x86/protection_keys.c @@ -192,7 +192,7 @@ void lots_o_noops_around_write(int *write_to_me) #define SYS_pkey_alloc 381 #define SYS_pkey_free 382 #define REG_IP_IDX REG_EIP -#define si_pkey_offset 0x18 +#define si_pkey_offset 0x14 #else #define SYS_mprotect_key 329 #define SYS_pkey_alloc 330 @@ -462,7 +462,7 @@ void pkey_disable_set(int pkey, int flags) unsigned long syscall_flags =3D 0; int ret; int pkey_rights; - u32 orig_pkru; + u32 orig_pkru =3D rdpkru(); =20 dprintf1("START->%s(%d, 0x%x)\n", __func__, pkey, flags); @@ -812,8 +812,6 @@ void setup_hugetlbfs(void) { int err; int fd; - int validated_nr_pages; - int i; char buf[] =3D "123"; =20 if (geteuid() !=3D 0) { @@ -1116,11 +1114,6 @@ void test_pkey_syscalls_on_non_allocated_pkey(int = *ptr, u16 pkey) err =3D sys_pkey_free(i); pkey_assert(err); =20 - /* not enforced when pkey_get() is not a syscall - err =3D pkey_get(i, 0); - pkey_assert(err < 0); - */ - err =3D sys_pkey_free(i); pkey_assert(err); =20 @@ -1133,14 +1126,8 @@ void test_pkey_syscalls_on_non_allocated_pkey(int = *ptr, u16 pkey) void test_pkey_syscalls_bad_args(int *ptr, u16 pkey) { int err; - int bad_flag =3D (PKEY_DISABLE_ACCESS | PKEY_DISABLE_WRITE) + 1; int bad_pkey =3D NR_PKEYS+99; =20 - /* not enforced when pkey_get() is not a syscall - err =3D pkey_get(bad_pkey, bad_flag); - pkey_assert(err < 0); - */ - /* pass a known-invalid pkey in: */ err =3D sys_mprotect_pkey(ptr, PAGE_SIZE, PROT_READ, bad_pkey); pkey_assert(err); @@ -1149,8 +1136,6 @@ void test_pkey_syscalls_bad_args(int *ptr, u16 pkey= ) /* Assumes that all pkeys other than 'pkey' are unallocated */ void test_pkey_alloc_exhaust(int *ptr, u16 pkey) { - unsigned long flags; - unsigned long init_val; int err; int allocated_pkeys[NR_PKEYS] =3D {0}; int nr_allocated_pkeys =3D 0; diff --git a/tools/testing/selftests/zram/Makefile b/tools/testing/selfte= sts/zram/Makefile index 29d8034..c3a87e5 100644 --- a/tools/testing/selftests/zram/Makefile +++ b/tools/testing/selftests/zram/Makefile @@ -2,8 +2,7 @@ all: =20 TEST_PROGS :=3D zram.sh TEST_FILES :=3D zram01.sh zram02.sh zram_lib.sh +EXTRA_CLEAN :=3D err.log =20 include ../lib.mk =20 -clean: - $(RM) err.log --------------CCC865A8D9E631AA5C057686 Content-Type: text/x-patch; name="fix.diff" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="fix.diff" diff --cc tools/testing/selftests/bpf/Makefile index c7816fe60feb,058351b0694f..000000000000 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@@ -1,26 -1,7 +1,20 @@@ -CFLAGS +=3D -Wall -O2 -I../../../../usr/include +LIBDIR :=3D ../../../lib +BPFOBJ :=3D $(LIBDIR)/bpf/bpf.o =20 -TEST_GEN_PROGS =3D test_verifier test_maps test_lru_map +CFLAGS +=3D -Wall -O2 -lcap -I../../../include/uapi -I$(LIBDIR) + - test_objs =3D test_verifier test_tag test_maps test_lru_map test_lpm_ma= p ++TEST_GEN_PROGS =3D test_verifier test_tag test_maps test_lru_map test_l= pm_map =20 - TEST_PROGS :=3D $(test_objs) test_kmod.sh - TEST_FILES :=3D $(test_objs) + TEST_PROGS :=3D test_kmod.sh =20 +.PHONY: all clean force + - all: $(test_objs) -=20 +# force a rebuild of BPFOBJ when its dependencies are updated +force: + +$(BPFOBJ): force + $(MAKE) -C $(dir $(BPFOBJ)) + +$(test_objs): $(BPFOBJ) + include ../lib.mk -=20 - clean: - $(RM) $(test_objs) --------------CCC865A8D9E631AA5C057686--