selftests/ftrace: Have reset_ftrace_filter handle multiple instances

"Linux Kernel Mailing List" <[email protected]>
Newsgroups gmane.linux.kernel.commits.head
Message-ID <[email protected]>
Web:        https://git.kernel.org/torvalds/c/0787ce336075ac0fa2d356de4e3c2a2488e851a6
Commit:     0787ce336075ac0fa2d356de4e3c2a2488e851a6
Parent:     df9d36d9e8adefe0975c7b5888967651b3db3af3
Refname:    refs/heads/master
Author:     Steven Rostedt (VMware) <[email protected]>
AuthorDate: Tue Feb 6 17:15:02 2018 -0500
Committer:  Steven Rostedt (VMware) <[email protected]>
CommitDate: Thu Feb 8 10:13:17 2018 -0500

    selftests/ftrace: Have reset_ftrace_filter handle multiple instances
    
    If a probe is attached to a static function that is in multiple files with
    the same name, removing it by name will remove all instances:
    
     # grep jump_label_unlock set_ftrace_filter
    jump_label_unlock:traceoff:unlimited
    jump_label_unlock:traceoff:unlimited
    
     # echo '!jump_label_unlock:traceoff' >> set_ftrace_filter
     # grep jump_label_unlock set_ftrace_filter
     #
    
    But the loop in reset_ftrace_filter will try to remove multiple instances
    multiple times. If this happens the second time will error and cause the
    test to fail.
    
    At each iteration of the loop, check to see if the probe being removed still
    exists.
    
    Cc: Shuah Khan <[email protected]>
    Signed-off-by: Steven Rostedt (VMware) <[email protected]>
---
 tools/testing/selftests/ftrace/test.d/functions | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/testing/selftests/ftrace/test.d/functions b/tools/testing/selftests/ftrace/test.d/functions
index e7c4c7b752a2..df3dd7fe5f9b 100644
--- a/tools/testing/selftests/ftrace/test.d/functions
+++ b/tools/testing/selftests/ftrace/test.d/functions
@@ -37,6 +37,9 @@ reset_ftrace_filter() { # reset all triggers in set_ftrace_filter
 	if [ "$tr" = "" ]; then
 	    continue
 	fi
+	if ! grep -q "$t" set_ftrace_filter; then
+		continue;
+	fi
 	name=`echo $t | cut -d: -f1 | cut -d' ' -f1`
 	if [ $tr = "enable_event" -o $tr = "disable_event" ]; then
 	    tr=`echo $t | cut -d: -f2-4`
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.