tools/testing/selftests/run_kselftest.sh

Source file repositories/reference/linux-study-clean/tools/testing/selftests/run_kselftest.sh

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/run_kselftest.sh
Extension
.sh
Size
3983 bytes
Lines
164
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
#
# Run installed kselftest tests.
#

BASE_DIR=$(cd "$(dirname "$0")" && pwd -P)

cd $BASE_DIR
TESTS="$BASE_DIR"/kselftest-list.txt
if [ ! -r "$TESTS" ] ; then
	echo "$0: Could not find list of tests to run ($TESTS)" >&2
	available=""
else
	available="$(cat "$TESTS")"
fi

. ./kselftest/runner.sh

usage()
{
	cat <<EOF
Usage: $0 [OPTIONS]
  -s | --summary		Print summary with detailed log in output.log (conflict with -p)
  -p | --per-test-log [DIR]	Print test log in /tmp or DIR with each test name (conflict with -s)
  -t | --test COLLECTION:TEST	Run TEST from COLLECTION
  -S | --skip COLLECTION:TEST	Skip TEST from COLLECTION
  -c | --collection COLLECTION	Run all tests from COLLECTION
  -l | --list			List the available collection:test entries
  -d | --dry-run		Don't actually run any tests
  -f | --no-error-on-fail	Don't exit with an error just because tests failed
  -n | --netns			Run each test in namespace
  -h | --help			Show this usage info
  -o | --override-timeout	Number of seconds after which we timeout
EOF
	exit $1
}

COLLECTIONS=""
TESTS=""
SKIP=""
dryrun=""
kselftest_override_timeout=""
ERROR_ON_FAIL=true
while true; do
	case "$1" in
		-s | --summary)
			logfile="$BASE_DIR"/output.log
			cat /dev/null > $logfile
			shift ;;
		-p | --per-test-log)
			per_test_logging=1
			if [ -n "$2" ] && [ "${2#-}" = "$2" ]; then
				per_test_log_dir="$2"
				if [ -e "$per_test_log_dir" ] && [ ! -d "$per_test_log_dir" ]; then
					echo "Per-test log path is not a dir:" \
					     "$per_test_log_dir" >&2
					exit 1
				fi
				if [ ! -d "$per_test_log_dir" ] && \
				   ! mkdir -p "$per_test_log_dir"; then
					echo "Could not create log dir:" \
					     "$per_test_log_dir" >&2
					exit 1
				fi
				per_test_log_dir=$(cd "$per_test_log_dir" && pwd -P)
				if [ -z "$per_test_log_dir" ]; then
					echo "Could not resolve per-test log directory" >&2
					exit 1
				fi

Annotation

Implementation Notes