pipe_test.sh 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #!/bin/bash
  2. # perf pipe recording and injection test
  3. # SPDX-License-Identifier: GPL-2.0
  4. shelldir=$(dirname "$0")
  5. # shellcheck source=lib/perf_has_symbol.sh
  6. . "${shelldir}"/lib/perf_has_symbol.sh
  7. sym="noploop"
  8. skip_test_missing_symbol ${sym}
  9. data=$(mktemp /tmp/perf.data.XXXXXX)
  10. data2=$(mktemp /tmp/perf.data2.XXXXXX)
  11. prog="perf test -w noploop"
  12. [ "$(uname -m)" = "s390x" ] && prog="$prog 3"
  13. err=0
  14. set -e
  15. cleanup() {
  16. rm -rf "${data}"
  17. rm -rf "${data}".old
  18. rm -rf "${data2}"
  19. rm -rf "${data2}".old
  20. trap - EXIT TERM INT
  21. }
  22. trap_cleanup() {
  23. echo "Unexpected signal in ${FUNCNAME[1]}"
  24. cleanup
  25. exit 1
  26. }
  27. trap trap_cleanup EXIT TERM INT
  28. test_record_report() {
  29. echo
  30. echo "Record+report pipe test"
  31. task="perf"
  32. if ! perf record -e task-clock:u -o - ${prog} | perf report -i - --task | grep -q ${task}
  33. then
  34. echo "Record+report pipe test [Failed - cannot find the test file in the perf report #1]"
  35. err=1
  36. return
  37. fi
  38. if ! perf record -g -e task-clock:u -o - ${prog} | perf report -i - --task | grep -q ${task}
  39. then
  40. echo "Record+report pipe test [Failed - cannot find the test file in the perf report #2]"
  41. err=1
  42. return
  43. fi
  44. perf record -g -e task-clock:u -o - ${prog} > ${data}
  45. if ! perf report -i ${data} --task | grep -q ${task}
  46. then
  47. echo "Record+report pipe test [Failed - cannot find the test file in the perf report #3]"
  48. err=1
  49. return
  50. fi
  51. echo "Record+report pipe test [Success]"
  52. }
  53. test_inject_bids() {
  54. inject_opt=$1
  55. echo
  56. echo "Inject ${inject_opt} build-ids test"
  57. if ! perf record -e task-clock:u -o - ${prog} | perf inject ${inject_opt}| perf report -i - | grep -q ${sym}
  58. then
  59. echo "Inject build-ids test [Failed - cannot find noploop function in pipe #1]"
  60. err=1
  61. return
  62. fi
  63. if ! perf record -g -e task-clock:u -o - ${prog} | perf inject ${inject_opt} | perf report -i - | grep -q ${sym}
  64. then
  65. echo "Inject ${inject_opt} build-ids test [Failed - cannot find noploop function in pipe #2]"
  66. err=1
  67. return
  68. fi
  69. perf record -e task-clock:u -o - ${prog} | perf inject ${inject_opt} -o ${data}
  70. if ! perf report -i ${data} | grep -q ${sym}; then
  71. echo "Inject ${inject_opt} build-ids test [Failed - cannot find noploop function in pipe #3]"
  72. err=1
  73. return
  74. fi
  75. perf record -e task-clock:u -o ${data} ${prog}
  76. if ! perf inject ${inject_opt} -i ${data} | perf report -i - | grep -q ${sym}; then
  77. echo "Inject ${inject_opt} build-ids test [Failed - cannot find noploop function in pipe #4]"
  78. err=1
  79. return
  80. fi
  81. perf record -e task-clock:u -o - ${prog} > ${data}
  82. if ! perf inject ${inject_opt} -i ${data} | perf report -i - | grep -q ${sym}; then
  83. echo "Inject ${inject_opt} build-ids test [Failed - cannot find noploop function in pipe #5]"
  84. err=1
  85. return
  86. fi
  87. perf record -e task-clock:u -o - ${prog} > ${data}
  88. perf inject ${inject_opt} -i ${data} -o ${data2}
  89. if ! perf report -i ${data2} | grep -q ${sym}; then
  90. echo "Inject ${inject_opt} build-ids test [Failed - cannot find noploop function in pipe #6]"
  91. err=1
  92. return
  93. fi
  94. echo "Inject ${inject_opt} build-ids test [Success]"
  95. }
  96. test_record_report
  97. test_inject_bids -B
  98. test_inject_bids -b
  99. test_inject_bids --buildid-all
  100. test_inject_bids --mmap2-buildid-all
  101. cleanup
  102. exit $err