]> git.ipfire.org Git - thirdparty/cups.git/blame - everywhere/bonjour-tests.bat
<rdar://problem/17837631> OS X continues sending print data after the print job is...
[thirdparty/cups.git] / everywhere / bonjour-tests.bat
CommitLineData
b32e6256 1@echo off
193013f9
MS
2::
3:: "$Id$"
4::
5:: IPP Everywhere Printer Self-Certification Manual 1.0: Section 5: Bonjour Tests.
6::
7:: Copyright 2014 by The Printer Working Group.
8::
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.
14::
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.
18::
19:: Usage:
20::
21:: bonjour-tests.bat 'Printer Name'
22::
23
b32e6256
MS
24set PLIST=%1 Bonjour Results.plist
25echo Sending output to "%PLIST%"...
193013f9
MS
26
27:: Write the standard XML plist header...
b32e6256
MS
28echo ^<?xml version=^"1.0^" encoding=^"UTF-8^"?^> >"%PLIST%"
29echo ^<!DOCTYPE plist PUBLIC ^"-//Apple Computer//DTD PLIST 1.0//EN^" ^"http://www.apple.com/DTDs/PropertyList-1.0.dtd^"^> >>"%PLIST%"
30echo ^<plist version=^"1.0^"^> >>"%PLIST%"
31echo ^<dict^> >>"%PLIST%"
32echo ^<key^>Tests^</key^>^<array^> >>"%PLIST%"
193013f9
MS
33
34set total=0
35set pass=0
36set fail=0
37set skip=0
38
39:: B-1. IPP Browse test: Printers appear in a search for "_ipp._tcp,_print" services?
b32e6256
MS
40set /a total+=1
41set <NUL /p="B-1. IPP Browse test: "
42echo ^<dict^>^<key^>Name^</key^>^<string^>B-1. IPP Browse test^</string^> >>"%PLIST%"
43echo ^<key^>FileId^</key^>^<string^>org.pwg.ipp-everywhere.20140826.bonjour^</string^> >>"%PLIST%"
44
3c08d652
MS
45set result=FAIL
46ippfind _ipp._tcp,_print.local. --name "%1" --quiet && set result=PASS
1b6d468c
MS
47if "%result%" == "PASS" (
48 set /a pass+=1
1b6d468c
MS
49) else (
50 set /a fail+=1
1b6d468c 51)
193013f9 52
b32e6256
MS
53echo %result%
54if "%result%" == "FAIL" (
55 echo ^<key^>Successful^</key^>^<false /^> >>"%PLIST%"
56) else (
57 echo ^<key^>Successful^</key^>^<true /^> >>"%PLIST%"
58)
59echo ^</dict^> >>"%PLIST%"
60
193013f9 61:: B-2. IPP TXT keys test: The IPP TXT record contains all required keys.
b32e6256
MS
62set /a total+=1
63set <NUL /p="B-2. IPP TXT keys test: "
64echo ^<dict^>^<key^>Name^</key^>^<string^>B-2. IPP TXT keys test^</string^> >>"%PLIST%"
65echo ^<key^>FileId^</key^>^<string^>org.pwg.ipp-everywhere.20140826.bonjour^</string^> >>"%PLIST%"
66
3c08d652
MS
67set result=FAIL
68ippfind "%1._ipp._tcp.local." --txt adminurl --txt pdl --txt rp --txt UUID --quiet && set result=PASS
1b6d468c
MS
69if "%result%" == "PASS" (
70 set /a pass+=1
1b6d468c
MS
71) else (
72 set /a fail+=1
b32e6256
MS
73 echo ^<key^>Errors^</key^>^<array^>^<string^> >>"%PLIST%"
74 ippfind "%1._ipp._tcp.local." -x echo adminurl="{txt_adminurl}" ";" >>"%PLIST%"
75 ippfind "%1._ipp._tcp.local." -x echo pdl="{txt_pdl}" ";" >>"%PLIST%"
76 ippfind "%1._ipp._tcp.local." -x echo rp="{txt_rp}" ";" >>"%PLIST%"
77 ippfind "%1._ipp._tcp.local." -x echo UUID="{txt_uuid}" ";" >>"%PLIST%"
78 echo ^</string^>^</array^> >>"%PLIST%"
79)
80
81echo %result%
82if "%result%" == "FAIL" (
83 echo ^<key^>Successful^</key^>^<false /^> >>"%PLIST%"
84
85 ippfind "%1._ipp._tcp.local." -x echo adminurl="{txt_adminurl}" ";"
86 ippfind "%1._ipp._tcp.local." -x echo pdl="{txt_pdl}" ";"
87 ippfind "%1._ipp._tcp.local." -x echo rp="{txt_rp}" ";"
88 ippfind "%1._ipp._tcp.local." -x echo UUID="{txt_uuid}" ";"
89) else (
90 echo ^<key^>Successful^</key^>^<true /^> >>"%PLIST%"
1b6d468c 91)
b32e6256 92echo ^</dict^> >>"%PLIST%"
193013f9
MS
93
94:: B-3. IPP Resolve test: Printer responds to an IPP Get-Printer-Attributes request using the resolved hostname, port, and resource path.
b32e6256
MS
95set /a total+=1
96set <NUL /p="B-3. IPP Resolve test: "
97echo ^<dict^>^<key^>Name^</key^>^<string^>B-3. IPP Resolve test^</string^> >>"%PLIST%"
98echo ^<key^>FileId^</key^>^<string^>org.pwg.ipp-everywhere.20140826.bonjour^</string^> >>"%PLIST%"
99
3c08d652 100set result=FAIL
1b6d468c
MS
101(ippfind "%1._ipp._tcp.local." --ls && set result=PASS) >nul:
102if "%result%" == "PASS" (
103 set /a pass+=1
1b6d468c
MS
104) else (
105 set /a fail+=1
b32e6256 106 echo ^<key^>Errors^</key^>^<array^>^<string^> >>"%PLIST%"
1b6d468c 107 ippfind "%1._ipp._tcp.local." --ls >>"%PLIST%"
b32e6256 108 echo ^</string^>^</array^> >>"%PLIST%"
1b6d468c 109)
193013f9 110
b32e6256
MS
111echo %result%
112if "%result%" == "FAIL" (
113 echo ^<key^>Successful^</key^>^<false /^> >>"%PLIST%"
114) else (
115 echo ^<key^>Successful^</key^>^<true /^> >>"%PLIST%"
116)
117echo ^</dict^> >>"%PLIST%"
118
193013f9 119:: B-4. IPP TXT values test: The IPP TXT record values match the reported IPP attribute values.
b32e6256
MS
120set /a total+=1
121set <NUL /p="B-4. IPP TXT values test: "
122echo ^<dict^>^<key^>Name^</key^>^<string^>B-4. IPP TXT values test^</string^> >>"%PLIST%"
123echo ^<key^>FileId^</key^>^<string^>org.pwg.ipp-everywhere.20140826.bonjour^</string^> >>"%PLIST%"
124
3c08d652 125set result=FAIL
b32e6256 126ippfind "%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 -d "ADMINURL={txt_adminurl}" -d "UUID={txt_uuid}" "{}" bonjour-value-tests.test ";" && set result=PASS
1b6d468c
MS
127if "%result%" == "PASS" (
128 set /a pass+=1
1b6d468c
MS
129) else (
130 set /a fail+=1
b32e6256
MS
131 echo ^<key^>Errors^</key^>^<array^>^<string^> >>"%PLIST%"
132 ippfind "%1._ipp._tcp.local." -x echo adminurl="{txt_adminurl}" ";" >>"%PLIST%"
133 ippfind "%1._ipp._tcp.local." -x echo pdl="{txt_pdl}" ";" >>"%PLIST%"
134 ippfind "%1._ipp._tcp.local." -x echo rp="{txt_rp}" ";" >>"%PLIST%"
135 ippfind "%1._ipp._tcp.local." -x echo UUID="{txt_uuid}" ";" >>"%PLIST%"
136 ippfind "%1._ipp._tcp.local." -x ipptool -t "{}" bonjour-value-tests.test ";" | findstr /r [TG][EO][DT]: >>"%PLIST%"
137 echo ^</string^>^</array^> >>"%PLIST%"
1b6d468c 138)
193013f9 139
b32e6256
MS
140echo %result%
141if "%result%" == "FAIL" (
142 echo ^<key^>Successful^</key^>^<false /^> >>"%PLIST%"
143
144 ippfind "%1._ipp._tcp.local." -x echo adminurl="{txt_adminurl}" ";"
145 ippfind "%1._ipp._tcp.local." -x echo pdl="{txt_pdl}" ";"
146 ippfind "%1._ipp._tcp.local." -x echo rp="{txt_rp}" ";"
147 ippfind "%1._ipp._tcp.local." -x echo UUID="{txt_uuid}" ";"
148 ippfind "%1._ipp._tcp.local." -x ipptool -t "{}" bonjour-value-tests.test ";" | findstr /r [TG][EO][DT]:
149) else (
150 echo ^<key^>Successful^</key^>^<true /^> >>"%PLIST%"
151)
152echo ^</dict^> >>"%PLIST%"
153
193013f9 154:: B-5. TLS tests: Performed only if TLS is supported
b32e6256
MS
155set /a total+=1
156set <NUL /p="B-5. TLS tests: "
157echo ^<dict^>^<key^>Name^</key^>^<string^>B-5. TLS tests^</string^> >>"%PLIST%"
158echo ^<key^>FileId^</key^>^<string^>org.pwg.ipp-everywhere.20140826.bonjour^</string^> >>"%PLIST%"
159
160set result=SKIP
161ippfind "%1._ipp._tcp.local." --txt tls --quiet && set result=PASS
1b6d468c
MS
162if "%result%" == "PASS" (
163 set /a pass+=1
3c08d652 164 set HAVE_TLS=1
1b6d468c
MS
165) else (
166 set /a skip+=1
3c08d652 167 set HAVE_TLS=0
1b6d468c 168)
193013f9 169
b32e6256
MS
170echo %result%
171if "%result%" == "SKIP" (
172 echo ^<key^>Successful^</key^>^<true /^> >>"%PLIST%"
173 echo ^<key^>Skipped^</key^>^<true /^> >>"%PLIST%"
174) else (
175 echo ^<key^>Successful^</key^>^<true /^> >>"%PLIST%"
176)
177echo ^</dict^> >>"%PLIST%"
178
193013f9 179:: B-5.1 HTTP Upgrade test: Printer responds to an IPP Get-Printer-Attributes request after doing an HTTP Upgrade to TLS.
b32e6256
MS
180set /a total+=1
181set <NUL /p="B-5.1 HTTP Upgrade test: "
182echo ^<dict^>^<key^>Name^</key^>^<string^>B-5.1 HTTP Upgrade test^</string^> >>"%PLIST%"
183echo ^<key^>FileId^</key^>^<string^>org.pwg.ipp-everywhere.20140826.bonjour^</string^> >>"%PLIST%"
184
1b6d468c 185if "%HAVE_TLS%" == "1" (
3c08d652 186 set result=FAIL
1b6d468c
MS
187 ippfind "%1._ipp._tcp.local." -x ipptool -E -q "{}" bonjour-access-tests.test ";" && set result=PASS
188 if "%result%" == "PASS" (
189 set /a pass+=1
1b6d468c
MS
190 ) else (
191 set /a fail+=1
b32e6256 192 echo ^<key^>Errors^</key^>^<array^>^<string^> >>"%PLIST"
1b6d468c 193 ippfind "%1._ipp._tcp.local." -x ipptool -E -q "{}" bonjour-access-tests.test ";" >>"%PLIST%"
b32e6256 194 echo ^</string^>^</array^> >>"%PLIST%"
1b6d468c
MS
195 )
196) else (
197 set /a skip+=1
b32e6256
MS
198 set result=SKIP
199)
200
201echo %result%
202if "%result%" == "FAIL" (
203 echo ^<key^>Successful^</key^>^<false /^> >>"%PLIST%"
204) else (
205 if "%result%" == "SKIP" (
206 echo ^<key^>Successful^</key^>^<true /^> >>"%PLIST%"
207 echo ^<key^>Skipped^</key^>^<true /^> >>"%PLIST%"
208 ) else (
209 echo ^<key^>Successful^</key^>^<true /^> >>"%PLIST%"
210 )
1b6d468c 211)
b32e6256 212echo ^</dict^> >>"%PLIST%"
193013f9
MS
213
214:: B-5.2 IPPS Browse test: Printer appears in a search for "_ipps._tcp,_print" services.
b32e6256
MS
215set /a total+=1
216set <NUL /p="B-5.2 IPPS Browse test: "
217echo ^<dict^>^<key^>Name^</key^>^<string^>B-5.2 IPPS Browse test^</string^> >>"%PLIST%"
218echo ^<key^>FileId^</key^>^<string^>org.pwg.ipp-everywhere.20140826.bonjour^</string^> >>"%PLIST%"
219
1b6d468c
MS
220if "%HAVE_TLS%" == "1" (
221 set result=FAIL
222 ippfind _ipps._tcp,_print.local. --name "%1" --quiet && set result=PASS
223 if "%result%" == "PASS" (
224 set /a pass+=1
1b6d468c
MS
225 ) else (
226 set /a fail+=1
1b6d468c
MS
227 )
228) else (
229 set /a skip+=1
b32e6256 230 set result=SKIP
1b6d468c 231)
193013f9 232
b32e6256
MS
233echo %result%
234if "%result%" == "FAIL" (
235 echo ^<key^>Successful^</key^>^<false /^> >>"%PLIST%"
236) else (
237 if "%result%" == "SKIP" (
238 echo ^<key^>Successful^</key^>^<true /^> >>"%PLIST%"
239 echo ^<key^>Skipped^</key^>^<true /^> >>"%PLIST%"
240 ) else (
241 echo ^<key^>Successful^</key^>^<true /^> >>"%PLIST%"
242 )
243)
244echo ^</dict^> >>"%PLIST%"
245
193013f9 246:: B-5.3 IPPS TXT keys test: The TXT record for IPPS contains all required keys
b32e6256
MS
247set /a total+=1
248set <NUL /p="B-5.3 IPPS TXT keys test: "
249echo ^<dict^>^<key^>Name^</key^>^<string^>B-5.3 IPPS TXT keys test^</string^> >>"%PLIST%"
250echo ^<key^>FileId^</key^>^<string^>org.pwg.ipp-everywhere.20140826.bonjour^</string^> >>"%PLIST%"
251
1b6d468c
MS
252if "%HAVE_TLS%" == "1" (
253 set result=FAIL
254 ippfind "%1._ipps._tcp.local." --txt adminurl --txt pdl --txt rp --txt TLS --txt UUID --quiet && set result=PASS
255 if "%result%" == "PASS" (
256 set /a pass+=1
1b6d468c
MS
257 ) else (
258 set /a fail+=1
b32e6256
MS
259 echo ^<key^>Errors^</key^>^<array^>^<string^> >>"%PLIST%"
260 ippfind "%1._ipps._tcp.local." -x echo adminurl={txt_adminurl}" ";" >>"%PLIST%"
261 ippfind "%1._ipps._tcp.local." -x echo pdl={txt_pdl}" ";" >>"%PLIST%"
262 ippfind "%1._ipps._tcp.local." -x echo rp={txt_rp}" ";" >>"%PLIST%"
263 ippfind "%1._ipps._tcp.local." -x echo TLS={txt_tls}" ";" >>"%PLIST%"
264 ippfind "%1._ipps._tcp.local." -x echo UUID={txt_uuid}" ";" >>"%PLIST%"
265 echo ^</string^>^</array^> >>"%PLIST%"
1b6d468c
MS
266 )
267) else (
268 set /a skip+=1
b32e6256 269 set result=SKIP
1b6d468c 270)
193013f9 271
b32e6256
MS
272echo %result%
273if "%result%" == "FAIL" (
274 echo ^<key^>Successful^</key^>^<false /^> >>"%PLIST%"
275
276 ippfind "%1._ipps._tcp.local." -x echo adminurl={txt_adminurl}" ";"
277 ippfind "%1._ipps._tcp.local." -x echo pdl={txt_pdl}" ";"
278 ippfind "%1._ipps._tcp.local." -x echo rp={txt_rp}" ";"
279 ippfind "%1._ipps._tcp.local." -x echo TLS={txt_tls}" ";"
280 ippfind "%1._ipps._tcp.local." -x echo UUID={txt_uuid}" ";"
281) else (
282 if "%result%" == "SKIP" (
283 echo ^<key^>Successful^</key^>^<true /^> >>"%PLIST%"
284 echo ^<key^>Skipped^</key^>^<true /^> >>"%PLIST%"
285 ) else (
286 echo ^<key^>Successful^</key^>^<true /^> >>"%PLIST%"
287 )
288)
289echo ^</dict^> >>"%PLIST%"
290
193013f9 291:: B-5.4 IPPS Resolve test: Printer responds to an IPPS Get-Printer-Attributes request using the resolved hostname, port, and resource path.
b32e6256
MS
292set /a total+=1
293set <NUL /p="B-5.4 IPPS Resolve test: "
294echo ^<dict^>^<key^>Name^</key^>^<string^>B-5.4 IPPS Resolve test^</string^> >>"%PLIST%"
295echo ^<key^>FileId^</key^>^<string^>org.pwg.ipp-everywhere.20140826.bonjour^</string^> >>"%PLIST%"
296
1b6d468c
MS
297if "%HAVE_TLS%" == "1" (
298 set result=FAIL
299 (ippfind "%1._ipps._tcp.local." --ls && set result=PASS) >nul:
300 if "%result%" == "PASS" (
301 set /a pass+=1
1b6d468c
MS
302 ) else (
303 set /a fail+=1
b32e6256 304 echo ^<key^>Errors^</key^>^<array^>^<string^> >>"%PLIST%"
1b6d468c 305 ippfind "%1._ipps._tcp.local." --ls >>"%PLIST%"
b32e6256 306 echo ^</string^>^</array^> >>"%PLIST%"
1b6d468c
MS
307 )
308) else (
309 set /a skip+=1
b32e6256
MS
310 set result=SKIP
311)
312
313echo %result%
314if "%result%" == "FAIL" (
315 echo ^<key^>Successful^</key^>^<false /^> >>"%PLIST%"
316) else (
317 if "%result%" == "SKIP" (
318 echo ^<key^>Successful^</key^>^<true /^> >>"%PLIST%"
319 echo ^<key^>Skipped^</key^>^<true /^> >>"%PLIST%"
320 ) else (
321 echo ^<key^>Successful^</key^>^<true /^> >>"%PLIST%"
322 )
1b6d468c 323)
b32e6256 324echo ^</dict^> >>"%PLIST%"
193013f9
MS
325
326:: B-5.5 IPPS TXT values test: The TXT record values for IPPS match the reported IPPS attribute values.
b32e6256
MS
327set /a total+=1
328set <NUL /p="B-5.5 IPPS TXT values test: "
329echo ^<dict^>^<key^>Name^</key^>^<string^>B-5.5 IPPS TXT values test^</string^> >>"%PLIST%"
330echo ^<key^>FileId^</key^>^<string^>org.pwg.ipp-everywhere.20140826.bonjour^</string^> >>"%PLIST%"
331
1b6d468c
MS
332if "%HAVE_TLS%" == "1" (
333 set result=FAIL
b32e6256 334 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 ";" && set result=PASS
1b6d468c
MS
335 if "%result%" == "PASS" (
336 set /a pass+=1
1b6d468c
MS
337 ) else (
338 set /a fail+=1
b32e6256
MS
339 echo ^<key^>Errors^</key^>^<array^>^<string^> >>"%PLIST%"
340 ippfind "%1._ipps._tcp.local." -x echo adminurl="{txt_adminurl}" ";" >>"%PLIST%"
341 ippfind "%1._ipps._tcp.local." -x echo pdl="{txt_pdl}" ";" >>"%PLIST%"
342 ippfind "%1._ipps._tcp.local." -x echo rp="{txt_rp}" ";" >>"%PLIST%"
343 ippfind "%1._ipps._tcp.local." -x echo TLS="{txt_tls}" ";" >>"%PLIST%"
344 ippfind "%1._ipps._tcp.local." -x echo UUID="{txt_uuid}" ";" >>"%PLIST%"
345 ippfind "%1._ipps._tcp.local." -x ipptool -t "{}" bonjour-value-tests.test ";" | findstr /r [TG][EO][DT]: >>"%PLIST"
346 echo ^</string^>^</array^> >>"%PLIST%"
1b6d468c
MS
347 )
348) else (
349 set /a skip+=1
b32e6256 350 set result=SKIP
1b6d468c 351)
193013f9 352
b32e6256
MS
353echo %result%
354if "%result%" == "FAIL" (
355 echo ^<key^>Successful^</key^>^<false /^> >>"%PLIST%"
356
357 ippfind "%1._ipps._tcp.local." -x echo adminurl="{txt_adminurl}" ";"
358 ippfind "%1._ipps._tcp.local." -x echo pdl="{txt_pdl}" ";"
359 ippfind "%1._ipps._tcp.local." -x echo rp="{txt_rp}" ";"
360 ippfind "%1._ipps._tcp.local." -x echo TLS="{txt_tls}" ";"
361 ippfind "%1._ipps._tcp.local." -x echo UUID="{txt_uuid}" ";"
362 ippfind "%1._ipp._tcp.local." -x ipptool -t "{}" bonjour-value-tests.test ";" | findstr /r [TG][EO][DT]:
363) else (
364 if "%result%" == "SKIP" (
365 echo ^<key^>Successful^</key^>^<true /^> >>"%PLIST%"
366 echo ^<key^>Skipped^</key^>^<true /^> >>"%PLIST%"
367 ) else (
368 echo ^<key^>Successful^</key^>^<true /^> >>"%PLIST%"
369 )
370)
371echo ^</dict^> >>"%PLIST%"
372
193013f9 373:: Finish up...
b32e6256
MS
374echo ^</array^> >>"%PLIST%"
375echo ^<key^>Successful^</key^> >>"%PLIST%"
1b6d468c 376if %fail% gtr 0 (
b32e6256 377 echo ^<false /^> >>"%PLIST%"
1b6d468c 378) else (
b32e6256 379 echo ^<true /^> >>"%PLIST%"
1b6d468c 380)
b32e6256
MS
381echo ^</dict^> >>"%PLIST%"
382echo ^</plist^> >>"%PLIST%"
193013f9 383
1b6d468c
MS
384set /a score=%pass% + %skip%
385set /a score=100 * %score% / %total%
b32e6256
MS
386echo Summary: %total% tests, %pass% passed, %fail% failed, %skip% skipped
387echo Score: %score%%%
193013f9
MS
388
389::
390:: End of "$Id$".
391::