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.

perf test: perf data --to-ctf testing

If babeltrace is detected check that --to-ctf functions with a data
file and in pipe mode.

Committer testing:

$ perf test 'perf data convert --to-ctf'
124: 'perf data convert --to-ctf' command test : Ok
$ perf test -vv 'perf data convert --to-ctf'
124: 'perf data convert --to-ctf' command test:
--- start ---
test child forked, pid 556008
libbabeltrace: [ on ] # HAVE_LIBBABELTRACE_SUPPORT
Testing Perf Data Conversion Command to CTF (File input)
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.021 MB /tmp/__perf_test.perf.data.9TxzZ (115 samples) ]
[ perf data convert: Converted '/tmp/__perf_test.perf.data.9TxzZ' into CTF data '/tmp/__perf_test.ctf.f5EkS' ]
[ perf data convert: Converted and wrote 0.012 MB (115 samples) ]
Perf Data Converter Command to CTF (File input) [SUCCESS]
Testing Perf Data Conversion Command to CTF (Pipe mode)
[ perf record: Woken up 2 times to write data ]
[ perf record: Captured and wrote 0.047 MB - ]
Failed to setup all events.
[ perf data convert: Converted '/tmp/__perf_test.perf.data.9TxzZ' into CTF data '/tmp/__perf_test.ctf.f5EkS' ]
[ perf data convert: Converted and wrote 0.000 MB (0 samples) ]
Perf Data Converter Command to CTF (Pipe mode) [SUCCESS]
Unexpected signal in main
---- end(0) ----
124: 'perf data convert --to-ctf' command test : Ok
$

Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Derek Foreman <derek.foreman@collabora.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
9083ce53 fc4577b5

+104
+104
tools/perf/tests/shell/test_perf_data_converter_ctf.sh
··· 1 + #!/bin/bash 2 + # 'perf data convert --to-ctf' command test 3 + # SPDX-License-Identifier: GPL-2.0 4 + 5 + set -e 6 + 7 + err=0 8 + 9 + perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX) 10 + ctf_dir=$(mktemp -d /tmp/__perf_test.ctf.XXXXX) 11 + 12 + cleanup() 13 + { 14 + rm -f "${perfdata}" 15 + rm -rf "${ctf_dir}" 16 + trap - exit term int 17 + } 18 + 19 + trap_cleanup() 20 + { 21 + echo "Unexpected signal in ${FUNCNAME[1]}" 22 + cleanup 23 + exit ${err} 24 + } 25 + trap trap_cleanup exit term int 26 + 27 + check_babeltrace_support() 28 + { 29 + if ! perf check feature libbabeltrace 30 + then 31 + echo "perf not linked with libbabeltrace, skipping test" 32 + exit 2 33 + fi 34 + } 35 + 36 + test_ctf_converter_file() 37 + { 38 + echo "Testing Perf Data Conversion Command to CTF (File input)" 39 + # Record some data 40 + if ! perf record -o "$perfdata" -F 99 -g -- perf test -w noploop 41 + then 42 + echo "Failed to record perf data" 43 + err=1 44 + return 45 + fi 46 + 47 + # Cleanup previous ctf dir 48 + rm -rf "${ctf_dir}" 49 + 50 + # Convert 51 + if ! perf data convert --to-ctf "$ctf_dir" --force -i "$perfdata" 52 + then 53 + echo "Perf Data Converter Command to CTF (File input) [FAILED]" 54 + err=1 55 + return 56 + fi 57 + 58 + if [ -d "${ctf_dir}" ] && [ "$(ls -A "${ctf_dir}")" ] 59 + then 60 + echo "Perf Data Converter Command to CTF (File input) [SUCCESS]" 61 + else 62 + echo "Perf Data Converter Command to CTF (File input) [FAILED]" 63 + echo " Output directory empty or missing" 64 + err=1 65 + fi 66 + } 67 + 68 + test_ctf_converter_pipe() 69 + { 70 + echo "Testing Perf Data Conversion Command to CTF (Pipe mode)" 71 + 72 + # Cleanup previous ctf dir 73 + rm -rf "${ctf_dir}" 74 + 75 + # Record to stdout and pipe to $perfdata file 76 + if ! perf record -o - -F 99 -g -- perf test -w noploop > "$perfdata" 77 + then 78 + echo "Failed to record perf data" 79 + err=1 80 + return 81 + fi 82 + 83 + if ! perf data convert --to-ctf "$ctf_dir" --force -i "$perfdata" 84 + then 85 + echo "Perf Data Converter Command to CTF (Pipe mode) [FAILED]" 86 + err=1 87 + return 88 + fi 89 + 90 + if [ -d "${ctf_dir}" ] && [ "$(ls -A "${ctf_dir}")" ] 91 + then 92 + echo "Perf Data Converter Command to CTF (Pipe mode) [SUCCESS]" 93 + else 94 + echo "Perf Data Converter Command to CTF (Pipe mode) [FAILED]" 95 + echo " Output directory empty or missing" 96 + err=1 97 + fi 98 + } 99 + 100 + check_babeltrace_support 101 + test_ctf_converter_file 102 + test_ctf_converter_pipe 103 + 104 + exit ${err}