| 1 |
#!/bin/sh |
| 2 |
# SPDX-License-Identifier: GPL-2.0 |
| 3 |
# description: event tracing - enable/disable with subsystem level files |
| 4 |
# requires: set_event events/sched/enable |
| 5 |
# flags: instance |
| 6 |
|
| 7 |
do_reset() { |
| 8 |
echo > set_event |
| 9 |
clear_trace |
| 10 |
} |
| 11 |
|
| 12 |
fail() { #msg |
| 13 |
echo $1 |
| 14 |
exit_fail |
| 15 |
} |
| 16 |
|
| 17 |
# As reading trace can last forever, simply look for 3 different |
| 18 |
# events then exit out of reading the file. If there's not 3 different |
| 19 |
# events, then the test has failed. |
| 20 |
check_unique() { |
| 21 |
cat trace | grep -v '^#' | awk ' |
| 22 |
BEGIN { cnt = 0; } |
| 23 |
{ |
| 24 |
for (i = 0; i < cnt; i++) { |
| 25 |
if (event[i] == $5) { |
| 26 |
break; |
| 27 |
} |
| 28 |
} |
| 29 |
if (i == cnt) { |
| 30 |
event[cnt++] = $5; |
| 31 |
if (cnt > 2) { |
| 32 |
exit; |
| 33 |
} |
| 34 |
} |
| 35 |
} |
| 36 |
END { |
| 37 |
printf "%d", cnt; |
| 38 |
}' |
| 39 |
} |
| 40 |
|
| 41 |
echo 'sched:*' > set_event |
| 42 |
|
| 43 |
yield |
| 44 |
|
| 45 |
count=`check_unique` |
| 46 |
if [ $count -lt 3 ]; then |
| 47 |
fail "at least fork, exec and exit events should be recorded" |
| 48 |
fi |
| 49 |
|
| 50 |
do_reset |
| 51 |
|
| 52 |
echo 1 > events/sched/enable |
| 53 |
|
| 54 |
yield |
| 55 |
|
| 56 |
count=`check_unique` |
| 57 |
if [ $count -lt 3 ]; then |
| 58 |
fail "at least fork, exec and exit events should be recorded" |
| 59 |
fi |
| 60 |
|
| 61 |
do_reset |
| 62 |
|
| 63 |
echo 0 > events/sched/enable |
| 64 |
|
| 65 |
yield |
| 66 |
|
| 67 |
count=`head -n 100 trace | grep -v ^# | awk '{ print $5 }' | sort -u | wc -l` |
| 68 |
if [ $count -ne 0 ]; then |
| 69 |
fail "any of scheduler events should not be recorded" |
| 70 |
fi |
| 71 |
|
| 72 |
exit 0 |