]>
Commit | Line | Data |
---|---|---|
1 | #!/bin/sh | |
2 | # | |
3 | # "$Id: run-stp-tests.sh 9034 2010-03-09 07:03:06Z mike $" | |
4 | # | |
5 | # Perform the complete set of IPP compliance tests specified in the | |
6 | # CUPS Software Test Plan. | |
7 | # | |
8 | # Copyright 2007-2011 by Apple Inc. | |
9 | # Copyright 1997-2007 by Easy Software Products, all rights reserved. | |
10 | # | |
11 | # These coded instructions, statements, and computer programs are the | |
12 | # property of Apple Inc. and are protected by Federal copyright | |
13 | # law. Distribution and use rights are outlined in the file "LICENSE.txt" | |
14 | # which should have been included with this file. If this file is | |
15 | # file is missing or damaged, see the license at "http://www.cups.org/". | |
16 | # | |
17 | ||
18 | argcount=$# | |
19 | ||
20 | # | |
21 | # Make the IPP test program... | |
22 | # | |
23 | ||
24 | make | |
25 | ||
26 | # | |
27 | # Solaris has a non-POSIX grep in /bin... | |
28 | # | |
29 | ||
30 | if test -x /usr/xpg4/bin/grep; then | |
31 | GREP=/usr/xpg4/bin/grep | |
32 | else | |
33 | GREP=grep | |
34 | fi | |
35 | ||
36 | # | |
37 | # Figure out the proper echo options... | |
38 | # | |
39 | ||
40 | if (echo "testing\c"; echo 1,2,3) | $GREP c >/dev/null; then | |
41 | ac_n=-n | |
42 | ac_c= | |
43 | else | |
44 | ac_n= | |
45 | ac_c='\c' | |
46 | fi | |
47 | ||
48 | # | |
49 | # Greet the tester... | |
50 | # | |
51 | ||
52 | echo "Welcome to the CUPS Automated Test Script." | |
53 | echo "" | |
54 | echo "Before we begin, it is important that you understand that the larger" | |
55 | echo "tests require significant amounts of RAM and disk space. If you" | |
56 | echo "attempt to run one of the big tests on a system that lacks sufficient" | |
57 | echo "disk and virtual memory, the UNIX kernel might decide to kill one or" | |
58 | echo "more system processes that you've grown attached to, like the X" | |
59 | echo "server. The question you may want to ask yourself before running a" | |
60 | echo "large test is: Do you feel lucky?" | |
61 | echo "" | |
62 | echo "OK, now that we have the Dirty Harry quote out of the way, please" | |
63 | echo "choose the type of test you wish to perform:" | |
64 | echo "" | |
65 | echo "0 - No testing, keep the scheduler running for me (all systems)" | |
66 | echo "1 - Basic conformance test, no load testing (all systems)" | |
67 | echo "2 - Basic conformance test, some load testing (minimum 256MB VM, 50MB disk)" | |
68 | echo "3 - Basic conformance test, extreme load testing (minimum 1GB VM, 500MB disk)" | |
69 | echo "4 - Basic conformance test, torture load testing (minimum 2GB VM, 1GB disk)" | |
70 | echo "" | |
71 | echo $ac_n "Enter the number of the test you wish to perform: [1] $ac_c" | |
72 | ||
73 | if test $# -gt 0; then | |
74 | testtype=$1 | |
75 | shift | |
76 | else | |
77 | read testtype | |
78 | fi | |
79 | echo "" | |
80 | ||
81 | case "$testtype" in | |
82 | 0) | |
83 | echo "Running in test mode (0)" | |
84 | nprinters1=0 | |
85 | nprinters2=0 | |
86 | pjobs=0 | |
87 | pprinters=0 | |
88 | ;; | |
89 | 2) | |
90 | echo "Running the medium tests (2)" | |
91 | nprinters1=10 | |
92 | nprinters2=20 | |
93 | pjobs=20 | |
94 | pprinters=10 | |
95 | ;; | |
96 | 3) | |
97 | echo "Running the extreme tests (3)" | |
98 | nprinters1=500 | |
99 | nprinters2=1000 | |
100 | pjobs=100 | |
101 | pprinters=50 | |
102 | ;; | |
103 | 4) | |
104 | echo "Running the torture tests (4)" | |
105 | nprinters1=10000 | |
106 | nprinters2=20000 | |
107 | pjobs=200 | |
108 | pprinters=100 | |
109 | ;; | |
110 | *) | |
111 | echo "Running the timid tests (1)" | |
112 | nprinters1=0 | |
113 | nprinters2=0 | |
114 | pjobs=10 | |
115 | pprinters=0 | |
116 | ;; | |
117 | esac | |
118 | ||
119 | # | |
120 | # See if we want to do SSL testing... | |
121 | # | |
122 | ||
123 | echo "" | |
124 | echo "Now you can choose whether to create a SSL/TLS encryption key and" | |
125 | echo "certificate for testing; these tests currently require the OpenSSL" | |
126 | echo "tools:" | |
127 | echo "" | |
128 | echo "0 - Do not do SSL/TLS encryption tests" | |
129 | echo "1 - Test but do not require encryption" | |
130 | echo "2 - Test and require encryption" | |
131 | echo "" | |
132 | echo $ac_n "Enter the number of the SSL/TLS tests to perform: [0] $ac_c" | |
133 | ||
134 | if test $# -gt 0; then | |
135 | ssltype=$1 | |
136 | shift | |
137 | else | |
138 | read ssltype | |
139 | fi | |
140 | echo "" | |
141 | ||
142 | case "$ssltype" in | |
143 | 1) | |
144 | echo "Will test but not require encryption (1)" | |
145 | ;; | |
146 | 2) | |
147 | echo "Will test and require encryption (2)" | |
148 | ;; | |
149 | *) | |
150 | echo "Not using SSL/TLS (0)" | |
151 | ssltype=0 | |
152 | ;; | |
153 | esac | |
154 | ||
155 | # | |
156 | # Information for the server/tests... | |
157 | # | |
158 | ||
159 | user="$USER" | |
160 | if test -z "$user"; then | |
161 | if test -x /usr/ucb/whoami; then | |
162 | user=`/usr/ucb/whoami` | |
163 | else | |
164 | user=`whoami` | |
165 | fi | |
166 | ||
167 | if test -z "$user"; then | |
168 | user="unknown" | |
169 | fi | |
170 | fi | |
171 | ||
172 | port=8631 | |
173 | cwd=`pwd` | |
174 | root=`dirname $cwd` | |
175 | ||
176 | # | |
177 | # Make sure that the LPDEST and PRINTER environment variables are | |
178 | # not included in the environment that is passed to the tests. These | |
179 | # will usually cause tests to fail erroneously... | |
180 | # | |
181 | ||
182 | unset LPDEST | |
183 | unset PRINTER | |
184 | ||
185 | # | |
186 | # See if we want to use valgrind... | |
187 | # | |
188 | ||
189 | echo "" | |
190 | echo "This test script can use the Valgrind software from:" | |
191 | echo "" | |
192 | echo " http://developer.kde.org/~sewardj/" | |
193 | echo "" | |
194 | echo $ac_n "Enter Y to use Valgrind or N to not use Valgrind: [N] $ac_c" | |
195 | ||
196 | if test $# -gt 0; then | |
197 | usevalgrind=$1 | |
198 | shift | |
199 | else | |
200 | read usevalgrind | |
201 | fi | |
202 | echo "" | |
203 | ||
204 | case "$usevalgrind" in | |
205 | Y* | y*) | |
206 | valgrind="valgrind --tool=memcheck --log-file=/tmp/cups-$user/log/valgrind.%p --error-limit=no --leak-check=yes --trace-children=yes --read-var-info=yes" | |
207 | echo "Using Valgrind; log files can be found in /tmp/cups-$user/log..." | |
208 | ;; | |
209 | ||
210 | *) | |
211 | valgrind="" | |
212 | ;; | |
213 | esac | |
214 | ||
215 | # | |
216 | # See if we want to do debug logging of the libraries... | |
217 | # | |
218 | ||
219 | echo "" | |
220 | echo "If CUPS was built with the --enable-debug-printfs configure option, you" | |
221 | echo "can enable debug logging of the libraries." | |
222 | echo "" | |
223 | echo $ac_n "Enter Y or a number from 0 to 9 to enable debug logging or N to not: [N] $ac_c" | |
224 | ||
225 | if test $# -gt 0; then | |
226 | usedebugprintfs=$1 | |
227 | shift | |
228 | else | |
229 | read usedebugprintfs | |
230 | fi | |
231 | echo "" | |
232 | ||
233 | case "$usedebugprintfs" in | |
234 | Y* | y*) | |
235 | echo "Enabling debug printfs; log files can be found in /tmp/cups-$user/log..." | |
236 | CUPS_DEBUG_LOG="/tmp/cups-$user/log/debug_printfs.%d"; export CUPS_DEBUG_LOG | |
237 | CUPS_DEBUG_LEVEL=5; export CUPS_DEBUG_LEVEL | |
238 | CUPS_DEBUG_FILTER='^(http|_http|ipp|_ipp|cups.*Request|cupsGetRespond|cupsSend).*$'; export CUPS_DEBUG_FILTER | |
239 | ;; | |
240 | ||
241 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9) | |
242 | echo "Enabling debug printfs; log files can be found in /tmp/cups-$user/log..." | |
243 | CUPS_DEBUG_LOG="/tmp/cups-$user/log/debug_printfs.%d"; export CUPS_DEBUG_LOG | |
244 | CUPS_DEBUG_LEVEL=$usedebugprintf; export CUPS_DEBUG_LEVEL | |
245 | CUPS_DEBUG_FILTER='^(http|_http|ipp|_ipp|cups.*Request|cupsGetRespond|cupsSend).*$'; export CUPS_DEBUG_FILTER | |
246 | ;; | |
247 | ||
248 | *) | |
249 | ;; | |
250 | esac | |
251 | ||
252 | # | |
253 | # Start by creating temporary directories for the tests... | |
254 | # | |
255 | ||
256 | echo "Creating directories for test..." | |
257 | ||
258 | rm -rf /tmp/cups-$user | |
259 | mkdir /tmp/cups-$user | |
260 | mkdir /tmp/cups-$user/bin | |
261 | mkdir /tmp/cups-$user/bin/backend | |
262 | mkdir /tmp/cups-$user/bin/driver | |
263 | mkdir /tmp/cups-$user/bin/filter | |
264 | mkdir /tmp/cups-$user/certs | |
265 | mkdir /tmp/cups-$user/share | |
266 | mkdir /tmp/cups-$user/share/banners | |
267 | mkdir /tmp/cups-$user/share/drv | |
268 | mkdir /tmp/cups-$user/share/locale | |
269 | for file in ../locale/cups_*.po; do | |
270 | loc=`basename $file .po | cut -c 6-` | |
271 | mkdir /tmp/cups-$user/share/locale/$loc | |
272 | ln -s $root/locale/cups_$loc.po /tmp/cups-$user/share/locale/$loc | |
273 | ln -s $root/locale/ppdc_$loc.po /tmp/cups-$user/share/locale/$loc | |
274 | done | |
275 | mkdir /tmp/cups-$user/share/mime | |
276 | mkdir /tmp/cups-$user/share/model | |
277 | mkdir /tmp/cups-$user/share/ppdc | |
278 | mkdir /tmp/cups-$user/interfaces | |
279 | mkdir /tmp/cups-$user/log | |
280 | mkdir /tmp/cups-$user/ppd | |
281 | mkdir /tmp/cups-$user/spool | |
282 | mkdir /tmp/cups-$user/spool/temp | |
283 | mkdir /tmp/cups-$user/ssl | |
284 | ||
285 | ln -s $root/backend/dnssd /tmp/cups-$user/bin/backend | |
286 | ln -s $root/backend/http /tmp/cups-$user/bin/backend | |
287 | ln -s $root/backend/ipp /tmp/cups-$user/bin/backend | |
288 | ln -s $root/backend/lpd /tmp/cups-$user/bin/backend | |
289 | ln -s $root/backend/mdns /tmp/cups-$user/bin/backend | |
290 | ln -s $root/backend/pseudo /tmp/cups-$user/bin/backend | |
291 | ln -s $root/backend/snmp /tmp/cups-$user/bin/backend | |
292 | ln -s $root/backend/socket /tmp/cups-$user/bin/backend | |
293 | ln -s $root/backend/usb /tmp/cups-$user/bin/backend | |
294 | ln -s $root/cgi-bin /tmp/cups-$user/bin | |
295 | ln -s $root/monitor /tmp/cups-$user/bin | |
296 | ln -s $root/notifier /tmp/cups-$user/bin | |
297 | ln -s $root/scheduler /tmp/cups-$user/bin/daemon | |
298 | ln -s $root/filter/commandtops /tmp/cups-$user/bin/filter | |
299 | ln -s $root/filter/gziptoany /tmp/cups-$user/bin/filter | |
300 | ln -s $root/filter/pstops /tmp/cups-$user/bin/filter | |
301 | ln -s $root/filter/rastertoepson /tmp/cups-$user/bin/filter | |
302 | ln -s $root/filter/rastertohp /tmp/cups-$user/bin/filter | |
303 | ln -s $root/filter/rastertolabel /tmp/cups-$user/bin/filter | |
304 | ln -s $root/filter/rastertopwg /tmp/cups-$user/bin/filter | |
305 | ||
306 | ln -s $root/data/classified /tmp/cups-$user/share/banners | |
307 | ln -s $root/data/confidential /tmp/cups-$user/share/banners | |
308 | ln -s $root/data/secret /tmp/cups-$user/share/banners | |
309 | ln -s $root/data/standard /tmp/cups-$user/share/banners | |
310 | ln -s $root/data/topsecret /tmp/cups-$user/share/banners | |
311 | ln -s $root/data/unclassified /tmp/cups-$user/share/banners | |
312 | ln -s $root/data /tmp/cups-$user/share | |
313 | ln -s $root/ppdc/sample.drv /tmp/cups-$user/share/drv | |
314 | ln -s $root/conf/mime.types /tmp/cups-$user/share/mime | |
315 | ln -s $root/conf/mime.convs /tmp/cups-$user/share/mime | |
316 | ln -s $root/data/*.h /tmp/cups-$user/share/ppdc | |
317 | ln -s $root/data/*.defs /tmp/cups-$user/share/ppdc | |
318 | ln -s $root/templates /tmp/cups-$user/share | |
319 | ||
320 | # | |
321 | # Mac OS X filters and configuration files... | |
322 | # | |
323 | ||
324 | if test `uname` = Darwin; then | |
325 | ln -s /usr/libexec/cups/filter/cgpdfto* /tmp/cups-$user/bin/filter | |
326 | ln -s /usr/libexec/cups/filter/cgbannertopdf /tmp/cups-$user/bin/filter | |
327 | ln -s /usr/libexec/cups/filter/cgimagetopdf /tmp/cups-$user/bin/filter | |
328 | ln -s /usr/libexec/cups/filter/cgtexttopdf /tmp/cups-$user/bin/filter | |
329 | ln -s /usr/libexec/cups/filter/nsimagetopdf /tmp/cups-$user/bin/filter | |
330 | ln -s /usr/libexec/cups/filter/nstexttopdf /tmp/cups-$user/bin/filter | |
331 | ln -s /usr/libexec/cups/filter/pictwpstops /tmp/cups-$user/bin/filter | |
332 | ln -s /usr/libexec/cups/filter/pstoappleps /tmp/cups-$user/bin/filter | |
333 | ln -s /usr/libexec/cups/filter/pstocupsraster /tmp/cups-$user/bin/filter | |
334 | ln -s /usr/libexec/cups/filter/pstopdffilter /tmp/cups-$user/bin/filter | |
335 | ln -s /usr/libexec/cups/filter/rastertourf /tmp/cups-$user/bin/filter | |
336 | ln -s /usr/libexec/cups/filter/xhtmltopdf /tmp/cups-$user/bin/filter | |
337 | ||
338 | if test -f /private/etc/cups/apple.types; then | |
339 | ln -s /private/etc/cups/apple.* /tmp/cups-$user/share/mime | |
340 | elif test -f /usr/share/cups/mime/apple.types; then | |
341 | ln -s /usr/share/cups/mime/apple.* /tmp/cups-$user/share/mime | |
342 | fi | |
343 | else | |
344 | ln -s /usr/lib/cups/filter/bannertops /tmp/cups-$user/bin/filter | |
345 | ln -s /usr/lib/cups/filter/imagetops /tmp/cups-$user/bin/filter | |
346 | ln -s /usr/lib/cups/filter/imagetoraster /tmp/cups-$user/bin/filter | |
347 | ln -s /usr/lib/cups/filter/pdftops /tmp/cups-$user/bin/filter | |
348 | ln -s /usr/lib/cups/filter/texttops /tmp/cups-$user/bin/filter | |
349 | ||
350 | ln -s /usr/share/cups/mime/legacy.convs /tmp/cups-$user/share/mime | |
351 | fi | |
352 | ||
353 | # | |
354 | # Then create the necessary config files... | |
355 | # | |
356 | ||
357 | echo "Creating cupsd.conf for test..." | |
358 | ||
359 | if test $ssltype = 2; then | |
360 | encryption="Encryption Required" | |
361 | else | |
362 | encryption="" | |
363 | fi | |
364 | ||
365 | cat >/tmp/cups-$user/cupsd.conf <<EOF | |
366 | Browsing Off | |
367 | FileDevice yes | |
368 | Printcap | |
369 | Listen 127.0.0.1:$port | |
370 | User $user | |
371 | ServerRoot /tmp/cups-$user | |
372 | StateDir /tmp/cups-$user | |
373 | ServerBin /tmp/cups-$user/bin | |
374 | CacheDir /tmp/cups-$user/share | |
375 | DataDir /tmp/cups-$user/share | |
376 | FontPath /tmp/cups-$user/share/fonts | |
377 | PassEnv LOCALEDIR | |
378 | PassEnv DYLD_INSERT_LIBRARIES | |
379 | DocumentRoot $root/doc | |
380 | RequestRoot /tmp/cups-$user/spool | |
381 | TempDir /tmp/cups-$user/spool/temp | |
382 | MaxSubscriptions 3 | |
383 | MaxLogSize 0 | |
384 | AccessLog /tmp/cups-$user/log/access_log | |
385 | ErrorLog /tmp/cups-$user/log/error_log | |
386 | PageLog /tmp/cups-$user/log/page_log | |
387 | AccessLogLevel actions | |
388 | LogLevel debug2 | |
389 | LogTimeFormat usecs | |
390 | PreserveJobHistory Yes | |
391 | <Policy default> | |
392 | <Limit All> | |
393 | Order Deny,Allow | |
394 | Deny from all | |
395 | Allow from 127.0.0.1 | |
396 | $encryption | |
397 | </Limit> | |
398 | </Policy> | |
399 | EOF | |
400 | ||
401 | # | |
402 | # Setup lots of test queues - half with PPD files, half without... | |
403 | # | |
404 | ||
405 | echo "Creating printers.conf for test..." | |
406 | ||
407 | i=1 | |
408 | while test $i -le $nprinters1; do | |
409 | cat >>/tmp/cups-$user/printers.conf <<EOF | |
410 | <Printer test-$i> | |
411 | Accepting Yes | |
412 | DeviceURI file:/dev/null | |
413 | Info Test PS printer $i | |
414 | JobSheets none none | |
415 | Location CUPS test suite | |
416 | State Idle | |
417 | StateMessage Printer $1 is idle. | |
418 | </Printer> | |
419 | EOF | |
420 | ||
421 | cp testps.ppd /tmp/cups-$user/ppd/test-$i.ppd | |
422 | ||
423 | i=`expr $i + 1` | |
424 | done | |
425 | ||
426 | while test $i -le $nprinters2; do | |
427 | cat >>/tmp/cups-$user/printers.conf <<EOF | |
428 | <Printer test-$i> | |
429 | Accepting Yes | |
430 | DeviceURI file:/dev/null | |
431 | Info Test raw printer $i | |
432 | JobSheets none none | |
433 | Location CUPS test suite | |
434 | State Idle | |
435 | StateMessage Printer $1 is idle. | |
436 | </Printer> | |
437 | EOF | |
438 | ||
439 | i=`expr $i + 1` | |
440 | done | |
441 | ||
442 | if test -f /tmp/cups-$user/printers.conf; then | |
443 | cp /tmp/cups-$user/printers.conf /tmp/cups-$user/printers.conf.orig | |
444 | else | |
445 | touch /tmp/cups-$user/printers.conf.orig | |
446 | fi | |
447 | ||
448 | # | |
449 | # Setup the paths... | |
450 | # | |
451 | ||
452 | echo "Setting up environment variables for test..." | |
453 | ||
454 | if test "x$LD_LIBRARY_PATH" = x; then | |
455 | LD_LIBRARY_PATH="$root/cups:$root/filter:$root/cgi-bin:$root/scheduler:$root/driver:$root/ppdc" | |
456 | else | |
457 | LD_LIBRARY_PATH="$root/cups:$root/filter:$root/cgi-bin:$root/scheduler:$root/driver:$root/ppdc:$LD_LIBRARY_PATH" | |
458 | fi | |
459 | ||
460 | export LD_LIBRARY_PATH | |
461 | ||
462 | LD_PRELOAD="$root/cups/libcups.so.2:$root/filter/libcupsimage.so.2:$root/cgi-bin/libcupscgi.so.1:$root/scheduler/libcupsmime.so.1:$root/driver/libcupsdriver.so.1:$root/ppdc/libcupsppdc.so.1" | |
463 | if test `uname` = SunOS -a -r /usr/lib/libCrun.so.1; then | |
464 | LD_PRELOAD="/usr/lib/libCrun.so.1:$LD_PRELOAD" | |
465 | fi | |
466 | export LD_PRELOAD | |
467 | ||
468 | if test "x$DYLD_LIBRARY_PATH" = x; then | |
469 | DYLD_LIBRARY_PATH="$root/cups:$root/filter:$root/cgi-bin:$root/scheduler:$root/driver:$root/ppdc" | |
470 | else | |
471 | DYLD_LIBRARY_PATH="$root/cups:$root/filter:$root/cgi-bin:$root/scheduler:$root/driver:$root/ppdc:$DYLD_LIBRARY_PATH" | |
472 | fi | |
473 | ||
474 | export DYLD_LIBRARY_PATH | |
475 | ||
476 | if test "x$SHLIB_PATH" = x; then | |
477 | SHLIB_PATH="$root/cups:$root/filter:$root/cgi-bin:$root/scheduler:$root/driver:$root/ppdc" | |
478 | else | |
479 | SHLIB_PATH="$root/cups:$root/filter:$root/cgi-bin:$root/scheduler:$root/driver:$root/ppdc:$SHLIB_PATH" | |
480 | fi | |
481 | ||
482 | export SHLIB_PATH | |
483 | ||
484 | CUPS_DISABLE_APPLE_DEFAULT=yes; export CUPS_DISABLE_APPLE_DEFAULT | |
485 | CUPS_SERVER=localhost:8631; export CUPS_SERVER | |
486 | CUPS_SERVERROOT=/tmp/cups-$user; export CUPS_SERVERROOT | |
487 | CUPS_STATEDIR=/tmp/cups-$user; export CUPS_STATEDIR | |
488 | CUPS_DATADIR=/tmp/cups-$user/share; export CUPS_DATADIR | |
489 | LOCALEDIR=/tmp/cups-$user/share/locale; export LOCALEDIR | |
490 | ||
491 | # | |
492 | # Set a new home directory to avoid getting user options mixed in... | |
493 | # | |
494 | ||
495 | HOME=/tmp/cups-$user | |
496 | export HOME | |
497 | ||
498 | # | |
499 | # Force POSIX locale for tests... | |
500 | # | |
501 | ||
502 | LANG=C | |
503 | export LANG | |
504 | ||
505 | LC_MESSAGES=C | |
506 | export LC_MESSAGES | |
507 | ||
508 | # | |
509 | # Start the server; run as foreground daemon in the background... | |
510 | # | |
511 | ||
512 | echo "Starting scheduler:" | |
513 | echo " $valgrind ../scheduler/cupsd -c /tmp/cups-$user/cupsd.conf -f >/tmp/cups-$user/log/debug_log 2>&1 &" | |
514 | echo "" | |
515 | ||
516 | if test `uname` = Darwin -a "x$valgrind" = x; then | |
517 | DYLD_INSERT_LIBRARIES=/usr/lib/libgmalloc.dylib | |
518 | ../scheduler/cupsd -c /tmp/cups-$user/cupsd.conf -f >/tmp/cups-$user/log/debug_log 2>&1 & | |
519 | else | |
520 | $valgrind ../scheduler/cupsd -c /tmp/cups-$user/cupsd.conf -f >/tmp/cups-$user/log/debug_log 2>&1 & | |
521 | fi | |
522 | ||
523 | cupsd=$! | |
524 | ||
525 | if test "x$testtype" = x0; then | |
526 | # Not running tests... | |
527 | echo "Scheduler is PID $cupsd and is listening on port 8631." | |
528 | echo "" | |
529 | ||
530 | # Create a helper script to run programs with... | |
531 | runcups="/tmp/cups-$user/runcups" | |
532 | ||
533 | echo "#!/bin/sh" >$runcups | |
534 | echo "# Helper script for running CUPS test instance." >>$runcups | |
535 | echo "" >>$runcups | |
536 | echo "# Set required environment variables..." >>$runcups | |
537 | echo "CUPS_DATADIR=\"$CUPS_DATADIR\"; export CUPS_DATADIR" >>$runcups | |
538 | echo "CUPS_SERVER=\"$CUPS_SERVER\"; export CUPS_SERVER" >>$runcups | |
539 | echo "CUPS_SERVERROOT=\"$CUPS_SERVERROOT\"; export CUPS_SERVERROOT" >>$runcups | |
540 | echo "CUPS_STATEDIR=\"$CUPS_STATEDIR\"; export CUPS_STATEDIR" >>$runcups | |
541 | echo "DYLD_LIBRARY_PATH=\"$DYLD_LIBRARY_PATH\"; export DYLD_LIBRARY_PATH" >>$runcups | |
542 | echo "LD_LIBRARY_PATH=\"$LD_LIBRARY_PATH\"; export LD_LIBRARY_PATH" >>$runcups | |
543 | echo "LD_PRELOAD=\"$LD_PRELOAD\"; export LD_PRELOAD" >>$runcups | |
544 | echo "LOCALEDIR=\"$LOCALEDIR\"; export LOCALEDIR" >>$runcups | |
545 | echo "SHLIB_PATH=\"$SHLIB_PATH\"; export SHLIB_PATH" >>$runcups | |
546 | echo "" >>$runcups | |
547 | echo "# Run command..." >>$runcups | |
548 | echo "exec \"\$@\"" >>$runcups | |
549 | ||
550 | chmod +x $runcups | |
551 | ||
552 | echo "The $runcups helper script can be used to test programs" | |
553 | echo "with the server." | |
554 | exit 0 | |
555 | fi | |
556 | ||
557 | if test $argcount -eq 0; then | |
558 | echo "Scheduler is PID $cupsd; run debugger now if you need to." | |
559 | echo "" | |
560 | echo $ac_n "Press ENTER to continue... $ac_c" | |
561 | read junk | |
562 | else | |
563 | echo "Scheduler is PID $cupsd." | |
564 | sleep 2 | |
565 | fi | |
566 | ||
567 | IPP_PORT=$port; export IPP_PORT | |
568 | ||
569 | while true; do | |
570 | running=`../systemv/lpstat -r 2>/dev/null` | |
571 | if test "x$running" = "xscheduler is running"; then | |
572 | break | |
573 | fi | |
574 | ||
575 | echo "Waiting for scheduler to become ready..." | |
576 | sleep 10 | |
577 | done | |
578 | ||
579 | # | |
580 | # Create the test report source file... | |
581 | # | |
582 | ||
583 | date=`date "+%Y-%m-%d"` | |
584 | strfile=/tmp/cups-$user/cups-str-1.6-$date-$user.html | |
585 | ||
586 | rm -f $strfile | |
587 | cat str-header.html >$strfile | |
588 | ||
589 | # | |
590 | # Run the IPP tests... | |
591 | # | |
592 | ||
593 | echo "" | |
594 | echo "Running IPP compliance tests..." | |
595 | ||
596 | echo "<H1>1 - IPP Compliance Tests</H1>" >>$strfile | |
597 | echo "<P>This section provides the results to the IPP compliance tests" >>$strfile | |
598 | echo "outlined in the CUPS Software Test Plan. These tests were run on" >>$strfile | |
599 | echo `date "+%Y-%m-%d"` by $user on `hostname`. >>$strfile | |
600 | echo "<PRE>" >>$strfile | |
601 | ||
602 | fail=0 | |
603 | for file in 4*.test; do | |
604 | echo "Performing $file..." | |
605 | echo "" >>$strfile | |
606 | ||
607 | ./ipptool -t ipp://localhost:$port/printers $file | tee -a $strfile | |
608 | status=$? | |
609 | ||
610 | if test $status != 0; then | |
611 | echo Test failed. | |
612 | fail=`expr $fail + 1` | |
613 | fi | |
614 | done | |
615 | ||
616 | echo "</PRE>" >>$strfile | |
617 | ||
618 | # | |
619 | # Run the command tests... | |
620 | # | |
621 | ||
622 | echo "" | |
623 | echo "Running command tests..." | |
624 | ||
625 | echo "<H1>2 - Command Tests</H1>" >>$strfile | |
626 | echo "<P>This section provides the results to the command tests" >>$strfile | |
627 | echo "outlined in the CUPS Software Test Plan. These tests were run on" >>$strfile | |
628 | echo $date by $user on `hostname`. >>$strfile | |
629 | echo "<PRE>" >>$strfile | |
630 | ||
631 | for file in 5*.sh; do | |
632 | echo "Performing $file..." | |
633 | echo "" >>$strfile | |
634 | echo "\"$file\":" >>$strfile | |
635 | ||
636 | sh $file $pjobs $pprinters | tee -a $strfile | |
637 | status=$? | |
638 | ||
639 | if test $status != 0; then | |
640 | echo Test failed. | |
641 | fail=`expr $fail + 1` | |
642 | fi | |
643 | done | |
644 | ||
645 | echo "</PRE>" >>$strfile | |
646 | ||
647 | # | |
648 | # Stop the server... | |
649 | # | |
650 | ||
651 | kill $cupsd | |
652 | ||
653 | # | |
654 | # Append the log files for post-mortim... | |
655 | # | |
656 | ||
657 | echo "<H1>3 - Log Files</H1>" >>$strfile | |
658 | ||
659 | # | |
660 | # Verify counts... | |
661 | # | |
662 | ||
663 | echo "Test Summary" | |
664 | echo "" | |
665 | echo "<H2>Summary</H2>" >>$strfile | |
666 | ||
667 | # Job control files | |
668 | count=`ls -1 /tmp/cups-$user/spool | wc -l` | |
669 | count=`expr $count - 1` | |
670 | if test $count != 0; then | |
671 | echo "FAIL: $count job control files were not purged." | |
672 | echo "<P>FAIL: $count job control files were not purged.</P>" >>$strfile | |
673 | fail=`expr $fail + 1` | |
674 | else | |
675 | echo "PASS: All job control files purged." | |
676 | echo "<P>PASS: All job control files purged.</P>" >>$strfile | |
677 | fi | |
678 | ||
679 | # Pages printed on Test1 (within 1 page for timing-dependent cancel issues) | |
680 | count=`$GREP '^Test1 ' /tmp/cups-$user/log/page_log | awk 'BEGIN{count=0}{count=count+$7}END{print count}'` | |
681 | expected=`expr $pjobs \* 2 + 34` | |
682 | expected2=`expr $expected + 2` | |
683 | if test $count -lt $expected -a $count -gt $expected2; then | |
684 | echo "FAIL: Printer 'Test1' produced $count page(s), expected $expected." | |
685 | echo "<P>FAIL: Printer 'Test1' produced $count page(s), expected $expected.</P>" >>$strfile | |
686 | fail=`expr $fail + 1` | |
687 | else | |
688 | echo "PASS: Printer 'Test1' correctly produced $count page(s)." | |
689 | echo "<P>PASS: Printer 'Test1' correctly produced $count page(s).</P>" >>$strfile | |
690 | fi | |
691 | ||
692 | # Paged printed on Test2 | |
693 | count=`$GREP '^Test2 ' /tmp/cups-$user/log/page_log | awk 'BEGIN{count=0}{count=count+$7}END{print count}'` | |
694 | expected=`expr $pjobs \* 2 + 3` | |
695 | if test $count != $expected; then | |
696 | echo "FAIL: Printer 'Test2' produced $count page(s), expected $expected." | |
697 | echo "<P>FAIL: Printer 'Test2' produced $count page(s), expected $expected.</P>" >>$strfile | |
698 | fail=`expr $fail + 1` | |
699 | else | |
700 | echo "PASS: Printer 'Test2' correctly produced $count page(s)." | |
701 | echo "<P>PASS: Printer 'Test2' correctly produced $count page(s).</P>" >>$strfile | |
702 | fi | |
703 | ||
704 | # Requests logged | |
705 | count=`wc -l /tmp/cups-$user/log/access_log | awk '{print $1}'` | |
706 | expected=`expr 37 + 18 + $pjobs \* 8 + $pprinters \* $pjobs \* 4` | |
707 | if test $count != $expected; then | |
708 | echo "FAIL: $count requests logged, expected $expected." | |
709 | echo "<P>FAIL: $count requests logged, expected $expected.</P>" >>$strfile | |
710 | fail=`expr $fail + 1` | |
711 | else | |
712 | echo "PASS: $count requests logged." | |
713 | echo "<P>PASS: $count requests logged.</P>" >>$strfile | |
714 | fi | |
715 | ||
716 | # Did CUPS-Get-Default get logged? | |
717 | if $GREP -q CUPS-Get-Default /tmp/cups-$user/log/access_log; then | |
718 | echo "FAIL: CUPS-Get-Default logged with 'AccessLogLevel actions'" | |
719 | echo "<P>FAIL: CUPS-Get-Default logged with 'AccessLogLevel actions'</P>" >>$strfile | |
720 | echo "<PRE>" >>$strfile | |
721 | $GREP CUPS-Get-Default /tmp/cups-$user/log/access_log | sed -e '1,$s/&/&/g' -e '1,$s/</</g' >>$strfile | |
722 | echo "</PRE>" >>$strfile | |
723 | fail=`expr $fail + 1` | |
724 | else | |
725 | echo "PASS: CUPS-Get-Default not logged." | |
726 | echo "<P>PASS: CUPS-Get-Default not logged.</P>" >>$strfile | |
727 | fi | |
728 | ||
729 | # Emergency log messages | |
730 | count=`$GREP '^X ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'` | |
731 | if test $count != 0; then | |
732 | echo "FAIL: $count emergency messages, expected 0." | |
733 | $GREP '^X ' /tmp/cups-$user/log/error_log | |
734 | echo "<P>FAIL: $count emergency messages, expected 0.</P>" >>$strfile | |
735 | echo "<PRE>" >>$strfile | |
736 | $GREP '^X ' /tmp/cups-$user/log/error_log | sed -e '1,$s/&/&/g' -e '1,$s/</</g' >>$strfile | |
737 | echo "</PRE>" >>$strfile | |
738 | fail=`expr $fail + 1` | |
739 | else | |
740 | echo "PASS: $count emergency messages." | |
741 | echo "<P>PASS: $count emergency messages.</P>" >>$strfile | |
742 | fi | |
743 | ||
744 | # Alert log messages | |
745 | count=`$GREP '^A ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'` | |
746 | if test $count != 0; then | |
747 | echo "FAIL: $count alert messages, expected 0." | |
748 | $GREP '^A ' /tmp/cups-$user/log/error_log | |
749 | echo "<P>FAIL: $count alert messages, expected 0.</P>" >>$strfile | |
750 | echo "<PRE>" >>$strfile | |
751 | $GREP '^A ' /tmp/cups-$user/log/error_log | sed -e '1,$s/&/&/g' -e '1,$s/</</g' >>$strfile | |
752 | echo "</PRE>" >>$strfile | |
753 | fail=`expr $fail + 1` | |
754 | else | |
755 | echo "PASS: $count alert messages." | |
756 | echo "<P>PASS: $count alert messages.</P>" >>$strfile | |
757 | fi | |
758 | ||
759 | # Critical log messages | |
760 | count=`$GREP '^C ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'` | |
761 | if test $count != 0; then | |
762 | echo "FAIL: $count critical messages, expected 0." | |
763 | $GREP '^C ' /tmp/cups-$user/log/error_log | |
764 | echo "<P>FAIL: $count critical messages, expected 0.</P>" >>$strfile | |
765 | echo "<PRE>" >>$strfile | |
766 | $GREP '^C ' /tmp/cups-$user/log/error_log | sed -e '1,$s/&/&/g' -e '1,$s/</</g' >>$strfile | |
767 | echo "</PRE>" >>$strfile | |
768 | fail=`expr $fail + 1` | |
769 | else | |
770 | echo "PASS: $count critical messages." | |
771 | echo "<P>PASS: $count critical messages.</P>" >>$strfile | |
772 | fi | |
773 | ||
774 | # Error log messages | |
775 | count=`$GREP '^E ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'` | |
776 | if test $count != 18; then | |
777 | echo "FAIL: $count error messages, expected 18." | |
778 | $GREP '^E ' /tmp/cups-$user/log/error_log | |
779 | echo "<P>FAIL: $count error messages, expected 18.</P>" >>$strfile | |
780 | echo "<PRE>" >>$strfile | |
781 | $GREP '^E ' /tmp/cups-$user/log/error_log | sed -e '1,$s/&/&/g' -e '1,$s/</</g' >>$strfile | |
782 | echo "</PRE>" >>$strfile | |
783 | fail=`expr $fail + 1` | |
784 | else | |
785 | echo "PASS: $count error messages." | |
786 | echo "<P>PASS: $count error messages.</P>" >>$strfile | |
787 | fi | |
788 | ||
789 | # Warning log messages | |
790 | count=`$GREP '^W ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'` | |
791 | if test $count != 9; then | |
792 | echo "FAIL: $count warning messages, expected 9." | |
793 | $GREP '^W ' /tmp/cups-$user/log/error_log | |
794 | echo "<P>FAIL: $count warning messages, expected 9.</P>" >>$strfile | |
795 | echo "<PRE>" >>$strfile | |
796 | $GREP '^W ' /tmp/cups-$user/log/error_log | sed -e '1,$s/&/&/g' -e '1,$s/</</g' >>$strfile | |
797 | echo "</PRE>" >>$strfile | |
798 | fail=`expr $fail + 1` | |
799 | else | |
800 | echo "PASS: $count warning messages." | |
801 | echo "<P>PASS: $count warning messages.</P>" >>$strfile | |
802 | fi | |
803 | ||
804 | # Notice log messages | |
805 | count=`$GREP '^N ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'` | |
806 | if test $count != 0; then | |
807 | echo "FAIL: $count notice messages, expected 0." | |
808 | $GREP '^N ' /tmp/cups-$user/log/error_log | |
809 | echo "<P>FAIL: $count notice messages, expected 0.</P>" >>$strfile | |
810 | echo "<PRE>" >>$strfile | |
811 | $GREP '^N ' /tmp/cups-$user/log/error_log | sed -e '1,$s/&/&/g' -e '1,$s/</</g' >>$strfile | |
812 | echo "</PRE>" >>$strfile | |
813 | fail=`expr $fail + 1` | |
814 | else | |
815 | echo "PASS: $count notice messages." | |
816 | echo "<P>PASS: $count notice messages.</P>" >>$strfile | |
817 | fi | |
818 | ||
819 | # Info log messages | |
820 | count=`$GREP '^I ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'` | |
821 | if test $count = 0; then | |
822 | echo "FAIL: $count info messages, expected more than 0." | |
823 | echo "<P>FAIL: $count info messages, expected more than 0.</P>" >>$strfile | |
824 | fail=`expr $fail + 1` | |
825 | else | |
826 | echo "PASS: $count info messages." | |
827 | echo "<P>PASS: $count info messages.</P>" >>$strfile | |
828 | fi | |
829 | ||
830 | # Debug log messages | |
831 | count=`$GREP '^D ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'` | |
832 | if test $count = 0; then | |
833 | echo "FAIL: $count debug messages, expected more than 0." | |
834 | echo "<P>FAIL: $count debug messages, expected more than 0.</P>" >>$strfile | |
835 | fail=`expr $fail + 1` | |
836 | else | |
837 | echo "PASS: $count debug messages." | |
838 | echo "<P>PASS: $count debug messages.</P>" >>$strfile | |
839 | fi | |
840 | ||
841 | # Debug2 log messages | |
842 | count=`$GREP '^d ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'` | |
843 | if test $count = 0; then | |
844 | echo "FAIL: $count debug2 messages, expected more than 0." | |
845 | echo "<P>FAIL: $count debug2 messages, expected more than 0.</P>" >>$strfile | |
846 | fail=`expr $fail + 1` | |
847 | else | |
848 | echo "PASS: $count debug2 messages." | |
849 | echo "<P>PASS: $count debug2 messages.</P>" >>$strfile | |
850 | fi | |
851 | ||
852 | # Log files... | |
853 | echo "<H2>access_log</H2>" >>$strfile | |
854 | echo "<PRE>" >>$strfile | |
855 | sed -e '1,$s/&/&/g' -e '1,$s/</</g' /tmp/cups-$user/log/access_log >>$strfile | |
856 | echo "</PRE>" >>$strfile | |
857 | ||
858 | echo "<H2>error_log</H2>" >>$strfile | |
859 | echo "<PRE>" >>$strfile | |
860 | $GREP -v '^d' /tmp/cups-$user/log/error_log | sed -e '1,$s/&/&/g' -e '1,$s/</</g' >>$strfile | |
861 | echo "</PRE>" >>$strfile | |
862 | ||
863 | echo "<H2>page_log</H2>" >>$strfile | |
864 | echo "<PRE>" >>$strfile | |
865 | sed -e '1,$s/&/&/g' -e '1,$s/</</g' /tmp/cups-$user/log/page_log >>$strfile | |
866 | echo "</PRE>" >>$strfile | |
867 | ||
868 | # | |
869 | # Format the reports and tell the user where to find them... | |
870 | # | |
871 | ||
872 | cat str-trailer.html >>$strfile | |
873 | ||
874 | echo "" | |
875 | ||
876 | if test $fail != 0; then | |
877 | echo "$fail tests failed." | |
878 | cp /tmp/cups-$user/log/error_log error_log-$date-$user | |
879 | cp $strfile . | |
880 | else | |
881 | echo "All tests were successful." | |
882 | fi | |
883 | ||
884 | echo "Log files can be found in /tmp/cups-$user/log." | |
885 | echo "A HTML report was created in $strfile." | |
886 | echo "" | |
887 | ||
888 | if test $fail != 0; then | |
889 | echo "Copies of the error_log and `basename $strfile` files are in" | |
890 | echo "`pwd`." | |
891 | echo "" | |
892 | ||
893 | exit 1 | |
894 | fi | |
895 | ||
896 | # | |
897 | # End of "$Id: run-stp-tests.sh 9034 2010-03-09 07:03:06Z mike $" | |
898 | # |