list.sh 758 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/bin/bash
  2. # perf list tests
  3. # SPDX-License-Identifier: GPL-2.0
  4. set -e
  5. shelldir=$(dirname "$0")
  6. # shellcheck source=lib/setup_python.sh
  7. . "${shelldir}"/lib/setup_python.sh
  8. list_output=$(mktemp /tmp/__perf_test.list_output.json.XXXXX)
  9. cleanup() {
  10. rm -f "${list_output}"
  11. trap - EXIT TERM INT
  12. }
  13. trap_cleanup() {
  14. cleanup
  15. exit 1
  16. }
  17. trap trap_cleanup EXIT TERM INT
  18. test_list_json() {
  19. echo "Json output test"
  20. # Generate perf list json output into list_output file.
  21. perf list -j -o "${list_output}"
  22. # Validate the json using python, redirect the json copy to /dev/null as
  23. # otherwise the test may block writing to stdout.
  24. $PYTHON -m json.tool "${list_output}" /dev/null
  25. echo "Json output test [Success]"
  26. }
  27. test_list_json
  28. cleanup
  29. exit 0