mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 11:56:58 +00:00
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
This commit is contained in:
@@ -118,7 +118,7 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
printf("dma mapping benchmark: threads:%d seconds:%d node:%d dir:%s granule: %d\n",
|
||||
threads, seconds, node, dir[directions], granule);
|
||||
threads, seconds, node, directions[dir], granule);
|
||||
printf("average map latency(us):%.1f standard deviation:%.1f\n",
|
||||
map.avg_map_100ns/10.0, map.map_stddev/10.0);
|
||||
printf("average unmap latency(us):%.1f standard deviation:%.1f\n",
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
#!/bin/sh
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
# description: Basic tests on writing to trace_marker_raw
|
||||
# requires: trace_marker_raw
|
||||
# flags: instance
|
||||
|
||||
is_little_endian() {
|
||||
if lscpu | grep -q 'Little Endian'; then
|
||||
echo 1;
|
||||
else
|
||||
echo 0;
|
||||
fi
|
||||
}
|
||||
|
||||
little=`is_little_endian`
|
||||
|
||||
make_str() {
|
||||
id=$1
|
||||
cnt=$2
|
||||
|
||||
if [ $little -eq 1 ]; then
|
||||
val=`printf "\\%03o\\%03o\\%03o\\%03o" \
|
||||
$(($id & 0xff)) \
|
||||
$((($id >> 8) & 0xff)) \
|
||||
$((($id >> 16) & 0xff)) \
|
||||
$((($id >> 24) & 0xff))`
|
||||
else
|
||||
val=`printf "\\%03o\\%03o\\%03o\\%03o" \
|
||||
$((($id >> 24) & 0xff)) \
|
||||
$((($id >> 16) & 0xff)) \
|
||||
$((($id >> 8) & 0xff)) \
|
||||
$(($id & 0xff))`
|
||||
fi
|
||||
|
||||
data=`printf -- 'X%.0s' $(seq $cnt)`
|
||||
|
||||
printf "${val}${data}"
|
||||
}
|
||||
|
||||
write_buffer() {
|
||||
id=$1
|
||||
size=$2
|
||||
|
||||
# write the string into the raw marker
|
||||
make_str $id $size > trace_marker_raw
|
||||
}
|
||||
|
||||
|
||||
test_multiple_writes() {
|
||||
|
||||
# Write a bunch of data where the id is the count of
|
||||
# data to write
|
||||
for i in `seq 1 10` `seq 101 110` `seq 1001 1010`; do
|
||||
write_buffer $i $i
|
||||
done
|
||||
|
||||
# add a little buffer
|
||||
echo stop > trace_marker
|
||||
|
||||
# Check to make sure the number of entries is the id (rounded up by 4)
|
||||
awk '/.*: # [0-9a-f]* / {
|
||||
print;
|
||||
cnt = -1;
|
||||
for (i = 0; i < NF; i++) {
|
||||
# The counter is after the "#" marker
|
||||
if ( $i == "#" ) {
|
||||
i++;
|
||||
cnt = strtonum("0x" $i);
|
||||
num = NF - (i + 1);
|
||||
# The number of items is always rounded up by 4
|
||||
cnt2 = int((cnt + 3) / 4) * 4;
|
||||
if (cnt2 != num) {
|
||||
exit 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// { if (NR > 30) { exit 0; } } ' trace_pipe;
|
||||
}
|
||||
|
||||
|
||||
get_buffer_data_size() {
|
||||
sed -ne 's/^.*data.*size:\([0-9][0-9]*\).*/\1/p' events/header_page
|
||||
}
|
||||
|
||||
test_buffer() {
|
||||
|
||||
# The id must be four bytes, test that 3 bytes fails a write
|
||||
if echo -n abc > ./trace_marker_raw ; then
|
||||
echo "Too small of write expected to fail but did not"
|
||||
exit_fail
|
||||
fi
|
||||
|
||||
size=`get_buffer_data_size`
|
||||
echo size = $size
|
||||
|
||||
# Now add a little more than what it can handle
|
||||
|
||||
if write_buffer 0xdeadbeef $size ; then
|
||||
echo "Too big of write expected to fail but did not"
|
||||
exit_fail
|
||||
fi
|
||||
}
|
||||
|
||||
test_buffer
|
||||
test_multiple_writes
|
||||
@@ -28,25 +28,21 @@ test -d events/fprobes/myevent1
|
||||
test -d events/fprobes/myevent2
|
||||
|
||||
echo 1 > events/fprobes/myevent1/enable
|
||||
# Make sure the event is attached and is the only one
|
||||
# Make sure the event is attached.
|
||||
grep -q $PLACE enabled_functions
|
||||
cnt=`cat enabled_functions | wc -l`
|
||||
if [ $cnt -ne $((ocnt + 1)) ]; then
|
||||
if [ $cnt -eq $ocnt ]; then
|
||||
exit_fail
|
||||
fi
|
||||
|
||||
echo 1 > events/fprobes/myevent2/enable
|
||||
# It should till be the only attached function
|
||||
cnt=`cat enabled_functions | wc -l`
|
||||
if [ $cnt -ne $((ocnt + 1)) ]; then
|
||||
exit_fail
|
||||
fi
|
||||
cnt2=`cat enabled_functions | wc -l`
|
||||
|
||||
echo 1 > events/fprobes/myevent3/enable
|
||||
# If the function is different, the attached function should be increased
|
||||
grep -q $PLACE2 enabled_functions
|
||||
cnt=`cat enabled_functions | wc -l`
|
||||
if [ $cnt -ne $((ocnt + 2)) ]; then
|
||||
if [ $cnt -eq $cnt2 ]; then
|
||||
exit_fail
|
||||
fi
|
||||
|
||||
@@ -56,12 +52,6 @@ echo "-:myevent2" >> dynamic_events
|
||||
grep -q myevent1 dynamic_events
|
||||
! grep -q myevent2 dynamic_events
|
||||
|
||||
# should still have 2 left
|
||||
cnt=`cat enabled_functions | wc -l`
|
||||
if [ $cnt -ne $((ocnt + 2)) ]; then
|
||||
exit_fail
|
||||
fi
|
||||
|
||||
echo 0 > events/fprobes/enable
|
||||
echo > dynamic_events
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
#!/bin/sh
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
# description: Generic dynamic event - enable/disable tracepoint probe events
|
||||
# requires: dynamic_events "t[:[<group>/][<event>]] <tracepoint> [<args>]":README
|
||||
|
||||
echo 0 > events/enable
|
||||
echo > dynamic_events
|
||||
|
||||
TRACEPOINT=sched_switch
|
||||
ENABLEFILE=events/tracepoints/myprobe/enable
|
||||
|
||||
:;: "Add tracepoint event on $TRACEPOINT" ;:
|
||||
|
||||
echo "t:myprobe ${TRACEPOINT}" >> dynamic_events
|
||||
|
||||
:;: "Check enable/disable to ensure it works" ;:
|
||||
|
||||
echo 1 > $ENABLEFILE
|
||||
|
||||
grep -q $TRACEPOINT trace
|
||||
|
||||
echo 0 > $ENABLEFILE
|
||||
|
||||
echo > trace
|
||||
|
||||
! grep -q $TRACEPOINT trace
|
||||
|
||||
:;: "Repeat enable/disable to ensure it works" ;:
|
||||
|
||||
echo 1 > $ENABLEFILE
|
||||
|
||||
grep -q $TRACEPOINT trace
|
||||
|
||||
echo 0 > $ENABLEFILE
|
||||
|
||||
echo > trace
|
||||
|
||||
! grep -q $TRACEPOINT trace
|
||||
|
||||
exit 0
|
||||
@@ -44,6 +44,12 @@ tap_timeout()
|
||||
fi
|
||||
}
|
||||
|
||||
report_failure()
|
||||
{
|
||||
echo "not ok $*"
|
||||
echo "$*" >> "$kselftest_failures_file"
|
||||
}
|
||||
|
||||
run_one()
|
||||
{
|
||||
DIR="$1"
|
||||
@@ -105,7 +111,7 @@ run_one()
|
||||
echo "# $TEST_HDR_MSG"
|
||||
if [ ! -e "$TEST" ]; then
|
||||
echo "# Warning: file $TEST is missing!"
|
||||
echo "not ok $test_num $TEST_HDR_MSG"
|
||||
report_failure "$test_num $TEST_HDR_MSG"
|
||||
else
|
||||
if [ -x /usr/bin/stdbuf ]; then
|
||||
stdbuf="/usr/bin/stdbuf --output=L "
|
||||
@@ -123,7 +129,7 @@ run_one()
|
||||
interpreter=$(head -n 1 "$TEST" | cut -c 3-)
|
||||
cmd="$stdbuf $interpreter ./$BASENAME_TEST"
|
||||
else
|
||||
echo "not ok $test_num $TEST_HDR_MSG"
|
||||
report_failure "$test_num $TEST_HDR_MSG"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
@@ -137,9 +143,9 @@ run_one()
|
||||
echo "ok $test_num $TEST_HDR_MSG # SKIP"
|
||||
elif [ $rc -eq $timeout_rc ]; then \
|
||||
echo "#"
|
||||
echo "not ok $test_num $TEST_HDR_MSG # TIMEOUT $kselftest_timeout seconds"
|
||||
report_failure "$test_num $TEST_HDR_MSG # TIMEOUT $kselftest_timeout seconds"
|
||||
else
|
||||
echo "not ok $test_num $TEST_HDR_MSG # exit=$rc"
|
||||
report_failure "$test_num $TEST_HDR_MSG # exit=$rc"
|
||||
fi)
|
||||
cd - >/dev/null
|
||||
fi
|
||||
|
||||
@@ -33,6 +33,7 @@ Usage: $0 [OPTIONS]
|
||||
-c | --collection COLLECTION Run all tests from COLLECTION
|
||||
-l | --list List the available collection:test entries
|
||||
-d | --dry-run Don't actually run any tests
|
||||
-f | --no-error-on-fail Don't exit with an error just because tests failed
|
||||
-n | --netns Run each test in namespace
|
||||
-h | --help Show this usage info
|
||||
-o | --override-timeout Number of seconds after which we timeout
|
||||
@@ -44,6 +45,7 @@ COLLECTIONS=""
|
||||
TESTS=""
|
||||
dryrun=""
|
||||
kselftest_override_timeout=""
|
||||
ERROR_ON_FAIL=true
|
||||
while true; do
|
||||
case "$1" in
|
||||
-s | --summary)
|
||||
@@ -65,6 +67,9 @@ while true; do
|
||||
-d | --dry-run)
|
||||
dryrun="echo"
|
||||
shift ;;
|
||||
-f | --no-error-on-fail)
|
||||
ERROR_ON_FAIL=false
|
||||
shift ;;
|
||||
-n | --netns)
|
||||
RUN_IN_NETNS=1
|
||||
shift ;;
|
||||
@@ -105,9 +110,18 @@ if [ -n "$TESTS" ]; then
|
||||
available="$(echo "$valid" | sed -e 's/ /\n/g')"
|
||||
fi
|
||||
|
||||
kselftest_failures_file="$(mktemp --tmpdir kselftest-failures-XXXXXX)"
|
||||
export kselftest_failures_file
|
||||
|
||||
collections=$(echo "$available" | cut -d: -f1 | sort | uniq)
|
||||
for collection in $collections ; do
|
||||
[ -w /dev/kmsg ] && echo "kselftest: Running tests in $collection" >> /dev/kmsg
|
||||
tests=$(echo "$available" | grep "^$collection:" | cut -d: -f2)
|
||||
($dryrun cd "$collection" && $dryrun run_many $tests)
|
||||
done
|
||||
|
||||
failures="$(cat "$kselftest_failures_file")"
|
||||
rm "$kselftest_failures_file"
|
||||
if "$ERROR_ON_FAIL" && [ "$failures" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user