]> git.ipfire.org Git - thirdparty/cups.git/blame - test/run-stp-tests.sh
Merge changes from CUPS 1.6svn-r9968.
[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
85dda01c
MS
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
ef416fc2 252#
253# Start by creating temporary directories for the tests...
254#
255
a74454a7 256echo "Creating directories for test..."
257
ef416fc2 258rm -rf /tmp/cups-$user
259mkdir /tmp/cups-$user
260mkdir /tmp/cups-$user/bin
261mkdir /tmp/cups-$user/bin/backend
839a51c8 262mkdir /tmp/cups-$user/bin/driver
ef416fc2 263mkdir /tmp/cups-$user/bin/filter
264mkdir /tmp/cups-$user/certs
265mkdir /tmp/cups-$user/share
266mkdir /tmp/cups-$user/share/banners
7a14d768 267mkdir /tmp/cups-$user/share/drv
4509bb49
MS
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
75bd9771 275mkdir /tmp/cups-$user/share/mime
ef416fc2 276mkdir /tmp/cups-$user/share/model
7a14d768 277mkdir /tmp/cups-$user/share/ppdc
ef416fc2 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
b19ccc9e 285ln -s $root/backend/dnssd /tmp/cups-$user/bin/backend
ef416fc2 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
7a14d768 289ln -s $root/backend/mdns /tmp/cups-$user/bin/backend
f14324a7 290ln -s $root/backend/pseudo /tmp/cups-$user/bin/backend
a74454a7 291ln -s $root/backend/snmp /tmp/cups-$user/bin/backend
ef416fc2 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
bd7854cb 295ln -s $root/monitor /tmp/cups-$user/bin
ef416fc2 296ln -s $root/notifier /tmp/cups-$user/bin
297ln -s $root/scheduler /tmp/cups-$user/bin/daemon
7a14d768 298ln -s $root/filter/commandtops /tmp/cups-$user/bin/filter
7a0cbd5e 299ln -s $root/filter/gziptoany /tmp/cups-$user/bin/filter
ef416fc2 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
eac3a0a0
MS
303ln -s $root/filter/rastertolabel /tmp/cups-$user/bin/filter
304ln -s $root/filter/rastertopwg /tmp/cups-$user/bin/filter
ef416fc2 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
ef416fc2 312ln -s $root/data /tmp/cups-$user/share
7a14d768 313ln -s $root/ppdc/sample.drv /tmp/cups-$user/share/drv
75bd9771
MS
314ln -s $root/conf/mime.types /tmp/cups-$user/share/mime
315ln -s $root/conf/mime.convs /tmp/cups-$user/share/mime
7a14d768
MS
316ln -s $root/data/*.h /tmp/cups-$user/share/ppdc
317ln -s $root/data/*.defs /tmp/cups-$user/share/ppdc
ef416fc2 318ln -s $root/templates /tmp/cups-$user/share
319
bc44d920 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
f0ab5bff
MS
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
bc44d920 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
eac3a0a0
MS
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
bc44d920 337
4509bb49
MS
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
839a51c8 343else
a4845881
MS
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
bc44d920 351fi
352
ef416fc2 353#
354# Then create the necessary config files...
355#
356
a74454a7 357echo "Creating cupsd.conf for test..."
358
ef416fc2 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
4509bb49 377PassEnv LOCALEDIR
85dda01c 378PassEnv DYLD_INSERT_LIBRARIES
ef416fc2 379DocumentRoot $root/doc
380RequestRoot /tmp/cups-$user/spool
381TempDir /tmp/cups-$user/spool/temp
52f6f666 382MaxSubscriptions 3
ef416fc2 383MaxLogSize 0
384AccessLog /tmp/cups-$user/log/access_log
385ErrorLog /tmp/cups-$user/log/error_log
386PageLog /tmp/cups-$user/log/page_log
e07d4801 387AccessLogLevel actions
7a14d768 388LogLevel debug2
b9faaae1 389LogTimeFormat usecs
ef416fc2 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
ef416fc2 401#
75bd9771 402# Setup lots of test queues - half with PPD files, half without...
ef416fc2 403#
404
a74454a7 405echo "Creating printers.conf for test..."
406
ef416fc2 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
426c6a59
MS
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
ef416fc2 447
ef416fc2 448#
449# Setup the paths...
450#
451
a74454a7 452echo "Setting up environment variables for test..."
453
ef416fc2 454if test "x$LD_LIBRARY_PATH" = x; then
50fe7201 455 LD_LIBRARY_PATH="$root/cups:$root/filter:$root/cgi-bin:$root/scheduler:$root/driver:$root/ppdc"
ef416fc2 456else
50fe7201 457 LD_LIBRARY_PATH="$root/cups:$root/filter:$root/cgi-bin:$root/scheduler:$root/driver:$root/ppdc:$LD_LIBRARY_PATH"
ef416fc2 458fi
459
460export LD_LIBRARY_PATH
461
50fe7201 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"
f11a948a
MS
463if test `uname` = SunOS -a -r /usr/lib/libCrun.so.1; then
464 LD_PRELOAD="/usr/lib/libCrun.so.1:$LD_PRELOAD"
465fi
ef416fc2 466export LD_PRELOAD
467
468if test "x$DYLD_LIBRARY_PATH" = x; then
50fe7201 469 DYLD_LIBRARY_PATH="$root/cups:$root/filter:$root/cgi-bin:$root/scheduler:$root/driver:$root/ppdc"
ef416fc2 470else
50fe7201 471 DYLD_LIBRARY_PATH="$root/cups:$root/filter:$root/cgi-bin:$root/scheduler:$root/driver:$root/ppdc:$DYLD_LIBRARY_PATH"
ef416fc2 472fi
473
474export DYLD_LIBRARY_PATH
475
476if test "x$SHLIB_PATH" = x; then
50fe7201 477 SHLIB_PATH="$root/cups:$root/filter:$root/cgi-bin:$root/scheduler:$root/driver:$root/ppdc"
ef416fc2 478else
50fe7201 479 SHLIB_PATH="$root/cups:$root/filter:$root/cgi-bin:$root/scheduler:$root/driver:$root/ppdc:$SHLIB_PATH"
ef416fc2 480fi
481
482export SHLIB_PATH
483
ef55b745 484CUPS_DISABLE_APPLE_DEFAULT=yes; export CUPS_DISABLE_APPLE_DEFAULT
b19ccc9e 485CUPS_SERVER=localhost:8631; export CUPS_SERVER
ef416fc2 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
4509bb49 489LOCALEDIR=/tmp/cups-$user/share/locale; export LOCALEDIR
ef416fc2 490
491#
492# Set a new home directory to avoid getting user options mixed in...
493#
494
495HOME=/tmp/cups-$user
496export HOME
497
f42414bf 498#
499# Force POSIX locale for tests...
500#
501
502LANG=C
503export LANG
504
0268488e
MS
505LC_MESSAGES=C
506export LC_MESSAGES
507
ef416fc2 508#
509# Start the server; run as foreground daemon in the background...
510#
511
512echo "Starting scheduler:"
a74454a7 513echo " $valgrind ../scheduler/cupsd -c /tmp/cups-$user/cupsd.conf -f >/tmp/cups-$user/log/debug_log 2>&1 &"
ef416fc2 514echo ""
515
b9faaae1 516if test `uname` = Darwin -a "x$valgrind" = x; then
85dda01c
MS
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 &
b9faaae1
MS
519else
520 $valgrind ../scheduler/cupsd -c /tmp/cups-$user/cupsd.conf -f >/tmp/cups-$user/log/debug_log 2>&1 &
521fi
522
ef416fc2 523cupsd=$!
524
ef416fc2 525if test "x$testtype" = x0; then
b19ccc9e 526 # Not running tests...
ef416fc2 527 echo "Scheduler is PID $cupsd and is listening on port 8631."
528 echo ""
b19ccc9e
MS
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."
ef416fc2 554 exit 0
555fi
556
a74454a7 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
ef416fc2 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
dd1abb6b 583date=`date "+%Y-%m-%d"`
a4845881 584strfile=/tmp/cups-$user/cups-str-1.6-$date-$user.html
ef416fc2 585
586rm -f $strfile
587cat str-header.html >$strfile
588
589#
590# Run the IPP tests...
591#
592
a74454a7 593echo ""
ef416fc2 594echo "Running IPP compliance tests..."
595
bd7854cb 596echo "<H1>1 - IPP Compliance Tests</H1>" >>$strfile
ef416fc2 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
e1d6a774 599echo `date "+%Y-%m-%d"` by $user on `hostname`. >>$strfile
ef416fc2 600echo "<PRE>" >>$strfile
601
602fail=0
603for file in 4*.test; do
604 echo "Performing $file..."
605 echo "" >>$strfile
606
aaf19ab0 607 ./ipptool -t ipp://localhost:$port/printers $file | tee -a $strfile
ef416fc2 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
a74454a7 622echo ""
ef416fc2 623echo "Running command tests..."
624
bd7854cb 625echo "<H1>2 - Command Tests</H1>" >>$strfile
ef416fc2 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
dd1abb6b 628echo $date by $user on `hostname`. >>$strfile
ef416fc2 629echo "<PRE>" >>$strfile
630
631for file in 5*.sh; do
632 echo "Performing $file..."
633 echo "" >>$strfile
634 echo "\"$file\":" >>$strfile
635
b9faaae1 636 sh $file $pjobs $pprinters | tee -a $strfile
ef416fc2 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
ef416fc2 647#
648# Stop the server...
649#
650
651kill $cupsd
652
653#
654# Append the log files for post-mortim...
655#
656
bd7854cb 657echo "<H1>3 - Log Files</H1>" >>$strfile
ef416fc2 658
839a51c8
MS
659#
660# Verify counts...
661#
662
663echo "Test Summary"
664echo ""
665echo "<H2>Summary</H2>" >>$strfile
666
ba55dc12
MS
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
7a14d768 679# Pages printed on Test1 (within 1 page for timing-dependent cancel issues)
0268488e 680count=`$GREP '^Test1 ' /tmp/cups-$user/log/page_log | awk 'BEGIN{count=0}{count=count+$7}END{print count}'`
969307f0
MS
681expected=`expr $pjobs \* 2 + 34`
682expected2=`expr $expected + 2`
683if test $count -lt $expected -a $count -gt $expected2; then
839a51c8
MS
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
0268488e 693count=`$GREP '^Test2 ' /tmp/cups-$user/log/page_log | awk 'BEGIN{count=0}{count=count+$7}END{print count}'`
839a51c8
MS
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
e07d4801 704# Requests logged
839a51c8 705count=`wc -l /tmp/cups-$user/log/access_log | awk '{print $1}'`
7cf5915e 706expected=`expr 37 + 18 + $pjobs \* 8 + $pprinters \* $pjobs \* 4`
e07d4801
MS
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?
0268488e 717if $GREP -q CUPS-Get-Default /tmp/cups-$user/log/access_log; then
e07d4801
MS
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
0268488e 721 $GREP CUPS-Get-Default /tmp/cups-$user/log/access_log | sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
e07d4801
MS
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
839a51c8
MS
728
729# Emergency log messages
0268488e 730count=`$GREP '^X ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'`
839a51c8
MS
731if test $count != 0; then
732 echo "FAIL: $count emergency messages, expected 0."
0268488e 733 $GREP '^X ' /tmp/cups-$user/log/error_log
839a51c8
MS
734 echo "<P>FAIL: $count emergency messages, expected 0.</P>" >>$strfile
735 echo "<PRE>" >>$strfile
0268488e 736 $GREP '^X ' /tmp/cups-$user/log/error_log | sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
839a51c8
MS
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
0268488e 745count=`$GREP '^A ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'`
839a51c8
MS
746if test $count != 0; then
747 echo "FAIL: $count alert messages, expected 0."
0268488e 748 $GREP '^A ' /tmp/cups-$user/log/error_log
839a51c8
MS
749 echo "<P>FAIL: $count alert messages, expected 0.</P>" >>$strfile
750 echo "<PRE>" >>$strfile
0268488e 751 $GREP '^A ' /tmp/cups-$user/log/error_log | sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
839a51c8
MS
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
0268488e 760count=`$GREP '^C ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'`
839a51c8
MS
761if test $count != 0; then
762 echo "FAIL: $count critical messages, expected 0."
0268488e 763 $GREP '^C ' /tmp/cups-$user/log/error_log
839a51c8
MS
764 echo "<P>FAIL: $count critical messages, expected 0.</P>" >>$strfile
765 echo "<PRE>" >>$strfile
0268488e 766 $GREP '^C ' /tmp/cups-$user/log/error_log | sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
839a51c8
MS
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
0268488e 775count=`$GREP '^E ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'`
d2354e63
MS
776if test $count != 18; then
777 echo "FAIL: $count error messages, expected 18."
0268488e 778 $GREP '^E ' /tmp/cups-$user/log/error_log
d2354e63 779 echo "<P>FAIL: $count error messages, expected 18.</P>" >>$strfile
839a51c8 780 echo "<PRE>" >>$strfile
0268488e 781 $GREP '^E ' /tmp/cups-$user/log/error_log | sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
839a51c8
MS
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
0268488e 790count=`$GREP '^W ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'`
10d09e33
MS
791if test $count != 9; then
792 echo "FAIL: $count warning messages, expected 9."
0268488e 793 $GREP '^W ' /tmp/cups-$user/log/error_log
10d09e33 794 echo "<P>FAIL: $count warning messages, expected 9.</P>" >>$strfile
839a51c8 795 echo "<PRE>" >>$strfile
0268488e 796 $GREP '^W ' /tmp/cups-$user/log/error_log | sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
839a51c8
MS
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
0268488e 805count=`$GREP '^N ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'`
839a51c8
MS
806if test $count != 0; then
807 echo "FAIL: $count notice messages, expected 0."
0268488e 808 $GREP '^N ' /tmp/cups-$user/log/error_log
839a51c8
MS
809 echo "<P>FAIL: $count notice messages, expected 0.</P>" >>$strfile
810 echo "<PRE>" >>$strfile
0268488e 811 $GREP '^N ' /tmp/cups-$user/log/error_log | sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
839a51c8
MS
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
0268488e 820count=`$GREP '^I ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'`
839a51c8
MS
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
0268488e 831count=`$GREP '^D ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'`
839a51c8
MS
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
0268488e 842count=`$GREP '^d ' /tmp/cups-$user/log/error_log | wc -l | awk '{print $1}'`
7a14d768
MS
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
839a51c8
MS
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...
ef416fc2 853echo "<H2>access_log</H2>" >>$strfile
854echo "<PRE>" >>$strfile
839a51c8 855sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' /tmp/cups-$user/log/access_log >>$strfile
ef416fc2 856echo "</PRE>" >>$strfile
857
858echo "<H2>error_log</H2>" >>$strfile
859echo "<PRE>" >>$strfile
0268488e 860$GREP -v '^d' /tmp/cups-$user/log/error_log | sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
ef416fc2 861echo "</PRE>" >>$strfile
862
863echo "<H2>page_log</H2>" >>$strfile
864echo "<PRE>" >>$strfile
839a51c8 865sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' /tmp/cups-$user/log/page_log >>$strfile
ef416fc2 866echo "</PRE>" >>$strfile
867
ef416fc2 868#
869# Format the reports and tell the user where to find them...
870#
871
ef416fc2 872cat str-trailer.html >>$strfile
873
ef416fc2 874echo ""
875
876if test $fail != 0; then
877 echo "$fail tests failed."
dd1abb6b
MS
878 cp /tmp/cups-$user/log/error_log error_log-$date-$user
879 cp $strfile .
ef416fc2 880else
881 echo "All tests were successful."
882fi
883
a74454a7 884echo "Log files can be found in /tmp/cups-$user/log."
839a51c8 885echo "A HTML report was created in $strfile."
ef416fc2 886echo ""
887
db0bd74a 888if test $fail != 0; then
dd1abb6b
MS
889 echo "Copies of the error_log and `basename $strfile` files are in"
890 echo "`pwd`."
891 echo ""
892
db0bd74a
MS
893 exit 1
894fi
895
ef416fc2 896#
a480a1b6 897# End of "$Id: run-stp-tests.sh 9034 2010-03-09 07:03:06Z mike $"
ef416fc2 898#