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: Test pipe mode with data conversion --to-json

Add pipe mode test for json data conversion. Tidy up exit and cleanup
code.

Committer testing:

$ perf test 'perf data convert --to-json'
124: 'perf data convert --to-json' command test : Ok
$ perf test -vv 'perf data convert --to-json'
124: 'perf data convert --to-json' command test:
--- start ---
test child forked, pid 548738
Testing Perf Data Conversion Command to JSON
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.020 MB /tmp/__perf_test.perf.data.krxvl (104 samples) ]
[ perf data convert: Converted '/tmp/__perf_test.perf.data.krxvl' into JSON data '/tmp/__perf_test.output.json.0z60p' ]
[ perf data convert: Converted and wrote 0.075 MB (104 samples) ]
Perf Data Converter Command to JSON [SUCCESS]
Validating Perf Data Converted JSON file
The file contains valid JSON format [SUCCESS]
Testing Perf Data Conversion Command to JSON (Pipe mode)
[ perf record: Woken up 2 times to write data ]
[ perf record: Captured and wrote 0.046 MB - ]
[ perf data convert: Converted '-' into JSON data '/tmp/__perf_test.output.json.0z60p' ]
[ perf data convert: Converted and wrote 0.081 MB (110 samples) ]
Perf Data Converter Command to JSON (Pipe mode) [SUCCESS]
Validating Perf Data Converted JSON file
The file contains valid JSON format [SUCCESS]
---- end(0) ----
124: 'perf data convert --to-json' 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
fc4577b5 5b92fc08

+24 -9
+24 -9
tools/perf/tests/shell/test_perf_data_converter_json.sh
··· 15 15 16 16 cleanup() 17 17 { 18 - rm -f "${perfdata}" 18 + rm -f "${perfdata}*" 19 19 rm -f "${result}" 20 20 trap - exit term int 21 21 } 22 22 23 23 trap_cleanup() 24 24 { 25 + echo "Unexpected signal in ${FUNCNAME[1]}" 25 26 cleanup 26 - exit ${err} 27 + exit 1 27 28 } 28 29 trap trap_cleanup exit term int 29 30 30 31 test_json_converter_command() 31 32 { 32 - echo "Testing Perf Data Convertion Command to JSON" 33 - perf record -o "$perfdata" -F 99 -g -- perf test -w noploop > /dev/null 2>&1 34 - perf data convert --to-json "$result" --force -i "$perfdata" >/dev/null 2>&1 33 + echo "Testing Perf Data Conversion Command to JSON" 34 + perf record -o "$perfdata" -F 99 -g -- perf test -w noploop 35 + perf data convert --to-json "$result" --force -i "$perfdata" 35 36 if [ "$(cat ${result} | wc -l)" -gt "0" ] ; then 36 37 echo "Perf Data Converter Command to JSON [SUCCESS]" 37 38 else 38 39 echo "Perf Data Converter Command to JSON [FAILED]" 39 40 err=1 40 - exit 41 + fi 42 + } 43 + 44 + test_json_converter_pipe() 45 + { 46 + echo "Testing Perf Data Conversion Command to JSON (Pipe mode)" 47 + perf record -o - -F 99 -g -- perf test -w noploop > "$perfdata" 48 + cat "$perfdata" | perf data convert --to-json "$result" --force -i - 49 + if [ "$(cat ${result} | wc -l)" -gt "0" ] ; then 50 + echo "Perf Data Converter Command to JSON (Pipe mode) [SUCCESS]" 51 + else 52 + echo "Perf Data Converter Command to JSON (Pipe mode) [FAILED]" 53 + err=1 41 54 fi 42 55 } 43 56 ··· 63 50 else 64 51 echo "The file does not contain valid JSON format [FAILED]" 65 52 err=1 66 - exit 67 53 fi 68 54 else 69 55 echo "File not found [FAILED]" 70 - err=2 71 - exit 56 + err=1 72 57 fi 73 58 } 74 59 75 60 test_json_converter_command 76 61 validate_json_format 77 62 63 + test_json_converter_pipe 64 + validate_json_format 65 + 66 + cleanup 78 67 exit ${err}