Skip to content
Snippets Groups Projects
Commit 59f1b395 authored by Justin Kim's avatar Justin Kim
Browse files

gstreamer-buffering: Pick up a running port by simple-httpd


Even if the port is already in use, simple-httpd doesn't report and
just show a message "Waiting for requests...". It's a simple bug of
example of libsoup2.4.
Fortunately, without a specific port, simple-httpd will pick up
a port which is available. Then, we can parse its stdout to parse
running port.

Signed-off-by: default avatarJustin Kim <justin.kim@collabora.com>
Reviewed-by: default avatarMathieu Duponchelle <mathieu.duponchelle@collabora.co.uk>
Differential Revision: https://phabricator.apertis.org/D4080
parent e5a9bd57
No related branches found
No related tags found
No related merge requests found
...@@ -12,6 +12,9 @@ VIDEO_PLAYER="${VIDEO_PLAYER:-${TESTLIBDIR}/video-player}" ...@@ -12,6 +12,9 @@ VIDEO_PLAYER="${VIDEO_PLAYER:-${TESTLIBDIR}/video-player}"
# Running HTTP server used for network cgroup test # Running HTTP server used for network cgroup test
HTTP_SERVER_PID="" HTTP_SERVER_PID=""
# Port number for local HTTP server
HTTP_SERVER_PORT=""
# List of processes to kill on exit # List of processes to kill on exit
PROC_KILL_LIST=() PROC_KILL_LIST=()
...@@ -41,12 +44,18 @@ _setup_qdiscs() { ...@@ -41,12 +44,18 @@ _setup_qdiscs() {
} }
_setup_http_server() { _setup_http_server() {
local port=$1 www_root=$2 local www_root=$1
TMPLOGFILE=`mktemp`
cd "${www_root}" || setup_failure 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 # Running HTTP servers used for network cgroup test
HTTP_SERVER_PID=$! 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() { _wipe_qdiscs() {
...@@ -83,8 +92,8 @@ setup_success ...@@ -83,8 +92,8 @@ setup_success
# Execute # # Execute #
########### ###########
test_gstreamer_download_buffering() { test_gstreamer_download_buffering() {
local ret server_pid port="9000" local ret server_pid
local media_file="http://localhost:${port}/trailer_400p.ogg" local media_file
## Setup ## ## Setup ##
_setup_qdiscs _setup_qdiscs
...@@ -92,10 +101,8 @@ test_gstreamer_download_buffering() { ...@@ -92,10 +101,8 @@ test_gstreamer_download_buffering() {
echo "Test setup complete, beginning test..." echo "Test setup complete, beginning test..."
## Test ## ## Test ##
_setup_http_server ${port} "${TEST_MEDIA_DIR}" _setup_http_server "${TEST_MEDIA_DIR}"
ret=$? ret=$?
# Wait for server to start up
_sleep 3
# Check it is running # Check it is running
if ! kill -0 ${HTTP_SERVER_PID}; then if ! kill -0 ${HTTP_SERVER_PID}; then
...@@ -108,6 +115,7 @@ test_gstreamer_download_buffering() { ...@@ -108,6 +115,7 @@ test_gstreamer_download_buffering() {
return $ret return $ret
fi fi
media_file="http://localhost:${HTTP_SERVER_PORT}/trailer_400p.ogg"
cd "${TESTLIBDIR}" cd "${TESTLIBDIR}"
${VIDEO_PLAYER} "${media_file}" ${VIDEO_PLAYER} "${media_file}"
ret=$? ret=$?
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment