diff mbox series

selftests/ftrace: Fix eventfs ownership testcase to find mount point

Message ID 172546382097.224182.6471842111781551515.stgit@devnote2 (mailing list archive)
State Accepted
Headers show
Series selftests/ftrace: Fix eventfs ownership testcase to find mount point | expand

Commit Message

Masami Hiramatsu (Google) Sept. 4, 2024, 3:30 p.m. UTC
From: Masami Hiramatsu (Google) <mhiramat@kernel.org>

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>
---
 .../ftrace/test.d/00basic/test_ownership.tc        |   12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

Steven Rostedt Sept. 4, 2024, 4:20 p.m. UTC | #1
On Thu,  5 Sep 2024 00:30:21 +0900
"Masami Hiramatsu (Google)" <mhiramat@kernel.org> wrote:

> From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> 
> 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>

-- Steve
Shuah Khan Sept. 4, 2024, 9:09 p.m. UTC | #2
On 9/4/24 10:20, Steven Rostedt wrote:
> On Thu,  5 Sep 2024 00:30:21 +0900
> "Masami Hiramatsu (Google)" <mhiramat@kernel.org> wrote:
> 
>> From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
>>
>> 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>
> 
> -- Steve

Thank you. Applied to linux-kselftest next for Linux 6.12-rc1

thanks,
-- Shuah
diff mbox series

Patch

diff --git a/tools/testing/selftests/ftrace/test.d/00basic/test_ownership.tc b/tools/testing/selftests/ftrace/test.d/00basic/test_ownership.tc
index c45094d1e1d2..803efd7b56c7 100644
--- a/tools/testing/selftests/ftrace/test.d/00basic/test_ownership.tc
+++ b/tools/testing/selftests/ftrace/test.d/00basic/test_ownership.tc
@@ -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