1 #!/bin/sh 1 #!/bin/sh 2 # SPDX-License-Identifier: GPL-2.0 2 # SPDX-License-Identifier: GPL-2.0 3 # 3 # 4 # Run installed kselftest tests. 4 # Run installed kselftest tests. 5 # 5 # 6 BASE_DIR=$(realpath $(dirname $0)) 6 BASE_DIR=$(realpath $(dirname $0)) 7 cd $BASE_DIR 7 cd $BASE_DIR 8 TESTS="$BASE_DIR"/kselftest-list.txt 8 TESTS="$BASE_DIR"/kselftest-list.txt 9 if [ ! -r "$TESTS" ] ; then 9 if [ ! -r "$TESTS" ] ; then 10 echo "$0: Could not find list of tests 10 echo "$0: Could not find list of tests to run ($TESTS)" >&2 11 available="" 11 available="" 12 else 12 else 13 available="$(cat "$TESTS")" 13 available="$(cat "$TESTS")" 14 fi 14 fi 15 15 16 . ./kselftest/runner.sh 16 . ./kselftest/runner.sh 17 ROOT=$PWD 17 ROOT=$PWD 18 18 19 usage() 19 usage() 20 { 20 { 21 cat <<EOF 21 cat <<EOF 22 Usage: $0 [OPTIONS] 22 Usage: $0 [OPTIONS] 23 -s | --summary Print summary !! 23 -s | --summary Print summary with detailed log in output.log 24 -p | --per_test_log Print test log << 25 -t | --test COLLECTION:TEST Run TEST from 24 -t | --test COLLECTION:TEST Run TEST from COLLECTION 26 -c | --collection COLLECTION Run all tests 25 -c | --collection COLLECTION Run all tests from COLLECTION 27 -l | --list List the avail 26 -l | --list List the available collection:test entries 28 -d | --dry-run Don't actually 27 -d | --dry-run Don't actually run any tests 29 -n | --netns Run each test << 30 -h | --help Show this usag 28 -h | --help Show this usage info 31 -o | --override-timeout Number of seco 29 -o | --override-timeout Number of seconds after which we timeout 32 EOF 30 EOF 33 exit $1 31 exit $1 34 } 32 } 35 33 36 COLLECTIONS="" 34 COLLECTIONS="" 37 TESTS="" 35 TESTS="" 38 dryrun="" 36 dryrun="" 39 kselftest_override_timeout="" 37 kselftest_override_timeout="" 40 while true; do 38 while true; do 41 case "$1" in 39 case "$1" in 42 -s | --summary) 40 -s | --summary) 43 logfile="$BASE_DIR"/ou 41 logfile="$BASE_DIR"/output.log 44 cat /dev/null > $logfi 42 cat /dev/null > $logfile 45 shift ;; 43 shift ;; 46 -p | --per-test-log) << 47 per_test_logging=1 << 48 shift ;; << 49 -t | --test) 44 -t | --test) 50 TESTS="$TESTS $2" 45 TESTS="$TESTS $2" 51 shift 2 ;; 46 shift 2 ;; 52 -c | --collection) 47 -c | --collection) 53 COLLECTIONS="$COLLECTI 48 COLLECTIONS="$COLLECTIONS $2" 54 shift 2 ;; 49 shift 2 ;; 55 -l | --list) 50 -l | --list) 56 echo "$available" 51 echo "$available" 57 exit 0 ;; 52 exit 0 ;; 58 -d | --dry-run) 53 -d | --dry-run) 59 dryrun="echo" 54 dryrun="echo" 60 shift ;; << 61 -n | --netns) << 62 RUN_IN_NETNS=1 << 63 shift ;; 55 shift ;; 64 -o | --override-timeout) 56 -o | --override-timeout) 65 kselftest_override_tim 57 kselftest_override_timeout="$2" 66 shift 2 ;; 58 shift 2 ;; 67 -h | --help) 59 -h | --help) 68 usage 0 ;; 60 usage 0 ;; 69 "") 61 "") 70 break ;; 62 break ;; 71 *) 63 *) 72 usage 1 ;; 64 usage 1 ;; 73 esac 65 esac 74 done 66 done 75 67 76 # Add all selected collections to the explicit 68 # Add all selected collections to the explicit test list. 77 if [ -n "$COLLECTIONS" ]; then 69 if [ -n "$COLLECTIONS" ]; then 78 for collection in $COLLECTIONS ; do 70 for collection in $COLLECTIONS ; do 79 found="$(echo "$available" | g 71 found="$(echo "$available" | grep "^$collection:")" 80 if [ -z "$found" ] ; then 72 if [ -z "$found" ] ; then 81 echo "No such collecti 73 echo "No such collection '$collection'" >&2 82 exit 1 74 exit 1 83 fi 75 fi 84 TESTS="$TESTS $found" 76 TESTS="$TESTS $found" 85 done 77 done 86 fi 78 fi 87 # Replace available test list with explicitly 79 # Replace available test list with explicitly selected tests. 88 if [ -n "$TESTS" ]; then 80 if [ -n "$TESTS" ]; then 89 valid="" 81 valid="" 90 for test in $TESTS ; do 82 for test in $TESTS ; do 91 found="$(echo "$available" | g 83 found="$(echo "$available" | grep "^${test}$")" 92 if [ -z "$found" ] ; then 84 if [ -z "$found" ] ; then 93 echo "No such test '$t 85 echo "No such test '$test'" >&2 94 exit 1 86 exit 1 95 fi 87 fi 96 valid="$valid $found" 88 valid="$valid $found" 97 done 89 done 98 available="$(echo "$valid" | sed -e 's 90 available="$(echo "$valid" | sed -e 's/ /\n/g')" 99 fi 91 fi 100 92 101 collections=$(echo "$available" | cut -d: -f1 93 collections=$(echo "$available" | cut -d: -f1 | sort | uniq) 102 for collection in $collections ; do 94 for collection in $collections ; do 103 [ -w /dev/kmsg ] && echo "kselftest: R 95 [ -w /dev/kmsg ] && echo "kselftest: Running tests in $collection" >> /dev/kmsg 104 tests=$(echo "$available" | grep "^$co 96 tests=$(echo "$available" | grep "^$collection:" | cut -d: -f2) 105 ($dryrun cd "$collection" && $dryrun r 97 ($dryrun cd "$collection" && $dryrun run_many $tests) 106 done 98 done
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.