mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-18 23:26:52 +07:00
selftests: Extract logic for multiple test runs
This moves the logic for running multiple tests into a single "run_many" function of runner.sh. Both "run_tests" and "emit_tests" are modified to use it. Summary handling is now controlled by the "per_test_logging" shell flag. Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
This commit is contained in:
parent
d4e59a536f
commit
bf66078235
@ -193,16 +193,14 @@ ifdef INSTALL_PATH
|
|||||||
echo " logfile=\$$BASE_DIR/output.log" >> $(ALL_SCRIPT)
|
echo " logfile=\$$BASE_DIR/output.log" >> $(ALL_SCRIPT)
|
||||||
echo " cat /dev/null > \$$logfile" >> $(ALL_SCRIPT)
|
echo " cat /dev/null > \$$logfile" >> $(ALL_SCRIPT)
|
||||||
echo "fi" >> $(ALL_SCRIPT)
|
echo "fi" >> $(ALL_SCRIPT)
|
||||||
echo "export KSFT_TAP_LEVEL=1" >> $(ALL_SCRIPT)
|
|
||||||
|
|
||||||
for TARGET in $(TARGETS); do \
|
for TARGET in $(TARGETS); do \
|
||||||
BUILD_TARGET=$$BUILD/$$TARGET; \
|
BUILD_TARGET=$$BUILD/$$TARGET; \
|
||||||
echo "echo ; echo TAP version 13" >> $(ALL_SCRIPT); \
|
|
||||||
echo "echo Running tests in $$TARGET" >> $(ALL_SCRIPT); \
|
|
||||||
echo "echo ========================================" >> $(ALL_SCRIPT); \
|
|
||||||
echo "[ -w /dev/kmsg ] && echo \"kselftest: Running tests in $$TARGET\" >> /dev/kmsg" >> $(ALL_SCRIPT); \
|
echo "[ -w /dev/kmsg ] && echo \"kselftest: Running tests in $$TARGET\" >> /dev/kmsg" >> $(ALL_SCRIPT); \
|
||||||
echo "cd $$TARGET" >> $(ALL_SCRIPT); \
|
echo "cd $$TARGET" >> $(ALL_SCRIPT); \
|
||||||
|
echo -n "run_many" >> $(ALL_SCRIPT); \
|
||||||
make -s --no-print-directory OUTPUT=$$BUILD_TARGET -C $$TARGET emit_tests >> $(ALL_SCRIPT); \
|
make -s --no-print-directory OUTPUT=$$BUILD_TARGET -C $$TARGET emit_tests >> $(ALL_SCRIPT); \
|
||||||
|
echo "" >> $(ALL_SCRIPT); \
|
||||||
echo "cd \$$ROOT" >> $(ALL_SCRIPT); \
|
echo "cd \$$ROOT" >> $(ALL_SCRIPT); \
|
||||||
done;
|
done;
|
||||||
|
|
||||||
|
@ -2,17 +2,20 @@
|
|||||||
# SPDX-License-Identifier: GPL-2.0
|
# SPDX-License-Identifier: GPL-2.0
|
||||||
#
|
#
|
||||||
# Runs a set of tests in a given subdirectory.
|
# Runs a set of tests in a given subdirectory.
|
||||||
|
export KSFT_TAP_LEVEL=1
|
||||||
export skip_rc=4
|
export skip_rc=4
|
||||||
export logfile=/dev/stdout
|
export logfile=/dev/stdout
|
||||||
|
export per_test_logging=
|
||||||
|
|
||||||
run_one()
|
run_one()
|
||||||
{
|
{
|
||||||
TEST="$1"
|
DIR="$1"
|
||||||
NUM="$2"
|
TEST="$2"
|
||||||
|
NUM="$3"
|
||||||
|
|
||||||
BASENAME_TEST=$(basename $TEST)
|
BASENAME_TEST=$(basename $TEST)
|
||||||
|
|
||||||
TEST_HDR_MSG="selftests: "`basename $PWD`:" $BASENAME_TEST"
|
TEST_HDR_MSG="selftests: $DIR: $BASENAME_TEST"
|
||||||
echo "$TEST_HDR_MSG"
|
echo "$TEST_HDR_MSG"
|
||||||
echo "========================================"
|
echo "========================================"
|
||||||
if [ ! -x "$TEST" ]; then
|
if [ ! -x "$TEST" ]; then
|
||||||
@ -30,3 +33,19 @@ run_one()
|
|||||||
cd - >/dev/null
|
cd - >/dev/null
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
run_many()
|
||||||
|
{
|
||||||
|
echo "TAP version 13"
|
||||||
|
DIR=$(basename "$PWD")
|
||||||
|
test_num=0
|
||||||
|
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
|
||||||
|
}
|
||||||
|
@ -67,19 +67,11 @@ endif
|
|||||||
|
|
||||||
.ONESHELL:
|
.ONESHELL:
|
||||||
define RUN_TESTS
|
define RUN_TESTS
|
||||||
@export KSFT_TAP_LEVEL=`echo 1`; \
|
@. $(selfdir)/kselftest/runner.sh; \
|
||||||
test_num=`echo 0`; \
|
|
||||||
. $(selfdir)/kselftest/runner.sh; \
|
|
||||||
echo "TAP version 13"; \
|
|
||||||
for TEST in $(1); do \
|
|
||||||
BASENAME_TEST=`basename $$TEST`; \
|
|
||||||
test_num=`echo $$test_num+1 | bc`; \
|
|
||||||
if [ "X$(summary)" != "X" ]; then \
|
if [ "X$(summary)" != "X" ]; then \
|
||||||
logfile="/tmp/$$BASENAME_TEST"; \
|
per_test_logging=1; \
|
||||||
cat /dev/null > "$$logfile"; \
|
|
||||||
fi; \
|
fi; \
|
||||||
run_one "$$BASENAME_TEST" "$$test_num"; \
|
run_many $(1)
|
||||||
done;
|
|
||||||
endef
|
endef
|
||||||
|
|
||||||
run_tests: all
|
run_tests: all
|
||||||
@ -117,12 +109,11 @@ else
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
emit_tests:
|
emit_tests:
|
||||||
@test_num=`echo 0`; \
|
|
||||||
for TEST in $(TEST_GEN_PROGS) $(TEST_CUSTOM_PROGS) $(TEST_PROGS); do \
|
for TEST in $(TEST_GEN_PROGS) $(TEST_CUSTOM_PROGS) $(TEST_PROGS); do \
|
||||||
BASENAME_TEST=`basename $$TEST`; \
|
BASENAME_TEST=`basename $$TEST`; \
|
||||||
test_num=`echo $$test_num+1 | bc`; \
|
echo " \\"; \
|
||||||
echo "run_one \"$$BASENAME_TEST\" \"$$test_num\""; \
|
echo -n " \"$$BASENAME_TEST\""; \
|
||||||
done;
|
done; \
|
||||||
|
|
||||||
# define if isn't already. It is undefined in make O= case.
|
# define if isn't already. It is undefined in make O= case.
|
||||||
ifeq ($(RM),)
|
ifeq ($(RM),)
|
||||||
|
Loading…
Reference in New Issue
Block a user