]> git.ipfire.org Git - thirdparty/cups.git/blob - test/run-stp-tests.sh
Merge changes from CUPS 1.6svn-r10112.
[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-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 if test `uname` = Darwin; then
208 VALGRIND="$VALGRIND --dsymutil=yes"
209 fi
210 export VALGRIND
211 echo "Using Valgrind; log files can be found in /tmp/cups-$user/log..."
212 ;;
213
214 *)
215 VALGRIND=""
216 export VALGRIND
217 ;;
218 esac
219
220 #
221 # See if we want to do debug logging of the libraries...
222 #
223
224 echo ""
225 echo "If CUPS was built with the --enable-debug-printfs configure option, you"
226 echo "can enable debug logging of the libraries."
227 echo ""
228 echo $ac_n "Enter Y or a number from 0 to 9 to enable debug logging or N to not: [N] $ac_c"
229
230 if test $# -gt 0; then
231 usedebugprintfs=$1
232 shift
233 else
234 read usedebugprintfs
235 fi
236 echo ""
237
238 case "$usedebugprintfs" in
239 Y* | y*)
240 echo "Enabling debug printfs; log files can be found in /tmp/cups-$user/log..."
241 CUPS_DEBUG_LOG="/tmp/cups-$user/log/debug_printfs.%d"; export CUPS_DEBUG_LOG
242 CUPS_DEBUG_LEVEL=5; export CUPS_DEBUG_LEVEL
243 CUPS_DEBUG_FILTER='^(http|_http|ipp|_ipp|cups.*Request|cupsGetResponse|cupsSend).*$'; export CUPS_DEBUG_FILTER
244 ;;
245
246 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9)
247 echo "Enabling debug printfs; log files can be found in /tmp/cups-$user/log..."
248 CUPS_DEBUG_LOG="/tmp/cups-$user/log/debug_printfs.%d"; export CUPS_DEBUG_LOG
249 CUPS_DEBUG_LEVEL=$usedebugprintf; export CUPS_DEBUG_LEVEL
250 CUPS_DEBUG_FILTER='^(http|_http|ipp|_ipp|cups.*Request|cupsGetResponse|cupsSend).*$'; export CUPS_DEBUG_FILTER
251 ;;
252
253 *)
254 ;;
255 esac
256
257 #
258 # Start by creating temporary directories for the tests...
259 #
260
261 echo "Creating directories for test..."
262
263 rm -rf /tmp/cups-$user
264 mkdir /tmp/cups-$user
265 mkdir /tmp/cups-$user/bin
266 mkdir /tmp/cups-$user/bin/backend
267 mkdir /tmp/cups-$user/bin/driver
268 mkdir /tmp/cups-$user/bin/filter
269 mkdir /tmp/cups-$user/certs
270 mkdir /tmp/cups-$user/share
271 mkdir /tmp/cups-$user/share/banners
272 mkdir /tmp/cups-$user/share/drv
273 mkdir /tmp/cups-$user/share/locale
274 for file in ../locale/cups_*.po; do
275 loc=`basename $file .po | cut -c 6-`
276 mkdir /tmp/cups-$user/share/locale/$loc
277 ln -s $root/locale/cups_$loc.po /tmp/cups-$user/share/locale/$loc
278 ln -s $root/locale/ppdc_$loc.po /tmp/cups-$user/share/locale/$loc
279 done
280 mkdir /tmp/cups-$user/share/mime
281 mkdir /tmp/cups-$user/share/model
282 mkdir /tmp/cups-$user/share/ppdc
283 mkdir /tmp/cups-$user/interfaces
284 mkdir /tmp/cups-$user/log
285 mkdir /tmp/cups-$user/ppd
286 mkdir /tmp/cups-$user/spool
287 mkdir /tmp/cups-$user/spool/temp
288 mkdir /tmp/cups-$user/ssl
289
290 ln -s $root/backend/dnssd /tmp/cups-$user/bin/backend
291 ln -s $root/backend/http /tmp/cups-$user/bin/backend
292 ln -s $root/backend/ipp /tmp/cups-$user/bin/backend
293 ln -s $root/backend/lpd /tmp/cups-$user/bin/backend
294 ln -s $root/backend/mdns /tmp/cups-$user/bin/backend
295 ln -s $root/backend/pseudo /tmp/cups-$user/bin/backend
296 ln -s $root/backend/snmp /tmp/cups-$user/bin/backend
297 ln -s $root/backend/socket /tmp/cups-$user/bin/backend
298 ln -s $root/backend/usb /tmp/cups-$user/bin/backend
299 ln -s $root/cgi-bin /tmp/cups-$user/bin
300 ln -s $root/monitor /tmp/cups-$user/bin
301 ln -s $root/notifier /tmp/cups-$user/bin
302 ln -s $root/scheduler /tmp/cups-$user/bin/daemon
303 ln -s $root/filter/commandtops /tmp/cups-$user/bin/filter
304 ln -s $root/filter/gziptoany /tmp/cups-$user/bin/filter
305 ln -s $root/filter/pstops /tmp/cups-$user/bin/filter
306 ln -s $root/filter/rastertoepson /tmp/cups-$user/bin/filter
307 ln -s $root/filter/rastertohp /tmp/cups-$user/bin/filter
308 ln -s $root/filter/rastertolabel /tmp/cups-$user/bin/filter
309 ln -s $root/filter/rastertopwg /tmp/cups-$user/bin/filter
310
311 ln -s $root/data/classified /tmp/cups-$user/share/banners
312 ln -s $root/data/confidential /tmp/cups-$user/share/banners
313 ln -s $root/data/secret /tmp/cups-$user/share/banners
314 ln -s $root/data/standard /tmp/cups-$user/share/banners
315 ln -s $root/data/topsecret /tmp/cups-$user/share/banners
316 ln -s $root/data/unclassified /tmp/cups-$user/share/banners
317 ln -s $root/data /tmp/cups-$user/share
318 ln -s $root/ppdc/sample.drv /tmp/cups-$user/share/drv
319 ln -s $root/conf/mime.types /tmp/cups-$user/share/mime
320 ln -s $root/conf/mime.convs /tmp/cups-$user/share/mime
321 ln -s $root/data/*.h /tmp/cups-$user/share/ppdc
322 ln -s $root/data/*.defs /tmp/cups-$user/share/ppdc
323 ln -s $root/templates /tmp/cups-$user/share
324
325 #
326 # Mac OS X filters and configuration files...
327 #
328
329 if test `uname` = Darwin; then
330 ln -s /usr/libexec/cups/filter/cgpdfto* /tmp/cups-$user/bin/filter
331 ln -s /usr/libexec/cups/filter/cgbannertopdf /tmp/cups-$user/bin/filter
332 ln -s /usr/libexec/cups/filter/cgimagetopdf /tmp/cups-$user/bin/filter
333 ln -s /usr/libexec/cups/filter/cgtexttopdf /tmp/cups-$user/bin/filter
334 ln -s /usr/libexec/cups/filter/nsimagetopdf /tmp/cups-$user/bin/filter
335 ln -s /usr/libexec/cups/filter/nstexttopdf /tmp/cups-$user/bin/filter
336 ln -s /usr/libexec/cups/filter/pictwpstops /tmp/cups-$user/bin/filter
337 ln -s /usr/libexec/cups/filter/pstoappleps /tmp/cups-$user/bin/filter
338 ln -s /usr/libexec/cups/filter/pstocupsraster /tmp/cups-$user/bin/filter
339 ln -s /usr/libexec/cups/filter/pstopdffilter /tmp/cups-$user/bin/filter
340 ln -s /usr/libexec/cups/filter/rastertourf /tmp/cups-$user/bin/filter
341 ln -s /usr/libexec/cups/filter/xhtmltopdf /tmp/cups-$user/bin/filter
342
343 if test -f /private/etc/cups/apple.types; then
344 ln -s /private/etc/cups/apple.* /tmp/cups-$user/share/mime
345 elif test -f /usr/share/cups/mime/apple.types; then
346 ln -s /usr/share/cups/mime/apple.* /tmp/cups-$user/share/mime
347 fi
348 else
349 ln -s /usr/lib/cups/filter/bannertops /tmp/cups-$user/bin/filter
350 ln -s /usr/lib/cups/filter/imagetops /tmp/cups-$user/bin/filter
351 ln -s /usr/lib/cups/filter/imagetoraster /tmp/cups-$user/bin/filter
352 ln -s /usr/lib/cups/filter/pdftops /tmp/cups-$user/bin/filter
353 ln -s /usr/lib/cups/filter/texttops /tmp/cups-$user/bin/filter
354
355 ln -s /usr/share/cups/mime/legacy.convs /tmp/cups-$user/share/mime
356 fi
357
358 #
359 # Then create the necessary config files...
360 #
361
362 echo "Creating cupsd.conf for test..."
363
364 if test $ssltype = 2; then
365 encryption="Encryption Required"
366 else
367 encryption=""
368 fi
369
370 cat >/tmp/cups-$user/cupsd.conf <<EOF
371 Browsing Off
372 FileDevice yes
373 Printcap
374 Listen 127.0.0.1:$port
375 User $user
376 ServerRoot /tmp/cups-$user
377 StateDir /tmp/cups-$user
378 ServerBin /tmp/cups-$user/bin
379 CacheDir /tmp/cups-$user/share
380 DataDir /tmp/cups-$user/share
381 FontPath /tmp/cups-$user/share/fonts
382 PassEnv LOCALEDIR
383 PassEnv DYLD_INSERT_LIBRARIES
384 DocumentRoot $root/doc
385 RequestRoot /tmp/cups-$user/spool
386 TempDir /tmp/cups-$user/spool/temp
387 MaxSubscriptions 3
388 MaxLogSize 0
389 AccessLog /tmp/cups-$user/log/access_log
390 ErrorLog /tmp/cups-$user/log/error_log
391 PageLog /tmp/cups-$user/log/page_log
392 AccessLogLevel actions
393 LogLevel debug2
394 LogTimeFormat usecs
395 PreserveJobHistory Yes
396 <Policy default>
397 <Limit All>
398 Order Deny,Allow
399 Deny from all
400 Allow from 127.0.0.1
401 $encryption
402 </Limit>
403 </Policy>
404 EOF
405
406 #
407 # Setup lots of test queues - half with PPD files, half without...
408 #
409
410 echo "Creating printers.conf for test..."
411
412 i=1
413 while test $i -le $nprinters1; do
414 cat >>/tmp/cups-$user/printers.conf <<EOF
415 <Printer test-$i>
416 Accepting Yes
417 DeviceURI file:/dev/null
418 Info Test PS printer $i
419 JobSheets none none
420 Location CUPS test suite
421 State Idle
422 StateMessage Printer $1 is idle.
423 </Printer>
424 EOF
425
426 cp testps.ppd /tmp/cups-$user/ppd/test-$i.ppd
427
428 i=`expr $i + 1`
429 done
430
431 while test $i -le $nprinters2; do
432 cat >>/tmp/cups-$user/printers.conf <<EOF
433 <Printer test-$i>
434 Accepting Yes
435 DeviceURI file:/dev/null
436 Info Test raw printer $i
437 JobSheets none none
438 Location CUPS test suite
439 State Idle
440 StateMessage Printer $1 is idle.
441 </Printer>
442 EOF
443
444 i=`expr $i + 1`
445 done
446
447 if test -f /tmp/cups-$user/printers.conf; then
448 cp /tmp/cups-$user/printers.conf /tmp/cups-$user/printers.conf.orig
449 else
450 touch /tmp/cups-$user/printers.conf.orig
451 fi
452
453 #
454 # Setup the paths...
455 #
456
457 echo "Setting up environment variables for test..."
458
459 if test "x$LD_LIBRARY_PATH" = x; then
460 LD_LIBRARY_PATH="$root/cups:$root/filter:$root/cgi-bin:$root/scheduler:$root/driver:$root/ppdc"
461 else
462 LD_LIBRARY_PATH="$root/cups:$root/filter:$root/cgi-bin:$root/scheduler:$root/driver:$root/ppdc:$LD_LIBRARY_PATH"
463 fi
464
465 export LD_LIBRARY_PATH
466
467 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"
468 if test `uname` = SunOS -a -r /usr/lib/libCrun.so.1; then
469 LD_PRELOAD="/usr/lib/libCrun.so.1:$LD_PRELOAD"
470 fi
471 export LD_PRELOAD
472
473 if test "x$DYLD_LIBRARY_PATH" = x; then
474 DYLD_LIBRARY_PATH="$root/cups:$root/filter:$root/cgi-bin:$root/scheduler:$root/driver:$root/ppdc"
475 else
476 DYLD_LIBRARY_PATH="$root/cups:$root/filter:$root/cgi-bin:$root/scheduler:$root/driver:$root/ppdc:$DYLD_LIBRARY_PATH"
477 fi
478
479 export DYLD_LIBRARY_PATH
480
481 if test "x$SHLIB_PATH" = x; then
482 SHLIB_PATH="$root/cups:$root/filter:$root/cgi-bin:$root/scheduler:$root/driver:$root/ppdc"
483 else
484 SHLIB_PATH="$root/cups:$root/filter:$root/cgi-bin:$root/scheduler:$root/driver:$root/ppdc:$SHLIB_PATH"
485 fi
486
487 export SHLIB_PATH
488
489 CUPS_DISABLE_APPLE_DEFAULT=yes; export CUPS_DISABLE_APPLE_DEFAULT
490 CUPS_SERVER=localhost:8631; export CUPS_SERVER
491 CUPS_SERVERROOT=/tmp/cups-$user; export CUPS_SERVERROOT
492 CUPS_STATEDIR=/tmp/cups-$user; export CUPS_STATEDIR
493 CUPS_DATADIR=/tmp/cups-$user/share; export CUPS_DATADIR
494 LOCALEDIR=/tmp/cups-$user/share/locale; export LOCALEDIR
495
496 #
497 # Set a new home directory to avoid getting user options mixed in...
498 #
499
500 HOME=/tmp/cups-$user
501 export HOME
502
503 #
504 # Force POSIX locale for tests...
505 #
506
507 LANG=C
508 export LANG
509
510 LC_MESSAGES=C
511 export LC_MESSAGES
512
513 #
514 # Start the server; run as foreground daemon in the background...
515 #
516
517 echo "Starting scheduler:"
518 echo " $VALGRIND ../scheduler/cupsd -c /tmp/cups-$user/cupsd.conf -f >/tmp/cups-$user/log/debug_log 2>&1 &"
519 echo ""
520
521 if test `uname` = Darwin -a "x$VALGRIND" = x; then
522 DYLD_INSERT_LIBRARIES=/usr/lib/libgmalloc.dylib
523 ../scheduler/cupsd -c /tmp/cups-$user/cupsd.conf -f >/tmp/cups-$user/log/debug_log 2>&1 &
524 else
525 $VALGRIND ../scheduler/cupsd -c /tmp/cups-$user/cupsd.conf -f >/tmp/cups-$user/log/debug_log 2>&1 &
526 fi
527
528 cupsd=$!
529
530 if test "x$testtype" = x0; then
531 # Not running tests...
532 echo "Scheduler is PID $cupsd and is listening on port 8631."
533 echo ""
534
535 # Create a helper script to run programs with...
536 runcups="/tmp/cups-$user/runcups"
537
538 echo "#!/bin/sh" >$runcups
539 echo "# Helper script for running CUPS test instance." >>$runcups
540 echo "" >>$runcups
541 echo "# Set required environment variables..." >>$runcups
542 echo "CUPS_DATADIR=\"$CUPS_DATADIR\"; export CUPS_DATADIR" >>$runcups
543 echo "CUPS_SERVER=\"$CUPS_SERVER\"; export CUPS_SERVER" >>$runcups
544 echo "CUPS_SERVERROOT=\"$CUPS_SERVERROOT\"; export CUPS_SERVERROOT" >>$runcups
545 echo "CUPS_STATEDIR=\"$CUPS_STATEDIR\"; export CUPS_STATEDIR" >>$runcups
546 echo "DYLD_LIBRARY_PATH=\"$DYLD_LIBRARY_PATH\"; export DYLD_LIBRARY_PATH" >>$runcups
547 echo "LD_LIBRARY_PATH=\"$LD_LIBRARY_PATH\"; export LD_LIBRARY_PATH" >>$runcups
548 echo "LD_PRELOAD=\"$LD_PRELOAD\"; export LD_PRELOAD" >>$runcups
549 echo "LOCALEDIR=\"$LOCALEDIR\"; export LOCALEDIR" >>$runcups
550 echo "SHLIB_PATH=\"$SHLIB_PATH\"; export SHLIB_PATH" >>$runcups
551 echo "" >>$runcups
552 echo "# Run command..." >>$runcups
553 echo "exec \"\$@\"" >>$runcups
554
555 chmod +x $runcups
556
557 echo "The $runcups helper script can be used to test programs"
558 echo "with the server."
559 exit 0
560 fi
561
562 if test $argcount -eq 0; then
563 echo "Scheduler is PID $cupsd; run debugger now if you need to."
564 echo ""
565 echo $ac_n "Press ENTER to continue... $ac_c"
566 read junk
567 else
568 echo "Scheduler is PID $cupsd."
569 sleep 2
570 fi
571
572 IPP_PORT=$port; export IPP_PORT
573
574 while true; do
575 running=`../systemv/lpstat -r 2>/dev/null`
576 if test "x$running" = "xscheduler is running"; then
577 break
578 fi
579
580 echo "Waiting for scheduler to become ready..."
581 sleep 10
582 done
583
584 #
585 # Create the test report source file...
586 #
587
588 date=`date "+%Y-%m-%d"`
589 strfile=/tmp/cups-$user/cups-str-1.6-$date-$user.html
590
591 rm -f $strfile
592 cat str-header.html >$strfile
593
594 #
595 # Run the IPP tests...
596 #
597
598 echo ""
599 echo "Running IPP compliance tests..."
600
601 echo "<H1>1 - IPP Compliance Tests</H1>" >>$strfile
602 echo "<P>This section provides the results to the IPP compliance tests" >>$strfile
603 echo "outlined in the CUPS Software Test Plan. These tests were run on" >>$strfile
604 echo `date "+%Y-%m-%d"` by $user on `hostname`. >>$strfile
605 echo "<PRE>" >>$strfile
606
607 fail=0
608 for file in 4*.test; do
609 echo $ac_n "Performing $file: $ac_c"
610 echo "" >>$strfile
611
612 $VALGRIND ./ipptool -tI ipp://localhost:$port/printers $file >> $strfile
613 status=$?
614
615 if test $status != 0; then
616 echo FAIL
617 fail=`expr $fail + 1`
618 else
619 echo PASS
620 fi
621 done
622
623 echo "</PRE>" >>$strfile
624
625 #
626 # Run the command tests...
627 #
628
629 echo ""
630 echo "Running command tests..."
631
632 echo "<H1>2 - Command Tests</H1>" >>$strfile
633 echo "<P>This section provides the results to the command tests" >>$strfile
634 echo "outlined in the CUPS Software Test Plan. These tests were run on" >>$strfile
635 echo $date by $user on `hostname`. >>$strfile
636 echo "<PRE>" >>$strfile
637
638 for file in 5*.sh; do
639 echo $ac_n "Performing $file: $ac_c"
640 echo "" >>$strfile
641 echo "\"$file\":" >>$strfile
642
643 sh $file $pjobs $pprinters >> $strfile
644 status=$?
645
646 if test $status != 0; then
647 echo FAIL
648 fail=`expr $fail + 1`
649 else
650 echo PASS
651 fi
652 done
653
654 echo "</PRE>" >>$strfile
655
656 #
657 # Stop the server...
658 #
659
660 kill $cupsd
661
662 #
663 # Append the log files for post-mortim...
664 #
665
666 echo "<H1>3 - Log Files</H1>" >>$strfile
667
668 #
669 # Verify counts...
670 #
671
672 echo "Test Summary"
673 echo ""
674 echo "<H2>Summary</H2>" >>$strfile
675
676 # Job control files
677 count=`ls -1 /tmp/cups-$user/spool | wc -l`
678 count=`expr $count - 1`
679 if test $count != 0; then
680 echo "FAIL: $count job control files were not purged."
681 echo "<P>FAIL: $count job control files were not purged.</P>" >>$strfile
682 fail=`expr $fail + 1`
683 else
684 echo "PASS: All job control files purged."
685 echo "<P>PASS: All job control files purged.</P>" >>$strfile
686 fi
687
688 # Pages printed on Test1 (within 1 page for timing-dependent cancel issues)
689 count=`$GREP '^Test1 ' /tmp/cups-$user/log/page_log | awk 'BEGIN{count=0}{count=count+$7}END{print count}'`
690 expected=`expr $pjobs \* 2 + 34`
691 expected2=`expr $expected + 2`
692 if test $count -lt $expected -a $count -gt $expected2; then
693 echo "FAIL: Printer 'Test1' produced $count page(s), expected $expected."
694 echo "<P>FAIL: Printer 'Test1' produced $count page(s), expected $expected.</P>" >>$strfile
695 fail=`expr $fail + 1`
696 else
697 echo "PASS: Printer 'Test1' correctly produced $count page(s)."
698 echo "<P>PASS: Printer 'Test1' correctly produced $count page(s).</P>" >>$strfile
699 fi
700
701 # Paged printed on Test2
702 count=`$GREP '^Test2 ' /tmp/cups-$user/log/page_log | awk 'BEGIN{count=0}{count=count+$7}END{print count}'`
703 expected=`expr $pjobs \* 2 + 3`
704 if test $count != $expected; then
705 echo "FAIL: Printer 'Test2' produced $count page(s), expected $expected."
706 echo "<P>FAIL: Printer 'Test2' produced $count page(s), expected $expected.</P>" >>$strfile
707 fail=`expr $fail + 1`
708 else
709 echo "PASS: Printer 'Test2' correctly produced $count page(s)."
710 echo "<P>PASS: Printer 'Test2' correctly produced $count page(s).</P>" >>$strfile
711 fi
712
713 # Requests logged
714 count=`wc -l /tmp/cups-$user/log/access_log | awk '{print $1}'`
715 expected=`expr 37 + 18 + $pjobs \* 8 + $pprinters \* $pjobs \* 4`
716 if test $count != $expected; then
717 echo "FAIL: $count requests logged, expected $expected."
718 echo "<P>FAIL: $count requests logged, expected $expected.</P>" >>$strfile
719 fail=`expr $fail + 1`
720 else
721 echo "PASS: $count requests logged."
722 echo "<P>PASS: $count requests logged.</P>" >>$strfile
723 fi
724
725 # Did CUPS-Get-Default get logged?
726 if $GREP -q CUPS-Get-Default /tmp/cups-$user/log/access_log; then
727 echo "FAIL: CUPS-Get-Default logged with 'AccessLogLevel actions'"
728 echo "<P>FAIL: CUPS-Get-Default logged with 'AccessLogLevel actions'</P>" >>$strfile
729 echo "<PRE>" >>$strfile
730 $GREP CUPS-Get-Default /tmp/cups-$user/log/access_log | sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
731 echo "</PRE>" >>$strfile
732 fail=`expr $fail + 1`
733 else
734 echo "PASS: CUPS-Get-Default not logged."
735 echo "<P>PASS: CUPS-Get-Default not logged.</P>" >>$strfile
736 fi
737
738 # Emergency log messages
739 count=`$GREP '^X ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'`
740 if test $count != 0; then
741 echo "FAIL: $count emergency messages, expected 0."
742 $GREP '^X ' /tmp/cups-$user/log/error_log
743 echo "<P>FAIL: $count emergency messages, expected 0.</P>" >>$strfile
744 echo "<PRE>" >>$strfile
745 $GREP '^X ' /tmp/cups-$user/log/error_log | sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
746 echo "</PRE>" >>$strfile
747 fail=`expr $fail + 1`
748 else
749 echo "PASS: $count emergency messages."
750 echo "<P>PASS: $count emergency messages.</P>" >>$strfile
751 fi
752
753 # Alert log messages
754 count=`$GREP '^A ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'`
755 if test $count != 0; then
756 echo "FAIL: $count alert messages, expected 0."
757 $GREP '^A ' /tmp/cups-$user/log/error_log
758 echo "<P>FAIL: $count alert messages, expected 0.</P>" >>$strfile
759 echo "<PRE>" >>$strfile
760 $GREP '^A ' /tmp/cups-$user/log/error_log | sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
761 echo "</PRE>" >>$strfile
762 fail=`expr $fail + 1`
763 else
764 echo "PASS: $count alert messages."
765 echo "<P>PASS: $count alert messages.</P>" >>$strfile
766 fi
767
768 # Critical log messages
769 count=`$GREP '^C ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'`
770 if test $count != 0; then
771 echo "FAIL: $count critical messages, expected 0."
772 $GREP '^C ' /tmp/cups-$user/log/error_log
773 echo "<P>FAIL: $count critical messages, expected 0.</P>" >>$strfile
774 echo "<PRE>" >>$strfile
775 $GREP '^C ' /tmp/cups-$user/log/error_log | sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
776 echo "</PRE>" >>$strfile
777 fail=`expr $fail + 1`
778 else
779 echo "PASS: $count critical messages."
780 echo "<P>PASS: $count critical messages.</P>" >>$strfile
781 fi
782
783 # Error log messages
784 count=`$GREP '^E ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'`
785 if test $count != 18; then
786 echo "FAIL: $count error messages, expected 18."
787 $GREP '^E ' /tmp/cups-$user/log/error_log
788 echo "<P>FAIL: $count error messages, expected 18.</P>" >>$strfile
789 echo "<PRE>" >>$strfile
790 $GREP '^E ' /tmp/cups-$user/log/error_log | sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
791 echo "</PRE>" >>$strfile
792 fail=`expr $fail + 1`
793 else
794 echo "PASS: $count error messages."
795 echo "<P>PASS: $count error messages.</P>" >>$strfile
796 fi
797
798 # Warning log messages
799 count=`$GREP '^W ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'`
800 if test $count != 9; then
801 echo "FAIL: $count warning messages, expected 9."
802 $GREP '^W ' /tmp/cups-$user/log/error_log
803 echo "<P>FAIL: $count warning messages, expected 9.</P>" >>$strfile
804 echo "<PRE>" >>$strfile
805 $GREP '^W ' /tmp/cups-$user/log/error_log | sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
806 echo "</PRE>" >>$strfile
807 fail=`expr $fail + 1`
808 else
809 echo "PASS: $count warning messages."
810 echo "<P>PASS: $count warning messages.</P>" >>$strfile
811 fi
812
813 # Notice log messages
814 count=`$GREP '^N ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'`
815 if test $count != 0; then
816 echo "FAIL: $count notice messages, expected 0."
817 $GREP '^N ' /tmp/cups-$user/log/error_log
818 echo "<P>FAIL: $count notice messages, expected 0.</P>" >>$strfile
819 echo "<PRE>" >>$strfile
820 $GREP '^N ' /tmp/cups-$user/log/error_log | sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
821 echo "</PRE>" >>$strfile
822 fail=`expr $fail + 1`
823 else
824 echo "PASS: $count notice messages."
825 echo "<P>PASS: $count notice messages.</P>" >>$strfile
826 fi
827
828 # Info log messages
829 count=`$GREP '^I ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'`
830 if test $count = 0; then
831 echo "FAIL: $count info messages, expected more than 0."
832 echo "<P>FAIL: $count info messages, expected more than 0.</P>" >>$strfile
833 fail=`expr $fail + 1`
834 else
835 echo "PASS: $count info messages."
836 echo "<P>PASS: $count info messages.</P>" >>$strfile
837 fi
838
839 # Debug log messages
840 count=`$GREP '^D ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'`
841 if test $count = 0; then
842 echo "FAIL: $count debug messages, expected more than 0."
843 echo "<P>FAIL: $count debug messages, expected more than 0.</P>" >>$strfile
844 fail=`expr $fail + 1`
845 else
846 echo "PASS: $count debug messages."
847 echo "<P>PASS: $count debug messages.</P>" >>$strfile
848 fi
849
850 # Debug2 log messages
851 count=`$GREP '^d ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'`
852 if test $count = 0; then
853 echo "FAIL: $count debug2 messages, expected more than 0."
854 echo "<P>FAIL: $count debug2 messages, expected more than 0.</P>" >>$strfile
855 fail=`expr $fail + 1`
856 else
857 echo "PASS: $count debug2 messages."
858 echo "<P>PASS: $count debug2 messages.</P>" >>$strfile
859 fi
860
861 # Log files...
862 echo "<H2>access_log</H2>" >>$strfile
863 echo "<PRE>" >>$strfile
864 sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' /tmp/cups-$user/log/access_log >>$strfile
865 echo "</PRE>" >>$strfile
866
867 echo "<H2>error_log</H2>" >>$strfile
868 echo "<PRE>" >>$strfile
869 $GREP -v '^d' /tmp/cups-$user/log/error_log | sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
870 echo "</PRE>" >>$strfile
871
872 echo "<H2>page_log</H2>" >>$strfile
873 echo "<PRE>" >>$strfile
874 sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' /tmp/cups-$user/log/page_log >>$strfile
875 echo "</PRE>" >>$strfile
876
877 #
878 # Format the reports and tell the user where to find them...
879 #
880
881 cat str-trailer.html >>$strfile
882
883 echo ""
884
885 if test $fail != 0; then
886 echo "$fail tests failed."
887 cp /tmp/cups-$user/log/error_log error_log-$date-$user
888 cp $strfile .
889 else
890 echo "All tests were successful."
891 fi
892
893 echo "Log files can be found in /tmp/cups-$user/log."
894 echo "A HTML report was created in $strfile."
895 echo ""
896
897 if test $fail != 0; then
898 echo "Copies of the error_log and `basename $strfile` files are in"
899 echo "`pwd`."
900 echo ""
901
902 exit 1
903 fi
904
905 #
906 # End of "$Id: run-stp-tests.sh 9034 2010-03-09 07:03:06Z mike $"
907 #