18c2ecf20Sopenharmony_ci#!/bin/sh 28c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0 38c2ecf20Sopenharmony_ci# description: event tracing - restricts events based on pid 48c2ecf20Sopenharmony_ci# requires: set_event set_event_pid events/sched 58c2ecf20Sopenharmony_ci# flags: instance 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_cido_reset() { 88c2ecf20Sopenharmony_ci echo > set_event 98c2ecf20Sopenharmony_ci echo > set_event_pid 108c2ecf20Sopenharmony_ci echo 0 > options/event-fork 118c2ecf20Sopenharmony_ci clear_trace 128c2ecf20Sopenharmony_ci} 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_cifail() { #msg 158c2ecf20Sopenharmony_ci do_reset 168c2ecf20Sopenharmony_ci echo $1 178c2ecf20Sopenharmony_ci exit_fail 188c2ecf20Sopenharmony_ci} 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ciecho 0 > options/event-fork 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ciecho 1 > events/sched/sched_switch/enable 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ciyield 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_cicount=`cat trace | grep sched_switch | wc -l` 278c2ecf20Sopenharmony_ciif [ $count -eq 0 ]; then 288c2ecf20Sopenharmony_ci fail "sched_switch events are not recorded" 298c2ecf20Sopenharmony_cifi 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_cido_reset 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ciread mypid rest < /proc/self/stat 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ciecho $mypid > set_event_pid 368c2ecf20Sopenharmony_cigrep -q $mypid set_event_pid 378c2ecf20Sopenharmony_ciecho 'sched:sched_switch' > set_event 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_ciyield 408c2ecf20Sopenharmony_ci 418c2ecf20Sopenharmony_cicount=`cat trace | grep sched_switch | grep -v "pid=$mypid" | wc -l` 428c2ecf20Sopenharmony_ciif [ $count -ne 0 ]; then 438c2ecf20Sopenharmony_ci fail "sched_switch events from other task are recorded" 448c2ecf20Sopenharmony_cifi 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_cido_reset 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ciecho $mypid > set_event_pid 498c2ecf20Sopenharmony_ciecho 1 > options/event-fork 508c2ecf20Sopenharmony_ciecho 1 > events/sched/sched_switch/enable 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ciyield 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_cicount=`cat trace | grep sched_switch | grep -v "pid=$mypid" | wc -l` 558c2ecf20Sopenharmony_ciif [ $count -eq 0 ]; then 568c2ecf20Sopenharmony_ci fail "sched_switch events from other task are not recorded" 578c2ecf20Sopenharmony_cifi 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_cido_reset 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ciexit 0 62