]> git.ipfire.org Git - thirdparty/cups.git/blame_incremental - test/run-stp-tests.sh
Merge changes from CUPS 1.6svn-r9968.
[thirdparty/cups.git] / test / run-stp-tests.sh
... / ...
CommitLineData
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
18argcount=$#
19
20#
21# Make the IPP test program...
22#
23
24make
25
26#
27# Solaris has a non-POSIX grep in /bin...
28#
29
30if test -x /usr/xpg4/bin/grep; then
31 GREP=/usr/xpg4/bin/grep
32else
33 GREP=grep
34fi
35
36#
37# Figure out the proper echo options...
38#
39
40if (echo "testing\c"; echo 1,2,3) | $GREP c >/dev/null; then
41 ac_n=-n
42 ac_c=
43else
44 ac_n=
45 ac_c='\c'
46fi
47
48#
49# Greet the tester...
50#
51
52echo "Welcome to the CUPS Automated Test Script."
53echo ""
54echo "Before we begin, it is important that you understand that the larger"
55echo "tests require significant amounts of RAM and disk space. If you"
56echo "attempt to run one of the big tests on a system that lacks sufficient"
57echo "disk and virtual memory, the UNIX kernel might decide to kill one or"
58echo "more system processes that you've grown attached to, like the X"
59echo "server. The question you may want to ask yourself before running a"
60echo "large test is: Do you feel lucky?"
61echo ""
62echo "OK, now that we have the Dirty Harry quote out of the way, please"
63echo "choose the type of test you wish to perform:"
64echo ""
65echo "0 - No testing, keep the scheduler running for me (all systems)"
66echo "1 - Basic conformance test, no load testing (all systems)"
67echo "2 - Basic conformance test, some load testing (minimum 256MB VM, 50MB disk)"
68echo "3 - Basic conformance test, extreme load testing (minimum 1GB VM, 500MB disk)"
69echo "4 - Basic conformance test, torture load testing (minimum 2GB VM, 1GB disk)"
70echo ""
71echo $ac_n "Enter the number of the test you wish to perform: [1] $ac_c"
72
73if test $# -gt 0; then
74 testtype=$1
75 shift
76else
77 read testtype
78fi
79echo ""
80
81case "$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 ;;
117esac
118
119#
120# See if we want to do SSL testing...
121#
122
123echo ""
124echo "Now you can choose whether to create a SSL/TLS encryption key and"
125echo "certificate for testing; these tests currently require the OpenSSL"
126echo "tools:"
127echo ""
128echo "0 - Do not do SSL/TLS encryption tests"
129echo "1 - Test but do not require encryption"
130echo "2 - Test and require encryption"
131echo ""
132echo $ac_n "Enter the number of the SSL/TLS tests to perform: [0] $ac_c"
133
134if test $# -gt 0; then
135 ssltype=$1
136 shift
137else
138 read ssltype
139fi
140echo ""
141
142case "$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 ;;
153esac
154
155#
156# Information for the server/tests...
157#
158
159user="$USER"
160if 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
170fi
171
172port=8631
173cwd=`pwd`
174root=`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
182unset LPDEST
183unset PRINTER
184
185#
186# See if we want to use valgrind...
187#
188
189echo ""
190echo "This test script can use the Valgrind software from:"
191echo ""
192echo " http://developer.kde.org/~sewardj/"
193echo ""
194echo $ac_n "Enter Y to use Valgrind or N to not use Valgrind: [N] $ac_c"
195
196if test $# -gt 0; then
197 usevalgrind=$1
198 shift
199else
200 read usevalgrind
201fi
202echo ""
203
204case "$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 ;;
213esac
214
215#
216# See if we want to do debug logging of the libraries...
217#
218
219echo ""
220echo "If CUPS was built with the --enable-debug-printfs configure option, you"
221echo "can enable debug logging of the libraries."
222echo ""
223echo $ac_n "Enter Y or a number from 0 to 9 to enable debug logging or N to not: [N] $ac_c"
224
225if test $# -gt 0; then
226 usedebugprintfs=$1
227 shift
228else
229 read usedebugprintfs
230fi
231echo ""
232
233case "$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 ;;
250esac
251
252#
253# Start by creating temporary directories for the tests...
254#
255
256echo "Creating directories for test..."
257
258rm -rf /tmp/cups-$user
259mkdir /tmp/cups-$user
260mkdir /tmp/cups-$user/bin
261mkdir /tmp/cups-$user/bin/backend
262mkdir /tmp/cups-$user/bin/driver
263mkdir /tmp/cups-$user/bin/filter
264mkdir /tmp/cups-$user/certs
265mkdir /tmp/cups-$user/share
266mkdir /tmp/cups-$user/share/banners
267mkdir /tmp/cups-$user/share/drv
268mkdir /tmp/cups-$user/share/locale
269for 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
274done
275mkdir /tmp/cups-$user/share/mime
276mkdir /tmp/cups-$user/share/model
277mkdir /tmp/cups-$user/share/ppdc
278mkdir /tmp/cups-$user/interfaces
279mkdir /tmp/cups-$user/log
280mkdir /tmp/cups-$user/ppd
281mkdir /tmp/cups-$user/spool
282mkdir /tmp/cups-$user/spool/temp
283mkdir /tmp/cups-$user/ssl
284
285ln -s $root/backend/dnssd /tmp/cups-$user/bin/backend
286ln -s $root/backend/http /tmp/cups-$user/bin/backend
287ln -s $root/backend/ipp /tmp/cups-$user/bin/backend
288ln -s $root/backend/lpd /tmp/cups-$user/bin/backend
289ln -s $root/backend/mdns /tmp/cups-$user/bin/backend
290ln -s $root/backend/pseudo /tmp/cups-$user/bin/backend
291ln -s $root/backend/snmp /tmp/cups-$user/bin/backend
292ln -s $root/backend/socket /tmp/cups-$user/bin/backend
293ln -s $root/backend/usb /tmp/cups-$user/bin/backend
294ln -s $root/cgi-bin /tmp/cups-$user/bin
295ln -s $root/monitor /tmp/cups-$user/bin
296ln -s $root/notifier /tmp/cups-$user/bin
297ln -s $root/scheduler /tmp/cups-$user/bin/daemon
298ln -s $root/filter/commandtops /tmp/cups-$user/bin/filter
299ln -s $root/filter/gziptoany /tmp/cups-$user/bin/filter
300ln -s $root/filter/pstops /tmp/cups-$user/bin/filter
301ln -s $root/filter/rastertoepson /tmp/cups-$user/bin/filter
302ln -s $root/filter/rastertohp /tmp/cups-$user/bin/filter
303ln -s $root/filter/rastertolabel /tmp/cups-$user/bin/filter
304ln -s $root/filter/rastertopwg /tmp/cups-$user/bin/filter
305
306ln -s $root/data/classified /tmp/cups-$user/share/banners
307ln -s $root/data/confidential /tmp/cups-$user/share/banners
308ln -s $root/data/secret /tmp/cups-$user/share/banners
309ln -s $root/data/standard /tmp/cups-$user/share/banners
310ln -s $root/data/topsecret /tmp/cups-$user/share/banners
311ln -s $root/data/unclassified /tmp/cups-$user/share/banners
312ln -s $root/data /tmp/cups-$user/share
313ln -s $root/ppdc/sample.drv /tmp/cups-$user/share/drv
314ln -s $root/conf/mime.types /tmp/cups-$user/share/mime
315ln -s $root/conf/mime.convs /tmp/cups-$user/share/mime
316ln -s $root/data/*.h /tmp/cups-$user/share/ppdc
317ln -s $root/data/*.defs /tmp/cups-$user/share/ppdc
318ln -s $root/templates /tmp/cups-$user/share
319
320#
321# Mac OS X filters and configuration files...
322#
323
324if 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
343else
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
351fi
352
353#
354# Then create the necessary config files...
355#
356
357echo "Creating cupsd.conf for test..."
358
359if test $ssltype = 2; then
360 encryption="Encryption Required"
361else
362 encryption=""
363fi
364
365cat >/tmp/cups-$user/cupsd.conf <<EOF
366Browsing Off
367FileDevice yes
368Printcap
369Listen 127.0.0.1:$port
370User $user
371ServerRoot /tmp/cups-$user
372StateDir /tmp/cups-$user
373ServerBin /tmp/cups-$user/bin
374CacheDir /tmp/cups-$user/share
375DataDir /tmp/cups-$user/share
376FontPath /tmp/cups-$user/share/fonts
377PassEnv LOCALEDIR
378PassEnv DYLD_INSERT_LIBRARIES
379DocumentRoot $root/doc
380RequestRoot /tmp/cups-$user/spool
381TempDir /tmp/cups-$user/spool/temp
382MaxSubscriptions 3
383MaxLogSize 0
384AccessLog /tmp/cups-$user/log/access_log
385ErrorLog /tmp/cups-$user/log/error_log
386PageLog /tmp/cups-$user/log/page_log
387AccessLogLevel actions
388LogLevel debug2
389LogTimeFormat usecs
390PreserveJobHistory Yes
391<Policy default>
392<Limit All>
393Order Deny,Allow
394Deny from all
395Allow from 127.0.0.1
396$encryption
397</Limit>
398</Policy>
399EOF
400
401#
402# Setup lots of test queues - half with PPD files, half without...
403#
404
405echo "Creating printers.conf for test..."
406
407i=1
408while test $i -le $nprinters1; do
409 cat >>/tmp/cups-$user/printers.conf <<EOF
410<Printer test-$i>
411Accepting Yes
412DeviceURI file:/dev/null
413Info Test PS printer $i
414JobSheets none none
415Location CUPS test suite
416State Idle
417StateMessage Printer $1 is idle.
418</Printer>
419EOF
420
421 cp testps.ppd /tmp/cups-$user/ppd/test-$i.ppd
422
423 i=`expr $i + 1`
424done
425
426while test $i -le $nprinters2; do
427 cat >>/tmp/cups-$user/printers.conf <<EOF
428<Printer test-$i>
429Accepting Yes
430DeviceURI file:/dev/null
431Info Test raw printer $i
432JobSheets none none
433Location CUPS test suite
434State Idle
435StateMessage Printer $1 is idle.
436</Printer>
437EOF
438
439 i=`expr $i + 1`
440done
441
442if test -f /tmp/cups-$user/printers.conf; then
443 cp /tmp/cups-$user/printers.conf /tmp/cups-$user/printers.conf.orig
444else
445 touch /tmp/cups-$user/printers.conf.orig
446fi
447
448#
449# Setup the paths...
450#
451
452echo "Setting up environment variables for test..."
453
454if test "x$LD_LIBRARY_PATH" = x; then
455 LD_LIBRARY_PATH="$root/cups:$root/filter:$root/cgi-bin:$root/scheduler:$root/driver:$root/ppdc"
456else
457 LD_LIBRARY_PATH="$root/cups:$root/filter:$root/cgi-bin:$root/scheduler:$root/driver:$root/ppdc:$LD_LIBRARY_PATH"
458fi
459
460export LD_LIBRARY_PATH
461
462LD_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"
463if test `uname` = SunOS -a -r /usr/lib/libCrun.so.1; then
464 LD_PRELOAD="/usr/lib/libCrun.so.1:$LD_PRELOAD"
465fi
466export LD_PRELOAD
467
468if test "x$DYLD_LIBRARY_PATH" = x; then
469 DYLD_LIBRARY_PATH="$root/cups:$root/filter:$root/cgi-bin:$root/scheduler:$root/driver:$root/ppdc"
470else
471 DYLD_LIBRARY_PATH="$root/cups:$root/filter:$root/cgi-bin:$root/scheduler:$root/driver:$root/ppdc:$DYLD_LIBRARY_PATH"
472fi
473
474export DYLD_LIBRARY_PATH
475
476if test "x$SHLIB_PATH" = x; then
477 SHLIB_PATH="$root/cups:$root/filter:$root/cgi-bin:$root/scheduler:$root/driver:$root/ppdc"
478else
479 SHLIB_PATH="$root/cups:$root/filter:$root/cgi-bin:$root/scheduler:$root/driver:$root/ppdc:$SHLIB_PATH"
480fi
481
482export SHLIB_PATH
483
484CUPS_DISABLE_APPLE_DEFAULT=yes; export CUPS_DISABLE_APPLE_DEFAULT
485CUPS_SERVER=localhost:8631; export CUPS_SERVER
486CUPS_SERVERROOT=/tmp/cups-$user; export CUPS_SERVERROOT
487CUPS_STATEDIR=/tmp/cups-$user; export CUPS_STATEDIR
488CUPS_DATADIR=/tmp/cups-$user/share; export CUPS_DATADIR
489LOCALEDIR=/tmp/cups-$user/share/locale; export LOCALEDIR
490
491#
492# Set a new home directory to avoid getting user options mixed in...
493#
494
495HOME=/tmp/cups-$user
496export HOME
497
498#
499# Force POSIX locale for tests...
500#
501
502LANG=C
503export LANG
504
505LC_MESSAGES=C
506export LC_MESSAGES
507
508#
509# Start the server; run as foreground daemon in the background...
510#
511
512echo "Starting scheduler:"
513echo " $valgrind ../scheduler/cupsd -c /tmp/cups-$user/cupsd.conf -f >/tmp/cups-$user/log/debug_log 2>&1 &"
514echo ""
515
516if 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 &
519else
520 $valgrind ../scheduler/cupsd -c /tmp/cups-$user/cupsd.conf -f >/tmp/cups-$user/log/debug_log 2>&1 &
521fi
522
523cupsd=$!
524
525if 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
555fi
556
557if 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
562else
563 echo "Scheduler is PID $cupsd."
564 sleep 2
565fi
566
567IPP_PORT=$port; export IPP_PORT
568
569while 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
577done
578
579#
580# Create the test report source file...
581#
582
583date=`date "+%Y-%m-%d"`
584strfile=/tmp/cups-$user/cups-str-1.6-$date-$user.html
585
586rm -f $strfile
587cat str-header.html >$strfile
588
589#
590# Run the IPP tests...
591#
592
593echo ""
594echo "Running IPP compliance tests..."
595
596echo "<H1>1 - IPP Compliance Tests</H1>" >>$strfile
597echo "<P>This section provides the results to the IPP compliance tests" >>$strfile
598echo "outlined in the CUPS Software Test Plan. These tests were run on" >>$strfile
599echo `date "+%Y-%m-%d"` by $user on `hostname`. >>$strfile
600echo "<PRE>" >>$strfile
601
602fail=0
603for 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
614done
615
616echo "</PRE>" >>$strfile
617
618#
619# Run the command tests...
620#
621
622echo ""
623echo "Running command tests..."
624
625echo "<H1>2 - Command Tests</H1>" >>$strfile
626echo "<P>This section provides the results to the command tests" >>$strfile
627echo "outlined in the CUPS Software Test Plan. These tests were run on" >>$strfile
628echo $date by $user on `hostname`. >>$strfile
629echo "<PRE>" >>$strfile
630
631for 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
643done
644
645echo "</PRE>" >>$strfile
646
647#
648# Stop the server...
649#
650
651kill $cupsd
652
653#
654# Append the log files for post-mortim...
655#
656
657echo "<H1>3 - Log Files</H1>" >>$strfile
658
659#
660# Verify counts...
661#
662
663echo "Test Summary"
664echo ""
665echo "<H2>Summary</H2>" >>$strfile
666
667# Job control files
668count=`ls -1 /tmp/cups-$user/spool | wc -l`
669count=`expr $count - 1`
670if 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`
674else
675 echo "PASS: All job control files purged."
676 echo "<P>PASS: All job control files purged.</P>" >>$strfile
677fi
678
679# Pages printed on Test1 (within 1 page for timing-dependent cancel issues)
680count=`$GREP '^Test1 ' /tmp/cups-$user/log/page_log | awk 'BEGIN{count=0}{count=count+$7}END{print count}'`
681expected=`expr $pjobs \* 2 + 34`
682expected2=`expr $expected + 2`
683if 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`
687else
688 echo "PASS: Printer 'Test1' correctly produced $count page(s)."
689 echo "<P>PASS: Printer 'Test1' correctly produced $count page(s).</P>" >>$strfile
690fi
691
692# Paged printed on Test2
693count=`$GREP '^Test2 ' /tmp/cups-$user/log/page_log | awk 'BEGIN{count=0}{count=count+$7}END{print count}'`
694expected=`expr $pjobs \* 2 + 3`
695if 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`
699else
700 echo "PASS: Printer 'Test2' correctly produced $count page(s)."
701 echo "<P>PASS: Printer 'Test2' correctly produced $count page(s).</P>" >>$strfile
702fi
703
704# Requests logged
705count=`wc -l /tmp/cups-$user/log/access_log | awk '{print $1}'`
706expected=`expr 37 + 18 + $pjobs \* 8 + $pprinters \* $pjobs \* 4`
707if 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`
711else
712 echo "PASS: $count requests logged."
713 echo "<P>PASS: $count requests logged.</P>" >>$strfile
714fi
715
716# Did CUPS-Get-Default get logged?
717if $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/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
722 echo "</PRE>" >>$strfile
723 fail=`expr $fail + 1`
724else
725 echo "PASS: CUPS-Get-Default not logged."
726 echo "<P>PASS: CUPS-Get-Default not logged.</P>" >>$strfile
727fi
728
729# Emergency log messages
730count=`$GREP '^X ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'`
731if 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/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
737 echo "</PRE>" >>$strfile
738 fail=`expr $fail + 1`
739else
740 echo "PASS: $count emergency messages."
741 echo "<P>PASS: $count emergency messages.</P>" >>$strfile
742fi
743
744# Alert log messages
745count=`$GREP '^A ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'`
746if 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/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
752 echo "</PRE>" >>$strfile
753 fail=`expr $fail + 1`
754else
755 echo "PASS: $count alert messages."
756 echo "<P>PASS: $count alert messages.</P>" >>$strfile
757fi
758
759# Critical log messages
760count=`$GREP '^C ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'`
761if 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/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
767 echo "</PRE>" >>$strfile
768 fail=`expr $fail + 1`
769else
770 echo "PASS: $count critical messages."
771 echo "<P>PASS: $count critical messages.</P>" >>$strfile
772fi
773
774# Error log messages
775count=`$GREP '^E ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'`
776if 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/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
782 echo "</PRE>" >>$strfile
783 fail=`expr $fail + 1`
784else
785 echo "PASS: $count error messages."
786 echo "<P>PASS: $count error messages.</P>" >>$strfile
787fi
788
789# Warning log messages
790count=`$GREP '^W ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'`
791if 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/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
797 echo "</PRE>" >>$strfile
798 fail=`expr $fail + 1`
799else
800 echo "PASS: $count warning messages."
801 echo "<P>PASS: $count warning messages.</P>" >>$strfile
802fi
803
804# Notice log messages
805count=`$GREP '^N ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'`
806if 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/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
812 echo "</PRE>" >>$strfile
813 fail=`expr $fail + 1`
814else
815 echo "PASS: $count notice messages."
816 echo "<P>PASS: $count notice messages.</P>" >>$strfile
817fi
818
819# Info log messages
820count=`$GREP '^I ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'`
821if 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`
825else
826 echo "PASS: $count info messages."
827 echo "<P>PASS: $count info messages.</P>" >>$strfile
828fi
829
830# Debug log messages
831count=`$GREP '^D ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'`
832if 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`
836else
837 echo "PASS: $count debug messages."
838 echo "<P>PASS: $count debug messages.</P>" >>$strfile
839fi
840
841# Debug2 log messages
842count=`$GREP '^d ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'`
843if 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`
847else
848 echo "PASS: $count debug2 messages."
849 echo "<P>PASS: $count debug2 messages.</P>" >>$strfile
850fi
851
852# Log files...
853echo "<H2>access_log</H2>" >>$strfile
854echo "<PRE>" >>$strfile
855sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' /tmp/cups-$user/log/access_log >>$strfile
856echo "</PRE>" >>$strfile
857
858echo "<H2>error_log</H2>" >>$strfile
859echo "<PRE>" >>$strfile
860$GREP -v '^d' /tmp/cups-$user/log/error_log | sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
861echo "</PRE>" >>$strfile
862
863echo "<H2>page_log</H2>" >>$strfile
864echo "<PRE>" >>$strfile
865sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' /tmp/cups-$user/log/page_log >>$strfile
866echo "</PRE>" >>$strfile
867
868#
869# Format the reports and tell the user where to find them...
870#
871
872cat str-trailer.html >>$strfile
873
874echo ""
875
876if test $fail != 0; then
877 echo "$fail tests failed."
878 cp /tmp/cups-$user/log/error_log error_log-$date-$user
879 cp $strfile .
880else
881 echo "All tests were successful."
882fi
883
884echo "Log files can be found in /tmp/cups-$user/log."
885echo "A HTML report was created in $strfile."
886echo ""
887
888if 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
894fi
895
896#
897# End of "$Id: run-stp-tests.sh 9034 2010-03-09 07:03:06Z mike $"
898#