drm/nouveau: consume the return of large GSP message
[drm/drm-misc.git] / tools / perf / tests / shell / trace_exit_race.sh
blobfbb0adc33a8895166d635b28b77c7fece533e493
1 #!/bin/sh
2 # perf trace exit race
3 # SPDX-License-Identifier: GPL-2.0
5 # Check that the last events of a perf trace'd subprocess are not
6 # lost. Specifically, trace the exiting syscall of "true" 10 times and ensure
7 # the output contains 10 correct lines.
9 # shellcheck source=lib/probe.sh
10 . "$(dirname $0)"/lib/probe.sh
12 skip_if_no_perf_trace || exit 2
14 if [ "$1" = "-v" ]; then
15 verbose="1"
18 iter=10
19 regexp=" +[0-9]+\.[0-9]+ [0-9]+ syscalls:sys_enter_exit_group\(\)$"
21 trace_shutdown_race() {
22 for _ in $(seq $iter); do
23 perf trace --no-comm -e syscalls:sys_enter_exit_group true 2>>$file
24 done
25 result="$(grep -c -E "$regexp" $file)"
26 [ $result = $iter ]
30 file=$(mktemp /tmp/temporary_file.XXXXX)
32 # Do not use whatever ~/.perfconfig file, it may change the output
33 # via trace.{show_timestamp,show_prefix,etc}
34 export PERF_CONFIG=/dev/null
36 trace_shutdown_race
37 err=$?
39 if [ $err != 0 ] && [ "${verbose}" = "1" ]; then
40 lines_not_matching=$(mktemp /tmp/temporary_file.XXXXX)
41 if grep -v -E "$regexp" $file > $lines_not_matching ; then
42 echo "Lines not matching the expected regexp: '$regexp':"
43 cat $lines_not_matching
44 else
45 echo "Missing output, expected $iter but only got $result"
47 rm -f $lines_not_matching
50 rm -f ${file}
51 exit $err