Skip to content

Commit 7e021da

Browse files
mhiramatshuahkh
authored andcommitted
selftests: tracing: Fix to unmount tracefs for recovering environment
Fix to unmount the tracefs if the ftracetest mounted it for recovering system environment. If the tracefs is already mounted, this does nothing. Suggested-by: Mark Brown <broonie@kernel.org> Link: https://lore.kernel.org/all/29fce076-746c-4650-8358-b4e0fa215cf7@sirena.org.uk/ Fixes: cbd965b ("ftrace/selftests: Return the skip code when tracing directory not configured in kernel") Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org> Reviewed-by: Mark Brown <broonie@kernel.org> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
1 parent 7ab6fe6 commit 7e021da

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tools/testing/selftests/ftrace/ftracetest

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ err_ret=1
3131
# kselftest skip code is 4
3232
err_skip=4
3333

34+
# umount required
35+
UMOUNT_DIR=""
36+
3437
# cgroup RT scheduling prevents chrt commands from succeeding, which
3538
# induces failures in test wakeup tests. Disable for the duration of
3639
# the tests.
@@ -45,6 +48,9 @@ setup() {
4548

4649
cleanup() {
4750
echo $sched_rt_runtime_orig > $sched_rt_runtime
51+
if [ -n "${UMOUNT_DIR}" ]; then
52+
umount ${UMOUNT_DIR} ||:
53+
fi
4854
}
4955

5056
errexit() { # message
@@ -161,11 +167,13 @@ if [ -z "$TRACING_DIR" ]; then
161167
mount -t tracefs nodev /sys/kernel/tracing ||
162168
errexit "Failed to mount /sys/kernel/tracing"
163169
TRACING_DIR="/sys/kernel/tracing"
170+
UMOUNT_DIR=${TRACING_DIR}
164171
# If debugfs exists, then so does /sys/kernel/debug
165172
elif [ -d "/sys/kernel/debug" ]; then
166173
mount -t debugfs nodev /sys/kernel/debug ||
167174
errexit "Failed to mount /sys/kernel/debug"
168175
TRACING_DIR="/sys/kernel/debug/tracing"
176+
UMOUNT_DIR=${TRACING_DIR}
169177
else
170178
err_ret=$err_skip
171179
errexit "debugfs and tracefs are not configured in this kernel"

0 commit comments

Comments
 (0)