162306a36Sopenharmony_ci#!/bin/sh
262306a36Sopenharmony_ci# perf pipe recording and injection test
362306a36Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0
462306a36Sopenharmony_ci
562306a36Sopenharmony_cidata=$(mktemp /tmp/perf.data.XXXXXX)
662306a36Sopenharmony_ciprog="perf test -w noploop"
762306a36Sopenharmony_citask="perf"
862306a36Sopenharmony_cisym="noploop"
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ciif ! perf record -e task-clock:u -o - ${prog} | perf report -i - --task | grep ${task}; then
1162306a36Sopenharmony_ci	echo "cannot find the test file in the perf report"
1262306a36Sopenharmony_ci	exit 1
1362306a36Sopenharmony_cifi
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ciif ! perf record -e task-clock:u -o - ${prog} | perf inject -b | perf report -i - | grep ${sym}; then
1662306a36Sopenharmony_ci	echo "cannot find noploop function in pipe #1"
1762306a36Sopenharmony_ci	exit 1
1862306a36Sopenharmony_cifi
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ciperf record -e task-clock:u -o - ${prog} | perf inject -b -o ${data}
2162306a36Sopenharmony_ciif ! perf report -i ${data} | grep ${sym}; then
2262306a36Sopenharmony_ci	echo "cannot find noploop function in pipe #2"
2362306a36Sopenharmony_ci	exit 1
2462306a36Sopenharmony_cifi
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ciperf record -e task-clock:u -o ${data} ${prog}
2762306a36Sopenharmony_ciif ! perf inject -b -i ${data} | perf report -i - | grep ${sym}; then
2862306a36Sopenharmony_ci	echo "cannot find noploop function in pipe #3"
2962306a36Sopenharmony_ci	exit 1
3062306a36Sopenharmony_cifi
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_cirm -f ${data} ${data}.old
3462306a36Sopenharmony_ciexit 0
35