2 # SPDX-License-Identifier: GPL-2.0
4 # Run installed kselftest tests.
6 BASE_DIR=$(realpath $(dirname $0))
8 TESTS="$BASE_DIR"/kselftest-list.txt
9 if [ ! -r "$TESTS" ] ; then
10 echo "$0: Could not find list of tests to run ($TESTS)" >&2
13 available="$(cat "$TESTS")"
16 . ./kselftest/runner.sh
23 -s | --summary Print summary with detailed log in output.log
24 -t | --test COLLECTION:TEST Run TEST from COLLECTION
25 -c | --collection COLLECTION Run all tests from COLLECTION
26 -l | --list List the available collection:test entries
27 -d | --dry-run Don't actually run any tests
28 -h | --help Show this usage info
29 -o | --override-timeout Number of seconds after which we timeout
37 kselftest_override_timeout=""
41 logfile="$BASE_DIR"/output.log
42 cat /dev/null > $logfile
48 COLLECTIONS="$COLLECTIONS $2"
56 -o | --override-timeout)
57 kselftest_override_timeout="$2"
68 # Add all selected collections to the explicit test list.
69 if [ -n "$COLLECTIONS" ]; then
70 for collection in $COLLECTIONS ; do
71 found="$(echo "$available" | grep "^$collection:")"
72 if [ -z "$found" ] ; then
73 echo "No such collection '$collection'" >&2
79 # Replace available test list with explicitly selected tests.
80 if [ -n "$TESTS" ]; then
82 for test in $TESTS ; do
83 found="$(echo "$available" | grep "^${test}$")"
84 if [ -z "$found" ] ; then
85 echo "No such test '$test'" >&2
90 available="$(echo "$valid" | sed -e 's/ /\n/g')"
93 collections=$(echo "$available" | cut -d: -f1 | sort | uniq)
94 for collection in $collections ; do
95 [ -w /dev/kmsg ] && echo "kselftest: Running tests in $collection" >> /dev/kmsg
96 tests=$(echo "$available" | grep "^$collection:" | cut -d: -f2)
97 ($dryrun cd "$collection" && $dryrun run_many $tests)