Skip to content

Commit

Permalink
test: fix CHECK_TYPE behaviour
Browse files Browse the repository at this point in the history
- By default, no Valgrind tool has been forced, and a Valgrind tool or
lack of it will be picked depending on the particular test's
requirements.
- Providing 'force-enable [memcheck|pmemcheck|helgrind|drd]' will force
all tests to be run under the forced Valgrind tool unless a test forced
a different Valgrind tool in which case the given will test will be skipped.
- Providing 'force-enable none' will run all tests that do not require
explicitly any Valgrind tool and skip all other tests.

Ref: #5811
Ref: #5791

Signed-off-by: Jan Michalski <jan.michalski@intel.com>
  • Loading branch information
janekmi committed Aug 21, 2023
1 parent 24ad25f commit 61c2945
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
9 changes: 4 additions & 5 deletions src/test/RUNTESTS.sh
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,8 @@ runtest() {
do
export RUNTEST_DIR=$1
export RUNTEST_PARAMS="TEST=$ttype FS=$fs BUILD=$build"
# FORCE_CHECK_TYPE is required for easy force-enable condition failure detection.
# Please see require_valgrind() for details.
export RUNTEST_EXTRA="CHECK_TYPE=$checktype \
FORCE_CHECK_TYPE=$checktype \
DISABLE_VALGRIND_TESTS=$disable_valgrind_tests \
CHECK_POOL=$check_pool \
$special_params"
export RUNTEST_SCRIPT="$runscript"
Expand Down Expand Up @@ -369,6 +367,7 @@ testfile=all
testseq=all
check_pool=0
checktype="none"
disable_valgrind_tests=0
skip_dir=""
keep_going=n
keep_going_skip=n
Expand Down Expand Up @@ -456,15 +455,15 @@ do
case "$receivetype"
in
none)
forcechecktype=$receivetype
disable_valgrind_tests=1
;;
memcheck|pmemcheck|helgrind|drd)
checktype=$receivetype
;;
*)
usage "bad force-enable: $receivetype"
;;
esac
checktype=$receivetype
;;
-k)
skip_dir="$skip_dir $2"
Expand Down
18 changes: 12 additions & 6 deletions src/test/unittest/unittest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ fi
. ../testconfig.sh
. ../envconfig.sh

# Required for easy force-enable condition failure detection.
# Please see require_valgrind() for details.
CHECK_TYPE_COPY=$CHECK_TYPE

if [ -t 1 ]; then
IS_TERMINAL_STDOUT=YES
fi
Expand Down Expand Up @@ -1441,8 +1445,9 @@ function valgrind_version_no_check() {
# valgrind package is installed
#
function require_valgrind() {
if [ "$FORCE_CHECK_TYPE" == "none" ]; then
msg "$UNITTEST_NAME: SKIP valgrind test"
if [ "$DISABLE_VALGRIND_TESTS" == "1" ]; then
msg=$(interactive_yellow STDOUT "SKIP:")
echo -e "$UNITTEST_NAME: $msg all Valgrind tests are disabled"
exit 0
fi
# bc is used inside valgrind_version_no_check
Expand All @@ -1453,17 +1458,18 @@ function require_valgrind() {
local ret=$?
restore_exit_on_error
if [ $ret -ne 0 ]; then
# FORCE_CHECK_TYPE is basically a copy of CHECK_TYPE as it is provided by force-enable.
# CHECK_TYPE_COPY is a copy of CHECK_TYPE as it is provided by force-enable.
# This copy allowed us to workaround the overcomplicated legacy Valgrind processing logic
# and here just check whether any Valgrind tool has been force-enabled or not.
# Lack of Valgrind when it is force-enabled causes test failure.
# Lack of Valgrind, when it was just required by the given test, causes a skip.
if [ "$FORCE_CHECK_TYPE" != "none" ]; then
if [ "$CHECK_TYPE_COPY" != "none" ]; then
msg=$(interactive_red STDOUT "FAIL:")
echo -e "$UNITTEST_NAME: $msg valgrind not installed"
echo -e "$UNITTEST_NAME: $msg Valgrind not installed"
exit 1
else
msg "$UNITTEST_NAME: SKIP valgrind required"
msg=$(interactive_yellow STDOUT "SKIP:")
echo -e "$UNITTEST_NAME: $msg Valgrind required"
exit 0
fi
fi
Expand Down

0 comments on commit 61c2945

Please sign in to comment.