]> git.ipfire.org Git - thirdparty/cups.git/blame - test/run-stp-tests.sh
Merge changes from CUPS 1.5svn-r9567
[thirdparty/cups.git] / test / run-stp-tests.sh
CommitLineData
ef416fc2 1#!/bin/sh
2#
a480a1b6 3# "$Id: run-stp-tests.sh 9034 2010-03-09 07:03:06Z mike $"
ef416fc2 4#
5# Perform the complete set of IPP compliance tests specified in the
6# CUPS Software Test Plan.
7#
0268488e 8# Copyright 2007-2011 by Apple Inc.
f899b121 9# Copyright 1997-2007 by Easy Software Products, all rights reserved.
ef416fc2 10#
11# These coded instructions, statements, and computer programs are the
bc44d920 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/".
ef416fc2 16#
17
a74454a7 18argcount=$#
19
ef416fc2 20#
21# Make the IPP test program...
22#
23
24make
25
0268488e
MS
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
bd7854cb 36#
37# Figure out the proper echo options...
38#
39
0268488e 40if (echo "testing\c"; echo 1,2,3) | $GREP c >/dev/null; then
bd7854cb 41 ac_n=-n
42 ac_c=
43else
44 ac_n=
45 ac_c='\c'
46fi
47
ef416fc2 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 ""
bd7854cb 71echo $ac_n "Enter the number of the test you wish to perform: [1] $ac_c"
ef416fc2 72
a74454a7 73if test $# -gt 0; then
74 testtype=$1
75 shift
76else
77 read testtype
78fi
bd7854cb 79echo ""
ef416fc2 80
81case "$testtype" in
82 0)
83 echo "Running in test mode (0)"
84 nprinters1=0
85 nprinters2=0
86 pjobs=0
b9faaae1 87 pprinters=0
ef416fc2 88 ;;
89 2)
90 echo "Running the medium tests (2)"
91 nprinters1=10
92 nprinters2=20
93 pjobs=20
b9faaae1 94 pprinters=10
ef416fc2 95 ;;
96 3)
97 echo "Running the extreme tests (3)"
98 nprinters1=500
99 nprinters2=1000
100 pjobs=100
b9faaae1 101 pprinters=50
ef416fc2 102 ;;
103 4)
104 echo "Running the torture tests (4)"
105 nprinters1=10000
106 nprinters2=20000
107 pjobs=200
b9faaae1 108 pprinters=100
ef416fc2 109 ;;
110 *)
111 echo "Running the timid tests (1)"
112 nprinters1=0
113 nprinters2=0
839a51c8 114 pjobs=10
b9faaae1 115 pprinters=0
ef416fc2 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"
411affcf 129echo "1 - Test but do not require encryption"
130echo "2 - Test and require encryption"
ef416fc2 131echo ""
bd7854cb 132echo $ac_n "Enter the number of the SSL/TLS tests to perform: [0] $ac_c"
ef416fc2 133
a74454a7 134if test $# -gt 0; then
135 ssltype=$1
136 shift
137else
138 read ssltype
139fi
bd7854cb 140echo ""
ef416fc2 141
142case "$ssltype" in
411affcf 143 1)
144 echo "Will test but not require encryption (1)"
145 ;;
146 2)
147 echo "Will test and require encryption (2)"
ef416fc2 148 ;;
ef416fc2 149 *)
411affcf 150 echo "Not using SSL/TLS (0)"
ef416fc2 151 ssltype=0
152 ;;
153esac
154
155#
156# Information for the server/tests...
157#
158
e1d6a774 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
ef416fc2 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
634763e8
MS
182unset LPDEST
183unset PRINTER
ef416fc2 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 ""
bd7854cb 194echo $ac_n "Enter Y to use Valgrind or N to not use Valgrind: [N] $ac_c"
ef416fc2 195
a74454a7 196if test $# -gt 0; then
197 usevalgrind=$1
198 shift
199else
200 read usevalgrind
201fi
bd7854cb 202echo ""
ef416fc2 203
204case "$usevalgrind" in
205 Y* | y*)
d1c13e16 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"
ef416fc2 207 echo "Using Valgrind; log files can be found in /tmp/cups-$user/log..."
208 ;;
209
210 *)
211 valgrind=""
212 ;;
213esac
214
215#
216# Start by creating temporary directories for the tests...
217#
218
a74454a7 219echo "Creating directories for test..."
220
ef416fc2 221rm -rf /tmp/cups-$user
222mkdir /tmp/cups-$user
223mkdir /tmp/cups-$user/bin
224mkdir /tmp/cups-$user/bin/backend
839a51c8 225mkdir /tmp/cups-$user/bin/driver
ef416fc2 226mkdir /tmp/cups-$user/bin/filter
227mkdir /tmp/cups-$user/certs
228mkdir /tmp/cups-$user/share
229mkdir /tmp/cups-$user/share/banners
7a14d768 230mkdir /tmp/cups-$user/share/drv
4509bb49
MS
231mkdir /tmp/cups-$user/share/locale
232for file in ../locale/cups_*.po; do
233 loc=`basename $file .po | cut -c 6-`
234 mkdir /tmp/cups-$user/share/locale/$loc
235 ln -s $root/locale/cups_$loc.po /tmp/cups-$user/share/locale/$loc
236 ln -s $root/locale/ppdc_$loc.po /tmp/cups-$user/share/locale/$loc
237done
75bd9771 238mkdir /tmp/cups-$user/share/mime
ef416fc2 239mkdir /tmp/cups-$user/share/model
7a14d768 240mkdir /tmp/cups-$user/share/ppdc
ef416fc2 241mkdir /tmp/cups-$user/interfaces
242mkdir /tmp/cups-$user/log
243mkdir /tmp/cups-$user/ppd
244mkdir /tmp/cups-$user/spool
245mkdir /tmp/cups-$user/spool/temp
246mkdir /tmp/cups-$user/ssl
247
b19ccc9e 248ln -s $root/backend/dnssd /tmp/cups-$user/bin/backend
ef416fc2 249ln -s $root/backend/http /tmp/cups-$user/bin/backend
250ln -s $root/backend/ipp /tmp/cups-$user/bin/backend
251ln -s $root/backend/lpd /tmp/cups-$user/bin/backend
7a14d768 252ln -s $root/backend/mdns /tmp/cups-$user/bin/backend
ef416fc2 253ln -s $root/backend/parallel /tmp/cups-$user/bin/backend
254ln -s $root/backend/serial /tmp/cups-$user/bin/backend
a74454a7 255ln -s $root/backend/snmp /tmp/cups-$user/bin/backend
ef416fc2 256ln -s $root/backend/socket /tmp/cups-$user/bin/backend
257ln -s $root/backend/usb /tmp/cups-$user/bin/backend
258ln -s $root/cgi-bin /tmp/cups-$user/bin
bd7854cb 259ln -s $root/monitor /tmp/cups-$user/bin
ef416fc2 260ln -s $root/notifier /tmp/cups-$user/bin
261ln -s $root/scheduler /tmp/cups-$user/bin/daemon
cda47a96 262ln -s $root/filter/bannertops /tmp/cups-$user/bin/filter
7a14d768 263ln -s $root/filter/commandtops /tmp/cups-$user/bin/filter
7a0cbd5e 264ln -s $root/filter/gziptoany /tmp/cups-$user/bin/filter
ef416fc2 265ln -s $root/filter/hpgltops /tmp/cups-$user/bin/filter
ef416fc2 266ln -s $root/filter/pstops /tmp/cups-$user/bin/filter
267ln -s $root/filter/rastertoepson /tmp/cups-$user/bin/filter
268ln -s $root/filter/rastertohp /tmp/cups-$user/bin/filter
269ln -s $root/filter/texttops /tmp/cups-$user/bin/filter
ef416fc2 270
271ln -s $root/data/classified /tmp/cups-$user/share/banners
272ln -s $root/data/confidential /tmp/cups-$user/share/banners
273ln -s $root/data/secret /tmp/cups-$user/share/banners
274ln -s $root/data/standard /tmp/cups-$user/share/banners
275ln -s $root/data/topsecret /tmp/cups-$user/share/banners
276ln -s $root/data/unclassified /tmp/cups-$user/share/banners
a74454a7 277ln -s $root/data /tmp/cups-$user/share/charmaps
ef416fc2 278ln -s $root/data /tmp/cups-$user/share/charsets
279ln -s $root/data /tmp/cups-$user/share
280ln -s $root/fonts /tmp/cups-$user/share
7a14d768 281ln -s $root/ppdc/sample.drv /tmp/cups-$user/share/drv
75bd9771
MS
282ln -s $root/conf/mime.types /tmp/cups-$user/share/mime
283ln -s $root/conf/mime.convs /tmp/cups-$user/share/mime
7a14d768
MS
284ln -s $root/data/*.h /tmp/cups-$user/share/ppdc
285ln -s $root/data/*.defs /tmp/cups-$user/share/ppdc
ef416fc2 286ln -s $root/templates /tmp/cups-$user/share
287
bc44d920 288#
289# Mac OS X filters and configuration files...
290#
291
292if test `uname` = Darwin; then
293 ln -s /usr/libexec/cups/filter/cgpdfto* /tmp/cups-$user/bin/filter
f0ab5bff
MS
294 ln -s /usr/libexec/cups/filter/cgbannertopdf /tmp/cups-$user/bin/filter
295 ln -s /usr/libexec/cups/filter/cgimagetopdf /tmp/cups-$user/bin/filter
296 ln -s /usr/libexec/cups/filter/cgtexttopdf /tmp/cups-$user/bin/filter
bc44d920 297 ln -s /usr/libexec/cups/filter/nsimagetopdf /tmp/cups-$user/bin/filter
298 ln -s /usr/libexec/cups/filter/nstexttopdf /tmp/cups-$user/bin/filter
299 ln -s /usr/libexec/cups/filter/pictwpstops /tmp/cups-$user/bin/filter
300 ln -s /usr/libexec/cups/filter/pstoappleps /tmp/cups-$user/bin/filter
301 ln -s /usr/libexec/cups/filter/pstocupsraster /tmp/cups-$user/bin/filter
302 ln -s /usr/libexec/cups/filter/pstopdffilter /tmp/cups-$user/bin/filter
303
4509bb49
MS
304 if test -f /private/etc/cups/apple.types; then
305 ln -s /private/etc/cups/apple.* /tmp/cups-$user/share/mime
306 elif test -f /usr/share/cups/mime/apple.types; then
307 ln -s /usr/share/cups/mime/apple.* /tmp/cups-$user/share/mime
308 fi
839a51c8
MS
309else
310 ln -s $root/filter/imagetops /tmp/cups-$user/bin/filter
311 ln -s $root/filter/imagetoraster /tmp/cups-$user/bin/filter
312 ln -s $root/filter/pdftops /tmp/cups-$user/bin/filter
bc44d920 313fi
314
ef416fc2 315#
316# Then create the necessary config files...
317#
318
a74454a7 319echo "Creating cupsd.conf for test..."
320
ef416fc2 321if test $ssltype = 2; then
322 encryption="Encryption Required"
323else
324 encryption=""
325fi
326
327cat >/tmp/cups-$user/cupsd.conf <<EOF
328Browsing Off
329FileDevice yes
330Printcap
331Listen 127.0.0.1:$port
332User $user
333ServerRoot /tmp/cups-$user
334StateDir /tmp/cups-$user
335ServerBin /tmp/cups-$user/bin
336CacheDir /tmp/cups-$user/share
337DataDir /tmp/cups-$user/share
338FontPath /tmp/cups-$user/share/fonts
4509bb49 339PassEnv LOCALEDIR
ef416fc2 340DocumentRoot $root/doc
341RequestRoot /tmp/cups-$user/spool
342TempDir /tmp/cups-$user/spool/temp
52f6f666 343MaxSubscriptions 3
ef416fc2 344MaxLogSize 0
345AccessLog /tmp/cups-$user/log/access_log
346ErrorLog /tmp/cups-$user/log/error_log
347PageLog /tmp/cups-$user/log/page_log
e07d4801 348AccessLogLevel actions
7a14d768 349LogLevel debug2
b9faaae1 350LogTimeFormat usecs
ef416fc2 351PreserveJobHistory Yes
352<Policy default>
353<Limit All>
354Order Deny,Allow
355Deny from all
356Allow from 127.0.0.1
357$encryption
358</Limit>
359</Policy>
360EOF
361
ef416fc2 362#
75bd9771 363# Setup lots of test queues - half with PPD files, half without...
ef416fc2 364#
365
a74454a7 366echo "Creating printers.conf for test..."
367
ef416fc2 368i=1
369while test $i -le $nprinters1; do
370 cat >>/tmp/cups-$user/printers.conf <<EOF
371<Printer test-$i>
372Accepting Yes
373DeviceURI file:/dev/null
374Info Test PS printer $i
375JobSheets none none
376Location CUPS test suite
377State Idle
378StateMessage Printer $1 is idle.
379</Printer>
380EOF
381
382 cp testps.ppd /tmp/cups-$user/ppd/test-$i.ppd
383
384 i=`expr $i + 1`
385done
386
387while test $i -le $nprinters2; do
388 cat >>/tmp/cups-$user/printers.conf <<EOF
389<Printer test-$i>
390Accepting Yes
391DeviceURI file:/dev/null
392Info Test raw printer $i
393JobSheets none none
394Location CUPS test suite
395State Idle
396StateMessage Printer $1 is idle.
397</Printer>
398EOF
399
400 i=`expr $i + 1`
401done
402
426c6a59
MS
403if test -f /tmp/cups-$user/printers.conf; then
404 cp /tmp/cups-$user/printers.conf /tmp/cups-$user/printers.conf.orig
405else
406 touch /tmp/cups-$user/printers.conf.orig
407fi
ef416fc2 408
ef416fc2 409#
410# Setup the paths...
411#
412
a74454a7 413echo "Setting up environment variables for test..."
414
ef416fc2 415if test "x$LD_LIBRARY_PATH" = x; then
50fe7201 416 LD_LIBRARY_PATH="$root/cups:$root/filter:$root/cgi-bin:$root/scheduler:$root/driver:$root/ppdc"
ef416fc2 417else
50fe7201 418 LD_LIBRARY_PATH="$root/cups:$root/filter:$root/cgi-bin:$root/scheduler:$root/driver:$root/ppdc:$LD_LIBRARY_PATH"
ef416fc2 419fi
420
421export LD_LIBRARY_PATH
422
50fe7201 423LD_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"
f11a948a
MS
424if test `uname` = SunOS -a -r /usr/lib/libCrun.so.1; then
425 LD_PRELOAD="/usr/lib/libCrun.so.1:$LD_PRELOAD"
426fi
ef416fc2 427export LD_PRELOAD
428
429if test "x$DYLD_LIBRARY_PATH" = x; then
50fe7201 430 DYLD_LIBRARY_PATH="$root/cups:$root/filter:$root/cgi-bin:$root/scheduler:$root/driver:$root/ppdc"
ef416fc2 431else
50fe7201 432 DYLD_LIBRARY_PATH="$root/cups:$root/filter:$root/cgi-bin:$root/scheduler:$root/driver:$root/ppdc:$DYLD_LIBRARY_PATH"
ef416fc2 433fi
434
435export DYLD_LIBRARY_PATH
436
437if test "x$SHLIB_PATH" = x; then
50fe7201 438 SHLIB_PATH="$root/cups:$root/filter:$root/cgi-bin:$root/scheduler:$root/driver:$root/ppdc"
ef416fc2 439else
50fe7201 440 SHLIB_PATH="$root/cups:$root/filter:$root/cgi-bin:$root/scheduler:$root/driver:$root/ppdc:$SHLIB_PATH"
ef416fc2 441fi
442
443export SHLIB_PATH
444
ef55b745 445CUPS_DISABLE_APPLE_DEFAULT=yes; export CUPS_DISABLE_APPLE_DEFAULT
b19ccc9e 446CUPS_SERVER=localhost:8631; export CUPS_SERVER
ef416fc2 447CUPS_SERVERROOT=/tmp/cups-$user; export CUPS_SERVERROOT
448CUPS_STATEDIR=/tmp/cups-$user; export CUPS_STATEDIR
449CUPS_DATADIR=/tmp/cups-$user/share; export CUPS_DATADIR
4509bb49 450LOCALEDIR=/tmp/cups-$user/share/locale; export LOCALEDIR
ef416fc2 451
452#
453# Set a new home directory to avoid getting user options mixed in...
454#
455
456HOME=/tmp/cups-$user
457export HOME
458
f42414bf 459#
460# Force POSIX locale for tests...
461#
462
463LANG=C
464export LANG
465
0268488e
MS
466LC_MESSAGES=C
467export LC_MESSAGES
468
ef416fc2 469#
470# Start the server; run as foreground daemon in the background...
471#
472
473echo "Starting scheduler:"
a74454a7 474echo " $valgrind ../scheduler/cupsd -c /tmp/cups-$user/cupsd.conf -f >/tmp/cups-$user/log/debug_log 2>&1 &"
ef416fc2 475echo ""
476
b9faaae1
MS
477if test `uname` = Darwin -a "x$valgrind" = x; then
478 DYLD_INSERT_LIBRARIES=/usr/lib/libgmalloc.dylib \
479 $valgrind ../scheduler/cupsd -c /tmp/cups-$user/cupsd.conf -f >/tmp/cups-$user/log/debug_log 2>&1 &
480else
481 $valgrind ../scheduler/cupsd -c /tmp/cups-$user/cupsd.conf -f >/tmp/cups-$user/log/debug_log 2>&1 &
482fi
483
ef416fc2 484cupsd=$!
485
ef416fc2 486if test "x$testtype" = x0; then
b19ccc9e 487 # Not running tests...
ef416fc2 488 echo "Scheduler is PID $cupsd and is listening on port 8631."
489 echo ""
b19ccc9e
MS
490
491 # Create a helper script to run programs with...
492 runcups="/tmp/cups-$user/runcups"
493
494 echo "#!/bin/sh" >$runcups
495 echo "# Helper script for running CUPS test instance." >>$runcups
496 echo "" >>$runcups
497 echo "# Set required environment variables..." >>$runcups
498 echo "CUPS_DATADIR=\"$CUPS_DATADIR\"; export CUPS_DATADIR" >>$runcups
499 echo "CUPS_SERVER=\"$CUPS_SERVER\"; export CUPS_SERVER" >>$runcups
500 echo "CUPS_SERVERROOT=\"$CUPS_SERVERROOT\"; export CUPS_SERVERROOT" >>$runcups
501 echo "CUPS_STATEDIR=\"$CUPS_STATEDIR\"; export CUPS_STATEDIR" >>$runcups
502 echo "DYLD_LIBRARY_PATH=\"$DYLD_LIBRARY_PATH\"; export DYLD_LIBRARY_PATH" >>$runcups
503 echo "LD_LIBRARY_PATH=\"$LD_LIBRARY_PATH\"; export LD_LIBRARY_PATH" >>$runcups
504 echo "LD_PRELOAD=\"$LD_PRELOAD\"; export LD_PRELOAD" >>$runcups
505 echo "LOCALEDIR=\"$LOCALEDIR\"; export LOCALEDIR" >>$runcups
506 echo "SHLIB_PATH=\"$SHLIB_PATH\"; export SHLIB_PATH" >>$runcups
507 echo "" >>$runcups
508 echo "# Run command..." >>$runcups
509 echo "exec \"\$@\"" >>$runcups
510
511 chmod +x $runcups
512
513 echo "The $runcups helper script can be used to test programs"
514 echo "with the server."
ef416fc2 515 exit 0
516fi
517
a74454a7 518if test $argcount -eq 0; then
519 echo "Scheduler is PID $cupsd; run debugger now if you need to."
520 echo ""
521 echo $ac_n "Press ENTER to continue... $ac_c"
522 read junk
523else
524 echo "Scheduler is PID $cupsd."
525 sleep 2
526fi
ef416fc2 527
528IPP_PORT=$port; export IPP_PORT
529
530while true; do
531 running=`../systemv/lpstat -r 2>/dev/null`
532 if test "x$running" = "xscheduler is running"; then
533 break
534 fi
535
536 echo "Waiting for scheduler to become ready..."
537 sleep 10
538done
539
540#
541# Create the test report source file...
542#
543
dd1abb6b 544date=`date "+%Y-%m-%d"`
a480a1b6 545strfile=/tmp/cups-$user/cups-str-1.5-$date-$user.html
ef416fc2 546
547rm -f $strfile
548cat str-header.html >$strfile
549
550#
551# Run the IPP tests...
552#
553
a74454a7 554echo ""
ef416fc2 555echo "Running IPP compliance tests..."
556
bd7854cb 557echo "<H1>1 - IPP Compliance Tests</H1>" >>$strfile
ef416fc2 558echo "<P>This section provides the results to the IPP compliance tests" >>$strfile
559echo "outlined in the CUPS Software Test Plan. These tests were run on" >>$strfile
e1d6a774 560echo `date "+%Y-%m-%d"` by $user on `hostname`. >>$strfile
ef416fc2 561echo "<PRE>" >>$strfile
562
563fail=0
564for file in 4*.test; do
565 echo "Performing $file..."
566 echo "" >>$strfile
567
aaf19ab0 568 ./ipptool -t ipp://localhost:$port/printers $file | tee -a $strfile
ef416fc2 569 status=$?
570
571 if test $status != 0; then
572 echo Test failed.
573 fail=`expr $fail + 1`
574 fi
575done
576
577echo "</PRE>" >>$strfile
578
579#
580# Run the command tests...
581#
582
a74454a7 583echo ""
ef416fc2 584echo "Running command tests..."
585
bd7854cb 586echo "<H1>2 - Command Tests</H1>" >>$strfile
ef416fc2 587echo "<P>This section provides the results to the command tests" >>$strfile
588echo "outlined in the CUPS Software Test Plan. These tests were run on" >>$strfile
dd1abb6b 589echo $date by $user on `hostname`. >>$strfile
ef416fc2 590echo "<PRE>" >>$strfile
591
592for file in 5*.sh; do
593 echo "Performing $file..."
594 echo "" >>$strfile
595 echo "\"$file\":" >>$strfile
596
b9faaae1 597 sh $file $pjobs $pprinters | tee -a $strfile
ef416fc2 598 status=$?
599
600 if test $status != 0; then
601 echo Test failed.
602 fail=`expr $fail + 1`
603 fi
604done
605
606echo "</PRE>" >>$strfile
607
ef416fc2 608#
609# Stop the server...
610#
611
612kill $cupsd
613
614#
615# Append the log files for post-mortim...
616#
617
bd7854cb 618echo "<H1>3 - Log Files</H1>" >>$strfile
ef416fc2 619
839a51c8
MS
620#
621# Verify counts...
622#
623
624echo "Test Summary"
625echo ""
626echo "<H2>Summary</H2>" >>$strfile
627
ba55dc12
MS
628# Job control files
629count=`ls -1 /tmp/cups-$user/spool | wc -l`
630count=`expr $count - 1`
631if test $count != 0; then
632 echo "FAIL: $count job control files were not purged."
633 echo "<P>FAIL: $count job control files were not purged.</P>" >>$strfile
634 fail=`expr $fail + 1`
635else
636 echo "PASS: All job control files purged."
637 echo "<P>PASS: All job control files purged.</P>" >>$strfile
638fi
639
7a14d768 640# Pages printed on Test1 (within 1 page for timing-dependent cancel issues)
0268488e 641count=`$GREP '^Test1 ' /tmp/cups-$user/log/page_log | awk 'BEGIN{count=0}{count=count+$7}END{print count}'`
969307f0
MS
642expected=`expr $pjobs \* 2 + 34`
643expected2=`expr $expected + 2`
644if test $count -lt $expected -a $count -gt $expected2; then
839a51c8
MS
645 echo "FAIL: Printer 'Test1' produced $count page(s), expected $expected."
646 echo "<P>FAIL: Printer 'Test1' produced $count page(s), expected $expected.</P>" >>$strfile
647 fail=`expr $fail + 1`
648else
649 echo "PASS: Printer 'Test1' correctly produced $count page(s)."
650 echo "<P>PASS: Printer 'Test1' correctly produced $count page(s).</P>" >>$strfile
651fi
652
653# Paged printed on Test2
0268488e 654count=`$GREP '^Test2 ' /tmp/cups-$user/log/page_log | awk 'BEGIN{count=0}{count=count+$7}END{print count}'`
839a51c8
MS
655expected=`expr $pjobs \* 2 + 3`
656if test $count != $expected; then
657 echo "FAIL: Printer 'Test2' produced $count page(s), expected $expected."
658 echo "<P>FAIL: Printer 'Test2' produced $count page(s), expected $expected.</P>" >>$strfile
659 fail=`expr $fail + 1`
660else
661 echo "PASS: Printer 'Test2' correctly produced $count page(s)."
662 echo "<P>PASS: Printer 'Test2' correctly produced $count page(s).</P>" >>$strfile
663fi
664
e07d4801 665# Requests logged
839a51c8 666count=`wc -l /tmp/cups-$user/log/access_log | awk '{print $1}'`
7cf5915e 667expected=`expr 37 + 18 + $pjobs \* 8 + $pprinters \* $pjobs \* 4`
e07d4801
MS
668if test $count != $expected; then
669 echo "FAIL: $count requests logged, expected $expected."
670 echo "<P>FAIL: $count requests logged, expected $expected.</P>" >>$strfile
671 fail=`expr $fail + 1`
672else
673 echo "PASS: $count requests logged."
674 echo "<P>PASS: $count requests logged.</P>" >>$strfile
675fi
676
677# Did CUPS-Get-Default get logged?
0268488e 678if $GREP -q CUPS-Get-Default /tmp/cups-$user/log/access_log; then
e07d4801
MS
679 echo "FAIL: CUPS-Get-Default logged with 'AccessLogLevel actions'"
680 echo "<P>FAIL: CUPS-Get-Default logged with 'AccessLogLevel actions'</P>" >>$strfile
681 echo "<PRE>" >>$strfile
0268488e 682 $GREP CUPS-Get-Default /tmp/cups-$user/log/access_log | sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
e07d4801
MS
683 echo "</PRE>" >>$strfile
684 fail=`expr $fail + 1`
685else
686 echo "PASS: CUPS-Get-Default not logged."
687 echo "<P>PASS: CUPS-Get-Default not logged.</P>" >>$strfile
688fi
839a51c8
MS
689
690# Emergency log messages
0268488e 691count=`$GREP '^X ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'`
839a51c8
MS
692if test $count != 0; then
693 echo "FAIL: $count emergency messages, expected 0."
0268488e 694 $GREP '^X ' /tmp/cups-$user/log/error_log
839a51c8
MS
695 echo "<P>FAIL: $count emergency messages, expected 0.</P>" >>$strfile
696 echo "<PRE>" >>$strfile
0268488e 697 $GREP '^X ' /tmp/cups-$user/log/error_log | sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
839a51c8
MS
698 echo "</PRE>" >>$strfile
699 fail=`expr $fail + 1`
700else
701 echo "PASS: $count emergency messages."
702 echo "<P>PASS: $count emergency messages.</P>" >>$strfile
703fi
704
705# Alert log messages
0268488e 706count=`$GREP '^A ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'`
839a51c8
MS
707if test $count != 0; then
708 echo "FAIL: $count alert messages, expected 0."
0268488e 709 $GREP '^A ' /tmp/cups-$user/log/error_log
839a51c8
MS
710 echo "<P>FAIL: $count alert messages, expected 0.</P>" >>$strfile
711 echo "<PRE>" >>$strfile
0268488e 712 $GREP '^A ' /tmp/cups-$user/log/error_log | sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
839a51c8
MS
713 echo "</PRE>" >>$strfile
714 fail=`expr $fail + 1`
715else
716 echo "PASS: $count alert messages."
717 echo "<P>PASS: $count alert messages.</P>" >>$strfile
718fi
719
720# Critical log messages
0268488e 721count=`$GREP '^C ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'`
839a51c8
MS
722if test $count != 0; then
723 echo "FAIL: $count critical messages, expected 0."
0268488e 724 $GREP '^C ' /tmp/cups-$user/log/error_log
839a51c8
MS
725 echo "<P>FAIL: $count critical messages, expected 0.</P>" >>$strfile
726 echo "<PRE>" >>$strfile
0268488e 727 $GREP '^C ' /tmp/cups-$user/log/error_log | sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
839a51c8
MS
728 echo "</PRE>" >>$strfile
729 fail=`expr $fail + 1`
730else
731 echo "PASS: $count critical messages."
732 echo "<P>PASS: $count critical messages.</P>" >>$strfile
733fi
734
735# Error log messages
0268488e 736count=`$GREP '^E ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'`
d2354e63
MS
737if test $count != 18; then
738 echo "FAIL: $count error messages, expected 18."
0268488e 739 $GREP '^E ' /tmp/cups-$user/log/error_log
d2354e63 740 echo "<P>FAIL: $count error messages, expected 18.</P>" >>$strfile
839a51c8 741 echo "<PRE>" >>$strfile
0268488e 742 $GREP '^E ' /tmp/cups-$user/log/error_log | sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
839a51c8
MS
743 echo "</PRE>" >>$strfile
744 fail=`expr $fail + 1`
745else
746 echo "PASS: $count error messages."
747 echo "<P>PASS: $count error messages.</P>" >>$strfile
748fi
749
750# Warning log messages
0268488e 751count=`$GREP '^W ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'`
10d09e33
MS
752if test $count != 9; then
753 echo "FAIL: $count warning messages, expected 9."
0268488e 754 $GREP '^W ' /tmp/cups-$user/log/error_log
10d09e33 755 echo "<P>FAIL: $count warning messages, expected 9.</P>" >>$strfile
839a51c8 756 echo "<PRE>" >>$strfile
0268488e 757 $GREP '^W ' /tmp/cups-$user/log/error_log | sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
839a51c8
MS
758 echo "</PRE>" >>$strfile
759 fail=`expr $fail + 1`
760else
761 echo "PASS: $count warning messages."
762 echo "<P>PASS: $count warning messages.</P>" >>$strfile
763fi
764
765# Notice log messages
0268488e 766count=`$GREP '^N ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'`
839a51c8
MS
767if test $count != 0; then
768 echo "FAIL: $count notice messages, expected 0."
0268488e 769 $GREP '^N ' /tmp/cups-$user/log/error_log
839a51c8
MS
770 echo "<P>FAIL: $count notice messages, expected 0.</P>" >>$strfile
771 echo "<PRE>" >>$strfile
0268488e 772 $GREP '^N ' /tmp/cups-$user/log/error_log | sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
839a51c8
MS
773 echo "</PRE>" >>$strfile
774 fail=`expr $fail + 1`
775else
776 echo "PASS: $count notice messages."
777 echo "<P>PASS: $count notice messages.</P>" >>$strfile
778fi
779
780# Info log messages
0268488e 781count=`$GREP '^I ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'`
839a51c8
MS
782if test $count = 0; then
783 echo "FAIL: $count info messages, expected more than 0."
784 echo "<P>FAIL: $count info messages, expected more than 0.</P>" >>$strfile
785 fail=`expr $fail + 1`
786else
787 echo "PASS: $count info messages."
788 echo "<P>PASS: $count info messages.</P>" >>$strfile
789fi
790
791# Debug log messages
0268488e 792count=`$GREP '^D ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'`
839a51c8
MS
793if test $count = 0; then
794 echo "FAIL: $count debug messages, expected more than 0."
795 echo "<P>FAIL: $count debug messages, expected more than 0.</P>" >>$strfile
796 fail=`expr $fail + 1`
797else
798 echo "PASS: $count debug messages."
799 echo "<P>PASS: $count debug messages.</P>" >>$strfile
800fi
801
802# Debug2 log messages
0268488e 803count=`$GREP '^d ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'`
7a14d768
MS
804if test $count = 0; then
805 echo "FAIL: $count debug2 messages, expected more than 0."
806 echo "<P>FAIL: $count debug2 messages, expected more than 0.</P>" >>$strfile
839a51c8
MS
807 fail=`expr $fail + 1`
808else
809 echo "PASS: $count debug2 messages."
810 echo "<P>PASS: $count debug2 messages.</P>" >>$strfile
811fi
812
75bd9771 813# Page log file...
0268488e
MS
814if test `uname` = Darwin; then
815 # Currently just test for Mac OS X since others do not have UI to
816 # select a user-wide default media size...
817 if $GREP -iq 'testfile.pdf na_letter_8.5x11in' /tmp/cups-$user/log/page_log; then
818 echo "PASS: page_log formatted correctly."
819 echo "<P>PASS: page_log formatted correctly.</P>" >>$strfile
820 else
821 echo "FAIL: page_log formatted incorrectly."
822 echo "<P>FAIL: page_log formatted incorrectly - no page size information.</P>" >>$strfile
823 fail=`expr $fail + 1`
824 fi
75bd9771
MS
825fi
826
839a51c8 827# Log files...
ef416fc2 828echo "<H2>access_log</H2>" >>$strfile
829echo "<PRE>" >>$strfile
839a51c8 830sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' /tmp/cups-$user/log/access_log >>$strfile
ef416fc2 831echo "</PRE>" >>$strfile
832
833echo "<H2>error_log</H2>" >>$strfile
834echo "<PRE>" >>$strfile
0268488e 835$GREP -v '^d' /tmp/cups-$user/log/error_log | sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
ef416fc2 836echo "</PRE>" >>$strfile
837
838echo "<H2>page_log</H2>" >>$strfile
839echo "<PRE>" >>$strfile
839a51c8 840sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' /tmp/cups-$user/log/page_log >>$strfile
ef416fc2 841echo "</PRE>" >>$strfile
842
ef416fc2 843#
844# Format the reports and tell the user where to find them...
845#
846
ef416fc2 847cat str-trailer.html >>$strfile
848
ef416fc2 849echo ""
850
851if test $fail != 0; then
852 echo "$fail tests failed."
dd1abb6b
MS
853 cp /tmp/cups-$user/log/error_log error_log-$date-$user
854 cp $strfile .
ef416fc2 855else
856 echo "All tests were successful."
857fi
858
a74454a7 859echo "Log files can be found in /tmp/cups-$user/log."
839a51c8 860echo "A HTML report was created in $strfile."
ef416fc2 861echo ""
862
db0bd74a 863if test $fail != 0; then
dd1abb6b
MS
864 echo "Copies of the error_log and `basename $strfile` files are in"
865 echo "`pwd`."
866 echo ""
867
db0bd74a
MS
868 exit 1
869fi
870
ef416fc2 871#
a480a1b6 872# End of "$Id: run-stp-tests.sh 9034 2010-03-09 07:03:06Z mike $"
ef416fc2 873#