2 # perf pipe recording and injection test
3 # SPDX-License-Identifier: GPL-2.0
5 # skip if there's no compiler
6 if ! [ -x "$(command -v cc)" ]; then
7 echo "failed: no compiler, install gcc"
11 file=$(mktemp /tmp/test.file.XXXXXX)
12 data=$(mktemp /tmp/perf.data.XXXXXX)
14 cat <<EOF | cc -o ${file} -x c -
21 void sigalrm(int sig) {
25 __attribute__((noinline)) void noploop(void) {
30 int main(int argc, char *argv[]) {
36 signal(SIGALRM, sigalrm);
45 if ! perf record -e task-clock:u -o - ${file} | perf report -i - --task | grep test.file; then
46 echo "cannot find the test file in the perf report"
50 if ! perf record -e task-clock:u -o - ${file} | perf inject -b | perf report -i - | grep noploop; then
51 echo "cannot find noploop function in pipe #1"
55 perf record -e task-clock:u -o - ${file} | perf inject -b -o ${data}
56 if ! perf report -i ${data} | grep noploop; then
57 echo "cannot find noploop function in pipe #2"
61 perf record -e task-clock:u -o ${data} ${file}
62 if ! perf inject -b -i ${data} | perf report -i - | grep noploop; then
63 echo "cannot find noploop function in pipe #3"
68 rm -f ${file} ${data} ${data}.old