Skip to content

Commit

Permalink
selftests/ftrace: Fix eventfs ownership testcase to find mount point
Browse files Browse the repository at this point in the history
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: ee9793b ("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>
  • Loading branch information
mhiramat authored and shuahkh committed Sep 4, 2024
1 parent b4bcdff commit f0a6ece
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tools/testing/selftests/ftrace/test.d/00basic/test_ownership.tc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f0a6ece

Please sign in to comment.