ctdb-tests: Add functions for terminating tests on failure, skip, error
authorMartin Schwenke <martin@meltin.net>
Tue, 17 Sep 2019 06:00:13 +0000 (16:00 +1000)
committerAmitay Isaacs <amitay@samba.org>
Fri, 4 Oct 2019 09:41:27 +0000 (09:41 +0000)
This allows standard exit codes for failed and skipped tests, and test
errors.

Skipped tests currently just succeed and a test error is the same as a
failure.  These can be easily changed later when run_tests.sh is ready
to handle them.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/tests/scripts/common.sh

index de117e90caa6de96dcf72cd2034d71646afc72ae..1165fcadb47a657f76b7b8f8d24912294e7292f9 100644 (file)
@@ -23,6 +23,30 @@ if [ -d "$CTDB_SCRIPTS_TESTS_LIBEXEC_DIR" ] ; then
        PATH="${CTDB_SCRIPTS_TESTS_LIBEXEC_DIR}:${PATH}"
 fi
 
+ctdb_test_error ()
+{
+       if [ $# -gt 0 ] ; then
+               echo "$*"
+       fi
+       exit 1
+}
+
+ctdb_test_fail ()
+{
+       if [ $# -gt 0 ] ; then
+               echo "$*"
+       fi
+       exit 1
+}
+
+ctdb_test_skip ()
+{
+       if [ $# -gt 0 ] ; then
+               echo "$*"
+       fi
+       exit 0
+}
+
 # Wait until either timeout expires or command succeeds.  The command
 # will be tried once per second, unless timeout has format T/I, where
 # I is the recheck interval.