18c2ecf20Sopenharmony_ci#!/bin/sh
28c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0
38c2ecf20Sopenharmony_ci# description: event tracing - enable/disable with subsystem level files
48c2ecf20Sopenharmony_ci# requires: set_event events/sched/enable
58c2ecf20Sopenharmony_ci# flags: instance
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_cido_reset() {
88c2ecf20Sopenharmony_ci    echo > set_event
98c2ecf20Sopenharmony_ci    clear_trace
108c2ecf20Sopenharmony_ci}
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_cifail() { #msg
138c2ecf20Sopenharmony_ci    echo $1
148c2ecf20Sopenharmony_ci    exit_fail
158c2ecf20Sopenharmony_ci}
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ciecho 'sched:*' > set_event
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ciyield
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_cicount=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l`
228c2ecf20Sopenharmony_ciif [ $count -lt 3 ]; then
238c2ecf20Sopenharmony_ci    fail "at least fork, exec and exit events should be recorded"
248c2ecf20Sopenharmony_cifi
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_cido_reset
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ciecho 1 > events/sched/enable
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ciyield
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_cicount=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l`
338c2ecf20Sopenharmony_ciif [ $count -lt 3 ]; then
348c2ecf20Sopenharmony_ci    fail "at least fork, exec and exit events should be recorded"
358c2ecf20Sopenharmony_cifi
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_cido_reset
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ciecho 0 > events/sched/enable
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ciyield
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_cicount=`cat trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l`
448c2ecf20Sopenharmony_ciif [ $count -ne 0 ]; then
458c2ecf20Sopenharmony_ci    fail "any of scheduler events should not be recorded"
468c2ecf20Sopenharmony_cifi
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ciexit 0
49