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