tools/perf/tests/shell/pipe_test.sh

Source file repositories/reference/linux-study-clean/tools/perf/tests/shell/pipe_test.sh

File Facts

System
Linux kernel
Corpus path
tools/perf/tests/shell/pipe_test.sh
Extension
.sh
Size
3296 bytes
Lines
128
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: tools
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

#!/bin/bash
# perf pipe recording and injection test
# SPDX-License-Identifier: GPL-2.0

shelldir=$(dirname "$0")
# shellcheck source=lib/perf_has_symbol.sh
. "${shelldir}"/lib/perf_has_symbol.sh

sym="noploop"

skip_test_missing_symbol ${sym}

data=$(mktemp /tmp/perf.data.XXXXXX)
data2=$(mktemp /tmp/perf.data2.XXXXXX)
prog="perf test -w noploop"
[ "$(uname -m)" = "s390x" ] && prog="$prog 3"
err=0

set -e

cleanup() {
  rm -rf "${data}"
  rm -rf "${data}".old
  rm -rf "${data2}"
  rm -rf "${data2}".old

  trap - EXIT TERM INT
}

trap_cleanup() {
  echo "Unexpected signal in ${FUNCNAME[1]}"
  cleanup
  exit 1
}
trap trap_cleanup EXIT TERM INT

test_record_report() {
  echo
  echo "Record+report pipe test"

  task="perf"
  if ! perf record -e task-clock:u -o - ${prog} | perf report -i - --task | grep -q ${task}
  then
    echo "Record+report pipe test [Failed - cannot find the test file in the perf report #1]"
    err=1
    return
  fi

  if ! perf record -g -e task-clock:u -o - ${prog} | perf report -i - --task | grep -q ${task}
  then
    echo "Record+report pipe test [Failed - cannot find the test file in the perf report #2]"
    err=1
    return
  fi

  perf record -g -e task-clock:u -o - ${prog} > ${data}
  if ! perf report -i ${data} --task | grep -q ${task}
  then
    echo "Record+report pipe test [Failed - cannot find the test file in the perf report #3]"
    err=1
    return
  fi

  echo "Record+report pipe test [Success]"
}

test_inject_bids() {
  inject_opt=$1

  echo

Annotation

Implementation Notes