summaryrefslogtreecommitdiffstats
path: root/run-tests.sh
diff options
context:
space:
mode:
authorRaghavendra Talur <rtalur@redhat.com>2016-02-01 12:29:40 +0530
committerRaghavendra Talur <rtalur@redhat.com>2016-02-03 02:38:38 -0800
commitd9e5977b08259580deccad2e0eed3a106094820a (patch)
treec800f96f22058b09f08a135a2bd7e0ba6e64b360 /run-tests.sh
parent29bd2316b6d4f522e1bd00e3c9a1c97dcc7d80ea (diff)
tests: refactor option parsing into a function
Creating a separate function to parse options. This is required for subsequent patches where we add more options to run-tests.sh. Created a variable tests to hold the tests list or pattern as passing around $@ is not informative. Change-Id: I032639c07419f5136c604531c5719c13ac4f9fe3 BUG: 1251592 Signed-off-by: Raghavendra Talur <rtalur@redhat.com> Reviewed-on: http://review.gluster.org/13328 CentOS-regression: Gluster Build System <jenkins@build.gluster.com> Smoke: Gluster Build System <jenkins@build.gluster.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Rajesh Joseph <rjoseph@redhat.com> Reviewed-by: Ravishankar N <ravishankar@redhat.com>
Diffstat (limited to 'run-tests.sh')
-rwxr-xr-xrun-tests.sh45
1 files changed, 27 insertions, 18 deletions
diff --git a/run-tests.sh b/run-tests.sh
index f9000a1d918..aaaa1faa63d 100755
--- a/run-tests.sh
+++ b/run-tests.sh
@@ -3,6 +3,10 @@
#
export TZ=UTC
+force="no"
+retry="no"
+tests=""
+
function check_dependencies()
{
## Check all dependencies are present
@@ -165,7 +169,7 @@ function run_tests()
}
RES=0
for t in $(find ${regression_testsdir}/tests | LC_COLLATE=C sort) ; do
- if match $t "$@" ; then
+ if match $t "$tests" ; then
if [ -d $t ] ; then
echo "Running tests in directory $t"
prove -rf --timer $t
@@ -257,19 +261,19 @@ function run_all ()
function main()
{
- if [ $# -lt 1 ]; then
+ if [ "x$tests" = "x" ]; then
echo "Running all the regression test cases (new way)"
#prove -rf --timer ${regression_testsdir}/tests;
run_all
else
- run_tests "$@"
+ run_tests "$tests"
fi
}
function main_and_retry()
{
RESFILE=`mktemp /tmp/${0##*/}.XXXXXX` || exit 1
- main "$@" | tee ${RESFILE}
+ main "$tests" | tee ${RESFILE}
RET=$?
FAILED=$( awk '/Failed: /{print $1}' ${RESFILE} )
@@ -289,22 +293,27 @@ function main_and_retry()
return ${RET}
}
+function parse_args () {
+ args=`getopt fr $*`
+ set -- $args
+ while [ $# -gt 0 ]; do
+ case "$1" in
+ -f) force="yes" ;;
+ -r) retry="yes" ;;
+ --) shift; break;;
+ esac
+ shift
+ done
+ tests="$@"
+}
+
+
echo
echo ... GlusterFS Test Framework ...
echo
-force="no"
-retry="no"
-args=`getopt fr $*`
-set -- $args
-while [ $# -gt 0 ]; do
- case "$1" in
- -f) force="yes" ;;
- -r) retry="yes" ;;
- --) shift; break;;
- esac
- shift
-done
+# Get user options
+parse_args $@
# Make sure we're running as the root user
check_user
@@ -317,7 +326,7 @@ check_location
# Run the tests
if [ "x${retry}" = "xyes" ] ; then
- main_and_retry $@
+ main_and_retry "$tests"
else
- main "$@"
+ main "$tests"
fi