Linux Audio

Check our new training course

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