diff --git a/gstreamer-buffering/automated/run-test.sh b/gstreamer-buffering/automated/run-test.sh index 361e40f1cc0ddc31e3d05728533dbf4c6ab2f5fc..4890972f65d8ab202511572ec965f2859e7c07fb 100755 --- a/gstreamer-buffering/automated/run-test.sh +++ b/gstreamer-buffering/automated/run-test.sh @@ -12,6 +12,9 @@ VIDEO_PLAYER="${VIDEO_PLAYER:-${TESTLIBDIR}/video-player}" # Running HTTP server used for network cgroup test HTTP_SERVER_PID="" +# Port number for local HTTP server +HTTP_SERVER_PORT="" + # List of processes to kill on exit PROC_KILL_LIST=() @@ -41,12 +44,18 @@ _setup_qdiscs() { } _setup_http_server() { - local port=$1 www_root=$2 + local www_root=$1 + TMPLOGFILE=`mktemp` cd "${www_root}" || setup_failure - /usr/lib/libsoup2.4/simple-httpd -p ${port} & + /usr/lib/libsoup2.4/simple-httpd > ${TMPLOGFILE} & # 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} } _wipe_qdiscs() { @@ -83,8 +92,8 @@ setup_success # Execute # ########### test_gstreamer_download_buffering() { - local ret server_pid port="9000" - local media_file="http://localhost:${port}/trailer_400p.ogg" + local ret server_pid + local media_file ## Setup ## _setup_qdiscs @@ -92,10 +101,8 @@ test_gstreamer_download_buffering() { echo "Test setup complete, beginning test..." ## Test ## - _setup_http_server ${port} "${TEST_MEDIA_DIR}" + _setup_http_server "${TEST_MEDIA_DIR}" ret=$? - # Wait for server to start up - _sleep 3 # Check it is running if ! kill -0 ${HTTP_SERVER_PID}; then @@ -108,6 +115,7 @@ test_gstreamer_download_buffering() { return $ret fi + media_file="http://localhost:${HTTP_SERVER_PORT}/trailer_400p.ogg" cd "${TESTLIBDIR}" ${VIDEO_PLAYER} "${media_file}" ret=$?