Skip to content

Commit

Permalink
Merge pull request #5739 from grom72/bash-with-force-enable
Browse files Browse the repository at this point in the history
common: add support for --force-enable option in RUNTESTS.sh script
  • Loading branch information
janekmi committed Jun 26, 2023
2 parents 03e780b + d13f369 commit 54c43c6
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 55 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/pmem_long.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
fail-fast: false
matrix:
os: [[self-hosted, rhel],[self-hosted, opensuse]]
config: ['RUNTESTS -t long -b debug',
'RUNTESTS -t long -b nondebug',
'RUNTESTS -t long -b static-debug',
'RUNTESTS -t long -b static-nondebug',
config: ['RUNTESTS.sh -t long -b debug',
'RUNTESTS.sh -t long -b nondebug',
'RUNTESTS.sh -t long -b static-debug',
'RUNTESTS.sh -t long -b static-nondebug',
'RUNTESTS.py -t long -b debug',
'RUNTESTS.py -t long -b release',
'RUNTESTS.py -t long -b static_debug',
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pmem_valgrind_sh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
fail-fast: false
matrix:
config: ['-d', '-p', '-m', '-e']
config: ['drd', 'pmemcheck', 'memcheck', 'helgrind']
build: ['debug', 'nondebug', 'static-debug', 'static-nondebug']
os: [[self-hosted, rhel],[self-hosted, opensuse]]

Expand All @@ -38,4 +38,4 @@ jobs:
run: ./$WORKDIR/create-testconfig.sh

- name: Run tests
run: cd src/test/ && ./RUNTESTS -b ${{ matrix.build }} ${{ matrix.config }} force-enable
run: cd src/test/ && ./RUNTESTS.sh --force-enable ${{ matrix.config }} -b ${{ matrix.build }}
2 changes: 1 addition & 1 deletion src/test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ memcheck-summary-leaks:

check:
@[ -z "$(BLACKLIST_TESTS)" ] || echo "Blacklisted tests: $(BLACKLIST_TESTS)"
@./RUNTESTS $(RUNTEST_OPTIONS) $(LOCAL_TESTS)
@./RUNTESTS.sh $(RUNTEST_OPTIONS) $(LOCAL_TESTS)
$(MAKE)
@echo "No failures."

Expand Down
4 changes: 2 additions & 2 deletions src/test/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -629,10 +629,10 @@ $(TSTCHECKSPY):
@cd .. && ./RUNTESTS.py $(subst nondebug,release,$(RUNTEST_OPTIONS)) -u $(shell echo $@ | sed 's/^py\/[^0-9]*\([0-9]*\)$$/\1/') -- ${TST}

$(TSTCHECKS): sync-test
@cd .. && ./RUNTESTS ${TST} $(RUNTEST_OPTIONS) -s $@
@cd .. && ./RUNTESTS.sh ${TST} $(RUNTEST_OPTIONS) -s $@

check: sync-test
@cd .. && ./RUNTESTS ${TST} $(RUNTEST_OPTIONS)
@cd .. && ./RUNTESTS.sh ${TST} $(RUNTEST_OPTIONS)

pcheck: export NOTTY=1

Expand Down
27 changes: 14 additions & 13 deletions src/test/README
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ That file describes the local machine configuration (where to find persistent
memory, for example) and must be created by hand in each repo as it makes no
sense to check in that configuration description to the main repo.

testconfig.sh.example provides more detail. The script RUNTESTS, when run with
testconfig.sh.example provides more detail. The script RUNTESTS.sh, when run with
no arguments, will run all unit tests through all the combinations of fs-types
and build-types, running the "check" level test.

Expand All @@ -29,16 +29,16 @@ A testconfig.sh must exist to run these tests!
$ cp testconfig.sh.example testconfig.sh
$ ...edit testconfig.sh and modify as appropriate...

Tests may be run using the RUNTESTS script:
$ RUNTESTS (runs them all)
$ RUNTESTS testname (runs just the named test)
Tests may be run using the RUNTESTS.sh script:
$ RUNTESTS.sh (runs them all)
$ RUNTESTS.sh testname (runs just the named test)

Each test script (named something like "TEST0") is potentially run multiple
times with a different set of environment variables so run the test with
different target file systems or different versions of the libraries. To see
how RUNTESTS will run a test, use the -n option. For example:
how RUNTESTS.sh will run a test, use the -n option. For example:

$ RUNTESTS -n blk_nblock -s TEST0
$ RUNTESTS.sh -n blk_nblock -s TEST0
(in ./blk_nblock) TEST=check FS=none BUILD=debug ./TEST0
(in ./blk_nblock) TEST=check FS=none BUILD=nondebug ./TEST0
(in ./blk_nblock) TEST=check FS=none BUILD=static-debug ./TEST0
Expand All @@ -60,11 +60,12 @@ Notice how the TEST0 script is run repeatedly with different settings for
the three environment variables TEST, FS, and BUILD, providing the test type,
file system type, and build type to test.

RUNTESTS takes options to limit what it runs. The usage is:
RUNTESTS.sh takes options to limit what it runs. The usage is:

RUNTESTS [ -hnv ] [ -b build-type ] [ -t test-type ] [ -f fs-type ]
RUNTESTS.sh [ -hnv ] [ -b build-type ] [ -t test-type ] [ -f fs-type ]
[ -o timeout ] [ -s test-file ] [ -k skip-dir ]
[ -m memcheck ] [-p pmemcheck ] [ -e helgrind ] [ -d drd ] [ -c ]
[[ -m memcheck ] [-p pmemcheck ] [ -e helgrind ] [ -d drd ] ||
[ --force-enable memcheck|pmemcheck|helgrind|drd ]] [ -c ]
[tests...]

Build types are: debug, nondebug, static-debug, static-nondebug, all (default)
Expand All @@ -83,12 +84,12 @@ RUNTESTS takes options to limit what it runs. The usage is:

For example:

$ RUNTESTS -b debug blk_nblock -s TEST0
$ RUNTESTS.sh -b debug blk_nblock -s TEST0
blk_nblock/TEST0: SETUP (check/pmem/debug)
blk_nblock/TEST0: START: blk_nblock
blk_nblock/TEST0: PASS

Since the "-b debug" option was given, the RUNTESTS run above only executes
Since the "-b debug" option was given, the RUNTESTS.sh run above only executes
the test for the debug version of the library and skips the other variants.

Running the TEST* scripts directly is also common, especially when debugging
Expand All @@ -107,7 +108,7 @@ these defaults can be overridden on the command line:
$ TEST=check FS=any BUILD=nondebug ./TEST0

The above example runs TEST0 with the nondebug library, just as using
RUNTESTS with "-b nondebug" would from the parent directory.
RUNTESTS.sh with "-b nondebug" would from the parent directory.

In addition to overriding TEST, FS, and BUILD environment variables, the
unit test framework also looks for several other variables:
Expand Down Expand Up @@ -138,7 +139,7 @@ up and checking tests. Additionally, most unit tests build a local test
program and call it from the TEST* scripts.

In additional to TEST0, there can be as many TEST<num> scripts as desired, and
RUNTESTS will execute them in numeric order for each of the test runs it
RUNTESTS.sh will execute them in numeric order for each of the test runs it
executes.

There are two ways of setting test requirements:
Expand Down
74 changes: 46 additions & 28 deletions src/test/RUNTESTS → src/test/RUNTESTS.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2014-2022, Intel Corporation
# Copyright 2014-2023, Intel Corporation

#
# RUNTESTS -- setup the environment and run each test
# RUNTESTS.sh -- setup the environment and run each test
#

#
Expand All @@ -15,8 +15,9 @@ usage()
cat >&2 <<EOF
Usage: $0 [ -hnv ] [ -b build-type ] [ -t test-type ] [ -f fs-type ]
[ -o timeout ] [ -s test-file | -u test-sequence ] [-k skip-dir ]
[ -m memcheck ] [-p pmemcheck ] [ -e helgrind ] [ -d drd ] [ -c ]
[tests...]
[[ -m memcheck ] [-p pmemcheck ] [ -e helgrind ] [ -d drd ] ||
[ --force-enable memcheck|pmemcheck|helgrind|drd ]]
[ -c ] [tests...]
-h print this help message
-n dry run
-v be verbose
Expand Down Expand Up @@ -52,6 +53,10 @@ Usage: $0 [ -hnv ] [ -b build-type ] [ -t test-type ] [ -f fs-type ]
drd: auto (default, enable/disable based on test requirements),
force-enable (enable when test does not require drd, but
obey test's explicit drd disable)
--force-enable memcheck|pmemcheck|helgrind|drd
allows to force the use of a specific valgrind tool,
but skips tests where the tool is explicitly disabled
Can not be use with -m, -p, -e, -d.
-c check pool files with pmempool check utility
EOF
exit 1
Expand All @@ -75,13 +80,13 @@ runtest_local() {
elif [ "$use_timeout" -a "$testtype" = "check" ]
then
# set timeout for "check" tests
[ "$verbose" ] && echo "RUNTESTS: Running: (in ./$RUNTEST_DIR) \
[ "$verbose" ] && echo "RUNTESTS.sh: Running: (in ./$RUNTEST_DIR) \
$RUNTEST_PARAMS ./$RUNTEST_SCRIPT"
CMD_STR="$RUNTEST_EXTRA VERBOSE=$verbose $RUNTEST_PARAMS timeout \
--foreground $killopt $RUNTEST_TIMEOUT ./$RUNTEST_SCRIPT"
eval "$CMD_STR"
else
[ "$verbose" ] && echo "RUNTESTS: Running: (in ./$RUNTEST_DIR) $params ./$script"
[ "$verbose" ] && echo "RUNTESTS.sh: Running: (in ./$RUNTEST_DIR) $params ./$script"
CMD_STR="$RUNTEST_EXTRA VERBOSE=$verbose $RUNTEST_PARAMS ./$RUNTEST_SCRIPT"
eval "$CMD_STR"
fi
Expand All @@ -91,7 +96,7 @@ runtest_local() {
[ $retval = 124 -o $retval = 137 ] && errmsg='timed out'
[ $retval != 0 ] && {
[ -t 2 ] && command -v tput >/dev/null && errmsg="$(tput setaf 1)$errmsg$(tput sgr0)"
echo "RUNTESTS: stopping: $RUNTEST_DIR/$RUNTEST_SCRIPT $errmsg, $RUNTEST_PARAMS" >&2
echo "RUNTESTS.sh: stopping: $RUNTEST_DIR/$RUNTEST_SCRIPT $errmsg, $RUNTEST_PARAMS" >&2
if [ "$keep_going" == "y" ]; then
keep_going_exit_code=1
keep_going_skip=y
Expand Down Expand Up @@ -317,7 +322,7 @@ runtest() {

if [ "$KEEP_GOING" == "y" ] && [ "$CLEAN_FAILED" == "y" ]; then
# temporary file used for sharing data
# between RUNTESTS and tests processes
# between RUNTESTS.sh and tests processes
temp_loc=$(mktemp /tmp/data-location.XXXXXXXX)
export TEMP_LOC=$temp_loc
fi
Expand All @@ -336,7 +341,7 @@ runtest() {

[ -f testconfig.sh ] || {
cat >&2 <<EOF
RUNTESTS: stopping because no testconfig.sh is found.
RUNTESTS.sh: stopping because no testconfig.sh is found.
to create one:
cp testconfig.sh.example testconfig.sh
and edit testconfig.sh to describe the local machine configuration.
Expand Down Expand Up @@ -429,14 +434,31 @@ fi
#
# command-line argument processing...
#
args=`getopt k:nvb:t:f:o:s:u:m:e:p:d:cq:r:g:x: $*`
args=`getopt --unquoted --longoptions force-enable: k:nvb:t:f:o:s:u:m:e:p:d:cq:r:g:x: $*`
[ $? != 0 ] && usage
set -- $args
for arg
do
receivetype=auto
case "$arg"
in
--force-enable)
receivetype="$2"
shift 2
if [ "$checktype" != "none" ]; then
usage "cannot force-enable two test types at the same time"
fi

case "$receivetype"
in
memcheck|pmemcheck|helgrind|drd)
;;
*)
usage "bad force-enable: $receivetype"
;;
esac
checktype=$receivetype
;;
-k)
skip_dir="$skip_dir $2"
shift 2
Expand Down Expand Up @@ -497,12 +519,11 @@ do
auto)
;;
force-enable)
if [ "$checktype" != "none" ]
then
if [ "$checktype" != "none" ]; then
usage "cannot force-enable two test types at the same time"
else
checktype="memcheck"
fi

checktype="memcheck"
;;
*)
usage "bad memcheck: $receivetype"
Expand All @@ -517,12 +538,11 @@ do
auto)
;;
force-enable)
if [ "$checktype" != "none" ]
then
if [ "$checktype" != "none" ]; then
usage "cannot force-enable two test types at the same time"
else
checktype="pmemcheck"
fi

checktype="pmemcheck"
;;
*)
usage "bad pmemcheck: $receivetype"
Expand All @@ -537,12 +557,11 @@ do
auto)
;;
force-enable)
if [ "$checktype" != "none" ]
then
if [ "$checktype" != "none" ]; then
usage "cannot force-enable two test types at the same time"
else
checktype="helgrind"
fi

checktype="helgrind"
;;
*)
usage "bad helgrind: $receivetype"
Expand All @@ -557,12 +576,11 @@ do
auto)
;;
force-enable)
if [ "$checktype" != "none" ]
then
if [ "$checktype" != "none" ]; then
usage "cannot force-enable two test types at the same time"
else
checktype="drd"
fi

checktype="drd"
;;
*)
usage "bad drd: $receivetype"
Expand Down Expand Up @@ -659,7 +677,7 @@ fi
if [ "$1" ]; then
for test in $*
do
[ -d "$test" ] || echo "RUNTESTS: Test does not exist: $test"
[ -d "$test" ] || echo "RUNTESTS.sh: Test does not exist: $test"
[ -f "$test/TEST0" ] && runtest $test
done
else
Expand All @@ -668,7 +686,7 @@ else
do
testdir=`dirname $testfile0`
if [[ "$skip_dir" =~ "$testdir" ]]; then
echo "RUNTESTS: Skipping: $testdir"
echo "RUNTESTS.sh: Skipping: $testdir"
continue
fi
runtest $testdir
Expand Down
6 changes: 3 additions & 3 deletions src/test/unittest/unittest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1409,13 +1409,13 @@ function configure_valgrind() {
fi
else
if [ "$1" == "force-disable" ]; then
msg "$UNITTEST_NAME: SKIP RUNTESTS script parameter $CHECK_TYPE tries to enable valgrind test when all valgrind tests are disabled in TEST"
msg "$UNITTEST_NAME: SKIP RUNTESTS.sh script parameter $CHECK_TYPE tries to enable valgrind test when all valgrind tests are disabled in TEST"
exit 0
elif [ "$CHECK_TYPE" != "$1" -a "$2" == "force-enable" ]; then
msg "$UNITTEST_NAME: SKIP RUNTESTS script parameter $CHECK_TYPE tries to enable different valgrind test than one defined in TEST"
msg "$UNITTEST_NAME: SKIP RUNTESTS.sh script parameter $CHECK_TYPE tries to enable different valgrind test than one defined in TEST"
exit 0
elif [ "$CHECK_TYPE" == "$1" -a "$2" == "force-disable" ]; then
msg "$UNITTEST_NAME: SKIP RUNTESTS script parameter $CHECK_TYPE tries to enable test defined in TEST as force-disable"
msg "$UNITTEST_NAME: SKIP RUNTESTS.sh script parameter $CHECK_TYPE tries to enable test defined in TEST as force-disable"
exit 0
fi
require_valgrind_tool $CHECK_TYPE $3
Expand Down
2 changes: 1 addition & 1 deletion utils/check_whitespace
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ sub check_whitespace_with_exc {

$_ = basename($full);

return 0 unless /^(README.*|LICENSE.*|Makefile.*|CMakeLists.txt|.gitignore|TEST.*|RUNTESTS|check_whitespace|.*\.([chp13s]|sh|map|cpp|hpp|inc|py|md|cmake))$/;
return 0 unless /^(README.*|LICENSE.*|Makefile.*|CMakeLists.txt|.gitignore|TEST.*|RUNTESTS.sh|check_whitespace|.*\.([chp13s]|sh|map|cpp|hpp|inc|py|md|cmake))$/;
return 0 if -z;

check_whitespace($full, $_);
Expand Down
2 changes: 1 addition & 1 deletion utils/docker/run-build-package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ make -j$(nproc)
# Prepare test config once more. Now, with path to PMDK set in the OS
# (rather than in the git tree) - for testing packages installed in the system.
$SCRIPTSDIR/configure-tests.sh PKG
./RUNTESTS -t check
./RUNTESTS.sh -t check
popd

popd

0 comments on commit 54c43c6

Please sign in to comment.