4 # Tests GUPnPDLNADiscoverer by running tools/gupnp-dlna-info on the given list
5 # of media and comparing that against expected DLNA profile name and MIME type.
8 # test-discoverer.sh <file_list> <media_dir> <extra_args ...>
10 # <file_list> is a CSV file in the format:
11 # path_name,profile_name,mime_type
13 # Path names in the list are relative to <media_dir>
15 # <extra_args> are passed on to gupnp-dlna-info
17 # The first two parameters can be passed as the FILE_LIST and MEDIA_DIR
18 # environment variable as well (but you must either pass both as env vars or
19 # both on the command line).
22 # This test is trialled when executing 'make check'. In that case the
23 # $MEDIA_DIR is ./tests/media (where . is gupnp-dlna's source code
25 # You can get the default test media collection using the following command:
26 # git clone git://git.collabora.co.uk/git/user/arun/gupnp-dlna-media.git tests/media
28 if [[ "x${GUPNP_DLNA_INFO}" = "x" ]]; then
29 GUPNP_DLNA_INFO=@abs_top_builddir@/tools/gupnp-dlna-info
32 # See if params are available in the environment - if yes, carry on, else read
33 # them from the command line
34 if [[ "x${FILE_LIST}" = "x" || "x${MEDIA_DIR}" = "x" ]]; then
35 if [[ ${#} -lt 2 ]]; then
37 echo " ${0} <file_list> <media_dir> <extra_args ...>"
47 if [[ ! -e "${MEDIA_DIR}" ]]; then
49 echo "WARNING: the specified media directory (${MEDIA_DIR}) was not found. Skipping discoverer tests."
57 if [[ "${line:0:1}" = "#" ]]; then
62 # Parse the input line
63 path=$(echo ${line} | cut -f 1 -d ',')
64 profile=$(echo ${line} | cut -f 2 -d ',')
65 mime=$(echo ${line} | cut -f 3 -d ',')
67 # Run discoverer to get profile name/mime
68 out=$(${GUPNP_DLNA_INFO} -a ${@} ${MEDIA_DIR}/${path})
69 out_profile=$(echo ${out} | grep 'Name' | tr -s ' ' | awk '{ print $5 }')
70 out_mime=$(echo ${out} | grep 'Name' | tr -s ' ' | awk '{ print $8 }')
73 echo -n " Testing ${path} ... "
74 if [[ "x${profile}" != "x${out_profile}" || "x${mime}" != "x${out_mime}" ]]; then
76 echo -e "\e[01;31mFAIL: ${path},${out_profile},${out_mime}\e[0m"