162306a36Sopenharmony_ci#!/bin/sh 262306a36Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0 362306a36Sopenharmony_ci# 462306a36Sopenharmony_ci# Run installed kselftest tests. 562306a36Sopenharmony_ci# 662306a36Sopenharmony_ciBASE_DIR=$(realpath $(dirname $0)) 762306a36Sopenharmony_cicd $BASE_DIR 862306a36Sopenharmony_ciTESTS="$BASE_DIR"/kselftest-list.txt 962306a36Sopenharmony_ciif [ ! -r "$TESTS" ] ; then 1062306a36Sopenharmony_ci echo "$0: Could not find list of tests to run ($TESTS)" >&2 1162306a36Sopenharmony_ci available="" 1262306a36Sopenharmony_cielse 1362306a36Sopenharmony_ci available="$(cat "$TESTS")" 1462306a36Sopenharmony_cifi 1562306a36Sopenharmony_ci 1662306a36Sopenharmony_ci. ./kselftest/runner.sh 1762306a36Sopenharmony_ciROOT=$PWD 1862306a36Sopenharmony_ci 1962306a36Sopenharmony_ciusage() 2062306a36Sopenharmony_ci{ 2162306a36Sopenharmony_ci cat <<EOF 2262306a36Sopenharmony_ciUsage: $0 [OPTIONS] 2362306a36Sopenharmony_ci -s | --summary Print summary with detailed log in output.log 2462306a36Sopenharmony_ci -t | --test COLLECTION:TEST Run TEST from COLLECTION 2562306a36Sopenharmony_ci -c | --collection COLLECTION Run all tests from COLLECTION 2662306a36Sopenharmony_ci -l | --list List the available collection:test entries 2762306a36Sopenharmony_ci -d | --dry-run Don't actually run any tests 2862306a36Sopenharmony_ci -h | --help Show this usage info 2962306a36Sopenharmony_ci -o | --override-timeout Number of seconds after which we timeout 3062306a36Sopenharmony_ciEOF 3162306a36Sopenharmony_ci exit $1 3262306a36Sopenharmony_ci} 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ciCOLLECTIONS="" 3562306a36Sopenharmony_ciTESTS="" 3662306a36Sopenharmony_cidryrun="" 3762306a36Sopenharmony_cikselftest_override_timeout="" 3862306a36Sopenharmony_ciwhile true; do 3962306a36Sopenharmony_ci case "$1" in 4062306a36Sopenharmony_ci -s | --summary) 4162306a36Sopenharmony_ci logfile="$BASE_DIR"/output.log 4262306a36Sopenharmony_ci cat /dev/null > $logfile 4362306a36Sopenharmony_ci shift ;; 4462306a36Sopenharmony_ci -t | --test) 4562306a36Sopenharmony_ci TESTS="$TESTS $2" 4662306a36Sopenharmony_ci shift 2 ;; 4762306a36Sopenharmony_ci -c | --collection) 4862306a36Sopenharmony_ci COLLECTIONS="$COLLECTIONS $2" 4962306a36Sopenharmony_ci shift 2 ;; 5062306a36Sopenharmony_ci -l | --list) 5162306a36Sopenharmony_ci echo "$available" 5262306a36Sopenharmony_ci exit 0 ;; 5362306a36Sopenharmony_ci -d | --dry-run) 5462306a36Sopenharmony_ci dryrun="echo" 5562306a36Sopenharmony_ci shift ;; 5662306a36Sopenharmony_ci -o | --override-timeout) 5762306a36Sopenharmony_ci kselftest_override_timeout="$2" 5862306a36Sopenharmony_ci shift 2 ;; 5962306a36Sopenharmony_ci -h | --help) 6062306a36Sopenharmony_ci usage 0 ;; 6162306a36Sopenharmony_ci "") 6262306a36Sopenharmony_ci break ;; 6362306a36Sopenharmony_ci *) 6462306a36Sopenharmony_ci usage 1 ;; 6562306a36Sopenharmony_ci esac 6662306a36Sopenharmony_cidone 6762306a36Sopenharmony_ci 6862306a36Sopenharmony_ci# Add all selected collections to the explicit test list. 6962306a36Sopenharmony_ciif [ -n "$COLLECTIONS" ]; then 7062306a36Sopenharmony_ci for collection in $COLLECTIONS ; do 7162306a36Sopenharmony_ci found="$(echo "$available" | grep "^$collection:")" 7262306a36Sopenharmony_ci if [ -z "$found" ] ; then 7362306a36Sopenharmony_ci echo "No such collection '$collection'" >&2 7462306a36Sopenharmony_ci exit 1 7562306a36Sopenharmony_ci fi 7662306a36Sopenharmony_ci TESTS="$TESTS $found" 7762306a36Sopenharmony_ci done 7862306a36Sopenharmony_cifi 7962306a36Sopenharmony_ci# Replace available test list with explicitly selected tests. 8062306a36Sopenharmony_ciif [ -n "$TESTS" ]; then 8162306a36Sopenharmony_ci valid="" 8262306a36Sopenharmony_ci for test in $TESTS ; do 8362306a36Sopenharmony_ci found="$(echo "$available" | grep "^${test}$")" 8462306a36Sopenharmony_ci if [ -z "$found" ] ; then 8562306a36Sopenharmony_ci echo "No such test '$test'" >&2 8662306a36Sopenharmony_ci exit 1 8762306a36Sopenharmony_ci fi 8862306a36Sopenharmony_ci valid="$valid $found" 8962306a36Sopenharmony_ci done 9062306a36Sopenharmony_ci available="$(echo "$valid" | sed -e 's/ /\n/g')" 9162306a36Sopenharmony_cifi 9262306a36Sopenharmony_ci 9362306a36Sopenharmony_cicollections=$(echo "$available" | cut -d: -f1 | sort | uniq) 9462306a36Sopenharmony_cifor collection in $collections ; do 9562306a36Sopenharmony_ci [ -w /dev/kmsg ] && echo "kselftest: Running tests in $collection" >> /dev/kmsg 9662306a36Sopenharmony_ci tests=$(echo "$available" | grep "^$collection:" | cut -d: -f2) 9762306a36Sopenharmony_ci ($dryrun cd "$collection" && $dryrun run_many $tests) 9862306a36Sopenharmony_cidone 99