]> git.ipfire.org Git - thirdparty/cups.git/blame - test/run-stp-tests.sh
Fix an issue with and time values (Issue #5538)
[thirdparty/cups.git] / test / run-stp-tests.sh
CommitLineData
ef416fc2 1#!/bin/sh
2#
8fe0183a
MS
3# Perform the complete set of IPP compliance tests specified in the
4# CUPS Software Test Plan.
ef416fc2 5#
488ec102 6# Copyright © 2007-2019 by Apple Inc.
afe94dff 7# Copyright © 1997-2007 by Easy Software Products, all rights reserved.
ef416fc2 8#
8fe0183a
MS
9# These coded instructions, statements, and computer programs are the
10# property of Apple Inc. and are protected by Federal copyright
11# law. Distribution and use rights are outlined in the file "LICENSE.txt"
12# which should have been included with this file. If this file is
13# file is missing or damaged, see the license at "http://www.cups.org/".
ef416fc2 14#
15
a74454a7 16argcount=$#
17
a29fd7dd
MS
18#
19# Don't allow "make check" or "make test" to be run by root...
20#
21
22if test "x`id -u`" = x0; then
23 echo Please run this as a normal user. Not supported when run as root.
24 exit 1
25fi
26
27#
28# Force the permissions of the files we create...
29#
30
31umask 022
32
ef416fc2 33#
34# Make the IPP test program...
35#
36
37make
38
0268488e
MS
39#
40# Solaris has a non-POSIX grep in /bin...
41#
42
43if test -x /usr/xpg4/bin/grep; then
44 GREP=/usr/xpg4/bin/grep
45else
46 GREP=grep
47fi
48
bd7854cb 49#
50# Figure out the proper echo options...
51#
52
0268488e 53if (echo "testing\c"; echo 1,2,3) | $GREP c >/dev/null; then
bd7854cb 54 ac_n=-n
55 ac_c=
56else
57 ac_n=
58 ac_c='\c'
59fi
60
ef416fc2 61#
62# Greet the tester...
63#
64
65echo "Welcome to the CUPS Automated Test Script."
66echo ""
67echo "Before we begin, it is important that you understand that the larger"
68echo "tests require significant amounts of RAM and disk space. If you"
69echo "attempt to run one of the big tests on a system that lacks sufficient"
70echo "disk and virtual memory, the UNIX kernel might decide to kill one or"
71echo "more system processes that you've grown attached to, like the X"
72echo "server. The question you may want to ask yourself before running a"
73echo "large test is: Do you feel lucky?"
74echo ""
75echo "OK, now that we have the Dirty Harry quote out of the way, please"
76echo "choose the type of test you wish to perform:"
77echo ""
78echo "0 - No testing, keep the scheduler running for me (all systems)"
79echo "1 - Basic conformance test, no load testing (all systems)"
80echo "2 - Basic conformance test, some load testing (minimum 256MB VM, 50MB disk)"
81echo "3 - Basic conformance test, extreme load testing (minimum 1GB VM, 500MB disk)"
82echo "4 - Basic conformance test, torture load testing (minimum 2GB VM, 1GB disk)"
83echo ""
bd7854cb 84echo $ac_n "Enter the number of the test you wish to perform: [1] $ac_c"
ef416fc2 85
a74454a7 86if test $# -gt 0; then
87 testtype=$1
88 shift
89else
90 read testtype
91fi
bd7854cb 92echo ""
ef416fc2 93
94case "$testtype" in
95 0)
96 echo "Running in test mode (0)"
a83658fa 97 nprinters=0
ef416fc2 98 pjobs=0
b9faaae1 99 pprinters=0
766a8229 100 loglevel="debug2"
ef416fc2 101 ;;
102 2)
103 echo "Running the medium tests (2)"
a83658fa 104 nprinters=20
ef416fc2 105 pjobs=20
b9faaae1 106 pprinters=10
766a8229 107 loglevel="debug"
ef416fc2 108 ;;
109 3)
110 echo "Running the extreme tests (3)"
a83658fa 111 nprinters=1000
ef416fc2 112 pjobs=100
b9faaae1 113 pprinters=50
766a8229 114 loglevel="debug"
ef416fc2 115 ;;
116 4)
117 echo "Running the torture tests (4)"
a83658fa 118 nprinters=20000
ef416fc2 119 pjobs=200
b9faaae1 120 pprinters=100
766a8229 121 loglevel="debug"
ef416fc2 122 ;;
123 *)
124 echo "Running the timid tests (1)"
a83658fa 125 nprinters=0
839a51c8 126 pjobs=10
b9faaae1 127 pprinters=0
766a8229 128 loglevel="debug2"
6a638e32 129 testtype="1"
ef416fc2 130 ;;
131esac
132
133#
134# See if we want to do SSL testing...
135#
136
137echo ""
138echo "Now you can choose whether to create a SSL/TLS encryption key and"
6ccb19f3 139echo "certificate for testing:"
ef416fc2 140echo ""
141echo "0 - Do not do SSL/TLS encryption tests"
411affcf 142echo "1 - Test but do not require encryption"
143echo "2 - Test and require encryption"
ef416fc2 144echo ""
bd7854cb 145echo $ac_n "Enter the number of the SSL/TLS tests to perform: [0] $ac_c"
ef416fc2 146
a74454a7 147if test $# -gt 0; then
148 ssltype=$1
149 shift
150else
151 read ssltype
152fi
bd7854cb 153echo ""
ef416fc2 154
155case "$ssltype" in
411affcf 156 1)
157 echo "Will test but not require encryption (1)"
158 ;;
159 2)
160 echo "Will test and require encryption (2)"
ef416fc2 161 ;;
ef416fc2 162 *)
411affcf 163 echo "Not using SSL/TLS (0)"
ef416fc2 164 ssltype=0
165 ;;
166esac
167
168#
169# Information for the server/tests...
170#
171
e1d6a774 172user="$USER"
173if test -z "$user"; then
174 if test -x /usr/ucb/whoami; then
175 user=`/usr/ucb/whoami`
176 else
177 user=`whoami`
178 fi
179
180 if test -z "$user"; then
181 user="unknown"
182 fi
183fi
184
95dd8876 185port="${CUPS_TESTPORT:=8631}"
ef416fc2 186cwd=`pwd`
187root=`dirname $cwd`
8fe0183a
MS
188CUPS_TESTROOT="$root"; export CUPS_TESTROOT
189
95dd8876
MS
190BASE="${CUPS_TESTBASE:=}"
191if test -z "$BASE"; then
192 if test -d /private/tmp; then
193 BASE=/private/tmp/cups-$user
194 else
195 BASE=/tmp/cups-$user
196 fi
8fe0183a 197fi
2a8db0cd 198export BASE
ef416fc2 199
200#
201# Make sure that the LPDEST and PRINTER environment variables are
202# not included in the environment that is passed to the tests. These
203# will usually cause tests to fail erroneously...
204#
205
634763e8
MS
206unset LPDEST
207unset PRINTER
ef416fc2 208
209#
210# See if we want to use valgrind...
211#
212
213echo ""
214echo "This test script can use the Valgrind software from:"
215echo ""
216echo " http://developer.kde.org/~sewardj/"
217echo ""
bd7854cb 218echo $ac_n "Enter Y to use Valgrind or N to not use Valgrind: [N] $ac_c"
ef416fc2 219
a74454a7 220if test $# -gt 0; then
221 usevalgrind=$1
222 shift
223else
224 read usevalgrind
225fi
bd7854cb 226echo ""
ef416fc2 227
228case "$usevalgrind" in
229 Y* | y*)
484798d8 230 VALGRIND="valgrind --tool=memcheck --log-file=$BASE/log/valgrind.%p --error-limit=no --leak-check=yes --trace-children=yes"
a2326b5b
MS
231 if test `uname` = Darwin; then
232 VALGRIND="$VALGRIND --dsymutil=yes"
233 fi
234 export VALGRIND
8fe0183a 235 echo "Using Valgrind; log files can be found in $BASE/log..."
ef416fc2 236 ;;
237
238 *)
a2326b5b
MS
239 VALGRIND=""
240 export VALGRIND
ef416fc2 241 ;;
242esac
243
85dda01c
MS
244#
245# See if we want to do debug logging of the libraries...
246#
247
248echo ""
249echo "If CUPS was built with the --enable-debug-printfs configure option, you"
250echo "can enable debug logging of the libraries."
251echo ""
252echo $ac_n "Enter Y or a number from 0 to 9 to enable debug logging or N to not: [N] $ac_c"
253
254if test $# -gt 0; then
255 usedebugprintfs=$1
256 shift
257else
258 read usedebugprintfs
259fi
260echo ""
261
262case "$usedebugprintfs" in
263 Y* | y*)
8fe0183a
MS
264 echo "Enabling debug printfs (level 5); log files can be found in $BASE/log..."
265 CUPS_DEBUG_LOG="$BASE/log/debug_printfs.%d"; export CUPS_DEBUG_LOG
85dda01c 266 CUPS_DEBUG_LEVEL=5; export CUPS_DEBUG_LEVEL
a2326b5b 267 CUPS_DEBUG_FILTER='^(http|_http|ipp|_ipp|cups.*Request|cupsGetResponse|cupsSend).*$'; export CUPS_DEBUG_FILTER
85dda01c
MS
268 ;;
269
270 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9)
8fe0183a
MS
271 echo "Enabling debug printfs (level $usedebugprintfs); log files can be found in $BASE/log..."
272 CUPS_DEBUG_LOG="$BASE/log/debug_printfs.%d"; export CUPS_DEBUG_LOG
c41769ff 273 CUPS_DEBUG_LEVEL="$usedebugprintfs"; export CUPS_DEBUG_LEVEL
830cfed9 274 CUPS_DEBUG_FILTER='^(http|_http|ipp|_ipp|cups.*Request|cupsGetResponse|cupsSend|mime).*$'; export CUPS_DEBUG_FILTER
85dda01c
MS
275 ;;
276
277 *)
278 ;;
279esac
280
ef416fc2 281#
282# Start by creating temporary directories for the tests...
283#
284
a74454a7 285echo "Creating directories for test..."
286
8fe0183a
MS
287rm -rf $BASE
288mkdir $BASE
289mkdir $BASE/bin
290mkdir $BASE/bin/backend
291mkdir $BASE/bin/driver
292mkdir $BASE/bin/filter
293mkdir $BASE/certs
294mkdir $BASE/share
295mkdir $BASE/share/banners
296mkdir $BASE/share/drv
297mkdir $BASE/share/locale
4509bb49
MS
298for file in ../locale/cups_*.po; do
299 loc=`basename $file .po | cut -c 6-`
8fe0183a
MS
300 mkdir $BASE/share/locale/$loc
301 ln -s $root/locale/cups_$loc.po $BASE/share/locale/$loc
4509bb49 302done
afe94dff
MS
303mkdir $BASE/share/locale/en
304ln -s $root/locale/cups.pot $BASE/share/locale/en/cups_en.po
8fe0183a
MS
305mkdir $BASE/share/mime
306mkdir $BASE/share/model
307mkdir $BASE/share/ppdc
308mkdir $BASE/interfaces
309mkdir $BASE/log
310mkdir $BASE/ppd
311mkdir $BASE/spool
312mkdir $BASE/spool/temp
313mkdir $BASE/ssl
314
315ln -s $root/backend/dnssd $BASE/bin/backend
316ln -s $root/backend/http $BASE/bin/backend
317ln -s $root/backend/ipp $BASE/bin/backend
afe94dff 318ln -s ipp $BASE/bin/backend/ipps
8fe0183a
MS
319ln -s $root/backend/lpd $BASE/bin/backend
320ln -s $root/backend/mdns $BASE/bin/backend
321ln -s $root/backend/pseudo $BASE/bin/backend
322ln -s $root/backend/snmp $BASE/bin/backend
323ln -s $root/backend/socket $BASE/bin/backend
324ln -s $root/backend/usb $BASE/bin/backend
325ln -s $root/cgi-bin $BASE/bin
326ln -s $root/monitor $BASE/bin
327ln -s $root/notifier $BASE/bin
328ln -s $root/scheduler $BASE/bin/daemon
329ln -s $root/filter/commandtops $BASE/bin/filter
330ln -s $root/filter/gziptoany $BASE/bin/filter
331ln -s $root/filter/pstops $BASE/bin/filter
332ln -s $root/filter/rastertoepson $BASE/bin/filter
333ln -s $root/filter/rastertohp $BASE/bin/filter
334ln -s $root/filter/rastertolabel $BASE/bin/filter
335ln -s $root/filter/rastertopwg $BASE/bin/filter
1d58a957
MS
336cat >$BASE/share/banners/standard <<EOF
337 ==== Cover Page ====
8fe0183a 338
1d58a957
MS
339
340 Job: {?printer-name}-{?job-id}
341 Owner: {?job-originating-user-name}
342 Name: {?job-name}
343 Pages: {?job-impressions}
344
345
346 ==== Cover Page ====
347EOF
348cat >$BASE/share/banners/classified <<EOF
349 ==== Classified - Do Not Disclose ====
350
351
352 Job: {?printer-name}-{?job-id}
353 Owner: {?job-originating-user-name}
354 Name: {?job-name}
355 Pages: {?job-impressions}
356
357
358 ==== Classified - Do Not Disclose ====
359EOF
8fe0183a
MS
360ln -s $root/data $BASE/share
361ln -s $root/ppdc/sample.drv $BASE/share/drv
362ln -s $root/conf/mime.types $BASE/share/mime
363ln -s $root/conf/mime.convs $BASE/share/mime
364ln -s $root/data/*.h $BASE/share/ppdc
365ln -s $root/data/*.defs $BASE/share/ppdc
366ln -s $root/templates $BASE/share
ef416fc2 367
bc44d920 368#
f3c17241 369# Local filters and configuration files...
bc44d920 370#
371
79a784c4
MS
372instfilter() {
373 # instfilter src dst format
374 #
375 # See if the filter exists in a standard location; if so, make a
376 # symlink, otherwise create a dummy script for the specified format.
377 #
378 src="$1"
379 dst="$2"
380 format="$3"
381
95dd8876 382 for dir in /usr/local/libexec/cups/filter /usr/libexec/cups/filter /usr/lib/cups/filter; do
79a784c4 383 if test -x "$dir/$src"; then
8fe0183a 384 ln -s "$dir/$src" "$BASE/bin/filter/$dst"
79a784c4
MS
385 return
386 fi
387 done
388
389 # Source filter not present, create a dummy filter
390 case $format in
391 passthru)
8fe0183a 392 ln -s gziptoany "$BASE/bin/filter/$dst"
79a784c4
MS
393 ;;
394 pdf)
8fe0183a 395 cat >"$BASE/bin/filter/$dst" <<EOF
79a784c4 396#!/bin/sh
e7061482
MS
397trap "" TERM
398trap "" PIPE
f0cd6a7c 399gziptoany "$1" "$2" "$3" "$4" "$5" \$6 >/dev/null
79a784c4
MS
400case "\$5" in
401 *media=a4* | *media=iso_a4* | *PageSize=A4*)
da5f55b5 402 gziptoany "$1" "$2" "$3" "$4" "$5" "$root/test/onepage-a4.pdf"
79a784c4
MS
403 ;;
404 *)
da5f55b5 405 gziptoany "$1" "$2" "$3" "$4" "$5" "$root/test/onepage-letter.pdf"
79a784c4
MS
406 ;;
407esac
408EOF
8fe0183a 409 chmod +x "$BASE/bin/filter/$dst"
79a784c4
MS
410 ;;
411 ps)
8fe0183a 412 cat >"$BASE/bin/filter/$dst" <<EOF
79a784c4 413#!/bin/sh
e7061482
MS
414trap "" TERM
415trap "" PIPE
f0cd6a7c 416gziptoany "$1" "$2" "$3" "$4" "$5" \$6 >/dev/null
79a784c4
MS
417case "\$5" in
418 *media=a4* | *media=iso_a4* | *PageSize=A4*)
da5f55b5 419 gziptoany "$1" "$2" "$3" "$4" "$5" "$root/test/onepage-a4.ps"
79a784c4
MS
420 ;;
421 *)
da5f55b5 422 gziptoany "$1" "$2" "$3" "$4" "$5" "$root/test/onepage-letter.ps"
79a784c4
MS
423 ;;
424esac
425EOF
8fe0183a 426 chmod +x "$BASE/bin/filter/$dst"
79a784c4
MS
427 ;;
428 raster)
8fe0183a 429 cat >"$BASE/bin/filter/$dst" <<EOF
79a784c4 430#!/bin/sh
e7061482
MS
431trap "" TERM
432trap "" PIPE
f0cd6a7c 433gziptoany "$1" "$2" "$3" "$4" "$5" \$6 >/dev/null
79a784c4
MS
434case "\$5" in
435 *media=a4* | *media=iso_a4* | *PageSize=A4*)
da5f55b5 436 gziptoany "$1" "$2" "$3" "$4" "$5" "$root/test/onepage-a4-300-black-1.pwg.gz"
79a784c4
MS
437 ;;
438 *)
da5f55b5 439 gziptoany "$1" "$2" "$3" "$4" "$5" "$root/test/onepage-letter-300-black-1.pwg.gz"
79a784c4
MS
440 ;;
441esac
442EOF
8fe0183a 443 chmod +x "$BASE/bin/filter/$dst"
79a784c4
MS
444 ;;
445 esac
446}
72d05bc9 447
8fe0183a 448ln -s $root/test/test.convs $BASE/share/mime
830cfed9 449ln -s $root/test/test.types $BASE/share/mime
79a784c4 450
bc44d920 451if test `uname` = Darwin; then
79a784c4
MS
452 instfilter cgimagetopdf imagetopdf pdf
453 instfilter cgpdftopdf pdftopdf passthru
454 instfilter cgpdftops pdftops ps
455 instfilter cgpdftoraster pdftoraster raster
830cfed9 456 instfilter cgpdftoraster pdftourf raster
79a784c4
MS
457 instfilter cgtexttopdf texttopdf pdf
458 instfilter pstocupsraster pstoraster raster
839a51c8 459else
79a784c4
MS
460 instfilter imagetopdf imagetopdf pdf
461 instfilter pdftopdf pdftopdf passthru
462 instfilter pdftops pdftops ps
463 instfilter pdftoraster pdftoraster raster
ae7225e5 464 instfilter pdftoraster pdftourf raster
79a784c4
MS
465 instfilter pstoraster pstoraster raster
466 instfilter texttopdf texttopdf pdf
467
468 if test -d /usr/share/cups/charsets; then
8fe0183a 469 ln -s /usr/share/cups/charsets $BASE/share
5a9febac 470 fi
bc44d920 471fi
472
ef416fc2 473#
474# Then create the necessary config files...
475#
476
a74454a7 477echo "Creating cupsd.conf for test..."
478
ef416fc2 479if test $ssltype = 2; then
480 encryption="Encryption Required"
481else
482 encryption=""
483fi
484
488ec102
MS
485if test $testtype = 0; then
486 jobhistory="30m"
487 jobfiles="5m"
488else
489 jobhistory="30"
490 jobfiles="Off"
491fi
492
8fe0183a 493cat >$BASE/cupsd.conf <<EOF
a29fd7dd 494StrictConformance Yes
ef416fc2 495Browsing Off
a29fd7dd 496Listen localhost:$port
8fe0183a 497Listen $BASE/sock
52f6f666 498MaxSubscriptions 3
ef416fc2 499MaxLogSize 0
e07d4801 500AccessLogLevel actions
766a8229 501LogLevel $loglevel
b9faaae1 502LogTimeFormat usecs
488ec102
MS
503PreserveJobHistory $jobhistory
504PreserveJobFiles $jobfiles
ef416fc2 505<Policy default>
506<Limit All>
a29fd7dd 507Order Allow,Deny
ef416fc2 508$encryption
509</Limit>
510</Policy>
511EOF
512
72d05bc9 513if test $testtype = 0; then
8fe0183a 514 echo WebInterface yes >>$BASE/cupsd.conf
72d05bc9
MS
515fi
516
8fe0183a 517cat >$BASE/cups-files.conf <<EOF
c41769ff
MS
518FileDevice yes
519Printcap
520User $user
8fe0183a
MS
521ServerRoot $BASE
522StateDir $BASE
523ServerBin $BASE/bin
524CacheDir $BASE/share
525DataDir $BASE/share
526FontPath $BASE/share/fonts
c41769ff 527DocumentRoot $root/doc
8fe0183a
MS
528RequestRoot $BASE/spool
529TempDir $BASE/spool/temp
530AccessLog $BASE/log/access_log
531ErrorLog $BASE/log/error_log
532PageLog $BASE/log/page_log
97cb5665 533
b5283eea 534PassEnv DYLD_INSERT_LIBRARIES
97cb5665
MS
535PassEnv DYLD_LIBRARY_PATH
536PassEnv LD_LIBRARY_PATH
537PassEnv LD_PRELOAD
538PassEnv LOCALEDIR
539PassEnv SHLIB_PATH
c41769ff
MS
540EOF
541
c1420c87 542if test $ssltype != 0 -a `uname` = Darwin; then
8fe0183a 543 echo "ServerKeychain $HOME/Library/Keychains/login.keychain" >> $BASE/cups-files.conf
c1420c87
MS
544fi
545
ef416fc2 546#
a83658fa 547# Setup lots of test queues with PPD files...
ef416fc2 548#
549
a74454a7 550echo "Creating printers.conf for test..."
551
ef416fc2 552i=1
a83658fa 553while test $i -le $nprinters; do
8fe0183a 554 cat >>$BASE/printers.conf <<EOF
ef416fc2 555<Printer test-$i>
556Accepting Yes
557DeviceURI file:/dev/null
558Info Test PS printer $i
559JobSheets none none
560Location CUPS test suite
561State Idle
562StateMessage Printer $1 is idle.
563</Printer>
564EOF
565
8fe0183a 566 cp testps.ppd $BASE/ppd/test-$i.ppd
ef416fc2 567
568 i=`expr $i + 1`
569done
570
8fe0183a
MS
571if test -f $BASE/printers.conf; then
572 cp $BASE/printers.conf $BASE/printers.conf.orig
426c6a59 573else
8fe0183a 574 touch $BASE/printers.conf.orig
426c6a59 575fi
ef416fc2 576
ef416fc2 577#
b5283eea 578# Create a helper script to run programs with...
ef416fc2 579#
580
a74454a7 581echo "Setting up environment variables for test..."
582
ef416fc2 583if test "x$LD_LIBRARY_PATH" = x; then
2bc91b0f 584 LD_LIBRARY_PATH="$root/cups:$root/filter"
ef416fc2 585else
2bc91b0f 586 LD_LIBRARY_PATH="$root/cups:$root/filter:$LD_LIBRARY_PATH"
ef416fc2 587fi
588
2bc91b0f 589LD_PRELOAD="$root/cups/libcups.so.2:$root/filter/libcupsimage.so.2"
f11a948a
MS
590if test `uname` = SunOS -a -r /usr/lib/libCrun.so.1; then
591 LD_PRELOAD="/usr/lib/libCrun.so.1:$LD_PRELOAD"
592fi
ef416fc2 593
7536de1a
MS
594if test -f $root/cups/libcups.2.dylib; then
595 if test "x$DYLD_INSERT_LIBRARIES" = x; then
2bc91b0f 596 DYLD_INSERT_LIBRARIES="$root/cups/libcups.2.dylib:$root/filter/libcupsimage.2.dylib"
7536de1a 597 else
2bc91b0f 598 DYLD_INSERT_LIBRARIES="$root/cups/libcups.2.dylib:$root/filter/libcupsimage.2.dylib:$DYLD_INSERT_LIBRARIES"
7536de1a 599 fi
7536de1a
MS
600fi
601
ef416fc2 602if test "x$DYLD_LIBRARY_PATH" = x; then
2bc91b0f 603 DYLD_LIBRARY_PATH="$root/cups:$root/filter"
ef416fc2 604else
2bc91b0f 605 DYLD_LIBRARY_PATH="$root/cups:$root/filter:$DYLD_LIBRARY_PATH"
ef416fc2 606fi
607
b5283eea 608# These get exported because they don't have side-effects...
ef55b745 609CUPS_DISABLE_APPLE_DEFAULT=yes; export CUPS_DISABLE_APPLE_DEFAULT
95dd8876 610CUPS_SERVER=localhost:$port; export CUPS_SERVER
8fe0183a
MS
611CUPS_SERVERROOT=$BASE; export CUPS_SERVERROOT
612CUPS_STATEDIR=$BASE; export CUPS_STATEDIR
613CUPS_DATADIR=$BASE/share; export CUPS_DATADIR
b5283eea 614IPP_PORT=$port; export IPP_PORT
8fe0183a 615LOCALEDIR=$BASE/share/locale; export LOCALEDIR
ef416fc2 616
b5283eea
MS
617echo "Creating wrapper script..."
618
619runcups="$BASE/runcups"; export runcups
620
621echo "#!/bin/sh" >$runcups
622echo "# Helper script for running CUPS test instance." >>$runcups
623echo "" >>$runcups
624echo "# Set required environment variables..." >>$runcups
625echo "CUPS_DATADIR=\"$CUPS_DATADIR\"; export CUPS_DATADIR" >>$runcups
626echo "CUPS_SERVER=\"$CUPS_SERVER\"; export CUPS_SERVER" >>$runcups
627echo "CUPS_SERVERROOT=\"$CUPS_SERVERROOT\"; export CUPS_SERVERROOT" >>$runcups
628echo "CUPS_STATEDIR=\"$CUPS_STATEDIR\"; export CUPS_STATEDIR" >>$runcups
629echo "DYLD_INSERT_LIBRARIES=\"$DYLD_INSERT_LIBRARIES\"; export DYLD_INSERT_LIBRARIES" >>$runcups
630echo "DYLD_LIBRARY_PATH=\"$DYLD_LIBRARY_PATH\"; export DYLD_LIBRARY_PATH" >>$runcups
631# IPP_PORT=$port; export IPP_PORT
632echo "LD_LIBRARY_PATH=\"$LD_LIBRARY_PATH\"; export LD_LIBRARY_PATH" >>$runcups
633echo "LD_PRELOAD=\"$LD_PRELOAD\"; export LD_PRELOAD" >>$runcups
634echo "LOCALEDIR=\"$LOCALEDIR\"; export LOCALEDIR" >>$runcups
b5283eea
MS
635if test "x$CUPS_DEBUG_LEVEL" != x; then
636 echo "CUPS_DEBUG_FILTER='$CUPS_DEBUG_FILTER'; export CUPS_DEBUG_FILTER" >>$runcups
637 echo "CUPS_DEBUG_LEVEL=$CUPS_DEBUG_LEVEL; export CUPS_DEBUG_LEVEL" >>$runcups
638 echo "CUPS_DEBUG_LOG='$CUPS_DEBUG_LOG'; export CUPS_DEBUG_LOG" >>$runcups
639fi
640echo "" >>$runcups
641echo "# Run command..." >>$runcups
642echo "exec \"\$@\"" >>$runcups
643
644chmod +x $runcups
645
ef416fc2 646#
647# Set a new home directory to avoid getting user options mixed in...
648#
649
8fe0183a 650HOME=$BASE
ef416fc2 651export HOME
652
f42414bf 653#
654# Force POSIX locale for tests...
655#
656
657LANG=C
658export LANG
659
0268488e
MS
660LC_MESSAGES=C
661export LC_MESSAGES
662
ef416fc2 663#
664# Start the server; run as foreground daemon in the background...
665#
666
667echo "Starting scheduler:"
b5283eea 668echo " $runcups $VALGRIND ../scheduler/cupsd -c $BASE/cupsd.conf -f >$BASE/log/debug_log 2>&1 &"
ef416fc2 669echo ""
670
a2326b5b 671if test `uname` = Darwin -a "x$VALGRIND" = x; then
7536de1a
MS
672 if test "x$DYLD_INSERT_LIBRARIES" = x; then
673 insert="/usr/lib/libgmalloc.dylib"
674 else
675 insert="/usr/lib/libgmalloc.dylib:$DYLD_INSERT_LIBRARIES"
676 fi
677
b5283eea 678 DYLD_INSERT_LIBRARIES="$insert" MallocStackLogging=1 $runcups ../scheduler/cupsd -c $BASE/cupsd.conf -f >$BASE/log/debug_log 2>&1 &
b9faaae1 679else
b5283eea 680 $runcups $VALGRIND ../scheduler/cupsd -c $BASE/cupsd.conf -f >$BASE/log/debug_log 2>&1 &
b9faaae1
MS
681fi
682
ef416fc2 683cupsd=$!
684
ef416fc2 685if test "x$testtype" = x0; then
b19ccc9e 686 # Not running tests...
6f260d7d 687 echo "Scheduler is PID $cupsd and is listening on port $port."
ef416fc2 688 echo ""
b19ccc9e 689
b19ccc9e
MS
690 echo "The $runcups helper script can be used to test programs"
691 echo "with the server."
ef416fc2 692 exit 0
693fi
694
a74454a7 695if test $argcount -eq 0; then
696 echo "Scheduler is PID $cupsd; run debugger now if you need to."
697 echo ""
698 echo $ac_n "Press ENTER to continue... $ac_c"
699 read junk
700else
701 echo "Scheduler is PID $cupsd."
702 sleep 2
703fi
ef416fc2 704
ef416fc2 705while true; do
b5283eea 706 running=`$runcups ../systemv/lpstat -r 2>/dev/null`
ef416fc2 707 if test "x$running" = "xscheduler is running"; then
708 break
709 fi
710
711 echo "Waiting for scheduler to become ready..."
712 sleep 10
713done
714
715#
716# Create the test report source file...
717#
718
dd1abb6b 719date=`date "+%Y-%m-%d"`
6015e919 720
35fc2243 721strfile=$BASE/cups-str-$date-$user.html
ef416fc2 722
723rm -f $strfile
724cat str-header.html >$strfile
725
726#
727# Run the IPP tests...
728#
729
a74454a7 730echo ""
ef416fc2 731echo "Running IPP compliance tests..."
732
35fc2243
MS
733echo " <h1><a name='IPP'>1 - IPP Compliance Tests</a></h1>" >>$strfile
734echo " <p>This section provides the results to the IPP compliance tests" >>$strfile
735echo " outlined in the CUPS Software Test Plan. These tests were run on" >>$strfile
736echo " $date by $user on `hostname`." >>$strfile
737echo " <pre>" >>$strfile
ef416fc2 738
739fail=0
a29fd7dd 740for file in 4*.test ipp-2.1.test; do
a2326b5b 741 echo $ac_n "Performing $file: $ac_c"
ef416fc2 742 echo "" >>$strfile
b5283eea 743 echo $ac_n "`date '+[%d/%b/%Y:%H:%M:%S %z]'` $ac_c" >>$strfile
ef416fc2 744
a29fd7dd
MS
745 if test $file = ipp-2.1.test; then
746 uri="ipp://localhost:$port/printers/Test1"
747 options="-V 2.1 -d NOPRINT=1 -f testfile.ps"
748 else
749 uri="ipp://localhost:$port/printers"
750 options=""
751 fi
b5283eea 752 $runcups $VALGRIND ./ipptool -tI $options $uri $file >> $strfile
ef416fc2 753 status=$?
754
755 if test $status != 0; then
a2326b5b 756 echo FAIL
ef416fc2 757 fail=`expr $fail + 1`
a2326b5b
MS
758 else
759 echo PASS
ef416fc2 760 fi
761done
762
35fc2243 763echo " </pre>" >>$strfile
ef416fc2 764
765#
766# Run the command tests...
767#
768
a74454a7 769echo ""
ef416fc2 770echo "Running command tests..."
771
35fc2243
MS
772echo " <h1><a name='COMMAND'>2 - Command Tests</a></h1>" >>$strfile
773echo " <p>This section provides the results to the command tests" >>$strfile
774echo " outlined in the CUPS Software Test Plan. These tests were run on" >>$strfile
775echo " $date by $user on `hostname`." >>$strfile
776echo " <pre>" >>$strfile
ef416fc2 777
778for file in 5*.sh; do
a2326b5b 779 echo $ac_n "Performing $file: $ac_c"
ef416fc2 780 echo "" >>$strfile
b5283eea 781 echo "`date '+[%d/%b/%Y:%H:%M:%S %z]'` \"$file\":" >>$strfile
ef416fc2 782
a2326b5b 783 sh $file $pjobs $pprinters >> $strfile
ef416fc2 784 status=$?
785
786 if test $status != 0; then
a2326b5b 787 echo FAIL
ef416fc2 788 fail=`expr $fail + 1`
a2326b5b
MS
789 else
790 echo PASS
ef416fc2 791 fi
792done
793
8e8d3a71
MS
794#
795# Log all allocations made by the scheduler...
796#
35fc2243 797
8e8d3a71
MS
798if test `uname` = Darwin -a "x$VALGRIND" = x; then
799 malloc_history $cupsd -callTree -showContent >$BASE/log/malloc_log 2>&1
800fi
801
698fa0aa
MS
802#
803# Restart the server...
804#
805
806echo $ac_n "Performing restart test: $ac_c"
807echo "" >>$strfile
b5283eea 808echo "`date '+[%d/%b/%Y:%H:%M:%S %z]'` \"5.10-restart\":" >>$strfile
698fa0aa
MS
809
810kill -HUP $cupsd
811
812while true; do
8e8d3a71
MS
813 sleep 10
814
b5283eea 815 running=`$runcups ../systemv/lpstat -r 2>/dev/null`
698fa0aa
MS
816 if test "x$running" = "xscheduler is running"; then
817 break
818 fi
698fa0aa
MS
819done
820
b5283eea 821description="`$runcups ../systemv/lpstat -l -p Test1 | grep Description | sed -e '1,$s/^[^:]*: //g'`"
698fa0aa
MS
822if test "x$description" != "xTest Printer 1"; then
823 echo "Failed, printer-info for Test1 is '$description', expected 'Test Printer 1'." >>$strfile
824 echo "FAIL (got '$description', expected 'Test Printer 1')"
825 fail=`expr $fail + 1`
826else
827 echo "Passed." >>$strfile
828 echo PASS
829fi
830
488ec102
MS
831
832#
833# Perform job history test...
834#
835
836echo $ac_n "Starting history test: $ac_c"
837echo "" >>$strfile
838echo "`date '+[%d/%b/%Y:%H:%M:%S %z]'` \"5.11-history\":" >>$strfile
839
840echo " lp -d Test1 testfile.jpg" >>$strfile
841
842$runcups ../systemv/lp -d Test1 testfile.jpg 2>&1 >>$strfile
843if test $? != 0; then
844 echo "FAIL (unable to queue test job)"
845 echo " FAILED" >>$strfile
846 fail=`expr $fail + 1`
847else
848 echo "PASS"
849 echo " PASSED" >>$strfile
850
851 ./waitjobs.sh >>$strfile
852
853 echo $ac_n "Verifying that history still exists: $ac_c"
854
855 echo " ls -l $BASE/spool" >>$strfile
856 count=`ls -1 $BASE/spool | wc -l`
857 if test $count = 1; then
858 echo "FAIL"
859 echo " FAILED (job control files not present)" >>$strfile
860 ls -l $BASE/spool >>$strfile
861 fail=`expr $fail + 1`
862 else
863 echo "PASS"
864 echo " PASSED" >>$strfile
865
866 echo $ac_n "Waiting for job history to expire: $ac_c"
867 echo "" >>$strfile
868 echo " sleep 35" >>$strfile
869 sleep 35
870
871 echo " lpstat" >>$strfile
872 $runcups ../systemv/lpstat 2>&1 >>$strfile
873
874 echo " ls -l $BASE/spool" >>$strfile
875 count=`ls -1 $BASE/spool | wc -l`
876 if test $count != 1; then
877 echo "FAIL"
878 echo " FAILED (job control files still present)" >>$strfile
879 ls -l $BASE/spool >>$strfile
880 fail=`expr $fail + 1`
881 else
882 echo "PASS"
883 echo " PASSED" >>$strfile
884 fi
885 fi
886fi
887
ef416fc2 888
ef416fc2 889#
890# Stop the server...
891#
892
488ec102
MS
893echo " </pre>" >>$strfile
894
ef416fc2 895kill $cupsd
87f8ade3
MS
896wait $cupsd
897cupsdstatus=$?
ef416fc2 898
839a51c8
MS
899#
900# Verify counts...
901#
902
903echo "Test Summary"
904echo ""
35fc2243 905echo " <h1><a name='SUMMARY'>3 - Test Summary</a></h1>" >>$strfile
87f8ade3
MS
906
907if test $cupsdstatus != 0; then
908 echo "FAIL: cupsd failed with exit status $cupsdstatus."
35fc2243 909 echo " <p>FAIL: cupsd failed with exit status $cupsdstatus.</p>" >>$strfile
87f8ade3
MS
910 fail=`expr $fail + 1`
911else
912 echo "PASS: cupsd exited with no errors."
35fc2243 913 echo " <p>PASS: cupsd exited with no errors.</p>" >>$strfile
87f8ade3 914fi
839a51c8 915
ba55dc12 916# Job control files
8fe0183a 917count=`ls -1 $BASE/spool | wc -l`
ba55dc12
MS
918count=`expr $count - 1`
919if test $count != 0; then
920 echo "FAIL: $count job control files were not purged."
35fc2243 921 echo " <p>FAIL: $count job control files were not purged.</p>" >>$strfile
ba55dc12
MS
922 fail=`expr $fail + 1`
923else
924 echo "PASS: All job control files purged."
35fc2243 925 echo " <p>PASS: All job control files purged.</p>" >>$strfile
ba55dc12
MS
926fi
927
7a14d768 928# Pages printed on Test1 (within 1 page for timing-dependent cancel issues)
8fe0183a 929count=`$GREP '^Test1 ' $BASE/log/page_log | awk 'BEGIN{count=0}{count=count+$7}END{print count}'`
969307f0
MS
930expected=`expr $pjobs \* 2 + 34`
931expected2=`expr $expected + 2`
932if test $count -lt $expected -a $count -gt $expected2; then
839a51c8 933 echo "FAIL: Printer 'Test1' produced $count page(s), expected $expected."
35fc2243 934 echo " <p>FAIL: Printer 'Test1' produced $count page(s), expected $expected.</p>" >>$strfile
839a51c8
MS
935 fail=`expr $fail + 1`
936else
937 echo "PASS: Printer 'Test1' correctly produced $count page(s)."
35fc2243 938 echo " <p>PASS: Printer 'Test1' correctly produced $count page(s).</p>" >>$strfile
839a51c8
MS
939fi
940
941# Paged printed on Test2
8fe0183a 942count=`$GREP '^Test2 ' $BASE/log/page_log | awk 'BEGIN{count=0}{count=count+$7}END{print count}'`
839a51c8
MS
943expected=`expr $pjobs \* 2 + 3`
944if test $count != $expected; then
945 echo "FAIL: Printer 'Test2' produced $count page(s), expected $expected."
35fc2243 946 echo " <p>FAIL: Printer 'Test2' produced $count page(s), expected $expected.</p>" >>$strfile
839a51c8
MS
947 fail=`expr $fail + 1`
948else
949 echo "PASS: Printer 'Test2' correctly produced $count page(s)."
35fc2243 950 echo " <p>PASS: Printer 'Test2' correctly produced $count page(s).</p>" >>$strfile
839a51c8
MS
951fi
952
a29fd7dd 953# Paged printed on Test3
afe94dff 954count=`$GREP '^Test3 ' $BASE/log/page_log | awk 'BEGIN{count=0}{count=count+$7}END{print count}'`
450310bd 955expected=2
b5283eea 956if test $count != $expected; then
a29fd7dd 957 echo "FAIL: Printer 'Test3' produced $count page(s), expected $expected."
35fc2243 958 echo " <p>FAIL: Printer 'Test3' produced $count page(s), expected $expected.</p>" >>$strfile
a29fd7dd
MS
959 fail=`expr $fail + 1`
960else
961 echo "PASS: Printer 'Test3' correctly produced $count page(s)."
35fc2243 962 echo " <p>PASS: Printer 'Test3' correctly produced $count page(s).</p>" >>$strfile
a29fd7dd
MS
963fi
964
e07d4801 965# Requests logged
8fe0183a 966count=`wc -l $BASE/log/access_log | awk '{print $1}'`
ba9d68cc 967expected=`expr 35 + 18 + 30 + $pjobs \* 8 + $pprinters \* $pjobs \* 4 + 2`
e07d4801
MS
968if test $count != $expected; then
969 echo "FAIL: $count requests logged, expected $expected."
35fc2243 970 echo " <p>FAIL: $count requests logged, expected $expected.</p>" >>$strfile
e07d4801
MS
971 fail=`expr $fail + 1`
972else
973 echo "PASS: $count requests logged."
35fc2243 974 echo " <p>PASS: $count requests logged.</p>" >>$strfile
e07d4801
MS
975fi
976
977# Did CUPS-Get-Default get logged?
8fe0183a 978if $GREP -q CUPS-Get-Default $BASE/log/access_log; then
e07d4801 979 echo "FAIL: CUPS-Get-Default logged with 'AccessLogLevel actions'"
35fc2243
MS
980 echo " <p>FAIL: CUPS-Get-Default logged with 'AccessLogLevel actions'</p>" >>$strfile
981 echo " <pre>" >>$strfile
8fe0183a 982 $GREP CUPS-Get-Default $BASE/log/access_log | sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
35fc2243 983 echo " </pre>" >>$strfile
e07d4801
MS
984 fail=`expr $fail + 1`
985else
986 echo "PASS: CUPS-Get-Default not logged."
35fc2243 987 echo " <p>PASS: CUPS-Get-Default not logged.</p>" >>$strfile
e07d4801 988fi
839a51c8
MS
989
990# Emergency log messages
8fe0183a 991count=`$GREP '^X ' $BASE/log/error_log | wc -l | awk '{print $1}'`
839a51c8
MS
992if test $count != 0; then
993 echo "FAIL: $count emergency messages, expected 0."
8fe0183a 994 $GREP '^X ' $BASE/log/error_log
35fc2243
MS
995 echo " <p>FAIL: $count emergency messages, expected 0.</p>" >>$strfile
996 echo " <pre>" >>$strfile
8fe0183a 997 $GREP '^X ' $BASE/log/error_log | sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
35fc2243 998 echo " </pre>" >>$strfile
839a51c8
MS
999 fail=`expr $fail + 1`
1000else
1001 echo "PASS: $count emergency messages."
35fc2243 1002 echo " <p>PASS: $count emergency messages.</p>" >>$strfile
839a51c8
MS
1003fi
1004
1005# Alert log messages
8fe0183a 1006count=`$GREP '^A ' $BASE/log/error_log | wc -l | awk '{print $1}'`
839a51c8
MS
1007if test $count != 0; then
1008 echo "FAIL: $count alert messages, expected 0."
8fe0183a 1009 $GREP '^A ' $BASE/log/error_log
35fc2243
MS
1010 echo " <p>FAIL: $count alert messages, expected 0.</p>" >>$strfile
1011 echo " <pre>" >>$strfile
8fe0183a 1012 $GREP '^A ' $BASE/log/error_log | sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
35fc2243 1013 echo " </pre>" >>$strfile
839a51c8
MS
1014 fail=`expr $fail + 1`
1015else
1016 echo "PASS: $count alert messages."
35fc2243 1017 echo " <p>PASS: $count alert messages.</p>" >>$strfile
839a51c8
MS
1018fi
1019
1020# Critical log messages
8fe0183a 1021count=`$GREP '^C ' $BASE/log/error_log | wc -l | awk '{print $1}'`
839a51c8
MS
1022if test $count != 0; then
1023 echo "FAIL: $count critical messages, expected 0."
8fe0183a 1024 $GREP '^C ' $BASE/log/error_log
35fc2243
MS
1025 echo " <p>FAIL: $count critical messages, expected 0.</p>" >>$strfile
1026 echo " <pre>" >>$strfile
8fe0183a 1027 $GREP '^C ' $BASE/log/error_log | sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
35fc2243 1028 echo " </pre>" >>$strfile
839a51c8
MS
1029 fail=`expr $fail + 1`
1030else
1031 echo "PASS: $count critical messages."
35fc2243 1032 echo " <p>PASS: $count critical messages.</p>" >>$strfile
839a51c8
MS
1033fi
1034
1035# Error log messages
97980490 1036count=`$GREP '^E ' $BASE/log/error_log | $GREP -v 'Unknown default SystemGroup' | wc -l | awk '{print $1}'`
a29fd7dd
MS
1037if test $count != 33; then
1038 echo "FAIL: $count error messages, expected 33."
8fe0183a 1039 $GREP '^E ' $BASE/log/error_log
35fc2243
MS
1040 echo " <p>FAIL: $count error messages, expected 33.</p>" >>$strfile
1041 echo " <pre>" >>$strfile
8fe0183a 1042 $GREP '^E ' $BASE/log/error_log | sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
35fc2243 1043 echo " </pre>" >>$strfile
839a51c8
MS
1044 fail=`expr $fail + 1`
1045else
1046 echo "PASS: $count error messages."
35fc2243 1047 echo " <p>PASS: $count error messages.</p>" >>$strfile
839a51c8
MS
1048fi
1049
1050# Warning log messages
8fe0183a 1051count=`$GREP '^W ' $BASE/log/error_log | $GREP -v CreateProfile | wc -l | awk '{print $1}'`
3fc450cd 1052if test $count != 8; then
ea99768e 1053 echo "FAIL: $count warning messages, expected 8."
8fe0183a 1054 $GREP '^W ' $BASE/log/error_log
35fc2243
MS
1055 echo " <p>FAIL: $count warning messages, expected 8.</p>" >>$strfile
1056 echo " <pre>" >>$strfile
8fe0183a 1057 $GREP '^W ' $BASE/log/error_log | sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
35fc2243 1058 echo " </pre>" >>$strfile
839a51c8
MS
1059 fail=`expr $fail + 1`
1060else
1061 echo "PASS: $count warning messages."
35fc2243 1062 echo " <p>PASS: $count warning messages.</p>" >>$strfile
839a51c8
MS
1063fi
1064
1065# Notice log messages
8fe0183a 1066count=`$GREP '^N ' $BASE/log/error_log | wc -l | awk '{print $1}'`
839a51c8
MS
1067if test $count != 0; then
1068 echo "FAIL: $count notice messages, expected 0."
8fe0183a 1069 $GREP '^N ' $BASE/log/error_log
35fc2243
MS
1070 echo " <p>FAIL: $count notice messages, expected 0.</p>" >>$strfile
1071 echo " <pre>" >>$strfile
8fe0183a 1072 $GREP '^N ' $BASE/log/error_log | sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
35fc2243 1073 echo " </pre>" >>$strfile
839a51c8
MS
1074 fail=`expr $fail + 1`
1075else
1076 echo "PASS: $count notice messages."
35fc2243 1077 echo " <p>PASS: $count notice messages.</p>" >>$strfile
839a51c8
MS
1078fi
1079
1080# Info log messages
8fe0183a 1081count=`$GREP '^I ' $BASE/log/error_log | wc -l | awk '{print $1}'`
839a51c8
MS
1082if test $count = 0; then
1083 echo "FAIL: $count info messages, expected more than 0."
35fc2243 1084 echo " <p>FAIL: $count info messages, expected more than 0.</p>" >>$strfile
839a51c8
MS
1085 fail=`expr $fail + 1`
1086else
1087 echo "PASS: $count info messages."
35fc2243 1088 echo " <p>PASS: $count info messages.</p>" >>$strfile
839a51c8
MS
1089fi
1090
1091# Debug log messages
8fe0183a 1092count=`$GREP '^D ' $BASE/log/error_log | wc -l | awk '{print $1}'`
839a51c8
MS
1093if test $count = 0; then
1094 echo "FAIL: $count debug messages, expected more than 0."
35fc2243 1095 echo " <p>FAIL: $count debug messages, expected more than 0.</p>" >>$strfile
839a51c8
MS
1096 fail=`expr $fail + 1`
1097else
1098 echo "PASS: $count debug messages."
35fc2243 1099 echo " <p>PASS: $count debug messages.</p>" >>$strfile
839a51c8
MS
1100fi
1101
1102# Debug2 log messages
8fe0183a 1103count=`$GREP '^d ' $BASE/log/error_log | wc -l | awk '{print $1}'`
7a14d768
MS
1104if test $count = 0; then
1105 echo "FAIL: $count debug2 messages, expected more than 0."
35fc2243 1106 echo " <p>FAIL: $count debug2 messages, expected more than 0.</p>" >>$strfile
839a51c8
MS
1107 fail=`expr $fail + 1`
1108else
1109 echo "PASS: $count debug2 messages."
35fc2243 1110 echo " <p>PASS: $count debug2 messages.</p>" >>$strfile
839a51c8
MS
1111fi
1112
87f8ade3 1113#
839a51c8 1114# Log files...
87f8ade3
MS
1115#
1116
35fc2243
MS
1117echo " <h1><a name='LOGS'>4 - Log Files</a></h1>" >>$strfile
1118
1119for file in $BASE/log/*_log; do
1120 baselog=`basename $file`
1121
1122 echo " <h2><a name=\"$baselog\">$baselog</a></h2>" >>$strfile
1123 case $baselog in
1124 error_log)
1125 echo " <blockquote>Note: debug2 messages have been filtered out of the HTML report.</blockquote>" >>$strfile
1126 echo " <pre>" >>$strfile
1127 $GREP -v '^d' $BASE/log/error_log | sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' >>$strfile
1128 echo " </pre>" >>$strfile
1129 ;;
1130
1131 *)
1132 echo " <pre>" >>$strfile
1133 sed -e '1,$s/&/&amp;/g' -e '1,$s/</&lt;/g' $file >>$strfile
1134 echo " </pre>" >>$strfile
1135 ;;
1136 esac
1137done
ef416fc2 1138
ef416fc2 1139#
1140# Format the reports and tell the user where to find them...
1141#
1142
ef416fc2 1143cat str-trailer.html >>$strfile
1144
ef416fc2 1145echo ""
d2f1a784
MS
1146for file in $BASE/log/*_log; do
1147 baselog=`basename $file`
1148 cp $file $baselog-$date-$user
1149 echo "Copied log file \"$baselog-$date-$user\" to test directory."
1150done
1151cp $strfile .
1152echo "Copied report file \"cups-str-$date-$user.html\" to test directory."
ef416fc2 1153
d2f1a784 1154# Clean out old failure log files after 1 week...
ae7225e5
MS
1155find . -name \*_log-\*-$user -a -mtime +7 -print -exec rm -f '{}' \; | awk '{print "Removed old log file \"" substr($1,3) "\" from test directory."}'
1156find . -name cups-str-\*-$user.html -a -mtime +7 -print -exec rm -f '{}' \; | awk '{print "Removed old report file \"" $1 "\" from test directory."}'
ef416fc2 1157
d2f1a784 1158echo ""
dd1abb6b 1159
d2f1a784
MS
1160if test $fail != 0; then
1161 echo "$fail tests failed."
db0bd74a 1162 exit 1
35fc2243
MS
1163else
1164 echo "All tests were successful."
db0bd74a 1165fi