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

Configure Feed

Select the types of activity you want to include in your feed.

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

Pull kselftest updates from Shuah Khan:

- ftrace test fixes to check for required filter files and kprobe args.

- Kselftest build/cross-build dependency check script to make it easier
for test ring admins/users to configure build systems correctly for
build/cross-build kselftests. Currently checks library dependencies.

- Checks if Kselftests can be built/cross-built on a system running
compile test on a trivial C file with LDLIBS specified for each
individual test in their Makefiles.

- Prints suggested target list for a system filtering out tests
failed the build dependency check from the TARGETS in Selftests
the main Makefile when optional -p is specified.

- Prints pass/fail dependency check for each tests/sub-test.

- Prints pass/fail targets and libraries.

- Default: runs dependency checks on all tests.

- Optional test name can be specified to check dependencies for it.

* tag 'linux-kselftest-5.7-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
selftests/ftrace: Check the first record for kprobe_args_type.tc
selftests: add build/cross-build dependency check script
selftests/ftrace: Check required filter files before running test

+315 -40
+1 -4
tools/testing/selftests/ftrace/test.d/ftrace/fgraph-filter-stack.tc
··· 10 10 exit_unsupported 11 11 fi 12 12 13 - if [ ! -f set_ftrace_filter ]; then 14 - echo "set_ftrace_filter not found? Is dynamic ftrace not set?" 15 - exit_unsupported 16 - fi 13 + check_filter_file set_ftrace_filter 17 14 18 15 do_reset() { 19 16 if [ -e /proc/sys/kernel/stack_tracer_enabled ]; then
+2
tools/testing/selftests/ftrace/test.d/ftrace/fgraph-filter.tc
··· 9 9 exit_unsupported 10 10 fi 11 11 12 + check_filter_file set_ftrace_filter 13 + 12 14 fail() { # msg 13 15 echo $1 14 16 exit_fail
+2
tools/testing/selftests/ftrace/test.d/ftrace/func-filter-glob.tc
··· 9 9 exit_unsupported 10 10 fi 11 11 12 + check_filter_file set_ftrace_filter 13 + 12 14 disable_tracing 13 15 clear_trace 14 16
+1 -4
tools/testing/selftests/ftrace/test.d/ftrace/func-filter-notrace-pid.tc
··· 15 15 exit_unsupported 16 16 fi 17 17 18 - if [ ! -f set_ftrace_filter ]; then 19 - echo "set_ftrace_filter not found? Is function tracer not set?" 20 - exit_unsupported 21 - fi 18 + check_filter_file set_ftrace_filter 22 19 23 20 do_function_fork=1 24 21
+1 -4
tools/testing/selftests/ftrace/test.d/ftrace/func-filter-pid.tc
··· 16 16 exit_unsupported 17 17 fi 18 18 19 - if [ ! -f set_ftrace_filter ]; then 20 - echo "set_ftrace_filter not found? Is function tracer not set?" 21 - exit_unsupported 22 - fi 19 + check_filter_file set_ftrace_filter 23 20 24 21 do_function_fork=1 25 22
+1 -1
tools/testing/selftests/ftrace/test.d/ftrace/func-filter-stacktrace.tc
··· 3 3 # description: ftrace - stacktrace filter command 4 4 # flags: instance 5 5 6 - [ ! -f set_ftrace_filter ] && exit_unsupported 6 + check_filter_file set_ftrace_filter 7 7 8 8 echo _do_fork:stacktrace >> set_ftrace_filter 9 9
+1 -4
tools/testing/selftests/ftrace/test.d/ftrace/func_event_triggers.tc
··· 11 11 # 12 12 13 13 # The triggers are set within the set_ftrace_filter file 14 - if [ ! -f set_ftrace_filter ]; then 15 - echo "set_ftrace_filter not found? Is dynamic ftrace not set?" 16 - exit_unsupported 17 - fi 14 + check_filter_file set_ftrace_filter 18 15 19 16 do_reset() { 20 17 reset_ftrace_filter
+1 -1
tools/testing/selftests/ftrace/test.d/ftrace/func_mod_trace.tc
··· 2 2 # SPDX-License-Identifier: GPL-2.0 3 3 # description: ftrace - function trace on module 4 4 5 - [ ! -f set_ftrace_filter ] && exit_unsupported 5 + check_filter_file set_ftrace_filter 6 6 7 7 : "mod: allows to filter a non exist function" 8 8 echo 'non_exist_func:mod:non_exist_module' > set_ftrace_filter
+1 -4
tools/testing/selftests/ftrace/test.d/ftrace/func_profiler.tc
··· 18 18 exit_unsupported; 19 19 fi 20 20 21 - if [ ! -f set_ftrace_filter ]; then 22 - echo "set_ftrace_filter not found? Is dynamic ftrace not set?" 23 - exit_unsupported 24 - fi 21 + check_filter_file set_ftrace_filter 25 22 26 23 if [ ! -f function_profile_enabled ]; then 27 24 echo "function_profile_enabled not found, function profiling enabled?"
+1 -4
tools/testing/selftests/ftrace/test.d/ftrace/func_set_ftrace_file.tc
··· 10 10 # 11 11 12 12 # The triggers are set within the set_ftrace_filter file 13 - if [ ! -f set_ftrace_filter ]; then 14 - echo "set_ftrace_filter not found? Is dynamic ftrace not set?" 15 - exit_unsupported 16 - fi 13 + check_filter_file set_ftrace_filter 17 14 18 15 fail() { # mesg 19 16 echo $1
+2
tools/testing/selftests/ftrace/test.d/ftrace/func_stack_tracer.tc
··· 8 8 exit_unsupported 9 9 fi 10 10 11 + check_filter_file stack_trace_filter 12 + 11 13 echo > stack_trace_filter 12 14 echo 0 > stack_max_size 13 15 echo 1 > /proc/sys/kernel/stack_tracer_enabled
+1 -4
tools/testing/selftests/ftrace/test.d/ftrace/func_traceonoff_triggers.tc
··· 11 11 # 12 12 13 13 # The triggers are set within the set_ftrace_filter file 14 - if [ ! -f set_ftrace_filter ]; then 15 - echo "set_ftrace_filter not found? Is dynamic ftrace not set?" 16 - exit_unsupported 17 - fi 14 + check_filter_file set_ftrace_filter 18 15 19 16 fail() { # mesg 20 17 echo $1
+6
tools/testing/selftests/ftrace/test.d/functions
··· 1 + check_filter_file() { # check filter file introduced by dynamic ftrace 2 + if [ ! -f "$1" ]; then 3 + echo "$1 not found? Is dynamic ftrace not set?" 4 + exit_unsupported 5 + fi 6 + } 1 7 2 8 clear_trace() { # reset trace output 3 9 echo > trace
+1 -1
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_type.tc
··· 38 38 echo 0 > events/kprobes/testprobe/enable 39 39 40 40 : "Confirm the arguments is recorded in given types correctly" 41 - ARGS=`grep "testprobe" trace | sed -e 's/.* arg1=\(.*\) arg2=\(.*\) arg3=\(.*\) arg4=\(.*\)/\1 \2 \3 \4/'` 41 + ARGS=`grep "testprobe" trace | head -n 1 | sed -e 's/.* arg1=\(.*\) arg2=\(.*\) arg3=\(.*\) arg4=\(.*\)/\1 \2 \3 \4/'` 42 42 check_types $ARGS $width 43 43 44 44 : "Clear event for next loop"
+2
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_ftrace.tc
··· 5 5 [ -f kprobe_events ] || exit_unsupported # this is configurable 6 6 grep "function" available_tracers || exit_unsupported # this is configurable 7 7 8 + check_filter_file set_ftrace_filter 9 + 8 10 # prepare 9 11 echo nop > current_tracer 10 12 echo _do_fork > set_ftrace_filter
+6 -6
tools/testing/selftests/gpio/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 3 - MOUNT_CFLAGS := $(shell pkg-config --cflags mount 2>/dev/null) 4 - MOUNT_LDLIBS := $(shell pkg-config --libs mount 2>/dev/null) 5 - ifeq ($(MOUNT_LDLIBS),) 6 - MOUNT_LDLIBS := -lmount -I/usr/include/libmount 3 + VAR_CFLAGS := $(shell pkg-config --cflags mount 2>/dev/null) 4 + VAR_LDLIBS := $(shell pkg-config --libs mount 2>/dev/null) 5 + ifeq ($(VAR_LDLIBS),) 6 + VAR_LDLIBS := -lmount -I/usr/include/libmount 7 7 endif 8 8 9 - CFLAGS += -O2 -g -std=gnu99 -Wall -I../../../../usr/include/ $(MOUNT_CFLAGS) 10 - LDLIBS += $(MOUNT_LDLIBS) 9 + CFLAGS += -O2 -g -std=gnu99 -Wall -I../../../../usr/include/ $(VAR_CFLAGS) 10 + LDLIBS += $(VAR_LDLIBS) 11 11 12 12 TEST_PROGS := gpio-mockup.sh 13 13 TEST_FILES := gpio-mockup-sysfs.sh
+1 -1
tools/testing/selftests/intel_pstate/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 CFLAGS := $(CFLAGS) -Wall -D_GNU_SOURCE 3 - LDLIBS := $(LDLIBS) -lm 3 + LDLIBS += -lm 4 4 5 5 uname_M := $(shell uname -m 2>/dev/null || echo not) 6 6 ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/x86/ -e s/x86_64/x86/)
+272
tools/testing/selftests/kselftest_deps.sh
··· 1 + #!/bin/bash 2 + # SPDX-License-Identifier: GPL-2.0 3 + # kselftest_deps.sh 4 + # 5 + # Checks for kselftest build dependencies on the build system. 6 + # Copyright (c) 2020 Shuah Khan <skhan@linuxfoundation.org> 7 + # 8 + # 9 + 10 + usage() 11 + { 12 + 13 + echo -e "Usage: $0 -[p] <compiler> [test_name]\n" 14 + echo -e "\tkselftest_deps.sh [-p] gcc" 15 + echo -e "\tkselftest_deps.sh [-p] gcc vm" 16 + echo -e "\tkselftest_deps.sh [-p] aarch64-linux-gnu-gcc" 17 + echo -e "\tkselftest_deps.sh [-p] aarch64-linux-gnu-gcc vm\n" 18 + echo "- Should be run in selftests directory in the kernel repo." 19 + echo "- Checks if Kselftests can be built/cross-built on a system." 20 + echo "- Parses all test/sub-test Makefile to find library dependencies." 21 + echo "- Runs compile test on a trivial C file with LDLIBS specified" 22 + echo " in the test Makefiles to identify missing library dependencies." 23 + echo "- Prints suggested target list for a system filtering out tests" 24 + echo " failed the build dependency check from the TARGETS in Selftests" 25 + echo " main Makefile when optional -p is specified." 26 + echo "- Prints pass/fail dependency check for each tests/sub-test." 27 + echo "- Prints pass/fail targets and libraries." 28 + echo "- Default: runs dependency checks on all tests." 29 + echo "- Optional test name can be specified to check dependencies for it." 30 + exit 1 31 + 32 + } 33 + 34 + # Start main() 35 + main() 36 + { 37 + 38 + base_dir=`pwd` 39 + # Make sure we're in the selftests top-level directory. 40 + if [ $(basename "$base_dir") != "selftests" ]; then 41 + echo -e "\tPlease run $0 in" 42 + echo -e "\ttools/testing/selftests directory ..." 43 + exit 1 44 + fi 45 + 46 + print_targets=0 47 + 48 + while getopts "p" arg; do 49 + case $arg in 50 + p) 51 + print_targets=1 52 + shift;; 53 + esac 54 + done 55 + 56 + if [ $# -eq 0 ] 57 + then 58 + usage 59 + fi 60 + 61 + # Compiler 62 + CC=$1 63 + 64 + tmp_file=$(mktemp).c 65 + trap "rm -f $tmp_file.o $tmp_file $tmp_file.bin" EXIT 66 + #echo $tmp_file 67 + 68 + pass=$(mktemp).out 69 + trap "rm -f $pass" EXIT 70 + #echo $pass 71 + 72 + fail=$(mktemp).out 73 + trap "rm -f $fail" EXIT 74 + #echo $fail 75 + 76 + # Generate tmp source fire for compile test 77 + cat << "EOF" > $tmp_file 78 + int main() 79 + { 80 + } 81 + EOF 82 + 83 + # Save results 84 + total_cnt=0 85 + fail_trgts=() 86 + fail_libs=() 87 + fail_cnt=0 88 + pass_trgts=() 89 + pass_libs=() 90 + pass_cnt=0 91 + 92 + # Get all TARGETS from selftests Makefile 93 + targets=$(egrep "^TARGETS +|^TARGETS =" Makefile | cut -d "=" -f2) 94 + 95 + # Single test case 96 + if [ $# -eq 2 ] 97 + then 98 + test=$2/Makefile 99 + 100 + l1_test $test 101 + l2_test $test 102 + l3_test $test 103 + 104 + print_results $1 $2 105 + exit $? 106 + fi 107 + 108 + # Level 1: LDLIBS set static. 109 + # 110 + # Find all LDLIBS set statically for all executables built by a Makefile 111 + # and filter out VAR_LDLIBS to discard the following: 112 + # gpio/Makefile:LDLIBS += $(VAR_LDLIBS) 113 + # Append space at the end of the list to append more tests. 114 + 115 + l1_tests=$(grep -r --include=Makefile "^LDLIBS" | \ 116 + grep -v "VAR_LDLIBS" | awk -F: '{print $1}') 117 + 118 + # Level 2: LDLIBS set dynamically. 119 + # 120 + # Level 2 121 + # Some tests have multiple valid LDLIBS lines for individual sub-tests 122 + # that need dependency checks. Find them and append them to the tests 123 + # e.g: vm/Makefile:$(OUTPUT)/userfaultfd: LDLIBS += -lpthread 124 + # Filter out VAR_LDLIBS to discard the following: 125 + # memfd/Makefile:$(OUTPUT)/fuse_mnt: LDLIBS += $(VAR_LDLIBS) 126 + # Append space at the end of the list to append more tests. 127 + 128 + l2_tests=$(grep -r --include=Makefile ": LDLIBS" | \ 129 + grep -v "VAR_LDLIBS" | awk -F: '{print $1}') 130 + 131 + # Level 3 132 + # gpio, memfd and others use pkg-config to find mount and fuse libs 133 + # respectively and save it in VAR_LDLIBS. If pkg-config doesn't find 134 + # any, VAR_LDLIBS set to default. 135 + # Use the default value and filter out pkg-config for dependency check. 136 + # e.g: 137 + # gpio/Makefile 138 + # VAR_LDLIBS := $(shell pkg-config --libs mount) 2>/dev/null) 139 + # memfd/Makefile 140 + # VAR_LDLIBS := $(shell pkg-config fuse --libs 2>/dev/null) 141 + 142 + l3_tests=$(grep -r --include=Makefile "^VAR_LDLIBS" | \ 143 + grep -v "pkg-config" | awk -F: '{print $1}') 144 + 145 + #echo $l1_tests 146 + #echo $l2_1_tests 147 + #echo $l3_tests 148 + 149 + all_tests 150 + print_results $1 $2 151 + 152 + exit $? 153 + } 154 + # end main() 155 + 156 + all_tests() 157 + { 158 + for test in $l1_tests; do 159 + l1_test $test 160 + done 161 + 162 + for test in $l2_tests; do 163 + l2_test $test 164 + done 165 + 166 + for test in $l3_tests; do 167 + l3_test $test 168 + done 169 + } 170 + 171 + # Use same parsing used for l1_tests and pick libraries this time. 172 + l1_test() 173 + { 174 + test_libs=$(grep --include=Makefile "^LDLIBS" $test | \ 175 + grep -v "VAR_LDLIBS" | \ 176 + sed -e 's/\:/ /' | \ 177 + sed -e 's/+/ /' | cut -d "=" -f 2) 178 + 179 + check_libs $test $test_libs 180 + } 181 + 182 + # Use same parsing used for l2__tests and pick libraries this time. 183 + l2_test() 184 + { 185 + test_libs=$(grep --include=Makefile ": LDLIBS" $test | \ 186 + grep -v "VAR_LDLIBS" | \ 187 + sed -e 's/\:/ /' | sed -e 's/+/ /' | \ 188 + cut -d "=" -f 2) 189 + 190 + check_libs $test $test_libs 191 + } 192 + 193 + l3_test() 194 + { 195 + test_libs=$(grep --include=Makefile "^VAR_LDLIBS" $test | \ 196 + grep -v "pkg-config" | sed -e 's/\:/ /' | 197 + sed -e 's/+/ /' | cut -d "=" -f 2) 198 + 199 + check_libs $test $test_libs 200 + } 201 + 202 + check_libs() 203 + { 204 + 205 + if [[ ! -z "${test_libs// }" ]] 206 + then 207 + 208 + #echo $test_libs 209 + 210 + for lib in $test_libs; do 211 + 212 + let total_cnt+=1 213 + $CC -o $tmp_file.bin $lib $tmp_file > /dev/null 2>&1 214 + if [ $? -ne 0 ]; then 215 + echo "FAIL: $test dependency check: $lib" >> $fail 216 + let fail_cnt+=1 217 + fail_libs+="$lib " 218 + fail_target=$(echo "$test" | cut -d "/" -f1) 219 + fail_trgts+="$fail_target " 220 + targets=$(echo "$targets" | grep -v "$fail_target") 221 + else 222 + echo "PASS: $test dependency check passed $lib" >> $pass 223 + let pass_cnt+=1 224 + pass_libs+="$lib " 225 + pass_trgts+="$(echo "$test" | cut -d "/" -f1) " 226 + fi 227 + 228 + done 229 + fi 230 + } 231 + 232 + print_results() 233 + { 234 + echo -e "========================================================"; 235 + echo -e "Kselftest Dependency Check for [$0 $1 $2] results..." 236 + 237 + if [ $print_targets -ne 0 ] 238 + then 239 + echo -e "Suggested Selftest Targets for your configuration:" 240 + echo -e "$targets"; 241 + fi 242 + 243 + echo -e "========================================================"; 244 + echo -e "Checked tests defining LDLIBS dependencies" 245 + echo -e "--------------------------------------------------------"; 246 + echo -e "Total tests with Dependencies:" 247 + echo -e "$total_cnt Pass: $pass_cnt Fail: $fail_cnt"; 248 + 249 + if [ $pass_cnt -ne 0 ]; then 250 + echo -e "--------------------------------------------------------"; 251 + cat $pass 252 + echo -e "--------------------------------------------------------"; 253 + echo -e "Targets passed build dependency check on system:" 254 + echo -e "$(echo "$pass_trgts" | xargs -n1 | sort -u | xargs)" 255 + fi 256 + 257 + if [ $fail_cnt -ne 0 ]; then 258 + echo -e "--------------------------------------------------------"; 259 + cat $fail 260 + echo -e "--------------------------------------------------------"; 261 + echo -e "Targets failed build dependency check on system:" 262 + echo -e "$(echo "$fail_trgts" | xargs -n1 | sort -u | xargs)" 263 + echo -e "--------------------------------------------------------"; 264 + echo -e "Missing libraries system" 265 + echo -e "$(echo "$fail_libs" | xargs -n1 | sort -u | xargs)" 266 + fi 267 + 268 + echo -e "--------------------------------------------------------"; 269 + echo -e "========================================================"; 270 + } 271 + 272 + main "$@"
+12 -2
tools/testing/selftests/memfd/Makefile
··· 8 8 TEST_PROGS := run_fuse_test.sh run_hugetlbfs_test.sh 9 9 TEST_GEN_FILES := fuse_test fuse_mnt 10 10 11 - fuse_mnt.o: CFLAGS += $(shell pkg-config fuse --cflags) 11 + VAR_CFLAGS := $(shell pkg-config fuse --cflags 2>/dev/null) 12 + ifeq ($(VAR_CFLAGS),) 13 + VAR_CFLAGS := -D_FILE_OFFSET_BITS=64 -I/usr/include/fuse 14 + endif 15 + 16 + VAR_LDLIBS := $(shell pkg-config fuse --libs 2>/dev/null) 17 + ifeq ($(VAR_LDLIBS),) 18 + VAR_LDLIBS := -lfuse -pthread 19 + endif 20 + 21 + fuse_mnt.o: CFLAGS += $(VAR_CFLAGS) 12 22 13 23 include ../lib.mk 14 24 15 - $(OUTPUT)/fuse_mnt: LDLIBS += $(shell pkg-config fuse --libs) 25 + $(OUTPUT)/fuse_mnt: LDLIBS += $(VAR_LDLIBS) 16 26 17 27 $(OUTPUT)/memfd_test: memfd_test.c common.c 18 28 $(OUTPUT)/fuse_test: fuse_test.c common.c