brintos

brintos / linux-shallow public Read only

0
0
Text · 3.2 KiB · d4c8005 Raw
127 lines · bash
1#!/bin/bash2# perf pipe recording and injection test3# SPDX-License-Identifier: GPL-2.04 5shelldir=$(dirname "$0")6# shellcheck source=lib/perf_has_symbol.sh7. "${shelldir}"/lib/perf_has_symbol.sh8 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"16err=017 18set -e19 20cleanup() {21  rm -rf "${data}"22  rm -rf "${data}".old23  rm -rf "${data2}"24  rm -rf "${data2}".old25 26  trap - EXIT TERM INT27}28 29trap_cleanup() {30  echo "Unexpected signal in ${FUNCNAME[1]}"31  cleanup32  exit 133}34trap trap_cleanup EXIT TERM INT35 36test_record_report() {37  echo38  echo "Record+report pipe test"39 40  task="perf"41  if ! perf record -e task-clock:u -o - ${prog} | perf report -i - --task | grep -q ${task}42  then43    echo "Record+report pipe test [Failed - cannot find the test file in the perf report #1]"44    err=145    return46  fi47 48  if ! perf record -g -e task-clock:u -o - ${prog} | perf report -i - --task | grep -q ${task}49  then50    echo "Record+report pipe test [Failed - cannot find the test file in the perf report #2]"51    err=152    return53  fi54 55  perf record -g -e task-clock:u -o - ${prog} > ${data}56  if ! perf report -i ${data} --task | grep -q ${task}57  then58    echo "Record+report pipe test [Failed - cannot find the test file in the perf report #3]"59    err=160    return61  fi62 63  echo "Record+report pipe test [Success]"64}65 66test_inject_bids() {67  inject_opt=$168 69  echo70  echo "Inject ${inject_opt} build-ids test"71 72  if ! perf record -e task-clock:u -o - ${prog} | perf inject ${inject_opt}| perf report -i - | grep -q ${sym}73  then74    echo "Inject build-ids test [Failed - cannot find noploop function in pipe #1]"75    err=176    return77  fi78 79  if ! perf record -g -e task-clock:u -o - ${prog} | perf inject ${inject_opt} | perf report -i - | grep -q ${sym}80  then81    echo "Inject ${inject_opt} build-ids test [Failed - cannot find noploop function in pipe #2]"82    err=183    return84  fi85 86  perf record -e task-clock:u -o - ${prog} | perf inject ${inject_opt} -o ${data}87  if ! perf report -i ${data} | grep -q ${sym}; then88    echo "Inject ${inject_opt} build-ids test [Failed - cannot find noploop function in pipe #3]"89    err=190    return91  fi92 93  perf record -e task-clock:u -o ${data} ${prog}94  if ! perf inject ${inject_opt} -i ${data} | perf report -i - | grep -q ${sym}; then95    echo "Inject ${inject_opt} build-ids test [Failed - cannot find noploop function in pipe #4]"96    err=197    return98  fi99 100  perf record -e task-clock:u -o - ${prog} > ${data}101  if ! perf inject ${inject_opt} -i ${data} | perf report -i - | grep -q ${sym}; then102    echo "Inject ${inject_opt} build-ids test [Failed - cannot find noploop function in pipe #5]"103    err=1104    return105  fi106 107  perf record -e task-clock:u -o - ${prog} > ${data}108  perf inject ${inject_opt} -i ${data} -o ${data2}109  if ! perf report -i ${data2} | grep -q ${sym}; then110    echo "Inject ${inject_opt} build-ids test [Failed - cannot find noploop function in pipe #6]"111    err=1112    return113  fi114 115  echo "Inject ${inject_opt} build-ids test [Success]"116}117 118test_record_report119test_inject_bids -B120test_inject_bids -b121test_inject_bids --buildid-all122test_inject_bids --mmap2-buildid-all123 124cleanup125exit $err126 127