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

perf tests: Add perf script test

Start a new set of shell tests for testing perf script. The initial
contribution is checking that some perf db-export functionality works
as reported in this regression by Ben Gainey <ben.gainey@arm.com>:
https://lore.kernel.org/lkml/20231207140911.3240408-1-ben.gainey@arm.com/

Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Ben Gainey <ben.gainey@arm.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20231207174057.1482161-1-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
bb177a85 ad30469a

+66
+66
tools/perf/tests/shell/script.sh
··· 1 + #!/bin/sh 2 + # perf script tests 3 + # SPDX-License-Identifier: GPL-2.0 4 + 5 + set -e 6 + 7 + temp_dir=$(mktemp -d /tmp/perf-test-script.XXXXXXXXXX) 8 + 9 + perfdatafile="${temp_dir}/perf.data" 10 + db_test="${temp_dir}/db_test.py" 11 + 12 + err=0 13 + 14 + cleanup() 15 + { 16 + trap - EXIT TERM INT 17 + sane=$(echo "${temp_dir}" | cut -b 1-21) 18 + if [ "${sane}" = "/tmp/perf-test-script" ] ; then 19 + echo "--- Cleaning up ---" 20 + rm -f "${temp_dir}/"* 21 + rmdir "${temp_dir}" 22 + fi 23 + } 24 + 25 + trap_cleanup() 26 + { 27 + cleanup 28 + exit 1 29 + } 30 + 31 + trap trap_cleanup EXIT TERM INT 32 + 33 + 34 + test_db() 35 + { 36 + echo "DB test" 37 + 38 + # Check if python script is supported 39 + libpython=$(perf version --build-options | grep python | grep -cv OFF) 40 + if [ "${libpython}" != "1" ] ; then 41 + echo "SKIP: python scripting is not supported" 42 + err=2 43 + return 44 + fi 45 + 46 + cat << "_end_of_file_" > "${db_test}" 47 + perf_db_export_mode = True 48 + perf_db_export_calls = False 49 + perf_db_export_callchains = True 50 + 51 + def sample_table(*args): 52 + print(f'sample_table({args})') 53 + 54 + def call_path_table(*args): 55 + print(f'call_path_table({args}') 56 + _end_of_file_ 57 + perf record -g -o "${perfdatafile}" true 58 + perf script -i "${perfdatafile}" -s "${db_test}" 59 + echo "DB test [Success]" 60 + } 61 + 62 + test_db 63 + 64 + cleanup 65 + 66 + exit $err