REGTEST: script: Add the option --clean to remove previous log direcotries

Running regtests several times leaves many direcotries. It is painful to remove
them by hand. This command do it for you. It ask a confirmation to proceed to be
sure. The template used to create log direcotries has been changed. The prefix
'haregtests-' has been added to help the cleanup function to find existing log
direcotries.
diff --git a/scripts/run-regtests.sh b/scripts/run-regtests.sh
index be53e97..43ba095 100755
--- a/scripts/run-regtests.sh
+++ b/scripts/run-regtests.sh
@@ -22,6 +22,9 @@
     --varnishtestparams <ARGS>, passes custom ARGS to varnishtest
       run-regtests.sh --varnishtestparams "-n 10"
 
+    --clean to cleanup previous reg-tests log directories and exit
+      run-regtests.sh --clean
+
   Including text below into a .vtc file will check for its requirements
   related to haproxy's target and compilation options
     # Below targets are not capable of completing this test succesfully
@@ -206,6 +209,34 @@
   done
 }
 
+_cleanup()
+{
+  DIRS=$(find "${TESTDIR}" -maxdepth 1 -type d -name "haregtests-*" -exec basename {} \; 2>/dev/null)
+  if [ -z "${DIRS}" ]; then
+    echo "No reg-tests log directory found"
+  else
+    echo "Cleanup following reg-tests log directories:"
+    for d in ${DIRS}; do
+      echo  "    o ${TESTDIR}/$d"
+    done
+    read -p "Continue (y/n)?" reply
+    case "$reply" in
+      y|Y)
+        for d in ${DIRS}; do
+          rm -r "${TESTDIR}/$d"
+        done
+        echo "done"
+        exit 0
+        ;;
+       *)
+        echo "aborted"
+        exit 1
+        ;;
+    esac
+  fi
+}
+
+
 _process() {
   while [ ${#} -gt 0 ]; do
     if _startswith "$1" "-"; then
@@ -225,6 +256,10 @@
           LEVEL="$2"
           shift
           ;;
+        --clean)
+          _cleanup
+          exit 0
+          ;;
         --help)
           _help
           ;;
@@ -247,6 +282,7 @@
 
 HAPROXY_PROGRAM="${HAPROXY_PROGRAM:-${PWD}/haproxy}"
 VARNISHTEST_PROGRAM="${VARNISHTEST_PROGRAM:-varnishtest}"
+TESTDIR="${TMPDIR:-/tmp}"
 REGTESTS=""
 
 jobcount=""
@@ -280,9 +316,8 @@
 
 TESTRUNDATETIME="$(date '+%Y-%m-%d_%H-%M-%S')"
 
-TESTDIR="${TMPDIR:-/tmp}"
 mkdir -p "$TESTDIR" || exit 1
-TESTDIR=$(mktemp -d "$TESTDIR/$TESTRUNDATETIME.XXXXXX") || exit 1
+TESTDIR=$(mktemp -d "$TESTDIR/haregtests-$TESTRUNDATETIME.XXXXXX") || exit 1
 
 export TMPDIR="$TESTDIR"
 export HAPROXY_PROGRAM="$HAPROXY_PROGRAM"