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-next-6.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest

Pull kselftest updates from Shuah Khan:

- Add basic test for trace_marker_raw file to tracing selftest

- Fix invalid array access in printf dma_map_benchmark selftest

- Add tprobe enable/disable testcase to tracing selftest

- Update fprobe selftest for ftrace based fprobe

* tag 'linux_kselftest-next-6.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
selftests: tracing: Update fprobe selftest for ftrace based fprobe
selftests: tracing: Add tprobe enable/disable testcase
selftests/run_kselftest.sh: exit with error if tests fail
selftests/dma: fix invalid array access in printf
selftests/tracing: Add basic test for trace_marker_raw file

+176 -19
+1 -1
tools/testing/selftests/dma/dma_map_benchmark.c
··· 118 118 } 119 119 120 120 printf("dma mapping benchmark: threads:%d seconds:%d node:%d dir:%s granule: %d\n", 121 - threads, seconds, node, dir[directions], granule); 121 + threads, seconds, node, directions[dir], granule); 122 122 printf("average map latency(us):%.1f standard deviation:%.1f\n", 123 123 map.avg_map_100ns/10.0, map.map_stddev/10.0); 124 124 printf("average unmap latency(us):%.1f standard deviation:%.1f\n",
+107
tools/testing/selftests/ftrace/test.d/00basic/trace_marker_raw.tc
··· 1 + #!/bin/sh 2 + # SPDX-License-Identifier: GPL-2.0 3 + # description: Basic tests on writing to trace_marker_raw 4 + # requires: trace_marker_raw 5 + # flags: instance 6 + 7 + is_little_endian() { 8 + if lscpu | grep -q 'Little Endian'; then 9 + echo 1; 10 + else 11 + echo 0; 12 + fi 13 + } 14 + 15 + little=`is_little_endian` 16 + 17 + make_str() { 18 + id=$1 19 + cnt=$2 20 + 21 + if [ $little -eq 1 ]; then 22 + val=`printf "\\%03o\\%03o\\%03o\\%03o" \ 23 + $(($id & 0xff)) \ 24 + $((($id >> 8) & 0xff)) \ 25 + $((($id >> 16) & 0xff)) \ 26 + $((($id >> 24) & 0xff))` 27 + else 28 + val=`printf "\\%03o\\%03o\\%03o\\%03o" \ 29 + $((($id >> 24) & 0xff)) \ 30 + $((($id >> 16) & 0xff)) \ 31 + $((($id >> 8) & 0xff)) \ 32 + $(($id & 0xff))` 33 + fi 34 + 35 + data=`printf -- 'X%.0s' $(seq $cnt)` 36 + 37 + printf "${val}${data}" 38 + } 39 + 40 + write_buffer() { 41 + id=$1 42 + size=$2 43 + 44 + # write the string into the raw marker 45 + make_str $id $size > trace_marker_raw 46 + } 47 + 48 + 49 + test_multiple_writes() { 50 + 51 + # Write a bunch of data where the id is the count of 52 + # data to write 53 + for i in `seq 1 10` `seq 101 110` `seq 1001 1010`; do 54 + write_buffer $i $i 55 + done 56 + 57 + # add a little buffer 58 + echo stop > trace_marker 59 + 60 + # Check to make sure the number of entries is the id (rounded up by 4) 61 + awk '/.*: # [0-9a-f]* / { 62 + print; 63 + cnt = -1; 64 + for (i = 0; i < NF; i++) { 65 + # The counter is after the "#" marker 66 + if ( $i == "#" ) { 67 + i++; 68 + cnt = strtonum("0x" $i); 69 + num = NF - (i + 1); 70 + # The number of items is always rounded up by 4 71 + cnt2 = int((cnt + 3) / 4) * 4; 72 + if (cnt2 != num) { 73 + exit 1; 74 + } 75 + break; 76 + } 77 + } 78 + } 79 + // { if (NR > 30) { exit 0; } } ' trace_pipe; 80 + } 81 + 82 + 83 + get_buffer_data_size() { 84 + sed -ne 's/^.*data.*size:\([0-9][0-9]*\).*/\1/p' events/header_page 85 + } 86 + 87 + test_buffer() { 88 + 89 + # The id must be four bytes, test that 3 bytes fails a write 90 + if echo -n abc > ./trace_marker_raw ; then 91 + echo "Too small of write expected to fail but did not" 92 + exit_fail 93 + fi 94 + 95 + size=`get_buffer_data_size` 96 + echo size = $size 97 + 98 + # Now add a little more than what it can handle 99 + 100 + if write_buffer 0xdeadbeef $size ; then 101 + echo "Too big of write expected to fail but did not" 102 + exit_fail 103 + fi 104 + } 105 + 106 + test_buffer 107 + test_multiple_writes
+4 -14
tools/testing/selftests/ftrace/test.d/dynevent/add_remove_fprobe.tc
··· 28 28 test -d events/fprobes/myevent2 29 29 30 30 echo 1 > events/fprobes/myevent1/enable 31 - # Make sure the event is attached and is the only one 31 + # Make sure the event is attached. 32 32 grep -q $PLACE enabled_functions 33 33 cnt=`cat enabled_functions | wc -l` 34 - if [ $cnt -ne $((ocnt + 1)) ]; then 34 + if [ $cnt -eq $ocnt ]; then 35 35 exit_fail 36 36 fi 37 37 38 38 echo 1 > events/fprobes/myevent2/enable 39 - # It should till be the only attached function 40 - cnt=`cat enabled_functions | wc -l` 41 - if [ $cnt -ne $((ocnt + 1)) ]; then 42 - exit_fail 43 - fi 39 + cnt2=`cat enabled_functions | wc -l` 44 40 45 41 echo 1 > events/fprobes/myevent3/enable 46 42 # If the function is different, the attached function should be increased 47 43 grep -q $PLACE2 enabled_functions 48 44 cnt=`cat enabled_functions | wc -l` 49 - if [ $cnt -ne $((ocnt + 2)) ]; then 45 + if [ $cnt -eq $cnt2 ]; then 50 46 exit_fail 51 47 fi 52 48 ··· 51 55 52 56 grep -q myevent1 dynamic_events 53 57 ! grep -q myevent2 dynamic_events 54 - 55 - # should still have 2 left 56 - cnt=`cat enabled_functions | wc -l` 57 - if [ $cnt -ne $((ocnt + 2)) ]; then 58 - exit_fail 59 - fi 60 58 61 59 echo 0 > events/fprobes/enable 62 60 echo > dynamic_events
+40
tools/testing/selftests/ftrace/test.d/dynevent/enable_disable_tprobe.tc
··· 1 + #!/bin/sh 2 + # SPDX-License-Identifier: GPL-2.0 3 + # description: Generic dynamic event - enable/disable tracepoint probe events 4 + # requires: dynamic_events "t[:[<group>/][<event>]] <tracepoint> [<args>]":README 5 + 6 + echo 0 > events/enable 7 + echo > dynamic_events 8 + 9 + TRACEPOINT=sched_switch 10 + ENABLEFILE=events/tracepoints/myprobe/enable 11 + 12 + :;: "Add tracepoint event on $TRACEPOINT" ;: 13 + 14 + echo "t:myprobe ${TRACEPOINT}" >> dynamic_events 15 + 16 + :;: "Check enable/disable to ensure it works" ;: 17 + 18 + echo 1 > $ENABLEFILE 19 + 20 + grep -q $TRACEPOINT trace 21 + 22 + echo 0 > $ENABLEFILE 23 + 24 + echo > trace 25 + 26 + ! grep -q $TRACEPOINT trace 27 + 28 + :;: "Repeat enable/disable to ensure it works" ;: 29 + 30 + echo 1 > $ENABLEFILE 31 + 32 + grep -q $TRACEPOINT trace 33 + 34 + echo 0 > $ENABLEFILE 35 + 36 + echo > trace 37 + 38 + ! grep -q $TRACEPOINT trace 39 + 40 + exit 0
+10 -4
tools/testing/selftests/kselftest/runner.sh
··· 44 44 fi 45 45 } 46 46 47 + report_failure() 48 + { 49 + echo "not ok $*" 50 + echo "$*" >> "$kselftest_failures_file" 51 + } 52 + 47 53 run_one() 48 54 { 49 55 DIR="$1" ··· 111 105 echo "# $TEST_HDR_MSG" 112 106 if [ ! -e "$TEST" ]; then 113 107 echo "# Warning: file $TEST is missing!" 114 - echo "not ok $test_num $TEST_HDR_MSG" 108 + report_failure "$test_num $TEST_HDR_MSG" 115 109 else 116 110 if [ -x /usr/bin/stdbuf ]; then 117 111 stdbuf="/usr/bin/stdbuf --output=L " ··· 129 123 interpreter=$(head -n 1 "$TEST" | cut -c 3-) 130 124 cmd="$stdbuf $interpreter ./$BASENAME_TEST" 131 125 else 132 - echo "not ok $test_num $TEST_HDR_MSG" 126 + report_failure "$test_num $TEST_HDR_MSG" 133 127 return 134 128 fi 135 129 fi ··· 143 137 echo "ok $test_num $TEST_HDR_MSG # SKIP" 144 138 elif [ $rc -eq $timeout_rc ]; then \ 145 139 echo "#" 146 - echo "not ok $test_num $TEST_HDR_MSG # TIMEOUT $kselftest_timeout seconds" 140 + report_failure "$test_num $TEST_HDR_MSG # TIMEOUT $kselftest_timeout seconds" 147 141 else 148 - echo "not ok $test_num $TEST_HDR_MSG # exit=$rc" 142 + report_failure "$test_num $TEST_HDR_MSG # exit=$rc" 149 143 fi) 150 144 cd - >/dev/null 151 145 fi
+14
tools/testing/selftests/run_kselftest.sh
··· 33 33 -c | --collection COLLECTION Run all tests from COLLECTION 34 34 -l | --list List the available collection:test entries 35 35 -d | --dry-run Don't actually run any tests 36 + -f | --no-error-on-fail Don't exit with an error just because tests failed 36 37 -n | --netns Run each test in namespace 37 38 -h | --help Show this usage info 38 39 -o | --override-timeout Number of seconds after which we timeout ··· 45 44 TESTS="" 46 45 dryrun="" 47 46 kselftest_override_timeout="" 47 + ERROR_ON_FAIL=true 48 48 while true; do 49 49 case "$1" in 50 50 -s | --summary) ··· 66 64 exit 0 ;; 67 65 -d | --dry-run) 68 66 dryrun="echo" 67 + shift ;; 68 + -f | --no-error-on-fail) 69 + ERROR_ON_FAIL=false 69 70 shift ;; 70 71 -n | --netns) 71 72 RUN_IN_NETNS=1 ··· 110 105 available="$(echo "$valid" | sed -e 's/ /\n/g')" 111 106 fi 112 107 108 + kselftest_failures_file="$(mktemp --tmpdir kselftest-failures-XXXXXX)" 109 + export kselftest_failures_file 110 + 113 111 collections=$(echo "$available" | cut -d: -f1 | sort | uniq) 114 112 for collection in $collections ; do 115 113 [ -w /dev/kmsg ] && echo "kselftest: Running tests in $collection" >> /dev/kmsg 116 114 tests=$(echo "$available" | grep "^$collection:" | cut -d: -f2) 117 115 ($dryrun cd "$collection" && $dryrun run_many $tests) 118 116 done 117 + 118 + failures="$(cat "$kselftest_failures_file")" 119 + rm "$kselftest_failures_file" 120 + if "$ERROR_ON_FAIL" && [ "$failures" ]; then 121 + exit 1 122 + fi