diff options
-rwxr-xr-x | run-tests.sh | 79 | ||||
-rw-r--r-- | tests/README.md | 10 |
2 files changed, 83 insertions, 6 deletions
diff --git a/run-tests.sh b/run-tests.sh index 39aeab3b624..14512648c03 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -99,18 +99,85 @@ function check_user() fi } +function run_tests() +{ + declare -A DONE + match() + { + # Patterns considered valid: + # 1. full or partial file/directory names + # basic matches tests/basic + # basic/afr matches tests/basic/afr + # 2. globs + # basic/* matches all files and directories in basic + # basic/*/ matches subdirectories in basic (afr|ec) + # 3. numbered bug matching + # 884455 matches bugs/bug-884455.t + # 859927 matches bugs/859927, bugs/bug-859927.t + # 1015990 matches /bugs/bug-1015990-rep.t, bug-1015990.t + # ...lots of other cases accepted as well, since globbing is tricky. + local t=$1 + local mt=$1 + shift + local a + local match=1 + if [ -d $t ] ; then + # Allow matching on globs like 'basic/*/' + mt=$t/ + fi + for a in "$@" ; do + case "$mt" in + *$a|*/bugs/$a/|*/bugs/$a.t|*/bugs/bug-$a.t|*/bugs/bug-$a-*.t) + match=0 + ;; + esac + done + if [ "${DONE[$(dirname $t)]}" != "" ] ; then + # Parentdir is already matched + match=1 + if [ -d $t ] ; then + # Ignore subdirectory as well + DONE[$t]=$t + fi + elif [ $match -eq 0 -a -d $t ] ; then + # Make sure children of this matched directory will be ignored + DONE[$t]=$t + elif [[ -f $t && ! $t =~ .*\.t ]] ; then + # Ignore files not ending in .t + match=1 + fi + return $match + } + RES=0 + for t in $(find ${regression_testsdir}/tests | LC_COLLATE=C sort) ; do + if match $t "$@" ; then + if [ -d $t ] ; then + echo "Running tests in directory $t" + prove -rf --timer $t + elif [ -f $t ] ; then + echo "Running tests in file $t" + prove -f --timer $t + fi + TMP_RES=$? + if [ ${TMP_RES} -ne 0 ] ; then + RES=${TMP_RES} + FAILED="$FAILED $t" + fi + fi + done + if [ ${RES} -ne 0 ] ; then + echo "Failed tests ${FAILED}" + fi + return ${RES} +} + function main() { if [ $# -lt 1 ]; then echo "Running all the regression test cases" prove -rf --timer ${regression_testsdir}/tests; else - ## TODO - echo "Running single regression test.." - echo "WARNING: yet to be implemented.. exiting safely" - exit 0 - #export DEBUG=1; - #echo "Automatically setting up DEBUG=1 for this test $1"; + run_tests "$@" fi } diff --git a/tests/README.md b/tests/README.md index 3a1406f6ff1..84138fffb45 100644 --- a/tests/README.md +++ b/tests/README.md @@ -20,6 +20,16 @@ Regression tests framework for GlusterFS ## Usage - Execute `/usr/share/glusterfs/run-tests.sh` as root. +- If you want to run individual tests located in `/usr/share/glusterfs/tests` + as opposed to the full test-suite, invoke it as + `/usr/share/glusterfs/run-tests.sh [pattern]*`, where pattern can be: + - the trailing parts of the full path of a test, + e.g. `tests/basic/mount.t` + - the name of a file or directory, e.g `self-heal.t` or `basic/` + - bug number, which will match against numbered bugs in the + `tests/bugs/` directory. + - a glob pattern (see `man 7 glob` for mor info on globs) + - If some test cases fail, report to GlusterFS community at `gluster-devel@gluster.org`. |