From d7e88ecac1c2451aef92c3b5cdf1893a8fb14796 Mon Sep 17 00:00:00 2001
From: Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Date: Tue, 20 Sep 2016 19:33:08 +0200
Subject: [PATCH] gstreamer-buffering: display simple-httpd logs if test is
 failing

Hopefully this should help debugging T2504 by telling us what's going on
in the http server.

Need to run the test with DEBUG=2 to have these extra debug info.

Signed-off-by: Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Reviewed-by: Justin Kim <justin.kim@collabora.com>
Differential Revision: https://phabricator.apertis.org/D4354
---
 gstreamer-buffering/automated/run-test.sh | 24 +++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/gstreamer-buffering/automated/run-test.sh b/gstreamer-buffering/automated/run-test.sh
index 4890972f..e6ee1d77 100755
--- a/gstreamer-buffering/automated/run-test.sh
+++ b/gstreamer-buffering/automated/run-test.sh
@@ -46,16 +46,14 @@ _setup_qdiscs() {
 _setup_http_server() {
     local www_root=$1
 
-    TMPLOGFILE=`mktemp`
+    HTTPD_LOG_FILE=`mktemp`
+    echo "simple-httpd log file:" $HTTPD_LOG_FILE
     cd "${www_root}" || setup_failure
-    /usr/lib/libsoup2.4/simple-httpd > ${TMPLOGFILE} &
+    /usr/lib/libsoup2.4/simple-httpd > ${HTTPD_LOG_FILE} &
     # Running HTTP servers used for network cgroup test
     HTTP_SERVER_PID=$!
 
-    HTTP_SERVER_PORT=$(grep -m1 "Listening" <( tail -f ${TMPLOGFILE} --pid ${HTTP_SERVER_PID}) | cut -d ':' -f 3 | sed "s/\///g")
-
-    # Remove a temporary file
-    rm -f ${TMPLOGFILE}
+    HTTP_SERVER_PORT=$(grep -m1 "Listening" <( tail -f ${HTTPD_LOG_FILE} --pid ${HTTP_SERVER_PID}) | cut -d ':' -f 3 | sed "s/\///g")
 }
 
 _wipe_qdiscs() {
@@ -64,6 +62,9 @@ _wipe_qdiscs() {
 
 _cleanup() {
     kill -9 ${HTTP_SERVER_PID}
+    if [ -n "$HTTPD_LOG_FILE" ]; then
+        rm $HTTPD_LOG_FILE
+    fi
     _wipe_qdiscs
 }
 
@@ -88,6 +89,15 @@ fi
 
 setup_success
 
+# used the display the simple-httpd logs if the test failed to help debugging
+display_httpd_log_file() {
+    if [ -n "$HTTPD_LOG_FILE" ]; then
+        echo "------------- simple-httpd logs -------------"
+        cat $HTTPD_LOG_FILE
+        echo "---------------------------------------------"
+    fi
+}
+
 ###########
 # Execute #
 ###########
@@ -111,6 +121,7 @@ test_gstreamer_download_buffering() {
 
     if [[ $ret -gt 0 ]]; then
         echo "Unable to start the http server properly!"
+        display_httpd_log_file
         _cleanup
         return $ret
     fi
@@ -121,6 +132,7 @@ test_gstreamer_download_buffering() {
     ret=$?
 
     if [[ $ret -gt 0 ]]; then
+        display_httpd_log_file
         echo "Test failed!"
     else
         echo "Test passed!"
-- 
GitLab