blob: 0e69aeebaa502890ad4bebcc0264be1bcce9e90b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
#!/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).
#
# This test is trialled when executing 'make check'. In that case the
# $MEDIA_DIR is ./tests/media (where . is gupnp-dlna's source code
# directory).
# You can get the default test media collection using the following command:
# git clone git://git.gnome.org/gupnp-dlna-media tests/media
if [[ "x${GUPNP_DLNA_INFO}" = "x" ]]; then
GUPNP_DLNA_INFO=@abs_top_builddir@/tools/gupnp-dlna-info-2.0
fi
# 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
if [[ ! -e "${MEDIA_DIR}" ]]; then
echo "***"
echo "WARNING: the specified media directory (${MEDIA_DIR}) was not found. Skipping discoverer tests."
echo "***"
exit 77
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 ',')
xfail=$(echo ${line} | cut -f 4 -d ',')
bug=$(echo ${line} | cut -f 5 -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
if [[ "x${xfail}" != "x" ]]; then
echo "XFAIL: ${bug}"
else
ret=1
echo -e "\e[01;31mFAIL: ${path},${out_profile},${out_mime}\e[0m"
fi
else
echo "PASS"
fi
done <${FILE_LIST}
exit ${ret}
|