mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00

There are 43 instances of posix shell tests and 35 instances of bash. To give us a single consistent language for testing in, replace all #!/bin/sh to #!/bin/bash. Common sources that are included in both different shells will now work as expected. And we no longer have to fix up bashisms that appear to work when someone's system has sh symlinked to bash, but don't work on other systems that have both shells installed. Although we could have chosen sh, it's not backwards compatible so it wouldn't be possible to bulk convert without re-writing the existing bash tests. Choosing bash also gives us some nicer features including 'local' variable definitions and regexes in if statements that are already widely used in the tests. It's not expected that there are any users with only sh available due to the large number of bash tests that exist. Discussed in relation to running shellcheck here: https://lore.kernel.org/linux-perf-users/e3751a74be34bbf3781c4644f518702a7270220b.1749785642.git.collin.funk1@gmail.com/ Signed-off-by: James Clark <james.clark@linaro.org> Reviewed-by: Collin Funk <collin.funk1@gmail.com> Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com> Link: https://lore.kernel.org/r/20250623-james-perf-bash-tests-v1-1-f572f54d4559@linaro.org Signed-off-by: Namhyung Kim <namhyung@kernel.org>
67 lines
1.8 KiB
Bash
Executable file
67 lines
1.8 KiB
Bash
Executable file
#!/bin/bash
|
|
# AMD IBS software filtering
|
|
|
|
echo "check availability of IBS swfilt"
|
|
|
|
# check if IBS PMU is available
|
|
if [ ! -d /sys/bus/event_source/devices/ibs_op ]; then
|
|
echo "[SKIP] IBS PMU does not exist"
|
|
exit 2
|
|
fi
|
|
|
|
# check if IBS PMU has swfilt format
|
|
if [ ! -f /sys/bus/event_source/devices/ibs_op/format/swfilt ]; then
|
|
echo "[SKIP] IBS PMU does not have swfilt"
|
|
exit 2
|
|
fi
|
|
|
|
echo "run perf record with modifier and swfilt"
|
|
|
|
# setting any modifiers should fail
|
|
perf record -B -e ibs_op//u -o /dev/null true 2> /dev/null
|
|
if [ $? -eq 0 ]; then
|
|
echo "[FAIL] IBS PMU should not accept exclude_kernel"
|
|
exit 1
|
|
fi
|
|
|
|
# setting it with swfilt should be fine
|
|
perf record -B -e ibs_op/swfilt/u -o /dev/null true
|
|
if [ $? -ne 0 ]; then
|
|
echo "[FAIL] IBS op PMU cannot handle swfilt for exclude_kernel"
|
|
exit 1
|
|
fi
|
|
|
|
# setting it with swfilt=1 should be fine
|
|
perf record -B -e ibs_op/swfilt=1/k -o /dev/null true
|
|
if [ $? -ne 0 ]; then
|
|
echo "[FAIL] IBS op PMU cannot handle swfilt for exclude_user"
|
|
exit 1
|
|
fi
|
|
|
|
# check ibs_fetch PMU as well
|
|
perf record -B -e ibs_fetch/swfilt/u -o /dev/null true
|
|
if [ $? -ne 0 ]; then
|
|
echo "[FAIL] IBS fetch PMU cannot handle swfilt for exclude_kernel"
|
|
exit 1
|
|
fi
|
|
|
|
# check system wide recording
|
|
perf record -aB --synth=no -e ibs_op/swfilt/k -o /dev/null true
|
|
if [ $? -ne 0 ]; then
|
|
echo "[FAIL] IBS op PMU cannot handle swfilt in system-wide mode"
|
|
exit 1
|
|
fi
|
|
|
|
echo "check number of samples with swfilt"
|
|
|
|
kernel_sample=$(perf record -e ibs_op/swfilt/u -o- true | perf script -i- -F misc | grep -c ^K)
|
|
if [ ${kernel_sample} -ne 0 ]; then
|
|
echo "[FAIL] unexpected kernel samples: " ${kernel_sample}
|
|
exit 1
|
|
fi
|
|
|
|
user_sample=$(perf record -e ibs_fetch/swfilt/k -o- true | perf script -i- -F misc | grep -c ^U)
|
|
if [ ${user_sample} -ne 0 ]; then
|
|
echo "[FAIL] unexpected user samples: " ${user_sample}
|
|
exit 1
|
|
fi
|