summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnders Blomdell <anders.blomdell@control.lth.se>2014-07-10 20:17:25 +0200
committerVijay Bellur <vbellur@redhat.com>2014-07-15 22:59:44 -0700
commitde359f8b2aa1be9127b6d27a6283c202d089cd81 (patch)
tree5d0c536fed59aaa8fe1eba23e47f5f0e90ab1bc8
parentfde2b73746e73ea16ba246b8261b552ed2d894dd (diff)
Add possibility to run single tests
Change-Id: I9282b711c09611bd0fd4cc814f3ec34aa67d10c0 BUG: 1118453 Signed-off-by: Anders Blomdell <anders.blomdell@control.lth.se> Reviewed-on: http://review.gluster.org/8291 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Harshavardhana <harsha@harshavardhana.net> Reviewed-by: Humble Devassy Chirammal <humble.devassy@gmail.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
-rwxr-xr-xrun-tests.sh79
-rw-r--r--tests/README.md10
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`.