summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustin Clift <justin@gluster.org>2014-03-06 16:53:50 +0000
committerVijay Bellur <vbellur@redhat.com>2014-03-09 23:34:37 -0700
commitbed3fcd3a47d3ca35b3536e0cad2b293dd240ce4 (patch)
tree3211bb4c75f21a03cefd91a302ccd036e6b007b0
parentdec7950d4b0944697e4bb8788cc02de2ac4d8708 (diff)
tests: Add initial sanity checks to the GlusterFS Test Framework
BUG: 1073168 Change-Id: I0b995d94fe83053d3294df1b5fad2eef3b4355d3 Signed-off-by: Justin Clift <justin@gluster.org> Reviewed-on: http://review.gluster.org/7193 Reviewed-by: Niels de Vos <ndevos@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com>
-rwxr-xr-xrun-tests.sh103
1 files changed, 99 insertions, 4 deletions
diff --git a/run-tests.sh b/run-tests.sh
index 128404ed5e7..e9897706066 100755
--- a/run-tests.sh
+++ b/run-tests.sh
@@ -1,17 +1,98 @@
#!/bin/bash
-# Copyright (c) 2013 Red Hat, Inc. <http://www.redhat.com>
+# Copyright (c) 2013-2014 Red Hat, Inc. <http://www.redhat.com>
#
-function _init()
+function check_dependencies()
+{
+ ## Check all dependencies are present
+ MISSING=""
+
+ # Check for dbench
+ if [ ! -x /usr/bin/dbench ]; then
+ MISSING="$MISSING dbench"
+ fi
+
+ # Check for git
+ env git --version > /dev/null 2>&1
+ if [ $? -ne 0 ]; then
+ MISSING="$MISSING git"
+ fi
+
+ # Check for mock
+ if [ ! -e /usr/bin/mock ]; then
+ MISSING="$MISSING mock"
+ fi
+
+ # Check for nfs-utils
+ env mount.nfs -V > /dev/null 2>&1
+ if [ $? -ne 0 ]; then
+ MISSING="$MISSING nfs-utils"
+ fi
+
+ # Check for the Perl Test Harness
+ env prove --version > /dev/null 2>&1
+ if [ $? -ne 0 ]; then
+ MISSING="$MISSING perl-Test-Harness"
+ fi
+
+ # Check for XFS programs
+ env mkfs.xfs -V > /dev/null 2>&1
+ if [ $? -ne 0 ]; then
+ MISSING="$MISSING xfsprogs"
+ fi
+
+ # Check for attr
+ env getfattr --version > /dev/null 2>&1
+ if [ $? -ne 0 ]; then
+ MISSING="$MISSING attr"
+ fi
+
+ ## If dependencies are missing, warn the user and abort
+ if [ "x$MISSING" != "x" ]; then
+ echo "Aborting."
+ echo
+ echo "The following required tools are missing:"
+ echo
+ for pkg in $MISSING; do
+ echo " * $pkg"
+ done
+ echo
+ echo "Please install them and try again."
+ echo
+ exit 2
+ fi
+}
+
+function check_location()
{
regression_testsdir=$(dirname $0);
if [ ! -f ${regression_testsdir}/tests/include.rc ]; then
- echo "Seems like GlusterFS quality tests are corrupted..aborting!!"
+ echo "Aborting."
+ echo
+ echo "The tests/ subdirectory seems to be missing."
+ echo
+ echo "Please correct the problem and try again."
+ echo
exit 1
fi
}
+function check_user()
+{
+ # If we're not running as root, warn the user and abort
+ MYUID=`/usr/bin/id -u`
+ if [ 0${MYUID} -ne 0 ]; then
+ echo "Aborting."
+ echo
+ echo "The GlusterFS Test Framework must be run as root."
+ echo
+ echo "Please change to the root user and try again."
+ echo
+ exit 3
+ fi
+}
+
function main()
{
if [ $# -lt 1 ]; then
@@ -27,4 +108,18 @@ function main()
fi
}
-_init "$@" && main "$@"
+echo
+echo ... GlusterFS Test Framework ...
+echo
+
+# Make sure we're running as the root user
+check_user
+
+# Make sure the needed programs are available
+check_dependencies
+
+# Check we're running from the right location
+check_location
+
+# Run the tests
+main "$@"