tests: New run_tests -C (cleanup) option
authorMartin Schwenke <martin@meltin.net>
Tue, 24 Apr 2012 04:39:24 +0000 (14:39 +1000)
committerMartin Schwenke <martin@meltin.net>
Fri, 27 Apr 2012 05:42:42 +0000 (15:42 +1000)
Sets TEST_CLEANUP=true and causes $TEST_VAR_DIR to be removed... and
potentially other cleanup actions in testcases.

Signed-off-by: Martin Schwenke <martin@meltin.net>
tests/scripts/run_tests

index ced884837dc6108ff6dcc362493023c5262e1a87..0ae4cee151546f8b32400448dd9c5337d4f9df23 100755 (executable)
@@ -9,6 +9,7 @@ Options:
   -l           Use local daemons for integration tests
   -e           Exit on the first test failure
   -V <dir>     Use <dir> as $TEST_VAR_DIR
+  -C           Clean up - kill daemons and remove $TEST_VAR_DIR when done
   -v           Verbose - print test output for non-failures (only some tests)
   -A           Use "cat -A" to print test output (only some tests)
   -D           Show diff between failed/expected test output (some tests only)
@@ -41,8 +42,9 @@ export TEST_CAT_RESULTS_OPTS=""
 export TEST_DIFF_RESULTS=false
 export TEST_LOCAL_DAEMONS  # No default, developer can "override"!
 export TEST_VAR_DIR=""
+export TEST_CLEANUP=false
 
-temp=$(getopt -n "$prog" -o "xdehlqsvV:XADH" -l help -- "$@")
+temp=$(getopt -n "$prog" -o "xdehlqsvV:XACDH" -l help -- "$@")
 
 [ $? != 0 ] && usage
 
@@ -60,6 +62,7 @@ while true ; do
        -V) TEST_VAR_DIR="$2" ; shift 2 ;;
        -X) TEST_COMMAND_TRACE=true ; shift ;;
        -A) TEST_CAT_RESULTS_OPTS="-A" ; shift ;;
+       -C) TEST_CLEANUP=true ; shift ;;
        -D) TEST_DIFF_RESULTS=true ; shift ;;
        -H) no_header=true ; shift ;;
        --) shift ; break ;;
@@ -207,6 +210,14 @@ fi
 
 rm -f "$sf"
 
+echo 
+if $TEST_CLEANUP ; then
+    echo "Removing TEST_VAR_DIR=$TEST_VAR_DIR"
+    rm -rf "$TEST_VAR_DIR"
+else
+    echo "Not cleaning up TEST_VAR_DIR=$TEST_VAR_DIR"
+fi
+
 if [ $tests_failed -gt 0 ] ; then
     if $no_header ; then
        exit $status