]>
git.ipfire.org Git - thirdparty/cups.git/blob - everywhere/bonjour-tests.sh
3 # "$Id: bonjour-tests.sh 13138 2016-03-15 14:59:54Z msweet $"
5 # IPP Everywhere Printer Self-Certification Manual 1.0: Section 5: Bonjour Tests.
7 # Copyright 2014-2015 by The Printer Working Group.
9 # This program may be copied and furnished to others, and derivative works
10 # that comment on, or otherwise explain it or assist in its implementation may
11 # be prepared, copied, published and distributed, in whole or in part, without
12 # restriction of any kind, provided that the above copyright notice and this
13 # paragraph are included on all such copies and derivative works.
15 # The IEEE-ISTO and the Printer Working Group DISCLAIM ANY AND ALL WARRANTIES,
16 # WHETHER EXPRESS OR IMPLIED INCLUDING (WITHOUT LIMITATION) ANY IMPLIED
17 # WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
21 # ./bonjour-tests.sh "Printer Name"
24 if test -x ..
/test
/ippfind-static
; then
25 IPPFIND
="../test/ippfind-static"
26 elif test -x .
/ippfind
; then
32 if test -x ..
/test
/ipptool-static
; then
33 IPPTOOL
="../test/ipptool-static"
34 elif test -x .
/ipptool
; then
40 PLIST
="$1 Bonjour Results.plist"
43 # Figure out the proper echo options...
46 if (echo "testing\c"; echo 1,2,3) |
grep c
>/dev
/null
; then
54 # Special case "_failN" name to show bad/missing TXT keys
55 if test "$2" = _fail2
-o "$2" = _fail4
-o "$2" = _fail5.3
-o "$2" = _fail5.5
; then
57 echo "<key>Errors</key><array>" >>"$PLIST"
58 if test "${IPPFIND_TXT_ADMINURL:-NOTSET}" = NOTSET
; then
59 echo " adminurl is not set."
60 echo "<string>adminurl is not set.</string>" >>"$PLIST"
61 elif test "$2" = _fail4
-o "$2" = _fail5.5
; then
62 case "$IPPFIND_TXT_ADMINURL" in
66 echo " adminurl has bad value '$IPPFIND_TXT_ADMINURL'."
67 echo "<string>adminurl has bad value '$IPPFIND_TXT_ADMINURL'.</string>" >>"$PLIST"
72 if test "${IPPFIND_TXT_PDL:-NOTSET}" = NOTSET
; then
73 echo " pdl is not set."
74 echo "<string>pdl is not set.</string>" >>"$PLIST"
75 elif test "$2" = _fail4
-o "$2" = _fail5.5
; then
76 case "$IPPFIND_TXT_PDL" in
80 echo " pdl is missing image/jpeg: '$IPPFIND_TXT_PDL'"
81 echo "<string>pdl is missing image/jpeg: '$IPPFIND_TXT_PDL'.</string>" >>"$PLIST"
85 case "$IPPFIND_TXT_PDL" in
89 echo " pdl is missing image/pwg-raster: '$IPPFIND_TXT_PDL'"
90 echo "<string>pdl is missing image/pwg-raster: '$IPPFIND_TXT_PDL'.</string>" >>"$PLIST"
95 if test "${IPPFIND_TXT_RP:-NOTSET}" = NOTSET
; then
96 echo " rp is not set."
97 echo "<string>rp is not set.</string>" >>"$PLIST"
98 elif test "$2" = _fail4
-o "$2" = _fail5.5
; then
99 case "$IPPFIND_TXT_RP" in
100 ipp
/print | ipp
/print
/*)
103 echo " rp has bad value '$IPPFIND_TXT_RP'"
104 echo "<string>rp has bad value '$IPPFIND_TXT_RP'.</string>" >>"$PLIST"
109 if test "${IPPFIND_TXT_UUID:-NOTSET}" = NOTSET
; then
110 echo " UUID is not set."
111 echo "<string>UUID is not set.</string>" >>"$PLIST"
112 elif test "$2" = _fail4
-o "$2" = _fail5.5
; then
113 case "$IPPFIND_TXT_UUID" in
114 [0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]-[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]-[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]-[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]-[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])
117 echo " UUID has bad value '$IPPFIND_TXT_UUID'"
118 echo "<string>UUID has bad value '$IPPFIND_TXT_UUID'.</string>" >>"$PLIST"
123 if test "$2" = _fail4
-o "$2" = _fail5.5
; then
124 $IPPTOOL -t $IPPFIND_SERVICE_URI bonjour-value-tests.
test
125 $IPPTOOL -t $IPPFIND_SERVICE_URI bonjour-value-tests.
test |
egrep '(GOT|EXPECTED):' |
sed -e '1,$s/^[ ]*//' |
awk '{print "<string>" $0 "</string>" }' >>"$PLIST"
128 echo "</array>" >>"$PLIST"
129 echo "<key>Successful</key><false />" >>"$PLIST"
130 echo "</dict>" >>"$PLIST"
136 # Write the standard XML plist header...
138 <?xml version="1.0" encoding="UTF-8"?>
139 <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
140 <plist version="1.0">
142 <key>Tests</key><array>
152 total
=`expr $total + 1`
153 echo $ac_n "$1: $ac_c"
154 echo "<dict><key>Name</key><string>$1</string>" >>"$PLIST"
155 echo "<key>FileId</key><string>org.pwg.ipp-everywhere.20151009.bonjour</string>" >>"$PLIST"
157 # end_test PASS/FAIL/SKIP
160 if test $1 = FAIL
; then
161 echo "<key>Successful</key><false />" >>"$PLIST"
162 elif test $1 = SKIP
; then
163 echo "<key>Successful</key><true />" >>"$PLIST"
164 echo "<key>Skipped</key><true />" >>"$PLIST"
166 echo "<key>Successful</key><true />" >>"$PLIST"
168 echo "</dict>" >>"$PLIST"
171 # B-1. IPP Browse test: Printers appear in a search for "_ipp._tcp,_print" services?
172 start_test
"B-1. IPP Browse test"
173 $IPPFIND _ipp._tcp
,_print.
local.
--name "$1" --quiet
175 pass
=`expr $pass + 1`
178 fail
=`expr $fail + 1`
182 # B-2. IPP TXT keys test: The IPP TXT record contains all required keys.
183 start_test
"B-2. IPP TXT keys test"
184 $IPPFIND "$1._ipp._tcp.local." --txt adminurl
--txt pdl
--txt rp
--txt UUID
--quiet
186 pass
=`expr $pass + 1`
189 fail
=`expr $fail + 1`
190 $IPPFIND "$1._ipp._tcp.local." -x .
/bonjour-tests.sh
'{service_name}' _fail2 \
;
193 # B-3. IPP Resolve test: Printer responds to an IPP Get-Printer-Attributes request using the resolved hostname, port, and resource path.
194 start_test
"B-3. IPP Resolve test"
195 $IPPFIND "$1._ipp._tcp.local." --ls >/dev
/null
197 pass
=`expr $pass + 1`
200 fail
=`expr $fail + 1`
201 echo "<key>Errors</key><array>" >>"$PLIST"
202 $IPPFIND "$1._ipp._tcp.local." --ls |
awk '{ print "<string>" $0 "</string>" }' >>"$PLIST"
203 echo "</array>" >>"$PLIST"
207 # B-4. IPP TXT values test: The IPP TXT record values match the reported IPP attribute values.
208 start_test
"B-4. IPP TXT values test"
209 $IPPFIND "$1._ipp._tcp.local." --txt-adminurl '^(http:|https:)//' --txt-pdl 'image/pwg-raster' --txt-pdl 'image/jpeg' --txt-rp '^ipp/(print|print/[^/]+)$' --txt-UUID '^[0-9a-fA-F]{8,8}-[0-9a-fA-F]{4,4}-[0-9a-fA-F]{4,4}-[0-9a-fA-F]{4,4}-[0-9a-fA-F]{12,12}$' -x $IPPTOOL -q '{}' bonjour-value-tests.
test \
;
211 pass
=`expr $pass + 1`
214 fail
=`expr $fail + 1`
215 $IPPFIND "$1._ipp._tcp.local." -x .
/bonjour-tests.sh
'{service_name}' _fail4 \
;
218 # B-5. TLS tests: Performed only if TLS is supported
219 start_test
"B-5. TLS tests"
220 $IPPFIND "$1._ipp._tcp.local." --txt tls
--quiet
222 pass
=`expr $pass + 1`
226 skip
=`expr $skip + 1`
231 # B-5.1 HTTP Upgrade test: Printer responds to an IPP Get-Printer-Attributes request after doing an HTTP Upgrade to TLS.
232 start_test
"B-5.1 HTTP Upgrade test"
233 if test $HAVE_TLS = 1; then
234 error
=`$IPPFIND "$1._ipp._tcp.local." -x $IPPTOOL -E -q '{}' bonjour-access-tests.test \; 2>&1`
236 pass
=`expr $pass + 1`
239 fail
=`expr $fail + 1`
240 echo "<key>Errors</key><array><string>$error</string></array>" >>"$PLIST"
246 skip
=`expr $skip + 1`
250 # B-5.2 IPPS Browse test: Printer appears in a search for "_ipps._tcp,_print" services.
251 start_test
"B-5.2 IPPS Browse test"
252 if test $HAVE_TLS = 1; then
253 $IPPFIND _ipps._tcp
,_print.
local.
--name "$1" --quiet
255 pass
=`expr $pass + 1`
258 fail
=`expr $fail + 1`
262 skip
=`expr $skip + 1`
266 # B-5.3 IPPS TXT keys test: The TXT record for IPPS contains all required keys
267 start_test
"B-5.3 IPPS TXT keys test"
268 if test $HAVE_TLS = 1; then
269 $IPPFIND "$1._ipps._tcp.local." --txt adminurl
--txt pdl
--txt rp
--txt TLS
--txt UUID
--quiet
271 pass
=`expr $pass + 1`
274 fail
=`expr $fail + 1`
275 $IPPFIND "$1._ipps._tcp.local." -x .
/bonjour-tests.sh
'{service_name}' _fail5.3 \
;
278 skip
=`expr $skip + 1`
282 # B-5.4 IPPS Resolve test: Printer responds to an IPPS Get-Printer-Attributes request using the resolved hostname, port, and resource path.
283 start_test
"B-5.4 IPPS Resolve test"
284 if test $HAVE_TLS = 1; then
285 $IPPFIND "$1._ipps._tcp.local." --ls >/dev
/null
287 pass
=`expr $pass + 1`
290 fail
=`expr $fail + 1`
291 echo "<key>Errors</key><array>" >>"$PLIST"
292 $IPPFIND "$1._ipps._tcp.local." --ls |
awk '{ print "<string>" $0 "</string>" }' >>"$PLIST"
293 echo "</array>" >>"$PLIST"
297 skip
=`expr $skip + 1`
301 # B-5.5 IPPS TXT values test: The TXT record values for IPPS match the reported IPPS attribute values.
302 start_test
"B-5.5 IPPS TXT values test"
303 if test $HAVE_TLS = 1; then
304 $IPPFIND "$1._ipps._tcp.local." --txt-adminurl '^(http:|https:)//' --txt-pdl 'image/pwg-raster' --txt-pdl 'image/jpeg' --txt-rp '^ipp/(print|print/[^/]+)$' --txt-UUID '^[0-9a-fA-F]{8,8}-[0-9a-fA-F]{4,4}-[0-9a-fA-F]{4,4}-[0-9a-fA-F]{4,4}-[0-9a-fA-F]{12,12}$' -x $IPPTOOL -q '{}' bonjour-value-tests.
test \
;
306 pass
=`expr $pass + 1`
309 fail
=`expr $fail + 1`
310 $IPPFIND "$1._ipps._tcp.local." -x .
/bonjour-tests.sh
'{service_name}' _fail5.5 \
;
313 skip
=`expr $skip + 1`
318 if test $fail -gt 0; then
321 <key>Successful</key>
327 <key>Successful</key>
337 score
=`expr $pass + $skip`
338 score
=`expr 100 \* $score / $total`
339 echo "Summary: $total tests, $pass passed, $fail failed, $skip skipped"
340 echo "Score: ${score}%"
343 # End of "$Id: bonjour-tests.sh 13138 2016-03-15 14:59:54Z msweet $".