Masami Hiramatsu | 76929ab | 2016-03-03 12:55:01 -0600 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # description: event trigger - test multiple histogram triggers |
| 3 | |
| 4 | do_reset() { |
| 5 | reset_trigger |
| 6 | echo > set_event |
| 7 | clear_trace |
| 8 | } |
| 9 | |
| 10 | fail() { #msg |
| 11 | do_reset |
| 12 | echo $1 |
| 13 | exit $FAIL |
| 14 | } |
| 15 | |
| 16 | if [ ! -f set_event -o ! -d events/sched ]; then |
| 17 | echo "event tracing is not supported" |
| 18 | exit_unsupported |
| 19 | fi |
| 20 | |
| 21 | if [ ! -f events/sched/sched_process_fork/trigger ]; then |
| 22 | echo "event trigger is not supported" |
| 23 | exit_unsupported |
| 24 | fi |
| 25 | |
| 26 | reset_tracer |
| 27 | do_reset |
| 28 | |
| 29 | FEATURE=`grep hist events/sched/sched_process_fork/trigger` |
| 30 | if [ -z "$FEATURE" ]; then |
| 31 | echo "hist trigger is not supported" |
| 32 | exit_unsupported |
| 33 | fi |
| 34 | |
| 35 | reset_trigger |
| 36 | |
| 37 | echo "Test histogram multiple tiggers" |
| 38 | |
| 39 | echo 'hist:keys=parent_pid:vals=child_pid' > events/sched/sched_process_fork/trigger |
| 40 | echo 'hist:keys=parent_comm:vals=child_pid' >> events/sched/sched_process_fork/trigger |
| 41 | for i in `seq 1 10` ; do ( echo "forked" > /dev/null); done |
| 42 | grep parent_pid events/sched/sched_process_fork/hist > /dev/null || \ |
| 43 | fail "hist trigger on sched_process_fork did not work" |
| 44 | grep child events/sched/sched_process_fork/hist > /dev/null || \ |
| 45 | fail "hist trigger on sched_process_fork did not work" |
| 46 | COMM=`cat /proc/$$/comm` |
| 47 | grep "parent_comm: $COMM" events/sched/sched_process_fork/hist > /dev/null || \ |
| 48 | fail "string key on sched_process_fork did not work" |
| 49 | |
| 50 | reset_trigger |
| 51 | |
| 52 | echo "Test histogram with its name" |
| 53 | |
| 54 | echo 'hist:name=test_hist:keys=common_pid' > events/sched/sched_process_fork/trigger |
| 55 | for i in `seq 1 10` ; do ( echo "forked" > /dev/null); done |
| 56 | grep test_hist events/sched/sched_process_fork/hist > /dev/null || \ |
| 57 | fail "named event on sched_process_fork did not work" |
| 58 | |
| 59 | echo "Test same named histogram on different events" |
| 60 | |
| 61 | echo 'hist:name=test_hist:keys=common_pid' > events/sched/sched_process_exit/trigger |
| 62 | for i in `seq 1 10` ; do ( echo "forked" > /dev/null); done |
| 63 | grep test_hist events/sched/sched_process_exit/hist > /dev/null || \ |
| 64 | fail "named event on sched_process_fork did not work" |
| 65 | |
| 66 | diffs=`diff events/sched/sched_process_exit/hist events/sched/sched_process_fork/hist | wc -l` |
| 67 | test $diffs -eq 0 || fail "Same name histograms are not same" |
| 68 | |
| 69 | reset_trigger |
| 70 | |
| 71 | do_reset |
| 72 | |
| 73 | exit 0 |