Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

Pull Kselftest update from Shuah Khan:
"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"

* tag 'linux-kselftest-4.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: (28 commits)
selftests/powerpc: Fix remaining fallout from recent changes
selftests/powerpc: Fix the clean rule since recent changes
selftests: Fix the .S and .S -> .o rules
selftests: Fix the .c linking rule
selftests: Fix selftests build to just build, not run tests
selftests, x86, protection_keys: fix wrong offset in siginfo
selftests, x86, protection_keys: fix uninitialized variable warning
selftest: cpufreq: Update MAINTAINERS file
selftest: cpufreq: Add special tests
selftest: cpufreq: Add support to test cpufreq modules
selftest: cpufreq: Add suspend/resume/hibernate support
selftest: cpufreq: Add support for cpufreq tests
selftests: Add intel_pstate to TARGETS
selftests/intel_pstate: Update makefile to match new style
selftests/intel_pstate: Fix warning on loop index overflow
cpupower: Restore format of frequency-info limit
selftests/futex: Add headers to makefile dependencies
selftests/futex: Add stdio used for logging
selftests: x86 protection_keys remove dead code
selftests: x86 protection_keys fix unused variable compile warnings
...

+1342 -419
+12
Documentation/kselftest.txt
··· 95 95 96 96 * Don't cause the top-level "make run_tests" to fail if your feature is 97 97 unconfigured. 98 + 99 + Contributing new tests(details) 100 + =============================== 101 + 102 + * Use TEST_GEN_XXX if such binaries or files are generated during 103 + compiling. 104 + TEST_PROGS, TEST_GEN_PROGS mean it is the excutable tested by 105 + default. 106 + TEST_PROGS_EXTENDED, TEST_GEN_PROGS_EXTENDED mean it is the 107 + executable which is not tested by default. 108 + TEST_FILES, TEST_GEN_FILES mean it is the file which is used by 109 + test.
+1
MAINTAINERS
··· 3452 3452 F: Documentation/cpu-freq/ 3453 3453 F: drivers/cpufreq/ 3454 3454 F: include/linux/cpufreq.h 3455 + F: tools/testing/selftests/cpufreq/ 3455 3456 3456 3457 CPU FREQUENCY DRIVERS - ARM BIG LITTLE 3457 3458 M: Viresh Kumar <viresh.kumar@linaro.org>
+12 -9
tools/power/cpupower/utils/cpufreq-info.c
··· 285 285 286 286 /* --hwlimits / -l */ 287 287 288 - static int get_hardware_limits(unsigned int cpu) 288 + static int get_hardware_limits(unsigned int cpu, unsigned int human) 289 289 { 290 290 unsigned long min, max; 291 291 292 - printf(_(" hardware limits: ")); 293 292 if (cpufreq_get_hardware_limits(cpu, &min, &max)) { 294 293 printf(_("Not Available\n")); 295 294 return -EINVAL; 296 295 } 297 296 298 - print_speed(min); 299 - printf(" - "); 300 - print_speed(max); 301 - printf("\n"); 297 + if (human) { 298 + printf(_(" hardware limits: ")); 299 + print_speed(min); 300 + printf(" - "); 301 + print_speed(max); 302 + printf("\n"); 303 + } else { 304 + printf("%lu %lu\n", min, max); 305 + } 302 306 return 0; 303 307 } 304 308 ··· 460 456 get_related_cpus(cpu); 461 457 get_affected_cpus(cpu); 462 458 get_latency(cpu, 1); 463 - get_hardware_limits(cpu); 459 + get_hardware_limits(cpu, 1); 464 460 465 461 freqs = cpufreq_get_available_frequencies(cpu); 466 462 if (freqs) { ··· 626 622 ret = get_driver(cpu); 627 623 break; 628 624 case 'l': 629 - ret = get_hardware_limits(cpu); 625 + ret = get_hardware_limits(cpu, human); 630 626 break; 631 627 case 'w': 632 628 ret = get_freq_hardware(cpu, human); ··· 643 639 } 644 640 if (ret) 645 641 return ret; 646 - printf("\n"); 647 642 } 648 643 return ret; 649 644 }
+29 -9
tools/testing/selftests/Makefile
··· 1 1 TARGETS = bpf 2 2 TARGETS += breakpoints 3 3 TARGETS += capabilities 4 + TARGETS += cpufreq 4 5 TARGETS += cpu-hotplug 5 6 TARGETS += efivarfs 6 7 TARGETS += exec ··· 9 8 TARGETS += ftrace 10 9 TARGETS += futex 11 10 TARGETS += gpio 11 + TARGETS += intel_pstate 12 12 TARGETS += ipc 13 13 TARGETS += kcmp 14 14 TARGETS += lib ··· 51 49 override MAKEFLAGS = 52 50 endif 53 51 52 + BUILD := $(O) 53 + ifndef BUILD 54 + BUILD := $(KBUILD_OUTPUT) 55 + endif 56 + ifndef BUILD 57 + BUILD := $(shell pwd) 58 + endif 59 + 60 + export BUILD 54 61 all: 55 - for TARGET in $(TARGETS); do \ 56 - make -C $$TARGET; \ 62 + for TARGET in $(TARGETS); do \ 63 + BUILD_TARGET=$$BUILD/$$TARGET; \ 64 + mkdir $$BUILD_TARGET -p; \ 65 + make OUTPUT=$$BUILD_TARGET -C $$TARGET;\ 57 66 done; 58 67 59 68 run_tests: all 60 69 for TARGET in $(TARGETS); do \ 61 - make -C $$TARGET run_tests; \ 70 + BUILD_TARGET=$$BUILD/$$TARGET; \ 71 + make OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests;\ 62 72 done; 63 73 64 74 hotplug: 65 75 for TARGET in $(TARGETS_HOTPLUG); do \ 66 - make -C $$TARGET; \ 76 + BUILD_TARGET=$$BUILD/$$TARGET; \ 77 + make OUTPUT=$$BUILD_TARGET -C $$TARGET;\ 67 78 done; 68 79 69 80 run_hotplug: hotplug 70 81 for TARGET in $(TARGETS_HOTPLUG); do \ 71 - make -C $$TARGET run_full_test; \ 82 + BUILD_TARGET=$$BUILD/$$TARGET; \ 83 + make OUTPUT=$$BUILD_TARGET -C $$TARGET run_full_test;\ 72 84 done; 73 85 74 86 clean_hotplug: 75 87 for TARGET in $(TARGETS_HOTPLUG); do \ 76 - make -C $$TARGET clean; \ 88 + BUILD_TARGET=$$BUILD/$$TARGET; \ 89 + make OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\ 77 90 done; 78 91 79 92 run_pstore_crash: ··· 103 86 @# Ask all targets to install their files 104 87 mkdir -p $(INSTALL_PATH) 105 88 for TARGET in $(TARGETS); do \ 106 - make -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install; \ 89 + BUILD_TARGET=$$BUILD/$$TARGET; \ 90 + make OUTPUT=$$BUILD_TARGET -C $$TARGET INSTALL_PATH=$(INSTALL_PATH)/$$TARGET install; \ 107 91 done; 108 92 109 93 @# Ask all targets to emit their test scripts ··· 113 95 echo "ROOT=\$$PWD" >> $(ALL_SCRIPT) 114 96 115 97 for TARGET in $(TARGETS); do \ 98 + BUILD_TARGET=$$BUILD/$$TARGET; \ 116 99 echo "echo ; echo Running tests in $$TARGET" >> $(ALL_SCRIPT); \ 117 100 echo "echo ========================================" >> $(ALL_SCRIPT); \ 118 101 echo "cd $$TARGET" >> $(ALL_SCRIPT); \ 119 - make -s --no-print-directory -C $$TARGET emit_tests >> $(ALL_SCRIPT); \ 102 + make -s --no-print-directory OUTPUT=$$BUILD_TARGET -C $$TARGET emit_tests >> $(ALL_SCRIPT); \ 120 103 echo "cd \$$ROOT" >> $(ALL_SCRIPT); \ 121 104 done; 122 105 ··· 128 109 129 110 clean: 130 111 for TARGET in $(TARGETS); do \ 131 - make -C $$TARGET clean; \ 112 + BUILD_TARGET=$$BUILD/$$TARGET; \ 113 + make OUTPUT=$$BUILD_TARGET -C $$TARGET clean;\ 132 114 done; 133 115 134 116 .PHONY: install
+2 -8
tools/testing/selftests/bpf/Makefile
··· 3 3 4 4 CFLAGS += -Wall -O2 -lcap -I../../../include/uapi -I$(LIBDIR) 5 5 6 - test_objs = test_verifier test_tag test_maps test_lru_map test_lpm_map 6 + TEST_GEN_PROGS = test_verifier test_tag test_maps test_lru_map test_lpm_map 7 7 8 - TEST_PROGS := $(test_objs) test_kmod.sh 9 - TEST_FILES := $(test_objs) 8 + TEST_PROGS := test_kmod.sh 10 9 11 10 .PHONY: all clean force 12 - 13 - all: $(test_objs) 14 11 15 12 # force a rebuild of BPFOBJ when its dependencies are updated 16 13 force: ··· 18 21 $(test_objs): $(BPFOBJ) 19 22 20 23 include ../lib.mk 21 - 22 - clean: 23 - $(RM) $(test_objs)
+3 -7
tools/testing/selftests/breakpoints/Makefile
··· 3 3 ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/x86/ -e s/x86_64/x86/) 4 4 5 5 ifeq ($(ARCH),x86) 6 - TEST_PROGS := breakpoint_test 6 + TEST_GEN_PROGS := breakpoint_test 7 7 endif 8 8 ifeq ($(ARCH),aarch64) 9 - TEST_PROGS := breakpoint_test_arm64 9 + TEST_GEN_PROGS := breakpoint_test_arm64 10 10 endif 11 11 12 - TEST_PROGS += step_after_suspend_test 13 - 14 - all: $(TEST_PROGS) 12 + TEST_GEN_PROGS += step_after_suspend_test 15 13 16 14 include ../lib.mk 17 15 18 - clean: 19 - rm -fr breakpoint_test breakpoint_test_arm64 step_after_suspend_test
+2 -9
tools/testing/selftests/capabilities/Makefile
··· 1 - TEST_FILES := validate_cap 2 - TEST_PROGS := test_execve 3 - 4 - BINARIES := $(TEST_FILES) $(TEST_PROGS) 1 + TEST_GEN_FILES := validate_cap 2 + TEST_GEN_PROGS := test_execve 5 3 6 4 CFLAGS += -O2 -g -std=gnu99 -Wall 7 5 LDLIBS += -lcap-ng -lrt -ldl 8 - 9 - all: $(BINARIES) 10 - 11 - clean: 12 - $(RM) $(BINARIES) 13 6 14 7 include ../lib.mk 15 8
+8
tools/testing/selftests/cpufreq/Makefile
··· 1 + all: 2 + 3 + TEST_PROGS := main.sh 4 + TEST_FILES := cpu.sh cpufreq.sh governor.sh module.sh special-tests.sh 5 + 6 + include ../lib.mk 7 + 8 + clean:
+84
tools/testing/selftests/cpufreq/cpu.sh
··· 1 + #!/bin/bash 2 + # 3 + # CPU helpers 4 + 5 + # protect against multiple inclusion 6 + if [ $FILE_CPU ]; then 7 + return 0 8 + else 9 + FILE_CPU=DONE 10 + fi 11 + 12 + source cpufreq.sh 13 + 14 + for_each_cpu() 15 + { 16 + cpus=$(ls $CPUROOT | grep "cpu[0-9].*") 17 + for cpu in $cpus; do 18 + $@ $cpu 19 + done 20 + } 21 + 22 + for_each_non_boot_cpu() 23 + { 24 + cpus=$(ls $CPUROOT | grep "cpu[1-9].*") 25 + for cpu in $cpus; do 26 + $@ $cpu 27 + done 28 + } 29 + 30 + #$1: cpu 31 + offline_cpu() 32 + { 33 + printf "Offline $1\n" 34 + echo 0 > $CPUROOT/$1/online 35 + } 36 + 37 + #$1: cpu 38 + online_cpu() 39 + { 40 + printf "Online $1\n" 41 + echo 1 > $CPUROOT/$1/online 42 + } 43 + 44 + #$1: cpu 45 + reboot_cpu() 46 + { 47 + offline_cpu $1 48 + online_cpu $1 49 + } 50 + 51 + # Reboot CPUs 52 + # param: number of times we want to run the loop 53 + reboot_cpus() 54 + { 55 + printf "** Test: Running ${FUNCNAME[0]} for $1 loops **\n\n" 56 + 57 + for i in `seq 1 $1`; do 58 + for_each_non_boot_cpu offline_cpu 59 + for_each_non_boot_cpu online_cpu 60 + printf "\n" 61 + done 62 + 63 + printf "\n%s\n\n" "------------------------------------------------" 64 + } 65 + 66 + # Prints warning for all CPUs with missing cpufreq directory 67 + print_unmanaged_cpus() 68 + { 69 + for_each_cpu cpu_should_have_cpufreq_directory 70 + } 71 + 72 + # Counts CPUs with cpufreq directories 73 + count_cpufreq_managed_cpus() 74 + { 75 + count=0; 76 + 77 + for cpu in `ls $CPUROOT | grep "cpu[0-9].*"`; do 78 + if [ -d $CPUROOT/$cpu/cpufreq ]; then 79 + let count=count+1; 80 + fi 81 + done 82 + 83 + echo $count; 84 + }
+241
tools/testing/selftests/cpufreq/cpufreq.sh
··· 1 + #!/bin/bash 2 + 3 + # protect against multiple inclusion 4 + if [ $FILE_CPUFREQ ]; then 5 + return 0 6 + else 7 + FILE_CPUFREQ=DONE 8 + fi 9 + 10 + source cpu.sh 11 + 12 + 13 + # $1: cpu 14 + cpu_should_have_cpufreq_directory() 15 + { 16 + if [ ! -d $CPUROOT/$1/cpufreq ]; then 17 + printf "Warning: No cpufreq directory present for $1\n" 18 + fi 19 + } 20 + 21 + cpu_should_not_have_cpufreq_directory() 22 + { 23 + if [ -d $CPUROOT/$1/cpufreq ]; then 24 + printf "Warning: cpufreq directory present for $1\n" 25 + fi 26 + } 27 + 28 + for_each_policy() 29 + { 30 + policies=$(ls $CPUFREQROOT| grep "policy[0-9].*") 31 + for policy in $policies; do 32 + $@ $policy 33 + done 34 + } 35 + 36 + for_each_policy_concurrent() 37 + { 38 + policies=$(ls $CPUFREQROOT| grep "policy[0-9].*") 39 + for policy in $policies; do 40 + $@ $policy & 41 + done 42 + } 43 + 44 + # $1: Path 45 + read_cpufreq_files_in_dir() 46 + { 47 + local files=`ls $1` 48 + 49 + printf "Printing directory: $1\n\n" 50 + 51 + for file in $files; do 52 + if [ -f $1/$file ]; then 53 + printf "$file:" 54 + cat $1/$file 55 + else 56 + printf "\n" 57 + read_cpufreq_files_in_dir "$1/$file" 58 + fi 59 + done 60 + printf "\n" 61 + } 62 + 63 + 64 + read_all_cpufreq_files() 65 + { 66 + printf "** Test: Running ${FUNCNAME[0]} **\n\n" 67 + 68 + read_cpufreq_files_in_dir $CPUFREQROOT 69 + 70 + printf "%s\n\n" "------------------------------------------------" 71 + } 72 + 73 + 74 + # UPDATE CPUFREQ FILES 75 + 76 + # $1: directory path 77 + update_cpufreq_files_in_dir() 78 + { 79 + local files=`ls $1` 80 + 81 + printf "Updating directory: $1\n\n" 82 + 83 + for file in $files; do 84 + if [ -f $1/$file ]; then 85 + # file is writable ? 86 + local wfile=$(ls -l $1/$file | awk '$1 ~ /^.*w.*/ { print $NF; }') 87 + 88 + if [ ! -z $wfile ]; then 89 + # scaling_setspeed is a special file and we 90 + # should skip updating it 91 + if [ $file != "scaling_setspeed" ]; then 92 + local val=$(cat $1/$file) 93 + printf "Writing $val to: $file\n" 94 + echo $val > $1/$file 95 + fi 96 + fi 97 + else 98 + printf "\n" 99 + update_cpufreq_files_in_dir "$1/$file" 100 + fi 101 + done 102 + 103 + printf "\n" 104 + } 105 + 106 + # Update all writable files with their existing values 107 + update_all_cpufreq_files() 108 + { 109 + printf "** Test: Running ${FUNCNAME[0]} **\n\n" 110 + 111 + update_cpufreq_files_in_dir $CPUFREQROOT 112 + 113 + printf "%s\n\n" "------------------------------------------------" 114 + } 115 + 116 + 117 + # CHANGE CPU FREQUENCIES 118 + 119 + # $1: policy 120 + find_current_freq() 121 + { 122 + cat $CPUFREQROOT/$1/scaling_cur_freq 123 + } 124 + 125 + # $1: policy 126 + # $2: frequency 127 + set_cpu_frequency() 128 + { 129 + printf "Change frequency for $1 to $2\n" 130 + echo $2 > $CPUFREQROOT/$1/scaling_setspeed 131 + } 132 + 133 + # $1: policy 134 + test_all_frequencies() 135 + { 136 + local filepath="$CPUFREQROOT/$1" 137 + 138 + backup_governor $1 139 + 140 + local found=$(switch_governor $1 "userspace") 141 + if [ $found = 1 ]; then 142 + printf "${FUNCNAME[0]}: userspace governor not available for: $1\n" 143 + return; 144 + fi 145 + 146 + printf "Switched governor for $1 to userspace\n\n" 147 + 148 + local freqs=$(cat $filepath/scaling_available_frequencies) 149 + printf "Available frequencies for $1: $freqs\n\n" 150 + 151 + # Set all frequencies one-by-one 152 + for freq in $freqs; do 153 + set_cpu_frequency $1 $freq 154 + done 155 + 156 + printf "\n" 157 + 158 + restore_governor $1 159 + } 160 + 161 + # $1: loop count 162 + shuffle_frequency_for_all_cpus() 163 + { 164 + printf "** Test: Running ${FUNCNAME[0]} for $1 loops **\n\n" 165 + 166 + for i in `seq 1 $1`; do 167 + for_each_policy test_all_frequencies 168 + done 169 + printf "\n%s\n\n" "------------------------------------------------" 170 + } 171 + 172 + # Basic cpufreq tests 173 + cpufreq_basic_tests() 174 + { 175 + printf "*** RUNNING CPUFREQ SANITY TESTS ***\n" 176 + printf "====================================\n\n" 177 + 178 + count=$(count_cpufreq_managed_cpus) 179 + if [ $count = 0 ]; then 180 + printf "No cpu is managed by cpufreq core, exiting\n" 181 + exit; 182 + else 183 + printf "CPUFreq manages: $count CPUs\n\n" 184 + fi 185 + 186 + # Detect & print which CPUs are not managed by cpufreq 187 + print_unmanaged_cpus 188 + 189 + # read/update all cpufreq files 190 + read_all_cpufreq_files 191 + update_all_cpufreq_files 192 + 193 + # hotplug cpus 194 + reboot_cpus 5 195 + 196 + # Test all frequencies 197 + shuffle_frequency_for_all_cpus 2 198 + 199 + # Test all governors 200 + shuffle_governors_for_all_cpus 1 201 + } 202 + 203 + # Suspend/resume 204 + # $1: "suspend" or "hibernate", $2: loop count 205 + do_suspend() 206 + { 207 + printf "** Test: Running ${FUNCNAME[0]}: Trying $1 for $2 loops **\n\n" 208 + 209 + # Is the directory available 210 + if [ ! -d $SYSFS/power/ -o ! -f $SYSFS/power/state ]; then 211 + printf "$SYSFS/power/state not available\n" 212 + return 1 213 + fi 214 + 215 + if [ $1 = "suspend" ]; then 216 + filename="mem" 217 + elif [ $1 = "hibernate" ]; then 218 + filename="disk" 219 + else 220 + printf "$1 is not a valid option\n" 221 + return 1 222 + fi 223 + 224 + if [ -n $filename ]; then 225 + present=$(cat $SYSFS/power/state | grep $filename) 226 + 227 + if [ -z "$present" ]; then 228 + printf "Tried to $1 but $filename isn't present in $SYSFS/power/state\n" 229 + return 1; 230 + fi 231 + 232 + for i in `seq 1 $2`; do 233 + printf "Starting $1\n" 234 + echo $filename > $SYSFS/power/state 235 + printf "Came out of $1\n" 236 + 237 + printf "Do basic tests after finishing $1 to verify cpufreq state\n\n" 238 + cpufreq_basic_tests 239 + done 240 + fi 241 + }
+153
tools/testing/selftests/cpufreq/governor.sh
··· 1 + #!/bin/bash 2 + # 3 + # Test governors 4 + 5 + # protect against multiple inclusion 6 + if [ $FILE_GOVERNOR ]; then 7 + return 0 8 + else 9 + FILE_GOVERNOR=DONE 10 + fi 11 + 12 + source cpu.sh 13 + source cpufreq.sh 14 + 15 + CUR_GOV= 16 + CUR_FREQ= 17 + 18 + # Find governor's directory path 19 + # $1: policy, $2: governor 20 + find_gov_directory() 21 + { 22 + if [ -d $CPUFREQROOT/$2 ]; then 23 + printf "$CPUFREQROOT/$2\n" 24 + elif [ -d $CPUFREQROOT/$1/$2 ]; then 25 + printf "$CPUFREQROOT/$1/$2\n" 26 + else 27 + printf "INVALID\n" 28 + fi 29 + } 30 + 31 + # $1: policy 32 + find_current_governor() 33 + { 34 + cat $CPUFREQROOT/$1/scaling_governor 35 + } 36 + 37 + # $1: policy 38 + backup_governor() 39 + { 40 + CUR_GOV=$(find_current_governor $1) 41 + 42 + printf "Governor backup done for $1: $CUR_GOV\n" 43 + 44 + if [ $CUR_GOV == "userspace" ]; then 45 + CUR_FREQ=$(find_current_freq $1) 46 + printf "Governor frequency backup done for $1: $CUR_FREQ\n" 47 + fi 48 + 49 + printf "\n" 50 + } 51 + 52 + # $1: policy 53 + restore_governor() 54 + { 55 + __switch_governor $1 $CUR_GOV 56 + 57 + printf "Governor restored for $1 to $CUR_GOV\n" 58 + 59 + if [ $CUR_GOV == "userspace" ]; then 60 + set_cpu_frequency $1 $CUR_FREQ 61 + printf "Governor frequency restored for $1: $CUR_FREQ\n" 62 + fi 63 + 64 + printf "\n" 65 + } 66 + 67 + # param: 68 + # $1: policy, $2: governor 69 + __switch_governor() 70 + { 71 + echo $2 > $CPUFREQROOT/$1/scaling_governor 72 + } 73 + 74 + # param: 75 + # $1: cpu, $2: governor 76 + __switch_governor_for_cpu() 77 + { 78 + echo $2 > $CPUROOT/$1/cpufreq/scaling_governor 79 + } 80 + 81 + # SWITCH GOVERNORS 82 + 83 + # $1: cpu, $2: governor 84 + switch_governor() 85 + { 86 + local filepath=$CPUFREQROOT/$1/scaling_available_governors 87 + 88 + # check if governor is available 89 + local found=$(cat $filepath | grep $2 | wc -l) 90 + if [ $found = 0 ]; then 91 + echo 1; 92 + return 93 + fi 94 + 95 + __switch_governor $1 $2 96 + echo 0; 97 + } 98 + 99 + # $1: policy, $2: governor 100 + switch_show_governor() 101 + { 102 + cur_gov=find_current_governor 103 + if [ $cur_gov == "userspace" ]; then 104 + cur_freq=find_current_freq 105 + fi 106 + 107 + # switch governor 108 + __switch_governor $1 $2 109 + 110 + printf "\nSwitched governor for $1 to $2\n\n" 111 + 112 + if [ $2 == "userspace" -o $2 == "powersave" -o $2 == "performance" ]; then 113 + printf "No files to read for $2 governor\n\n" 114 + return 115 + fi 116 + 117 + # show governor files 118 + local govpath=$(find_gov_directory $1 $2) 119 + read_cpufreq_files_in_dir $govpath 120 + } 121 + 122 + # $1: function to be called, $2: policy 123 + call_for_each_governor() 124 + { 125 + local filepath=$CPUFREQROOT/$2/scaling_available_governors 126 + 127 + # Exit if cpu isn't managed by cpufreq core 128 + if [ ! -f $filepath ]; then 129 + return; 130 + fi 131 + 132 + backup_governor $2 133 + 134 + local governors=$(cat $filepath) 135 + printf "Available governors for $2: $governors\n" 136 + 137 + for governor in $governors; do 138 + $1 $2 $governor 139 + done 140 + 141 + restore_governor $2 142 + } 143 + 144 + # $1: loop count 145 + shuffle_governors_for_all_cpus() 146 + { 147 + printf "** Test: Running ${FUNCNAME[0]} for $1 loops **\n\n" 148 + 149 + for i in `seq 1 $1`; do 150 + for_each_policy call_for_each_governor switch_show_governor 151 + done 152 + printf "%s\n\n" "------------------------------------------------" 153 + }
+194
tools/testing/selftests/cpufreq/main.sh
··· 1 + #!/bin/bash 2 + 3 + source cpu.sh 4 + source cpufreq.sh 5 + source governor.sh 6 + source module.sh 7 + source special-tests.sh 8 + 9 + FUNC=basic # do basic tests by default 10 + OUTFILE=cpufreq_selftest 11 + SYSFS= 12 + CPUROOT= 13 + CPUFREQROOT= 14 + 15 + helpme() 16 + { 17 + printf "Usage: $0 [-h] [-todg args] 18 + [-h <help>] 19 + [-o <output-file-for-dump>] 20 + [-t <basic: Basic cpufreq testing 21 + suspend: suspend/resume, 22 + hibernate: hibernate/resume, 23 + modtest: test driver or governor modules. Only to be used with -d or -g options, 24 + sptest1: Simple governor switch to produce lockdep. 25 + sptest2: Concurrent governor switch to produce lockdep. 26 + sptest3: Governor races, shuffle between governors quickly. 27 + sptest4: CPU hotplugs with updates to cpufreq files.>] 28 + [-d <driver's module name: only with \"-t modtest>\"] 29 + [-g <governor's module name: only with \"-t modtest>\"] 30 + \n" 31 + exit 2 32 + } 33 + 34 + prerequisite() 35 + { 36 + msg="skip all tests:" 37 + 38 + if [ $UID != 0 ]; then 39 + echo $msg must be run as root >&2 40 + exit 2 41 + fi 42 + 43 + taskset -p 01 $$ 44 + 45 + SYSFS=`mount -t sysfs | head -1 | awk '{ print $3 }'` 46 + 47 + if [ ! -d "$SYSFS" ]; then 48 + echo $msg sysfs is not mounted >&2 49 + exit 2 50 + fi 51 + 52 + CPUROOT=$SYSFS/devices/system/cpu 53 + CPUFREQROOT="$CPUROOT/cpufreq" 54 + 55 + if ! ls $CPUROOT/cpu* > /dev/null 2>&1; then 56 + echo $msg cpus not available in sysfs >&2 57 + exit 2 58 + fi 59 + 60 + if ! ls $CPUROOT/cpufreq > /dev/null 2>&1; then 61 + echo $msg cpufreq directory not available in sysfs >&2 62 + exit 2 63 + fi 64 + } 65 + 66 + parse_arguments() 67 + { 68 + while getopts ht:o:d:g: arg 69 + do 70 + case $arg in 71 + h) # --help 72 + helpme 73 + ;; 74 + 75 + t) # --func_type (Function to perform: basic, suspend, hibernate, modtest, sptest1/2/3/4 (default: basic)) 76 + FUNC=$OPTARG 77 + ;; 78 + 79 + o) # --output-file (Output file to store dumps) 80 + OUTFILE=$OPTARG 81 + ;; 82 + 83 + d) # --driver-mod-name (Name of the driver module) 84 + DRIVER_MOD=$OPTARG 85 + ;; 86 + 87 + g) # --governor-mod-name (Name of the governor module) 88 + GOVERNOR_MOD=$OPTARG 89 + ;; 90 + 91 + \?) 92 + helpme 93 + ;; 94 + esac 95 + done 96 + } 97 + 98 + do_test() 99 + { 100 + # Check if CPUs are managed by cpufreq or not 101 + count=$(count_cpufreq_managed_cpus) 102 + 103 + if [ $count = 0 -a $FUNC != "modtest" ]; then 104 + echo "No cpu is managed by cpufreq core, exiting" 105 + exit 2; 106 + fi 107 + 108 + case "$FUNC" in 109 + "basic") 110 + cpufreq_basic_tests 111 + ;; 112 + 113 + "suspend") 114 + do_suspend "suspend" 1 115 + ;; 116 + 117 + "hibernate") 118 + do_suspend "hibernate" 1 119 + ;; 120 + 121 + "modtest") 122 + # Do we have modules in place? 123 + if [ -z $DRIVER_MOD ] && [ -z $GOVERNOR_MOD ]; then 124 + echo "No driver or governor module passed with -d or -g" 125 + exit 2; 126 + fi 127 + 128 + if [ $DRIVER_MOD ]; then 129 + if [ $GOVERNOR_MOD ]; then 130 + module_test $DRIVER_MOD $GOVERNOR_MOD 131 + else 132 + module_driver_test $DRIVER_MOD 133 + fi 134 + else 135 + if [ $count = 0 ]; then 136 + echo "No cpu is managed by cpufreq core, exiting" 137 + exit 2; 138 + fi 139 + 140 + module_governor_test $GOVERNOR_MOD 141 + fi 142 + ;; 143 + 144 + "sptest1") 145 + simple_lockdep 146 + ;; 147 + 148 + "sptest2") 149 + concurrent_lockdep 150 + ;; 151 + 152 + "sptest3") 153 + governor_race 154 + ;; 155 + 156 + "sptest4") 157 + hotplug_with_updates 158 + ;; 159 + 160 + *) 161 + echo "Invalid [-f] function type" 162 + helpme 163 + ;; 164 + esac 165 + } 166 + 167 + # clear dumps 168 + # $1: file name 169 + clear_dumps() 170 + { 171 + echo "" > $1.txt 172 + echo "" > $1.dmesg_cpufreq.txt 173 + echo "" > $1.dmesg_full.txt 174 + } 175 + 176 + # $1: output file name 177 + dmesg_dumps() 178 + { 179 + dmesg | grep cpufreq >> $1.dmesg_cpufreq.txt 180 + 181 + # We may need the full logs as well 182 + dmesg >> $1.dmesg_full.txt 183 + } 184 + 185 + # Parse arguments 186 + parse_arguments $@ 187 + 188 + # Make sure all requirements are met 189 + prerequisite 190 + 191 + # Run requested functions 192 + clear_dumps $OUTFILE 193 + do_test >> $OUTFILE.txt 194 + dmesg_dumps $OUTFILE
+243
tools/testing/selftests/cpufreq/module.sh
··· 1 + #!/bin/bash 2 + # 3 + # Modules specific tests cases 4 + 5 + # protect against multiple inclusion 6 + if [ $FILE_MODULE ]; then 7 + return 0 8 + else 9 + FILE_MODULE=DONE 10 + fi 11 + 12 + source cpu.sh 13 + source cpufreq.sh 14 + source governor.sh 15 + 16 + # Check basic insmod/rmmod 17 + # $1: module 18 + test_basic_insmod_rmmod() 19 + { 20 + printf "** Test: Running ${FUNCNAME[0]} **\n\n" 21 + 22 + printf "Inserting $1 module\n" 23 + # insert module 24 + insmod $1 25 + if [ $? != 0 ]; then 26 + printf "Insmod $1 failed\n" 27 + exit; 28 + fi 29 + 30 + printf "Removing $1 module\n" 31 + # remove module 32 + rmmod $1 33 + if [ $? != 0 ]; then 34 + printf "rmmod $1 failed\n" 35 + exit; 36 + fi 37 + 38 + printf "\n" 39 + } 40 + 41 + # Insert cpufreq driver module and perform basic tests 42 + # $1: cpufreq-driver module to insert 43 + # $2: If we want to play with CPUs (1) or not (0) 44 + module_driver_test_single() 45 + { 46 + printf "** Test: Running ${FUNCNAME[0]} for driver $1 and cpus_hotplug=$2 **\n\n" 47 + 48 + if [ $2 -eq 1 ]; then 49 + # offline all non-boot CPUs 50 + for_each_non_boot_cpu offline_cpu 51 + printf "\n" 52 + fi 53 + 54 + # insert module 55 + printf "Inserting $1 module\n\n" 56 + insmod $1 57 + if [ $? != 0 ]; then 58 + printf "Insmod $1 failed\n" 59 + return; 60 + fi 61 + 62 + if [ $2 -eq 1 ]; then 63 + # online all non-boot CPUs 64 + for_each_non_boot_cpu online_cpu 65 + printf "\n" 66 + fi 67 + 68 + # run basic tests 69 + cpufreq_basic_tests 70 + 71 + # remove module 72 + printf "Removing $1 module\n\n" 73 + rmmod $1 74 + if [ $? != 0 ]; then 75 + printf "rmmod $1 failed\n" 76 + return; 77 + fi 78 + 79 + # There shouldn't be any cpufreq directories now. 80 + for_each_cpu cpu_should_not_have_cpufreq_directory 81 + printf "\n" 82 + } 83 + 84 + # $1: cpufreq-driver module to insert 85 + module_driver_test() 86 + { 87 + printf "** Test: Running ${FUNCNAME[0]} **\n\n" 88 + 89 + # check if module is present or not 90 + ls $1 > /dev/null 91 + if [ $? != 0 ]; then 92 + printf "$1: not present in `pwd` folder\n" 93 + return; 94 + fi 95 + 96 + # test basic module tests 97 + test_basic_insmod_rmmod $1 98 + 99 + # Do simple module test 100 + module_driver_test_single $1 0 101 + 102 + # Remove CPUs before inserting module and then bring them back 103 + module_driver_test_single $1 1 104 + printf "\n" 105 + } 106 + 107 + # find governor name based on governor module name 108 + # $1: governor module name 109 + find_gov_name() 110 + { 111 + if [ $1 = "cpufreq_ondemand.ko" ]; then 112 + printf "ondemand" 113 + elif [ $1 = "cpufreq_conservative.ko" ]; then 114 + printf "conservative" 115 + elif [ $1 = "cpufreq_userspace.ko" ]; then 116 + printf "userspace" 117 + elif [ $1 = "cpufreq_performance.ko" ]; then 118 + printf "performance" 119 + elif [ $1 = "cpufreq_powersave.ko" ]; then 120 + printf "powersave" 121 + elif [ $1 = "cpufreq_schedutil.ko" ]; then 122 + printf "schedutil" 123 + fi 124 + } 125 + 126 + # $1: governor string, $2: governor module, $3: policy 127 + # example: module_governor_test_single "ondemand" "cpufreq_ondemand.ko" 2 128 + module_governor_test_single() 129 + { 130 + printf "** Test: Running ${FUNCNAME[0]} for $3 **\n\n" 131 + 132 + backup_governor $3 133 + 134 + # switch to new governor 135 + printf "Switch from $CUR_GOV to $1\n" 136 + switch_show_governor $3 $1 137 + 138 + # try removing module, it should fail as governor is used 139 + printf "Removing $2 module\n\n" 140 + rmmod $2 141 + if [ $? = 0 ]; then 142 + printf "WARN: rmmod $2 succeeded even if governor is used\n" 143 + insmod $2 144 + else 145 + printf "Pass: unable to remove $2 while it is being used\n\n" 146 + fi 147 + 148 + # switch back to old governor 149 + printf "Switchback to $CUR_GOV from $1\n" 150 + restore_governor $3 151 + printf "\n" 152 + } 153 + 154 + # Insert cpufreq governor module and perform basic tests 155 + # $1: cpufreq-governor module to insert 156 + module_governor_test() 157 + { 158 + printf "** Test: Running ${FUNCNAME[0]} **\n\n" 159 + 160 + # check if module is present or not 161 + ls $1 > /dev/null 162 + if [ $? != 0 ]; then 163 + printf "$1: not present in `pwd` folder\n" 164 + return; 165 + fi 166 + 167 + # test basic module tests 168 + test_basic_insmod_rmmod $1 169 + 170 + # insert module 171 + printf "Inserting $1 module\n\n" 172 + insmod $1 173 + if [ $? != 0 ]; then 174 + printf "Insmod $1 failed\n" 175 + return; 176 + fi 177 + 178 + # switch to new governor for each cpu 179 + for_each_policy module_governor_test_single $(find_gov_name $1) $1 180 + 181 + # remove module 182 + printf "Removing $1 module\n\n" 183 + rmmod $1 184 + if [ $? != 0 ]; then 185 + printf "rmmod $1 failed\n" 186 + return; 187 + fi 188 + printf "\n" 189 + } 190 + 191 + # test modules: driver and governor 192 + # $1: driver module, $2: governor module 193 + module_test() 194 + { 195 + printf "** Test: Running ${FUNCNAME[0]} **\n\n" 196 + 197 + # check if modules are present or not 198 + ls $1 $2 > /dev/null 199 + if [ $? != 0 ]; then 200 + printf "$1 or $2: is not present in `pwd` folder\n" 201 + return; 202 + fi 203 + 204 + # TEST1: Insert gov after driver 205 + # insert driver module 206 + printf "Inserting $1 module\n\n" 207 + insmod $1 208 + if [ $? != 0 ]; then 209 + printf "Insmod $1 failed\n" 210 + return; 211 + fi 212 + 213 + # run governor tests 214 + module_governor_test $2 215 + 216 + # remove driver module 217 + printf "Removing $1 module\n\n" 218 + rmmod $1 219 + if [ $? != 0 ]; then 220 + printf "rmmod $1 failed\n" 221 + return; 222 + fi 223 + 224 + # TEST2: Insert driver after governor 225 + # insert governor module 226 + printf "Inserting $2 module\n\n" 227 + insmod $2 228 + if [ $? != 0 ]; then 229 + printf "Insmod $2 failed\n" 230 + return; 231 + fi 232 + 233 + # run governor tests 234 + module_driver_test $1 235 + 236 + # remove driver module 237 + printf "Removing $2 module\n\n" 238 + rmmod $2 239 + if [ $? != 0 ]; then 240 + printf "rmmod $2 failed\n" 241 + return; 242 + fi 243 + }
+115
tools/testing/selftests/cpufreq/special-tests.sh
··· 1 + #!/bin/bash 2 + # 3 + # Special test cases reported by people 4 + 5 + # Testcase 1: Reported here: http://marc.info/?l=linux-pm&m=140618592709858&w=2 6 + 7 + # protect against multiple inclusion 8 + if [ $FILE_SPECIAL ]; then 9 + return 0 10 + else 11 + FILE_SPECIAL=DONE 12 + fi 13 + 14 + source cpu.sh 15 + source cpufreq.sh 16 + source governor.sh 17 + 18 + # Test 1 19 + # $1: policy 20 + __simple_lockdep() 21 + { 22 + # switch to ondemand 23 + __switch_governor $1 "ondemand" 24 + 25 + # cat ondemand files 26 + local ondir=$(find_gov_directory $1 "ondemand") 27 + if [ -z $ondir ]; then 28 + printf "${FUNCNAME[0]}Ondemand directory not created, quit" 29 + return 30 + fi 31 + 32 + cat $ondir/* 33 + 34 + # switch to conservative 35 + __switch_governor $1 "conservative" 36 + } 37 + 38 + simple_lockdep() 39 + { 40 + printf "** Test: Running ${FUNCNAME[0]} **\n" 41 + 42 + for_each_policy __simple_lockdep 43 + } 44 + 45 + # Test 2 46 + # $1: policy 47 + __concurrent_lockdep() 48 + { 49 + for i in `seq 0 100`; do 50 + __simple_lockdep $1 51 + done 52 + } 53 + 54 + concurrent_lockdep() 55 + { 56 + printf "** Test: Running ${FUNCNAME[0]} **\n" 57 + 58 + for_each_policy_concurrent __concurrent_lockdep 59 + } 60 + 61 + # Test 3 62 + quick_shuffle() 63 + { 64 + # this is called concurrently from governor_race 65 + for I in `seq 1000` 66 + do 67 + echo ondemand | sudo tee $CPUFREQROOT/policy*/scaling_governor & 68 + echo userspace | sudo tee $CPUFREQROOT/policy*/scaling_governor & 69 + done 70 + } 71 + 72 + governor_race() 73 + { 74 + printf "** Test: Running ${FUNCNAME[0]} **\n" 75 + 76 + # run 8 concurrent instances 77 + for I in `seq 8` 78 + do 79 + quick_shuffle & 80 + done 81 + } 82 + 83 + # Test 4 84 + # $1: cpu 85 + hotplug_with_updates_cpu() 86 + { 87 + local filepath="$CPUROOT/$1/cpufreq" 88 + 89 + # switch to ondemand 90 + __switch_governor_for_cpu $1 "ondemand" 91 + 92 + for i in `seq 1 5000` 93 + do 94 + reboot_cpu $1 95 + done & 96 + 97 + local freqs=$(cat $filepath/scaling_available_frequencies) 98 + local oldfreq=$(cat $filepath/scaling_min_freq) 99 + 100 + for j in `seq 1 5000` 101 + do 102 + # Set all frequencies one-by-one 103 + for freq in $freqs; do 104 + echo $freq > $filepath/scaling_min_freq 105 + done 106 + done 107 + 108 + # restore old freq 109 + echo $oldfreq > $filepath/scaling_min_freq 110 + } 111 + 112 + hotplug_with_updates() 113 + { 114 + for_each_non_boot_cpu hotplug_with_updates_cpu 115 + }
+1 -7
tools/testing/selftests/efivarfs/Makefile
··· 1 1 CFLAGS = -Wall 2 2 3 - test_objs = open-unlink create-read 4 - 5 - all: $(test_objs) 6 - 3 + TEST_GEN_FILES := open-unlink create-read 7 4 TEST_PROGS := efivarfs.sh 8 - TEST_FILES := $(test_objs) 9 5 10 6 include ../lib.mk 11 7 12 - clean: 13 - rm -f $(test_objs)
+17 -21
tools/testing/selftests/exec/Makefile
··· 1 1 CFLAGS = -Wall 2 - BINARIES = execveat 3 - DEPS = execveat.symlink execveat.denatured script subdir 4 - all: $(BINARIES) $(DEPS) 5 2 6 - subdir: 7 - mkdir -p $@ 8 - script: 9 - echo '#!/bin/sh' > $@ 10 - echo 'exit $$*' >> $@ 11 - chmod +x $@ 12 - execveat.symlink: execveat 13 - ln -s -f $< $@ 14 - execveat.denatured: execveat 15 - cp $< $@ 16 - chmod -x $@ 17 - %: %.c 18 - $(CC) $(CFLAGS) -o $@ $^ 19 - 20 - TEST_PROGS := execveat 3 + TEST_GEN_PROGS := execveat 4 + TEST_GEN_FILES := execveat.symlink execveat.denatured script subdir 21 5 # Makefile is a run-time dependency, since it's accessed by the execveat test 22 - TEST_FILES := $(DEPS) Makefile 6 + TEST_FILES := Makefile 7 + 8 + EXTRA_CLEAN := $(OUTPUT)/subdir.moved $(OUTPUT)/execveat.moved $(OUTPUT)/xxxxx* 23 9 24 10 include ../lib.mk 25 11 26 - clean: 27 - rm -rf $(BINARIES) $(DEPS) subdir.moved execveat.moved xxxxx* 12 + $(OUTPUT)/subdir: 13 + mkdir -p $@ 14 + $(OUTPUT)/script: 15 + echo '#!/bin/sh' > $@ 16 + echo 'exit $$*' >> $@ 17 + chmod +x $@ 18 + $(OUTPUT)/execveat.symlink: $(OUTPUT)/execveat 19 + cd $(OUTPUT) && ln -s -f $(shell basename $<) $(shell basename $@) 20 + $(OUTPUT)/execveat.denatured: $(OUTPUT)/execveat 21 + cp $< $@ 22 + chmod -x $@ 23 +
+2 -4
tools/testing/selftests/ftrace/Makefile
··· 1 1 all: 2 2 3 3 TEST_PROGS := ftracetest 4 - TEST_DIRS := test.d 4 + TEST_FILES := test.d 5 + EXTRA_CLEAN := $(OUTPUT)/logs/* 5 6 6 7 include ../lib.mk 7 - 8 - clean: 9 - rm -rf logs/*
+16 -5
tools/testing/selftests/futex/Makefile
··· 3 3 TEST_PROGS := run.sh 4 4 5 5 .PHONY: all clean 6 - all: 7 - for DIR in $(SUBDIRS); do $(MAKE) -C $$DIR $@ ; done 8 6 9 7 include ../lib.mk 10 8 9 + all: 10 + for DIR in $(SUBDIRS); do \ 11 + BUILD_TARGET=$$OUTPUT/$$DIR; \ 12 + mkdir $$BUILD_TARGET -p; \ 13 + make OUTPUT=$$BUILD_TARGET -C $$DIR $@;\ 14 + done 15 + 11 16 override define RUN_TESTS 12 - ./run.sh 17 + @if [ `dirname $(OUTPUT)` = $(PWD) ]; then ./run.sh; fi 13 18 endef 14 19 15 20 override define INSTALL_RULE ··· 22 17 install -t $(INSTALL_PATH) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) 23 18 24 19 @for SUBDIR in $(SUBDIRS); do \ 25 - $(MAKE) -C $$SUBDIR INSTALL_PATH=$(INSTALL_PATH)/$$SUBDIR install; \ 20 + BUILD_TARGET=$$OUTPUT/$$SUBDIR; \ 21 + mkdir $$BUILD_TARGET -p; \ 22 + $(MAKE) OUTPUT=$$BUILD_TARGET -C $$SUBDIR INSTALL_PATH=$(INSTALL_PATH)/$$SUBDIR install; \ 26 23 done; 27 24 endef 28 25 ··· 33 26 endef 34 27 35 28 clean: 36 - for DIR in $(SUBDIRS); do $(MAKE) -C $$DIR $@ ; done 29 + for DIR in $(SUBDIRS); do \ 30 + BUILD_TARGET=$$OUTPUT/$$DIR; \ 31 + mkdir $$BUILD_TARGET -p; \ 32 + make OUTPUT=$$BUILD_TARGET -C $$DIR $@;\ 33 + done
+7 -10
tools/testing/selftests/futex/functional/Makefile
··· 2 2 CFLAGS := $(CFLAGS) -g -O2 -Wall -D_GNU_SOURCE -pthread $(INCLUDES) 3 3 LDFLAGS := $(LDFLAGS) -pthread -lrt 4 4 5 - HEADERS := ../include/futextest.h 6 - TARGETS := \ 5 + HEADERS := \ 6 + ../include/futextest.h \ 7 + ../include/atomic.h \ 8 + ../include/logging.h 9 + TEST_GEN_FILES := \ 7 10 futex_wait_timeout \ 8 11 futex_wait_wouldblock \ 9 12 futex_requeue_pi \ ··· 15 12 futex_wait_uninitialized_heap \ 16 13 futex_wait_private_mapped_file 17 14 18 - TEST_PROGS := $(TARGETS) run.sh 19 - 20 - .PHONY: all clean 21 - all: $(TARGETS) 22 - 23 - $(TARGETS): $(HEADERS) 15 + TEST_PROGS := run.sh 24 16 25 17 include ../../lib.mk 26 18 27 - clean: 28 - rm -f $(TARGETS) 19 + $(TEST_GEN_FILES): $(HEADERS)
+1
tools/testing/selftests/futex/include/logging.h
··· 21 21 #ifndef _LOGGING_H 22 22 #define _LOGGING_H 23 23 24 + #include <stdio.h> 24 25 #include <string.h> 25 26 #include <unistd.h> 26 27 #include <linux/futex.h>
+1
tools/testing/selftests/gpio/.gitignore
··· 1 + gpio-mockup-chardev
+4 -9
tools/testing/selftests/intel_pstate/Makefile
··· 1 - CC := $(CROSS_COMPILE)gcc 2 1 CFLAGS := $(CFLAGS) -Wall -D_GNU_SOURCE 3 2 LDFLAGS := $(LDFLAGS) -lm 4 3 5 - TARGETS := msr aperf 4 + TEST_GEN_FILES := msr aperf 6 5 7 - TEST_PROGS := $(TARGETS) run.sh 6 + TEST_PROGS := run.sh 8 7 9 - .PHONY: all clean 10 - all: $(TARGETS) 8 + include ../lib.mk 11 9 12 - $(TARGETS): $(HEADERS) 13 - 14 - clean: 15 - rm -f $(TARGETS) 10 + $(TEST_GEN_FILES): $(HEADERS)
+1 -1
tools/testing/selftests/intel_pstate/aperf.c
··· 14 14 } 15 15 16 16 int main(int argc, char **argv) { 17 - int i, cpu, fd; 17 + unsigned int i, cpu, fd; 18 18 char msr_file_name[64]; 19 19 long long tsc, old_tsc, new_tsc; 20 20 long long aperf, old_aperf, new_aperf;
+1
tools/testing/selftests/ipc/.gitignore
··· 1 1 msgque_test 2 + msgque
+1 -6
tools/testing/selftests/ipc/Makefile
··· 11 11 12 12 CFLAGS += -I../../../../usr/include/ 13 13 14 - all: 15 - $(CC) $(CFLAGS) msgque.c -o msgque_test 16 - 17 - TEST_PROGS := msgque_test 14 + TEST_GEN_PROGS := msgque 18 15 19 16 include ../lib.mk 20 17 21 - clean: 22 - rm -fr ./msgque_test
+2 -4
tools/testing/selftests/kcmp/Makefile
··· 1 1 CFLAGS += -I../../../../usr/include/ 2 2 3 - all: kcmp_test 3 + TEST_GEN_PROGS := kcmp_test 4 4 5 - TEST_PROGS := kcmp_test 5 + EXTRA_CLEAN := $(OUTPUT)/kcmp-test-file 6 6 7 7 include ../lib.mk 8 8 9 - clean: 10 - $(RM) kcmp_test kcmp-test-file
+30 -6
tools/testing/selftests/lib.mk
··· 2 2 # Makefile can operate with or without the kbuild infrastructure. 3 3 CC := $(CROSS_COMPILE)gcc 4 4 5 + TEST_GEN_PROGS := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_PROGS)) 6 + TEST_GEN_FILES := $(patsubst %,$(OUTPUT)/%,$(TEST_GEN_FILES)) 7 + 8 + all: $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) 9 + 5 10 define RUN_TESTS 6 - @for TEST in $(TEST_PROGS); do \ 7 - (./$$TEST && echo "selftests: $$TEST [PASS]") || echo "selftests: $$TEST [FAIL]"; \ 11 + @for TEST in $(TEST_GEN_PROGS) $(TEST_PROGS); do \ 12 + BASENAME_TEST=`basename $$TEST`; \ 13 + cd `dirname $$TEST`; (./$$BASENAME_TEST && echo "selftests: $$BASENAME_TEST [PASS]") || echo "selftests: $$BASENAME_TEST [FAIL]"; cd -;\ 8 14 done; 9 15 endef 10 16 ··· 20 14 define INSTALL_RULE 21 15 @if [ "X$(TEST_PROGS)$(TEST_PROGS_EXTENDED)$(TEST_FILES)" != "X" ]; then \ 22 16 mkdir -p ${INSTALL_PATH}; \ 23 - echo "rsync -a $(TEST_DIRS) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/"; \ 24 - rsync -a $(TEST_DIRS) $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/; \ 17 + echo "rsync -a $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/"; \ 18 + rsync -a $(TEST_PROGS) $(TEST_PROGS_EXTENDED) $(TEST_FILES) $(INSTALL_PATH)/; \ 19 + fi 20 + @if [ "X$(TEST_GEN_PROGS)$(TEST_GEN_PROGS_EXTENDED)$(TEST_GEN_FILES)" != "X" ]; then \ 21 + mkdir -p ${INSTALL_PATH}; \ 22 + echo "rsync -a $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(INSTALL_PATH)/"; \ 23 + rsync -a $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(INSTALL_PATH)/; \ 25 24 fi 26 25 endef 27 26 ··· 38 27 endif 39 28 40 29 define EMIT_TESTS 41 - @for TEST in $(TEST_PROGS); do \ 42 - echo "(./$$TEST && echo \"selftests: $$TEST [PASS]\") || echo \"selftests: $$TEST [FAIL]\""; \ 30 + @for TEST in $(TEST_GEN_PROGS) $(TEST_PROGS); do \ 31 + BASENAME_TEST=`basename $$TEST`; \ 32 + echo "(./$$BASENAME_TEST && echo \"selftests: $$BASENAME_TEST [PASS]\") || echo \"selftests: $$BASENAME_TEST [FAIL]\""; \ 43 33 done; 44 34 endef 45 35 46 36 emit_tests: 47 37 $(EMIT_TESTS) 38 + 39 + clean: 40 + $(RM) -r $(TEST_GEN_PROGS) $(TEST_GEN_PROGS_EXTENDED) $(TEST_GEN_FILES) $(EXTRA_CLEAN) 41 + 42 + $(OUTPUT)/%:%.c 43 + $(LINK.c) $^ $(LDLIBS) -o $@ 44 + 45 + $(OUTPUT)/%.o:%.S 46 + $(COMPILE.S) $^ -o $@ 47 + 48 + $(OUTPUT)/%:%.S 49 + $(LINK.S) $^ $(LDLIBS) -o $@ 48 50 49 51 .PHONY: run_tests all clean install emit_tests
+1 -5
tools/testing/selftests/membarrier/Makefile
··· 1 1 CFLAGS += -g -I../../../../usr/include/ 2 2 3 - TEST_PROGS := membarrier_test 4 - 5 - all: $(TEST_PROGS) 3 + TEST_GEN_PROGS := membarrier_test 6 4 7 5 include ../lib.mk 8 6 9 - clean: 10 - $(RM) $(TEST_PROGS)
+3 -12
tools/testing/selftests/memfd/Makefile
··· 1 - CC = $(CROSS_COMPILE)gcc 2 1 CFLAGS += -D_FILE_OFFSET_BITS=64 3 2 CFLAGS += -I../../../../include/uapi/ 4 3 CFLAGS += -I../../../../include/ 5 4 CFLAGS += -I../../../../usr/include/ 6 5 7 - TEST_PROGS := memfd_test 8 - 9 - all: $(TEST_PROGS) 10 - 11 - include ../lib.mk 12 - 13 - build_fuse: fuse_mnt fuse_test 6 + TEST_PROGS := run_fuse_test.sh 7 + TEST_GEN_FILES := memfd_test fuse_mnt fuse_test 14 8 15 9 fuse_mnt.o: CFLAGS += $(shell pkg-config fuse --cflags) 16 10 fuse_mnt: LDFLAGS += $(shell pkg-config fuse --libs) 17 11 18 - run_fuse: build_fuse 19 - @./run_fuse_test.sh || echo "fuse_test: [FAIL]" 12 + include ../lib.mk 20 13 21 - clean: 22 - $(RM) memfd_test fuse_test
+1 -6
tools/testing/selftests/mount/Makefile
··· 1 1 # Makefile for mount selftests. 2 2 CFLAGS = -Wall \ 3 3 -O2 4 - all: unprivileged-remount-test 5 4 6 - unprivileged-remount-test: unprivileged-remount-test.c 7 - $(CC) $(CFLAGS) unprivileged-remount-test.c -o unprivileged-remount-test 5 + TEST_GEN_PROGS := unprivileged-remount-test 8 6 9 7 include ../lib.mk 10 8 11 - TEST_PROGS := unprivileged-remount-test 12 9 override RUN_TESTS := if [ -f /proc/self/uid_map ] ; \ 13 10 then \ 14 11 ./unprivileged-remount-test ; \ ··· 14 17 fi 15 18 override EMIT_TESTS := echo "$(RUN_TESTS)" 16 19 17 - clean: 18 - rm -f unprivileged-remount-test
+1 -5
tools/testing/selftests/mqueue/Makefile
··· 1 1 CFLAGS += -O2 2 2 LDLIBS = -lrt -lpthread -lpopt 3 - TEST_PROGS := mq_open_tests mq_perf_tests 4 - 5 - all: $(TEST_PROGS) 3 + TEST_GEN_PROGS := mq_open_tests mq_perf_tests 6 4 7 5 include ../lib.mk 8 6 ··· 14 16 echo "./mq_perf_tests || echo \"selftests: mq_perf_tests [FAIL]\"" 15 17 endef 16 18 17 - clean: 18 - rm -f mq_open_tests mq_perf_tests
+4 -11
tools/testing/selftests/net/Makefile
··· 3 3 CFLAGS = -Wall -Wl,--no-as-needed -O2 -g 4 4 CFLAGS += -I../../../../usr/include/ 5 5 6 - NET_PROGS = socket 7 - NET_PROGS += psock_fanout psock_tpacket 8 - NET_PROGS += reuseport_bpf reuseport_bpf_cpu reuseport_bpf_numa 9 - NET_PROGS += reuseport_dualstack 10 - 11 - all: $(NET_PROGS) 12 6 reuseport_bpf_numa: LDFLAGS += -lnuma 13 - %: %.c 14 - $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ 15 7 16 8 TEST_PROGS := run_netsocktests run_afpackettests test_bpf.sh 17 - TEST_FILES := $(NET_PROGS) 9 + TEST_GEN_FILES = socket 10 + TEST_GEN_FILES += psock_fanout psock_tpacket 11 + TEST_GEN_FILES += reuseport_bpf reuseport_bpf_cpu reuseport_bpf_numa 12 + TEST_GEN_FILES += reuseport_dualstack 18 13 19 14 include ../lib.mk 20 15 21 - clean: 22 - $(RM) $(NET_PROGS)
+1 -8
tools/testing/selftests/nsfs/Makefile
··· 1 - TEST_PROGS := owner pidns 1 + TEST_GEN_PROGS := owner pidns 2 2 3 3 CFLAGS := -Wall -Werror 4 - 5 - all: owner pidns 6 - owner: owner.c 7 - pidns: pidns.c 8 - 9 - clean: 10 - $(RM) owner pidns 11 4 12 5 include ../lib.mk
+9 -5
tools/testing/selftests/powerpc/Makefile
··· 34 34 all: $(SUB_DIRS) 35 35 36 36 $(SUB_DIRS): 37 - $(MAKE) -k -C $@ all 37 + BUILD_TARGET=$$OUTPUT/$@; mkdir -p $$BUILD_TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -k -C $@ all 38 38 39 39 include ../lib.mk 40 40 41 41 override define RUN_TESTS 42 42 @for TARGET in $(SUB_DIRS); do \ 43 - $(MAKE) -C $$TARGET run_tests; \ 43 + BUILD_TARGET=$$OUTPUT/$$TARGET; \ 44 + $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests;\ 44 45 done; 45 46 endef 46 47 47 48 override define INSTALL_RULE 48 49 @for TARGET in $(SUB_DIRS); do \ 49 - $(MAKE) -C $$TARGET install; \ 50 + BUILD_TARGET=$$OUTPUT/$$TARGET; \ 51 + $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET install;\ 50 52 done; 51 53 endef 52 54 53 55 override define EMIT_TESTS 54 56 @for TARGET in $(SUB_DIRS); do \ 55 - $(MAKE) -s -C $$TARGET emit_tests; \ 57 + BUILD_TARGET=$$OUTPUT/$$TARGET; \ 58 + $(MAKE) OUTPUT=$$BUILD_TARGET -s -C $$TARGET emit_tests;\ 56 59 done; 57 60 endef 58 61 59 62 clean: 60 63 @for TARGET in $(SUB_DIRS); do \ 61 - $(MAKE) -C $$TARGET clean; \ 64 + BUILD_TARGET=$$OUTPUT/$$TARGET; \ 65 + $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean; \ 62 66 done; 63 67 rm -f tags 64 68
+2 -7
tools/testing/selftests/powerpc/alignment/Makefile
··· 1 - TEST_PROGS := copy_unaligned copy_first_unaligned paste_unaligned paste_last_unaligned 2 - 3 - all: $(TEST_PROGS) 4 - 5 - $(TEST_PROGS): ../harness.c ../utils.c copy_paste_unaligned_common.c 1 + TEST_GEN_PROGS := copy_unaligned copy_first_unaligned paste_unaligned paste_last_unaligned 6 2 7 3 include ../../lib.mk 8 4 9 - clean: 10 - rm -f $(TEST_PROGS) 5 + $(TEST_GEN_PROGS): ../harness.c ../utils.c copy_paste_unaligned_common.c
+6 -11
tools/testing/selftests/powerpc/benchmarks/Makefile
··· 1 - TEST_PROGS := gettimeofday context_switch mmap_bench futex_bench null_syscall 1 + TEST_GEN_PROGS := gettimeofday context_switch mmap_bench futex_bench null_syscall 2 2 3 3 CFLAGS += -O2 4 4 5 - all: $(TEST_PROGS) 6 - 7 - $(TEST_PROGS): ../harness.c 8 - 9 - context_switch: ../utils.c 10 - context_switch: CFLAGS += -maltivec -mvsx -mabi=altivec 11 - context_switch: LDLIBS += -lpthread 12 - 13 5 include ../../lib.mk 14 6 15 - clean: 16 - rm -f $(TEST_PROGS) *.o 7 + $(TEST_GEN_PROGS): ../harness.c 8 + 9 + $(OUTPUT)/context_switch: ../utils.c 10 + $(OUTPUT)/context_switch: CFLAGS += -maltivec -mvsx -mabi=altivec 11 + $(OUTPUT)/context_switch: LDLIBS += -lpthread
+2 -7
tools/testing/selftests/powerpc/context_switch/Makefile
··· 1 - TEST_PROGS := cp_abort 2 - 3 - all: $(TEST_PROGS) 4 - 5 - $(TEST_PROGS): ../harness.c ../utils.c 1 + TEST_GEN_PROGS := cp_abort 6 2 7 3 include ../../lib.mk 8 4 9 - clean: 10 - rm -f $(TEST_PROGS) 5 + $(TEST_GEN_PROGS): ../harness.c ../utils.c
+7 -12
tools/testing/selftests/powerpc/copyloops/Makefile
··· 7 7 # Use our CFLAGS for the implicit .S rule 8 8 ASFLAGS = $(CFLAGS) 9 9 10 - TEST_PROGS := copyuser_64 copyuser_power7 memcpy_64 memcpy_power7 10 + TEST_GEN_PROGS := copyuser_64 copyuser_power7 memcpy_64 memcpy_power7 11 11 EXTRA_SOURCES := validate.c ../harness.c 12 - 13 - all: $(TEST_PROGS) 14 - 15 - copyuser_64: CPPFLAGS += -D COPY_LOOP=test___copy_tofrom_user_base 16 - copyuser_power7: CPPFLAGS += -D COPY_LOOP=test___copy_tofrom_user_power7 17 - memcpy_64: CPPFLAGS += -D COPY_LOOP=test_memcpy 18 - memcpy_power7: CPPFLAGS += -D COPY_LOOP=test_memcpy_power7 19 - 20 - $(TEST_PROGS): $(EXTRA_SOURCES) 21 12 22 13 include ../../lib.mk 23 14 24 - clean: 25 - rm -f $(TEST_PROGS) *.o 15 + $(OUTPUT)/copyuser_64: CPPFLAGS += -D COPY_LOOP=test___copy_tofrom_user_base 16 + $(OUTPUT)/copyuser_power7: CPPFLAGS += -D COPY_LOOP=test___copy_tofrom_user_power7 17 + $(OUTPUT)/memcpy_64: CPPFLAGS += -D COPY_LOOP=test_memcpy 18 + $(OUTPUT)/memcpy_power7: CPPFLAGS += -D COPY_LOOP=test_memcpy_power7 19 + 20 + $(TEST_GEN_PROGS): $(EXTRA_SOURCES)
+4 -9
tools/testing/selftests/powerpc/dscr/Makefile
··· 1 - TEST_PROGS := dscr_default_test dscr_explicit_test dscr_user_test \ 1 + TEST_GEN_PROGS := dscr_default_test dscr_explicit_test dscr_user_test \ 2 2 dscr_inherit_test dscr_inherit_exec_test dscr_sysfs_test \ 3 3 dscr_sysfs_thread_test 4 4 5 - dscr_default_test: LDLIBS += -lpthread 6 - 7 - all: $(TEST_PROGS) 8 - 9 - $(TEST_PROGS): ../harness.c 10 - 11 5 include ../../lib.mk 12 6 13 - clean: 14 - rm -f $(TEST_PROGS) *.o 7 + $(OUTPUT)/dscr_default_test: LDLIBS += -lpthread 8 + 9 + $(TEST_GEN_PROGS): ../harness.c
+14 -19
tools/testing/selftests/powerpc/math/Makefile
··· 1 - TEST_PROGS := fpu_syscall fpu_preempt fpu_signal vmx_syscall vmx_preempt vmx_signal vsx_preempt 2 - 3 - all: $(TEST_PROGS) 4 - 5 - $(TEST_PROGS): ../harness.c 6 - $(TEST_PROGS): CFLAGS += -O2 -g -pthread -m64 -maltivec 7 - 8 - fpu_syscall: fpu_asm.S 9 - fpu_preempt: fpu_asm.S 10 - fpu_signal: fpu_asm.S 11 - 12 - vmx_syscall: vmx_asm.S 13 - vmx_preempt: vmx_asm.S 14 - vmx_signal: vmx_asm.S 15 - 16 - vsx_preempt: CFLAGS += -mvsx 17 - vsx_preempt: vsx_asm.S 1 + TEST_GEN_PROGS := fpu_syscall fpu_preempt fpu_signal vmx_syscall vmx_preempt vmx_signal vsx_preempt 18 2 19 3 include ../../lib.mk 20 4 21 - clean: 22 - rm -f $(TEST_PROGS) *.o 5 + $(TEST_GEN_PROGS): ../harness.c 6 + $(TEST_GEN_PROGS): CFLAGS += -O2 -g -pthread -m64 -maltivec 7 + 8 + $(OUTPUT)/fpu_syscall: fpu_asm.S 9 + $(OUTPUT)/fpu_preempt: fpu_asm.S 10 + $(OUTPUT)/fpu_signal: fpu_asm.S 11 + 12 + $(OUTPUT)/vmx_syscall: vmx_asm.S 13 + $(OUTPUT)/vmx_preempt: vmx_asm.S 14 + $(OUTPUT)/vmx_signal: vmx_asm.S 15 + 16 + $(OUTPUT)/vsx_preempt: CFLAGS += -mvsx 17 + $(OUTPUT)/vsx_preempt: vsx_asm.S
+8 -12
tools/testing/selftests/powerpc/mm/Makefile
··· 1 1 noarg: 2 2 $(MAKE) -C ../ 3 3 4 - TEST_PROGS := hugetlb_vs_thp_test subpage_prot prot_sao 5 - TEST_FILES := tempfile 6 - 7 - all: $(TEST_PROGS) $(TEST_FILES) 8 - 9 - $(TEST_PROGS): ../harness.c 10 - 11 - prot_sao: ../utils.c 4 + TEST_GEN_PROGS := hugetlb_vs_thp_test subpage_prot prot_sao 5 + TEST_GEN_FILES := tempfile 12 6 13 7 include ../../lib.mk 14 8 15 - tempfile: 16 - dd if=/dev/zero of=tempfile bs=64k count=1 9 + $(TEST_GEN_PROGS): ../harness.c 17 10 18 - clean: 19 - rm -f $(TEST_PROGS) tempfile 11 + $(OUTPUT)/prot_sao: ../utils.c 12 + 13 + $(OUTPUT)/tempfile: 14 + dd if=/dev/zero of=$@ bs=64k count=1 15 +
+13 -13
tools/testing/selftests/powerpc/pmu/Makefile
··· 1 1 noarg: 2 2 $(MAKE) -C ../ 3 3 4 - TEST_PROGS := count_instructions l3_bank_test per_event_excludes 4 + TEST_GEN_PROGS := count_instructions l3_bank_test per_event_excludes 5 5 EXTRA_SOURCES := ../harness.c event.c lib.c ../utils.c 6 6 7 - all: $(TEST_PROGS) ebb 7 + include ../../lib.mk 8 8 9 - $(TEST_PROGS): $(EXTRA_SOURCES) 9 + all: $(TEST_GEN_PROGS) ebb 10 + 11 + $(TEST_GEN_PROGS): $(EXTRA_SOURCES) 10 12 11 13 # loop.S can only be built 64-bit 12 - count_instructions: loop.S count_instructions.c $(EXTRA_SOURCES) 14 + $(OUTPUT)/count_instructions: loop.S count_instructions.c $(EXTRA_SOURCES) 13 15 $(CC) $(CFLAGS) -m64 -o $@ $^ 14 16 15 - per_event_excludes: ../utils.c 16 - 17 - include ../../lib.mk 17 + $(OUTPUT)/per_event_excludes: ../utils.c 18 18 19 19 DEFAULT_RUN_TESTS := $(RUN_TESTS) 20 20 override define RUN_TESTS 21 21 $(DEFAULT_RUN_TESTS) 22 - $(MAKE) -C ebb run_tests 22 + TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests 23 23 endef 24 24 25 25 DEFAULT_EMIT_TESTS := $(EMIT_TESTS) 26 26 override define EMIT_TESTS 27 27 $(DEFAULT_EMIT_TESTS) 28 - $(MAKE) -s -C ebb emit_tests 28 + TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -s -C $$TARGET emit_tests 29 29 endef 30 30 31 31 DEFAULT_INSTALL_RULE := $(INSTALL_RULE) 32 32 override define INSTALL_RULE 33 33 $(DEFAULT_INSTALL_RULE) 34 - $(MAKE) -C ebb install 34 + TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET install 35 35 endef 36 36 37 37 clean: 38 - rm -f $(TEST_PROGS) loop.o 39 - $(MAKE) -C ebb clean 38 + $(RM) $(TEST_GEN_PROGS) $(OUTPUT)/loop.o 39 + TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean 40 40 41 41 ebb: 42 - $(MAKE) -k -C $@ all 42 + TARGET=$@; BUILD_TARGET=$$OUTPUT/$$TARGET; mkdir -p $$BUILD_TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -k -C $$TARGET all 43 43 44 44 .PHONY: all run_tests clean ebb
+7 -12
tools/testing/selftests/powerpc/pmu/ebb/Makefile
··· 4 4 # The EBB handler is 64-bit code and everything links against it 5 5 CFLAGS += -m64 6 6 7 - TEST_PROGS := reg_access_test event_attributes_test cycles_test \ 7 + TEST_GEN_PROGS := reg_access_test event_attributes_test cycles_test \ 8 8 cycles_with_freeze_test pmc56_overflow_test \ 9 9 ebb_vs_cpu_event_test cpu_event_vs_ebb_test \ 10 10 cpu_event_pinned_vs_ebb_test task_event_vs_ebb_test \ ··· 16 16 lost_exception_test no_handler_test \ 17 17 cycles_with_mmcr2_test 18 18 19 - all: $(TEST_PROGS) 20 - 21 - $(TEST_PROGS): ../../harness.c ../../utils.c ../event.c ../lib.c \ 22 - ebb.c ebb_handler.S trace.c busy_loop.S 23 - 24 - instruction_count_test: ../loop.S 25 - 26 - lost_exception_test: ../lib.c 27 - 28 19 include ../../../lib.mk 29 20 30 - clean: 31 - rm -f $(TEST_PROGS) 21 + $(TEST_GEN_PROGS): ../../harness.c ../../utils.c ../event.c ../lib.c \ 22 + ebb.c ebb_handler.S trace.c busy_loop.S 23 + 24 + $(OUTPUT)/instruction_count_test: ../loop.S 25 + 26 + $(OUTPUT)/lost_exception_test: ../lib.c
+2 -7
tools/testing/selftests/powerpc/primitives/Makefile
··· 1 1 CFLAGS += -I$(CURDIR) 2 2 3 - TEST_PROGS := load_unaligned_zeropad 4 - 5 - all: $(TEST_PROGS) 6 - 7 - $(TEST_PROGS): ../harness.c 3 + TEST_GEN_PROGS := load_unaligned_zeropad 8 4 9 5 include ../../lib.mk 10 6 11 - clean: 12 - rm -f $(TEST_PROGS) *.o 7 + $(TEST_GEN_PROGS): ../harness.c
+2 -7
tools/testing/selftests/powerpc/stringloops/Makefile
··· 2 2 CFLAGS += -m64 3 3 CFLAGS += -I$(CURDIR) 4 4 5 - TEST_PROGS := memcmp 5 + TEST_GEN_PROGS := memcmp 6 6 EXTRA_SOURCES := memcmp_64.S ../harness.c 7 - 8 - all: $(TEST_PROGS) 9 - 10 - $(TEST_PROGS): $(EXTRA_SOURCES) 11 7 12 8 include ../../lib.mk 13 9 14 - clean: 15 - rm -f $(TEST_PROGS) *.o 10 + $(TEST_GEN_PROGS): $(EXTRA_SOURCES)
+9 -12
tools/testing/selftests/powerpc/switch_endian/Makefile
··· 1 - TEST_PROGS := switch_endian_test 1 + TEST_GEN_PROGS := switch_endian_test 2 2 3 3 ASFLAGS += -O2 -Wall -g -nostdlib -m64 4 4 5 - all: $(TEST_PROGS) 6 - 7 - switch_endian_test: check-reversed.S 8 - 9 - check-reversed.o: check.o 10 - $(CROSS_COMPILE)objcopy -j .text --reverse-bytes=4 -O binary $< $@ 11 - 12 - check-reversed.S: check-reversed.o 13 - hexdump -v -e '/1 ".byte 0x%02X\n"' $< > $@ 5 + EXTRA_CLEAN = $(OUTPUT)/*.o $(OUTPUT)/check-reversed.S 14 6 15 7 include ../../lib.mk 16 8 17 - clean: 18 - rm -f $(TEST_PROGS) *.o check-reversed.S 9 + $(OUTPUT)/switch_endian_test: $(OUTPUT)/check-reversed.S 10 + 11 + $(OUTPUT)/check-reversed.o: $(OUTPUT)/check.o 12 + $(CROSS_COMPILE)objcopy -j .text --reverse-bytes=4 -O binary $< $@ 13 + 14 + $(OUTPUT)/check-reversed.S: $(OUTPUT)/check-reversed.o 15 + hexdump -v -e '/1 ".byte 0x%02X\n"' $< > $@
+2 -7
tools/testing/selftests/powerpc/syscalls/Makefile
··· 1 - TEST_PROGS := ipc_unmuxed 1 + TEST_GEN_PROGS := ipc_unmuxed 2 2 3 3 CFLAGS += -I../../../../../usr/include 4 4 5 - all: $(TEST_PROGS) 6 - 7 - $(TEST_PROGS): ../harness.c 8 - 9 5 include ../../lib.mk 10 6 11 - clean: 12 - rm -f $(TEST_PROGS) *.o 7 + $(TEST_GEN_PROGS): ../harness.c
+12 -16
tools/testing/selftests/powerpc/tm/Makefile
··· 1 1 SIGNAL_CONTEXT_CHK_TESTS := tm-signal-context-chk-gpr tm-signal-context-chk-fpu \ 2 2 tm-signal-context-chk-vmx tm-signal-context-chk-vsx 3 3 4 - TEST_PROGS := tm-resched-dscr tm-syscall tm-signal-msr-resv tm-signal-stack \ 4 + TEST_GEN_PROGS := tm-resched-dscr tm-syscall tm-signal-msr-resv tm-signal-stack \ 5 5 tm-vmxcopy tm-fork tm-tar tm-tmspr $(SIGNAL_CONTEXT_CHK_TESTS) 6 - 7 - all: $(TEST_PROGS) 8 - 9 - $(TEST_PROGS): ../harness.c ../utils.c 10 - 11 - CFLAGS += -mhtm 12 - 13 - tm-syscall: tm-syscall-asm.S 14 - tm-syscall: CFLAGS += -I../../../../../usr/include 15 - tm-tmspr: CFLAGS += -pthread 16 - 17 - $(SIGNAL_CONTEXT_CHK_TESTS): tm-signal.S 18 - $(SIGNAL_CONTEXT_CHK_TESTS): CFLAGS += -mhtm -m64 -mvsx 19 6 20 7 include ../../lib.mk 21 8 22 - clean: 23 - rm -f $(TEST_PROGS) *.o 9 + $(TEST_GEN_PROGS): ../harness.c ../utils.c 10 + 11 + CFLAGS += -mhtm 12 + 13 + $(OUTPUT)/tm-syscall: tm-syscall-asm.S 14 + $(OUTPUT)/tm-syscall: CFLAGS += -I../../../../../usr/include 15 + $(OUTPUT)/tm-tmspr: CFLAGS += -pthread 16 + 17 + SIGNAL_CONTEXT_CHK_TESTS := $(patsubst %,$(OUTPUT)/%,$(SIGNAL_CONTEXT_CHK_TESTS)) 18 + $(SIGNAL_CONTEXT_CHK_TESTS): tm-signal.S 19 + $(SIGNAL_CONTEXT_CHK_TESTS): CFLAGS += -mhtm -m64 -mvsx
+3 -7
tools/testing/selftests/powerpc/vphn/Makefile
··· 1 - TEST_PROGS := test-vphn 1 + TEST_GEN_PROGS := test-vphn 2 2 3 3 CFLAGS += -m64 4 4 5 - all: $(TEST_PROGS) 6 - 7 - $(TEST_PROGS): ../harness.c 8 - 9 5 include ../../lib.mk 10 6 11 - clean: 12 - rm -f $(TEST_PROGS) 7 + $(TEST_GEN_PROGS): ../harness.c 8 +
+1 -3
tools/testing/selftests/pstore/Makefile
··· 5 5 6 6 TEST_PROGS := pstore_tests pstore_post_reboot_tests 7 7 TEST_FILES := common_tests pstore_crash_test 8 + EXTRA_CLEAN := logs/* *uuid 8 9 9 10 include ../lib.mk 10 11 11 12 run_crash: 12 13 @sh pstore_crash_test || { echo "pstore_crash_test: [FAIL]"; exit 1; } 13 - 14 - clean: 15 - rm -rf logs/* *uuid
+1 -7
tools/testing/selftests/ptrace/Makefile
··· 1 1 CFLAGS += -iquote../../../../include/uapi -Wall 2 - peeksiginfo: peeksiginfo.c 3 2 4 - all: peeksiginfo 5 - 6 - clean: 7 - rm -f peeksiginfo 8 - 9 - TEST_PROGS := peeksiginfo 3 + TEST_GEN_PROGS := peeksiginfo 10 4 11 5 include ../lib.mk
+1 -5
tools/testing/selftests/seccomp/Makefile
··· 1 - TEST_PROGS := seccomp_bpf 1 + TEST_GEN_PROGS := seccomp_bpf 2 2 CFLAGS += -Wl,-no-as-needed -Wall 3 3 LDFLAGS += -lpthread 4 4 5 - all: $(TEST_PROGS) 6 - 7 5 include ../lib.mk 8 6 9 - clean: 10 - $(RM) $(TEST_PROGS)
+1 -4
tools/testing/selftests/sigaltstack/Makefile
··· 1 1 CFLAGS = -Wall 2 - BINARIES = sas 3 - all: $(BINARIES) 2 + TEST_GEN_PROGS = sas 4 3 5 4 include ../lib.mk 6 5 7 - clean: 8 - rm -rf $(BINARIES)
+2 -8
tools/testing/selftests/size/Makefile
··· 1 - all: get_size 1 + CFLAGS := -static -ffreestanding -nostartfiles -s 2 2 3 - get_size: get_size.c 4 - $(CC) -static -ffreestanding -nostartfiles -s $< -o $@ 5 - 6 - TEST_PROGS := get_size 3 + TEST_GEN_PROGS := get_size 7 4 8 5 include ../lib.mk 9 - 10 - clean: 11 - $(RM) get_size
+2 -8
tools/testing/selftests/timers/Makefile
··· 1 - CC = $(CROSS_COMPILE)gcc 2 1 BUILD_FLAGS = -DKTEST 3 2 CFLAGS += -O3 -Wl,-no-as-needed -Wall $(BUILD_FLAGS) 4 3 LDFLAGS += -lrt -lpthread 5 4 6 5 # these are all "safe" tests that don't modify 7 6 # system time or require escalated privledges 8 - TEST_PROGS = posix_timers nanosleep nsleep-lat set-timer-lat mqueue-lat \ 7 + TEST_GEN_PROGS = posix_timers nanosleep nsleep-lat set-timer-lat mqueue-lat \ 9 8 inconsistency-check raw_skew threadtest rtctest 10 9 11 - TEST_PROGS_EXTENDED = alarmtimer-suspend valid-adjtimex adjtick change_skew \ 10 + TEST_GEN_PROGS_EXTENDED = alarmtimer-suspend valid-adjtimex adjtick change_skew \ 12 11 skew_consistency clocksource-switch leap-a-day \ 13 12 leapcrash set-tai set-2038 set-tz 14 13 15 - bins = $(TEST_PROGS) $(TEST_PROGS_EXTENDED) 16 - 17 - all: ${bins} 18 14 19 15 include ../lib.mk 20 16 ··· 30 34 ./set-tai 31 35 ./set-2038 32 36 33 - clean: 34 - rm -f ${bins}
+25 -33
tools/testing/selftests/vm/Makefile
··· 1 1 # Makefile for vm selftests 2 2 3 3 CFLAGS = -Wall -I ../../../../usr/include $(EXTRA_CFLAGS) 4 - BINARIES = compaction_test 5 - BINARIES += hugepage-mmap 6 - BINARIES += hugepage-shm 7 - BINARIES += map_hugetlb 8 - BINARIES += mlock2-tests 9 - BINARIES += on-fault-limit 10 - BINARIES += thuge-gen 11 - BINARIES += transhuge-stress 12 - BINARIES += userfaultfd 13 - BINARIES += userfaultfd_hugetlb 14 - BINARIES += userfaultfd_shmem 15 - BINARIES += mlock-random-test 16 - 17 - all: $(BINARIES) 18 - %: %.c 19 - $(CC) $(CFLAGS) -o $@ $^ -lrt 20 - userfaultfd: userfaultfd.c ../../../../usr/include/linux/kernel.h 21 - $(CC) $(CFLAGS) -O2 -o $@ $< -lpthread 22 - 23 - userfaultfd_hugetlb: userfaultfd.c ../../../../usr/include/linux/kernel.h 24 - $(CC) $(CFLAGS) -DHUGETLB_TEST -O2 -o $@ $< -lpthread 25 - 26 - userfaultfd_shmem: userfaultfd.c ../../../../usr/include/linux/kernel.h 27 - $(CC) $(CFLAGS) -DSHMEM_TEST -O2 -o $@ $< -lpthread 28 - 29 - mlock-random-test: mlock-random-test.c 30 - $(CC) $(CFLAGS) -o $@ $< -lcap 31 - 32 - ../../../../usr/include/linux/kernel.h: 33 - make -C ../../../.. headers_install 4 + LDLIBS = -lrt 5 + TEST_GEN_FILES = compaction_test 6 + TEST_GEN_FILES += hugepage-mmap 7 + TEST_GEN_FILES += hugepage-shm 8 + TEST_GEN_FILES += map_hugetlb 9 + TEST_GEN_FILES += mlock2-tests 10 + TEST_GEN_FILES += on-fault-limit 11 + TEST_GEN_FILES += thuge-gen 12 + TEST_GEN_FILES += transhuge-stress 13 + TEST_GEN_FILES += userfaultfd 14 + TEST_GEN_FILES += userfaultfd_hugetlb 15 + TEST_GEN_FILES += userfaultfd_shmem 16 + TEST_GEN_FILES += mlock-random-test 34 17 35 18 TEST_PROGS := run_vmtests 36 - TEST_FILES := $(BINARIES) 37 19 38 20 include ../lib.mk 39 21 40 - clean: 41 - $(RM) $(BINARIES) 22 + $(OUTPUT)/userfaultfd: LDLIBS += -lpthread ../../../../usr/include/linux/kernel.h 23 + 24 + $(OUTPUT)/userfaultfd_hugetlb: userfaultfd.c ../../../../usr/include/linux/kernel.h 25 + $(CC) $(CFLAGS) -DHUGETLB_TEST -O2 -o $@ $< -lpthread 26 + 27 + $(OUTPUT)/userfaultfd_shmem: userfaultfd.c ../../../../usr/include/linux/kernel.h 28 + $(CC) $(CFLAGS) -DSHMEM_TEST -O2 -o $@ $< -lpthread 29 + 30 + $(OUTPUT)/mlock-random-test: LDLIBS += -lcap 31 + 32 + ../../../../usr/include/linux/kernel.h: 33 + make -C ../../../.. headers_install
+10 -7
tools/testing/selftests/x86/Makefile
··· 17 17 BINARIES_32 := $(TARGETS_C_32BIT_ALL:%=%_32) 18 18 BINARIES_64 := $(TARGETS_C_64BIT_ALL:%=%_64) 19 19 20 + BINARIES_32 := $(patsubst %,$(OUTPUT)/%,$(BINARIES_32)) 21 + BINARIES_64 := $(patsubst %,$(OUTPUT)/%,$(BINARIES_64)) 22 + 20 23 CFLAGS := -O2 -g -std=gnu99 -pthread -Wall 21 24 22 25 UNAME_M := $(shell uname -m) ··· 43 40 clean: 44 41 $(RM) $(BINARIES_32) $(BINARIES_64) 45 42 46 - $(TARGETS_C_32BIT_ALL:%=%_32): %_32: %.c 43 + $(BINARIES_32): $(OUTPUT)/%_32: %.c 47 44 $(CC) -m32 -o $@ $(CFLAGS) $(EXTRA_CFLAGS) $^ -lrt -ldl -lm 48 45 49 - $(TARGETS_C_64BIT_ALL:%=%_64): %_64: %.c 46 + $(BINARIES_64): $(OUTPUT)/%_64: %.c 50 47 $(CC) -m64 -o $@ $(CFLAGS) $(EXTRA_CFLAGS) $^ -lrt -ldl 51 48 52 49 # x86_64 users should be encouraged to install 32-bit libraries ··· 68 65 endif 69 66 70 67 # Some tests have additional dependencies. 71 - sysret_ss_attrs_64: thunks.S 72 - ptrace_syscall_32: raw_syscall_helper_32.S 73 - test_syscall_vdso_32: thunks_32.S 68 + $(OUTPUT)/sysret_ss_attrs_64: thunks.S 69 + $(OUTPUT)/ptrace_syscall_32: raw_syscall_helper_32.S 70 + $(OUTPUT)/test_syscall_vdso_32: thunks_32.S 74 71 75 72 # check_initial_reg_state is special: it needs a custom entry, and it 76 73 # needs to be static so that its interpreter doesn't destroy its initial 77 74 # state. 78 - check_initial_reg_state_32: CFLAGS += -Wl,-ereal_start -static 79 - check_initial_reg_state_64: CFLAGS += -Wl,-ereal_start -static 75 + $(OUTPUT)/check_initial_reg_state_32: CFLAGS += -Wl,-ereal_start -static 76 + $(OUTPUT)/check_initial_reg_state_64: CFLAGS += -Wl,-ereal_start -static
+2 -17
tools/testing/selftests/x86/protection_keys.c
··· 192 192 #define SYS_pkey_alloc 381 193 193 #define SYS_pkey_free 382 194 194 #define REG_IP_IDX REG_EIP 195 - #define si_pkey_offset 0x18 195 + #define si_pkey_offset 0x14 196 196 #else 197 197 #define SYS_mprotect_key 329 198 198 #define SYS_pkey_alloc 330 ··· 462 462 unsigned long syscall_flags = 0; 463 463 int ret; 464 464 int pkey_rights; 465 - u32 orig_pkru; 465 + u32 orig_pkru = rdpkru(); 466 466 467 467 dprintf1("START->%s(%d, 0x%x)\n", __func__, 468 468 pkey, flags); ··· 812 812 { 813 813 int err; 814 814 int fd; 815 - int validated_nr_pages; 816 - int i; 817 815 char buf[] = "123"; 818 816 819 817 if (geteuid() != 0) { ··· 1114 1116 err = sys_pkey_free(i); 1115 1117 pkey_assert(err); 1116 1118 1117 - /* not enforced when pkey_get() is not a syscall 1118 - err = pkey_get(i, 0); 1119 - pkey_assert(err < 0); 1120 - */ 1121 - 1122 1119 err = sys_pkey_free(i); 1123 1120 pkey_assert(err); 1124 1121 ··· 1126 1133 void test_pkey_syscalls_bad_args(int *ptr, u16 pkey) 1127 1134 { 1128 1135 int err; 1129 - int bad_flag = (PKEY_DISABLE_ACCESS | PKEY_DISABLE_WRITE) + 1; 1130 1136 int bad_pkey = NR_PKEYS+99; 1131 - 1132 - /* not enforced when pkey_get() is not a syscall 1133 - err = pkey_get(bad_pkey, bad_flag); 1134 - pkey_assert(err < 0); 1135 - */ 1136 1137 1137 1138 /* pass a known-invalid pkey in: */ 1138 1139 err = sys_mprotect_pkey(ptr, PAGE_SIZE, PROT_READ, bad_pkey); ··· 1136 1149 /* Assumes that all pkeys other than 'pkey' are unallocated */ 1137 1150 void test_pkey_alloc_exhaust(int *ptr, u16 pkey) 1138 1151 { 1139 - unsigned long flags; 1140 - unsigned long init_val; 1141 1152 int err; 1142 1153 int allocated_pkeys[NR_PKEYS] = {0}; 1143 1154 int nr_allocated_pkeys = 0;
+1 -2
tools/testing/selftests/zram/Makefile
··· 2 2 3 3 TEST_PROGS := zram.sh 4 4 TEST_FILES := zram01.sh zram02.sh zram_lib.sh 5 + EXTRA_CLEAN := err.log 5 6 6 7 include ../lib.mk 7 8 8 - clean: 9 - $(RM) err.log