tools/testing/selftests/ftrace/ftracetest

Source file repositories/reference/linux-study-clean/tools/testing/selftests/ftrace/ftracetest

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/ftrace/ftracetest
Extension
[no extension]
Size
12790 bytes
Lines
545
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: tools
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-only

# ftracetest - Ftrace test shell scripts
#
# Copyright (C) Hitachi Ltd., 2014
#  Written by Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
#

usage() { # errno [message]
[ ! -z "$2" ] && echo $2
echo "Usage: ftracetest [options] [testcase(s)] [testcase-directory(s)]"
echo " Options:"
echo "		-h|--help  Show help message"
echo "		-k|--keep  Keep passed test logs"
echo "		-K|--ktap  Output in KTAP format"
echo "		-v|--verbose Increase verbosity of test messages"
echo "		-vv        Alias of -v -v (Show all results in stdout)"
echo "		-vvv       Alias of -v -v -v (Show all commands immediately)"
echo "		--fail-unsupported Treat UNSUPPORTED as a failure"
echo "		--fail-unresolved Treat UNRESOLVED as a failure"
echo "		-d|--debug Debug mode (trace all shell commands)"
echo "		-l|--logdir <dir> Save logs on the <dir>"
echo "		            If <dir> is -, all logs output in console only"
echo "		--rv       Run RV selftests instead of ftrace ones"
exit $1
}

# default error
err_ret=1

# kselftest skip code is 4
err_skip=4

# umount required
UMOUNT_DIR=""

# cgroup RT scheduling prevents chrt commands from succeeding, which
# induces failures in test wakeup tests.  Disable for the duration of
# the tests.

readonly sched_rt_runtime=/proc/sys/kernel/sched_rt_runtime_us

sched_rt_runtime_orig=$(cat $sched_rt_runtime)

setup() {
  echo -1 > $sched_rt_runtime
}

cleanup() {
  echo $sched_rt_runtime_orig > $sched_rt_runtime
  if [ -n "${UMOUNT_DIR}" ]; then
    umount ${UMOUNT_DIR} ||:
  fi
}

errexit() { # message
  echo "Error: $1" 1>&2
  cleanup
  exit $err_ret
}

# Ensuring user privilege
if [ `id -u` -ne 0 ]; then
  errexit "this must be run by root user"
fi

setup

# Utilities

Annotation

Implementation Notes