ssl-opt/run_test: Introduce -l option to list test case names

 * Add an option in ssl-opt test case to list all the run_test calls
   and their names. This allows to show the parameters used and can
   make us avoid having to parse ssl-opt to look for extra
   parameters in the future.

Signed-off-by: Tomás González <tomasagustin.gonzalezorlando@arm.com>
diff --git a/tests/ssl-opt.sh b/tests/ssl-opt.sh
index 0dd7fe6..b9380ba 100755
--- a/tests/ssl-opt.sh
+++ b/tests/ssl-opt.sh
@@ -123,6 +123,7 @@
 EXCLUDE='^$'
 
 SHOW_TEST_NUMBER=0
+LIST_TESTS=0
 RUN_TEST_NUMBER=''
 
 PRESERVE_LOGS=0
@@ -140,6 +141,7 @@
     printf "  -f|--filter\tOnly matching tests are executed (substring or BRE)\n"
     printf "  -e|--exclude\tMatching tests are excluded (substring or BRE)\n"
     printf "  -n|--number\tExecute only numbered test (comma-separated, e.g. '245,256')\n"
+    printf "  -l|--list-tests\tList test names and exit\n"
     printf "  -s|--show-numbers\tShow test numbers in front of test names\n"
     printf "  -p|--preserve-logs\tPreserve logs of successful tests as well\n"
     printf "     --outcome-file\tFile where test outcomes are written\n"
@@ -167,6 +169,9 @@
             -s|--show-numbers)
                 SHOW_TEST_NUMBER=1
                 ;;
+            -l|--list-tests)
+                LIST_TESTS=1
+                ;;
             -p|--preserve-logs)
                 PRESERVE_LOGS=1
                 ;;
@@ -862,9 +867,13 @@
 
     LINE="$LINE$1"
     printf "%s " "$LINE"
-    LEN=$(( 72 - `echo "$LINE" | wc -c` ))
-    for i in `seq 1 $LEN`; do printf '.'; done
-    printf ' '
+    if [ "$LIST_TESTS" -gt 0 ]; then
+        printf "\n"
+    else
+        LEN=$(( 72 - `echo "$LINE" | wc -c` ))
+        for i in `seq 1 $LEN`; do printf '.'; done
+        printf ' '
+    fi
 
 }
 
@@ -1580,6 +1589,10 @@
 
     print_name "$NAME"
 
+    if [ "$LIST_TESTS" -gt 0 ]; then
+        return
+    fi
+
     # Do we only run numbered tests?
     if [ -n "$RUN_TEST_NUMBER" ]; then
         case ",$RUN_TEST_NUMBER," in
@@ -13375,17 +13388,21 @@
 requires_max_content_len 16384
 run_tests_memory_after_hanshake
 
-# Final report
+if [ "$LIST_TESTS" -eq 0 ]; then
 
-echo "------------------------------------------------------------------------"
+    # Final report
 
-if [ $FAILS = 0 ]; then
-    printf "PASSED"
-else
-    printf "FAILED"
+    echo "------------------------------------------------------------------------"
+
+    if [ $FAILS = 0 ]; then
+        printf "PASSED"
+    else
+        printf "FAILED"
+    fi
+    PASSES=$(( $TESTS - $FAILS ))
+    echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
+
 fi
-PASSES=$(( $TESTS - $FAILS ))
-echo " ($PASSES / $TESTS tests ($SKIPS skipped))"
 
 if [ $FAILS -gt 255 ]; then
     # Clamp at 255 as caller gets exit code & 0xFF