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