brintos

brintos / linux-shallow public Read only

0
0
Text · 2.5 KiB · a28c141 Raw
107 lines · bash
1#!/bin/sh2# SPDX-License-Identifier: GPL-2.03#4# Run installed kselftest tests.5#6BASE_DIR=$(realpath $(dirname $0))7cd $BASE_DIR8TESTS="$BASE_DIR"/kselftest-list.txt9if [ ! -r "$TESTS" ] ; then10	echo "$0: Could not find list of tests to run ($TESTS)" >&211	available=""12else13	available="$(cat "$TESTS")"14fi15 16. ./kselftest/runner.sh17ROOT=$PWD18 19usage()20{21	cat <<EOF22Usage: $0 [OPTIONS]23  -s | --summary		Print summary with detailed log in output.log (conflict with -p)24  -p | --per_test_log		Print test log in /tmp with each test name (conflict with -s)25  -t | --test COLLECTION:TEST	Run TEST from COLLECTION26  -c | --collection COLLECTION	Run all tests from COLLECTION27  -l | --list			List the available collection:test entries28  -d | --dry-run		Don't actually run any tests29  -n | --netns			Run each test in namespace30  -h | --help			Show this usage info31  -o | --override-timeout	Number of seconds after which we timeout32EOF33	exit $134}35 36COLLECTIONS=""37TESTS=""38dryrun=""39kselftest_override_timeout=""40while true; do41	case "$1" in42		-s | --summary)43			logfile="$BASE_DIR"/output.log44			cat /dev/null > $logfile45			shift ;;46		-p | --per-test-log)47			per_test_logging=148			shift ;;49		-t | --test)50			TESTS="$TESTS $2"51			shift 2 ;;52		-c | --collection)53			COLLECTIONS="$COLLECTIONS $2"54			shift 2 ;;55		-l | --list)56			echo "$available"57			exit 0 ;;58		-d | --dry-run)59			dryrun="echo"60			shift ;;61		-n | --netns)62			RUN_IN_NETNS=163			shift ;;64		-o | --override-timeout)65			kselftest_override_timeout="$2"66			shift 2 ;;67		-h | --help)68			usage 0 ;;69		"")70			break ;;71		*)72			usage 1 ;;73	esac74done75 76# Add all selected collections to the explicit test list.77if [ -n "$COLLECTIONS" ]; then78	for collection in $COLLECTIONS ; do79		found="$(echo "$available" | grep "^$collection:")"80		if [ -z "$found" ] ; then81			echo "No such collection '$collection'" >&282			exit 183		fi84		TESTS="$TESTS $found"85	done86fi87# Replace available test list with explicitly selected tests.88if [ -n "$TESTS" ]; then89	valid=""90	for test in $TESTS ; do91		found="$(echo "$available" | grep "^${test}$")"92		if [ -z "$found" ] ; then93			echo "No such test '$test'" >&294			exit 195		fi96		valid="$valid $found"97	done98	available="$(echo "$valid" | sed -e 's/ /\n/g')"99fi100 101collections=$(echo "$available" | cut -d: -f1 | sort | uniq)102for collection in $collections ; do103	[ -w /dev/kmsg ] && echo "kselftest: Running tests in $collection" >> /dev/kmsg104	tests=$(echo "$available" | grep "^$collection:" | cut -d: -f2)105	($dryrun cd "$collection" && $dryrun run_many $tests)106done107