]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
selftests/ftrace: Fix eventfs ownership testcase to find mount point
authorMasami Hiramatsu (Google) <mhiramat@kernel.org>
Wed, 4 Sep 2024 15:30:21 +0000 (00:30 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 4 Oct 2024 14:32:38 +0000 (16:32 +0200)
[ Upstream commit f0a6ecebd858658df213d114b0530f8f0b96e396 ]

Fix eventfs ownership testcase to find mount point if stat -c "%m" failed.
This can happen on the system based on busybox. In this case, this will
try to use the current working directory, which should be a tracefs top
directory (and eventfs is mounted as a part of tracefs.)
If it does not work, the test is skipped as UNRESOLVED because of
the environmental problem.

Fixes: ee9793be08b1 ("tracing/selftests: Add ownership modification tests for eventfs")
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Acked-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/testing/selftests/ftrace/test.d/00basic/test_ownership.tc

index c45094d1e1d2db2e812f7a7480256f581b63b3b8..803efd7b56c77d6622791f173d55bb9f9e540a9d 100644 (file)
@@ -6,6 +6,18 @@ original_group=`stat -c "%g" .`
 original_owner=`stat -c "%u" .`
 
 mount_point=`stat -c '%m' .`
+
+# If stat -c '%m' does not work (e.g. busybox) or failed, try to use the
+# current working directory (which should be a tracefs) as the mount point.
+if [ ! -d "$mount_point" ]; then
+       if mount | grep -qw $PWD ; then
+               mount_point=$PWD
+       else
+               # If PWD doesn't work, that is an environmental problem.
+               exit_unresolved
+       fi
+fi
+
 mount_options=`mount | grep "$mount_point" | sed -e 's/.*(\(.*\)).*/\1/'`
 
 # find another owner and group that is not the original