2019-04-25 07:12:30 +08:00
|
|
|
#!/bin/sh
|
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
#
|
|
|
|
# Runs a set of tests in a given subdirectory.
|
2019-04-25 07:12:32 +08:00
|
|
|
export KSFT_TAP_LEVEL=1
|
2019-04-25 07:12:30 +08:00
|
|
|
export skip_rc=4
|
|
|
|
export logfile=/dev/stdout
|
2019-04-25 07:12:32 +08:00
|
|
|
export per_test_logging=
|
2019-04-25 07:12:30 +08:00
|
|
|
|
|
|
|
run_one()
|
|
|
|
{
|
2019-04-25 07:12:32 +08:00
|
|
|
DIR="$1"
|
|
|
|
TEST="$2"
|
|
|
|
NUM="$3"
|
2019-04-25 07:12:30 +08:00
|
|
|
|
|
|
|
BASENAME_TEST=$(basename $TEST)
|
|
|
|
|
2019-04-25 07:12:32 +08:00
|
|
|
TEST_HDR_MSG="selftests: $DIR: $BASENAME_TEST"
|
2019-04-25 07:12:30 +08:00
|
|
|
echo "$TEST_HDR_MSG"
|
|
|
|
echo "========================================"
|
|
|
|
if [ ! -x "$TEST" ]; then
|
2019-04-25 07:12:34 +08:00
|
|
|
echo -n "$TEST_HDR_MSG: Warning: file $TEST is "
|
|
|
|
if [ ! -e "$TEST" ]; then
|
|
|
|
echo "missing!"
|
|
|
|
else
|
|
|
|
echo "not executable, correct this."
|
|
|
|
fi
|
2019-04-25 07:12:33 +08:00
|
|
|
echo "not ok $test_num $TEST_HDR_MSG"
|
2019-04-25 07:12:30 +08:00
|
|
|
else
|
|
|
|
cd `dirname $TEST` > /dev/null
|
|
|
|
(./$BASENAME_TEST >> "$logfile" 2>&1 &&
|
2019-04-25 07:12:33 +08:00
|
|
|
echo "ok $test_num $TEST_HDR_MSG") ||
|
2019-04-25 07:12:30 +08:00
|
|
|
(if [ $? -eq $skip_rc ]; then \
|
2019-04-25 07:12:33 +08:00
|
|
|
echo "not ok $test_num $TEST_HDR_MSG # SKIP"
|
2019-04-25 07:12:30 +08:00
|
|
|
else
|
2019-04-25 07:12:33 +08:00
|
|
|
echo "not ok $test_num $TEST_HDR_MSG"
|
2019-04-25 07:12:30 +08:00
|
|
|
fi)
|
|
|
|
cd - >/dev/null
|
|
|
|
fi
|
|
|
|
}
|
2019-04-25 07:12:32 +08:00
|
|
|
|
|
|
|
run_many()
|
|
|
|
{
|
|
|
|
echo "TAP version 13"
|
|
|
|
DIR=$(basename "$PWD")
|
|
|
|
test_num=0
|
2019-04-25 07:12:33 +08:00
|
|
|
total=$(echo "$@" | wc -w)
|
|
|
|
echo "1..$total"
|
2019-04-25 07:12:32 +08:00
|
|
|
for TEST in "$@"; do
|
|
|
|
BASENAME_TEST=$(basename $TEST)
|
|
|
|
test_num=$(( test_num + 1 ))
|
|
|
|
if [ -n "$per_test_logging" ]; then
|
|
|
|
logfile="/tmp/$BASENAME_TEST"
|
|
|
|
cat /dev/null > "$logfile"
|
|
|
|
fi
|
|
|
|
run_one "$DIR" "$TEST" "$test_num"
|
|
|
|
done
|
|
|
|
}
|