2 # 'perf data convert --to-json' command test
3 # SPDX-License-Identifier: GPL-2.0
9 shelldir=$(dirname "$0")
10 # shellcheck source=lib/setup_python.sh
11 . "${shelldir}"/lib/setup_python.sh
13 perfdata=$(mktemp /tmp/__perf_test.perf.data.XXXXX)
14 result=$(mktemp /tmp/__perf_test.output.json.XXXXX)
28 trap trap_cleanup exit term int
30 test_json_converter_command()
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
35 if [ "$(cat ${result} | wc -l)" -gt "0" ] ; then
36 echo "Perf Data Converter Command to JSON [SUCCESS]"
38 echo "Perf Data Converter Command to JSON [FAILED]"
44 validate_json_format()
46 echo "Validating Perf Data Converted JSON file"
47 if [ -f "$result" ] ; then
48 if $PYTHON -c "import json; json.load(open('$result'))" >/dev/null 2>&1 ; then
49 echo "The file contains valid JSON format [SUCCESS]"
51 echo "The file does not contain valid JSON format [FAILED]"
56 echo "File not found [FAILED]"
62 test_json_converter_command