Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests: tracing: Enable fprobe events before checking enable_functions

Since the fprobe is not registered before enabling the fprobe events,
enable_functions is also empty before enabling it. Thus the tests
which checking enable_functions must ensure the event is enabled before
testing the enable_functions.

Link: https://lore.kernel.org/all/174343538009.843280.6583146613234713007.stgit@devnote2/

Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>

+27 -19
+27 -19
tools/testing/selftests/ftrace/test.d/dynevent/add_remove_fprobe.tc
··· 16 16 17 17 echo "f:myevent1 $PLACE" >> dynamic_events 18 18 19 - # Make sure the event is attached and is the only one 20 - grep -q $PLACE enabled_functions 21 - cnt=`cat enabled_functions | wc -l` 22 - if [ $cnt -ne $((ocnt + 1)) ]; then 23 - exit_fail 24 - fi 25 - 26 19 echo "f:myevent2 $PLACE%return" >> dynamic_events 27 - 28 - # It should till be the only attached function 29 - cnt=`cat enabled_functions | wc -l` 30 - if [ $cnt -ne $((ocnt + 1)) ]; then 31 - exit_fail 32 - fi 33 20 34 21 # add another event 35 22 echo "f:myevent3 $PLACE2" >> dynamic_events 36 - 37 - grep -q $PLACE2 enabled_functions 38 - cnt=`cat enabled_functions | wc -l` 39 - if [ $cnt -ne $((ocnt + 2)) ]; then 40 - exit_fail 41 - fi 42 23 43 24 grep -q myevent1 dynamic_events 44 25 grep -q myevent2 dynamic_events ··· 27 46 test -d events/fprobes/myevent1 28 47 test -d events/fprobes/myevent2 29 48 49 + echo 1 > events/fprobes/myevent1/enable 50 + # Make sure the event is attached and is the only one 51 + grep -q $PLACE enabled_functions 52 + cnt=`cat enabled_functions | wc -l` 53 + if [ $cnt -ne $((ocnt + 1)) ]; then 54 + exit_fail 55 + fi 56 + 57 + echo 1 > events/fprobes/myevent2/enable 58 + # It should till be the only attached function 59 + cnt=`cat enabled_functions | wc -l` 60 + if [ $cnt -ne $((ocnt + 1)) ]; then 61 + exit_fail 62 + fi 63 + 64 + echo 1 > events/fprobes/myevent3/enable 65 + # If the function is different, the attached function should be increased 66 + grep -q $PLACE2 enabled_functions 67 + cnt=`cat enabled_functions | wc -l` 68 + if [ $cnt -ne $((ocnt + 2)) ]; then 69 + exit_fail 70 + fi 71 + 72 + echo 0 > events/fprobes/myevent2/enable 30 73 echo "-:myevent2" >> dynamic_events 31 74 32 75 grep -q myevent1 dynamic_events ··· 62 57 exit_fail 63 58 fi 64 59 60 + echo 0 > events/fprobes/enable 65 61 echo > dynamic_events 66 62 67 63 # Should have none left ··· 73 67 74 68 echo "f:myevent4 $PLACE" >> dynamic_events 75 69 70 + echo 1 > events/fprobes/myevent4/enable 76 71 # Should only have one enabled 77 72 cnt=`cat enabled_functions | wc -l` 78 73 if [ $cnt -ne $((ocnt + 1)) ]; then 79 74 exit_fail 80 75 fi 81 76 77 + echo 0 > events/fprobes/enable 82 78 echo > dynamic_events 83 79 84 80 # Should have none left