diff options
author | Arun Raghavan <arun.raghavan@collabora.co.uk> | 2010-07-14 10:46:12 +0530 |
---|---|---|
committer | Arun Raghavan <arun.raghavan@collabora.co.uk> | 2010-08-14 03:33:05 +0530 |
commit | d752a319859f3ea47af84c0d39b66bf88943bb6e (patch) | |
tree | b0a1d1b8dc3cac8886b3973169ab14a69e1faad5 /tests | |
parent | 4bf5dec94585bec1abdd0ae9cd198cd36c7d41c1 (diff) | |
download | gupnp-dlna-d752a319859f3ea47af84c0d39b66bf88943bb6e.tar.gz |
tests: Add a test harness for testing discoverer
The harness expects a tests/media directory with a file list in the
format described in a comment at the top of the harness. The means to
set up the media directory will come in a subsequent commit.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 3 | ||||
-rw-r--r-- | tests/test-discoverer.sh.in | 67 |
2 files changed, 70 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 064e2d7..5ff7b99 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -5,3 +5,6 @@ AM_LDFLAGS = $(top_builddir)/libgupnp-dlna/libgupnp-dlna-1.0.la $(top_builddir)/ dlna_profile_parser_SOURCES = dlna-profile-parser.c dlna_encoding_SOURCES = dlna-encoding.c + +TESTS_ENVIRONMENT = MEDIA_DIR="$(srcdir)/media" FILE_LIST="$(srcdir)/media/media-list.txt" ${SHELL} +TESTS = test-discoverer.sh diff --git a/tests/test-discoverer.sh.in b/tests/test-discoverer.sh.in new file mode 100644 index 0000000..9269722 --- /dev/null +++ b/tests/test-discoverer.sh.in @@ -0,0 +1,67 @@ +#!/bin/bash + +# +# Tests GUPnPDLNADiscoverer by running tools/gupnp-dlna-info on the given list +# of media and comparing that against expected DLNA profile name and MIME type. +# +# Usage: +# test-discoverer.sh <file_list> <media_dir> <extra_args ...> +# +# <file_list> is a CSV file in the format: +# path_name,profile_name,mime_type +# +# Path names in the list are relative to <media_dir> +# +# <extra_args> are passed on to gupnp-dlna-info +# +# The first two parameters can be passed as the FILE_LIST and MEDIA_DIR +# environment variable as well (but you must either pass both as env vars or +# both on the command line). +# + +GUPNP_DLNA_INFO=@abs_top_builddir@/tools/gupnp-dlna-info + +# See if params are available in the environment - if yes, carry on, else read +# them from the command line +if [[ "x${FILE_LIST}" = "x" || "x${MEDIA_DIR}" = "x" ]]; then + if [[ ${#} -lt 2 ]]; then + echo "Usage:" + echo " ${0} <file_list> <media_dir> <extra_args ...>" + exit -1 + fi + + FILE_LIST=${1} + shift + MEDIA_DIR=${1} + shift +fi + +ret=0 + +while read line; do + if [[ "${line:0:1}" = "#" ]]; then + # commented line + continue + fi + + # Parse the input line + path=$(echo ${line} | cut -f 1 -d ',') + profile=$(echo ${line} | cut -f 2 -d ',') + mime=$(echo ${line} | cut -f 3 -d ',') + + # Run discoverer to get profile name/mime + out=$(${GUPNP_DLNA_INFO} -a ${@} ${MEDIA_DIR}/${path}) + out_profile=$(echo ${out} | grep 'Name' | tr -s ' ' | awk '{ print $5 }') + out_mime=$(echo ${out} | grep 'Name' | tr -s ' ' | awk '{ print $8 }') + + # Now compare the two + echo -n " Testing ${path} ... " + if [[ "x${profile}" != "x${out_profile}" || "x${mime}" != "x${out_mime}" ]]; then + ret=1 + echo "FAIL: ${path},${out_profile},${out_mime}" + else + echo "PASS" + fi +done <${FILE_LIST} + +exit ${ret} |