0001
0002
0003
0004
0005
0006
0007 fail() {
0008 echo $1
0009 exit_fail
0010 }
0011
0012 test_hist_expr() {
0013 trigger="events/sched/sched_process_fork/trigger"
0014
0015 reset_trigger_file $trigger
0016
0017 echo "Test hist trigger expressions - $1"
0018
0019 echo "hist:keys=common_pid:x=$2" > $trigger
0020
0021 for i in `seq 1 10` ; do ( echo "forked" > /dev/null); done
0022
0023 actual=`grep -o 'x=[[:digit:]]*' $trigger | awk -F= '{ print $2 }'`
0024
0025 if [ $actual != $3 ]; then
0026 fail "Failed hist trigger expression evaluation: Expression: $2 Expected: $3, Actual: $actual"
0027 fi
0028
0029 reset_trigger_file $trigger
0030 }
0031
0032 check_error() {
0033 trigger="events/sched/sched_process_fork/trigger"
0034
0035 echo "Test hist trigger expressions - $1"
0036 ftrace_errlog_check 'hist:sched:sched_process_fork' "$2" $trigger
0037 }
0038
0039 test_hist_expr "Variable assignment" "123" "123"
0040
0041 test_hist_expr "Subtraction not associative" "16-8-4-2" "2"
0042
0043 test_hist_expr "Division not associative" "64/8/4/2" "1"
0044
0045 test_hist_expr "Same precedence operators (+,-) evaluated left to right" "16-8+4+2" "14"
0046
0047 test_hist_expr "Same precedence operators (*,/) evaluated left to right" "4*3/2*2" "12"
0048
0049 test_hist_expr "Multiplication evaluated before addition/subtraction" "4+3*2-2" "8"
0050
0051 test_hist_expr "Division evaluated before addition/subtraction" "4+6/2-2" "5"
0052
0053
0054
0055
0056 check_error "Too many subexpressions" 'hist:keys=common_pid:x=32+^10*3/20-4'
0057 check_error "Too many subexpressions" 'hist:keys=common_pid:x=^1+2+3+4+5'
0058
0059 check_error "Unary minus not supported in subexpression" 'hist:keys=common_pid:x=-(^1)+2'
0060
0061 check_error "Division by zero" 'hist:keys=common_pid:x=3/^0'
0062
0063 exit 0