1#!/bin/sh 2# perf sched stats tests 3# SPDX-License-Identifier: GPL-2.0 4 5set -e 6 7if [ "$(id -u)" != 0 ]; then 8 echo "[Skip] No root permission" 9 exit 2 10fi 11 12perfdata=$(mktemp /tmp/__perf_test_sched_stats.perf.data.XXXXX) 13perfdata2=$(mktemp /tmp/__perf_test_sched_stats.perf.data.XXXXX) 14 15cleanup() { 16 rm -f "${perfdata}" 17 rm -f "${perfdata}".old 18 rm -f "${perfdata2}" 19 rm -f "${perfdata2}".old 20 21 trap - EXIT TERM INT 22} 23 24trap_cleanup() { 25 echo "Unexpected signal in ${FUNCNAME[1]}" 26 cleanup 27 exit 1 28} 29trap trap_cleanup EXIT TERM INT 30 31err=0 32test_perf_sched_stats_record() { 33 echo "Basic perf sched stats record test" 34 if ! perf sched stats record -o "${perfdata}" true 2>&1 | \ 35 grep -E -q "[ perf sched stats: Wrote samples to perf.data ]" 36 then 37 echo "Basic perf sched stats record test [Failed]" 38 err=1 39 return 40 fi 41 echo "Basic perf sched stats record test [Success]" 42} 43 44test_perf_sched_stats_report() { 45 echo "Basic perf sched stats report test" 46 perf sched stats record -o "${perfdata}" true > /dev/null 47 if ! perf sched stats report -i "${perfdata}" 2>&1 | grep -E -q "Description" 48 then 49 echo "Basic perf sched stats report test [Failed]" 50 err=1 51 return 52 fi 53 echo "Basic perf sched stats report test [Success]" 54} 55 56test_perf_sched_stats_live() { 57 echo "Basic perf sched stats live mode test" 58 if ! perf sched stats true 2>&1 | grep -E -q "Description" 59 then 60 echo "Basic perf sched stats live mode test [Failed]" 61 err=1 62 return 63 fi 64 echo "Basic perf sched stats live mode test [Success]" 65} 66 67test_perf_sched_stats_diff() { 68 echo "Basic perf sched stats diff test" 69 perf sched stats record -o "${perfdata}" true > /dev/null 70 perf sched stats record -o "${perfdata2}" true > /dev/null 71 if ! perf sched stats diff "${perfdata}" "${perfdata2}" > /dev/null 72 then 73 echo "Basic perf sched stats diff test [Failed]" 74 err=1 75 return 76 fi 77 echo "Basic perf sched stats diff test [Success]" 78} 79 80test_perf_sched_stats_record 81test_perf_sched_stats_report 82test_perf_sched_stats_live 83test_perf_sched_stats_diff 84 85cleanup 86exit $err 87