]> git.ipfire.org Git - thirdparty/cups.git/blame - test/run-stp-tests.sh
<rdar://problem/5792631> dependency cycle in cups-144 / PrintingCore-250 / Applicatio...
[thirdparty/cups.git] / test / run-stp-tests.sh
CommitLineData
ef416fc2 1#!/bin/sh
2#
bc44d920 3# "$Id: run-stp-tests.sh 6649 2007-07-11 21:46:42Z mike $"
ef416fc2 4#
5# Perform the complete set of IPP compliance tests specified in the
6# CUPS Software Test Plan.
7#
bc44d920 8# Copyright 2007 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
bd7854cb 26#
27# Figure out the proper echo options...
28#
29
30if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
31 ac_n=-n
32 ac_c=
33else
34 ac_n=
35 ac_c='\c'
36fi
37
ef416fc2 38#
39# Greet the tester...
40#
41
42echo "Welcome to the CUPS Automated Test Script."
43echo ""
44echo "Before we begin, it is important that you understand that the larger"
45echo "tests require significant amounts of RAM and disk space. If you"
46echo "attempt to run one of the big tests on a system that lacks sufficient"
47echo "disk and virtual memory, the UNIX kernel might decide to kill one or"
48echo "more system processes that you've grown attached to, like the X"
49echo "server. The question you may want to ask yourself before running a"
50echo "large test is: Do you feel lucky?"
51echo ""
52echo "OK, now that we have the Dirty Harry quote out of the way, please"
53echo "choose the type of test you wish to perform:"
54echo ""
55echo "0 - No testing, keep the scheduler running for me (all systems)"
56echo "1 - Basic conformance test, no load testing (all systems)"
57echo "2 - Basic conformance test, some load testing (minimum 256MB VM, 50MB disk)"
58echo "3 - Basic conformance test, extreme load testing (minimum 1GB VM, 500MB disk)"
59echo "4 - Basic conformance test, torture load testing (minimum 2GB VM, 1GB disk)"
60echo ""
bd7854cb 61echo $ac_n "Enter the number of the test you wish to perform: [1] $ac_c"
ef416fc2 62
a74454a7 63if test $# -gt 0; then
64 testtype=$1
65 shift
66else
67 read testtype
68fi
bd7854cb 69echo ""
ef416fc2 70
71case "$testtype" in
72 0)
73 echo "Running in test mode (0)"
74 nprinters1=0
75 nprinters2=0
76 pjobs=0
77 ;;
78 2)
79 echo "Running the medium tests (2)"
80 nprinters1=10
81 nprinters2=20
82 pjobs=20
83 ;;
84 3)
85 echo "Running the extreme tests (3)"
86 nprinters1=500
87 nprinters2=1000
88 pjobs=100
89 ;;
90 4)
91 echo "Running the torture tests (4)"
92 nprinters1=10000
93 nprinters2=20000
94 pjobs=200
95 ;;
96 *)
97 echo "Running the timid tests (1)"
98 nprinters1=0
99 nprinters2=0
100 pjobs=0
101 ;;
102esac
103
104#
105# See if we want to do SSL testing...
106#
107
108echo ""
109echo "Now you can choose whether to create a SSL/TLS encryption key and"
110echo "certificate for testing; these tests currently require the OpenSSL"
111echo "tools:"
112echo ""
113echo "0 - Do not do SSL/TLS encryption tests"
411affcf 114echo "1 - Test but do not require encryption"
115echo "2 - Test and require encryption"
ef416fc2 116echo ""
bd7854cb 117echo $ac_n "Enter the number of the SSL/TLS tests to perform: [0] $ac_c"
ef416fc2 118
a74454a7 119if test $# -gt 0; then
120 ssltype=$1
121 shift
122else
123 read ssltype
124fi
bd7854cb 125echo ""
ef416fc2 126
127case "$ssltype" in
411affcf 128 1)
129 echo "Will test but not require encryption (1)"
130 ;;
131 2)
132 echo "Will test and require encryption (2)"
ef416fc2 133 ;;
ef416fc2 134 *)
411affcf 135 echo "Not using SSL/TLS (0)"
ef416fc2 136 ssltype=0
137 ;;
138esac
139
140#
141# Information for the server/tests...
142#
143
e1d6a774 144user="$USER"
145if test -z "$user"; then
146 if test -x /usr/ucb/whoami; then
147 user=`/usr/ucb/whoami`
148 else
149 user=`whoami`
150 fi
151
152 if test -z "$user"; then
153 user="unknown"
154 fi
155fi
156
ef416fc2 157port=8631
158cwd=`pwd`
159root=`dirname $cwd`
160
161#
162# Make sure that the LPDEST and PRINTER environment variables are
163# not included in the environment that is passed to the tests. These
164# will usually cause tests to fail erroneously...
165#
166
167typeset +x LPDEST
168typeset +x PRINTER
169
170#
171# See if we want to use valgrind...
172#
173
174echo ""
175echo "This test script can use the Valgrind software from:"
176echo ""
177echo " http://developer.kde.org/~sewardj/"
178echo ""
bd7854cb 179echo $ac_n "Enter Y to use Valgrind or N to not use Valgrind: [N] $ac_c"
ef416fc2 180
a74454a7 181if test $# -gt 0; then
182 usevalgrind=$1
183 shift
184else
185 read usevalgrind
186fi
bd7854cb 187echo ""
ef416fc2 188
189case "$usevalgrind" in
190 Y* | y*)
191 valgrind="valgrind --tool=memcheck --log-file=/tmp/cups-$user/log/valgrind --error-limit=no --leak-check=yes --trace-children=yes"
192 echo "Using Valgrind; log files can be found in /tmp/cups-$user/log..."
193 ;;
194
195 *)
196 valgrind=""
197 ;;
198esac
199
200#
201# Start by creating temporary directories for the tests...
202#
203
a74454a7 204echo "Creating directories for test..."
205
ef416fc2 206rm -rf /tmp/cups-$user
207mkdir /tmp/cups-$user
208mkdir /tmp/cups-$user/bin
209mkdir /tmp/cups-$user/bin/backend
210mkdir /tmp/cups-$user/bin/filter
211mkdir /tmp/cups-$user/certs
212mkdir /tmp/cups-$user/share
213mkdir /tmp/cups-$user/share/banners
214mkdir /tmp/cups-$user/share/model
215mkdir /tmp/cups-$user/interfaces
216mkdir /tmp/cups-$user/log
217mkdir /tmp/cups-$user/ppd
218mkdir /tmp/cups-$user/spool
219mkdir /tmp/cups-$user/spool/temp
220mkdir /tmp/cups-$user/ssl
221
222ln -s $root/backend/http /tmp/cups-$user/bin/backend
223ln -s $root/backend/ipp /tmp/cups-$user/bin/backend
224ln -s $root/backend/lpd /tmp/cups-$user/bin/backend
225ln -s $root/backend/parallel /tmp/cups-$user/bin/backend
226ln -s $root/backend/serial /tmp/cups-$user/bin/backend
a74454a7 227ln -s $root/backend/snmp /tmp/cups-$user/bin/backend
ef416fc2 228ln -s $root/backend/socket /tmp/cups-$user/bin/backend
229ln -s $root/backend/usb /tmp/cups-$user/bin/backend
230ln -s $root/cgi-bin /tmp/cups-$user/bin
bd7854cb 231ln -s $root/monitor /tmp/cups-$user/bin
ef416fc2 232ln -s $root/notifier /tmp/cups-$user/bin
233ln -s $root/scheduler /tmp/cups-$user/bin/daemon
234ln -s $root/filter/hpgltops /tmp/cups-$user/bin/filter
235ln -s $root/filter/imagetops /tmp/cups-$user/bin/filter
236ln -s $root/filter/imagetoraster /tmp/cups-$user/bin/filter
237ln -s $root/filter/pstops /tmp/cups-$user/bin/filter
238ln -s $root/filter/rastertoepson /tmp/cups-$user/bin/filter
239ln -s $root/filter/rastertohp /tmp/cups-$user/bin/filter
240ln -s $root/filter/texttops /tmp/cups-$user/bin/filter
50fe7201 241ln -s $root/filter/pdftops /tmp/cups-$user/bin/filter
ef416fc2 242
243ln -s $root/data/classified /tmp/cups-$user/share/banners
244ln -s $root/data/confidential /tmp/cups-$user/share/banners
245ln -s $root/data/secret /tmp/cups-$user/share/banners
246ln -s $root/data/standard /tmp/cups-$user/share/banners
247ln -s $root/data/topsecret /tmp/cups-$user/share/banners
248ln -s $root/data/unclassified /tmp/cups-$user/share/banners
a74454a7 249ln -s $root/data /tmp/cups-$user/share/charmaps
ef416fc2 250ln -s $root/data /tmp/cups-$user/share/charsets
251ln -s $root/data /tmp/cups-$user/share
252ln -s $root/fonts /tmp/cups-$user/share
253ln -s $root/ppd/*.ppd /tmp/cups-$user/share/model
254ln -s $root/templates /tmp/cups-$user/share
255
256if test $ssltype != 0; then
257 mkdir $root/ssl
258 cp server.* $root/ssl
259fi
260
bc44d920 261#
262# Mac OS X filters and configuration files...
263#
264
265if test `uname` = Darwin; then
266 ln -s /usr/libexec/cups/filter/cgpdfto* /tmp/cups-$user/bin/filter
267 ln -s /usr/libexec/cups/filter/nsimagetopdf /tmp/cups-$user/bin/filter
268 ln -s /usr/libexec/cups/filter/nstexttopdf /tmp/cups-$user/bin/filter
269 ln -s /usr/libexec/cups/filter/pictwpstops /tmp/cups-$user/bin/filter
270 ln -s /usr/libexec/cups/filter/pstoappleps /tmp/cups-$user/bin/filter
271 ln -s /usr/libexec/cups/filter/pstocupsraster /tmp/cups-$user/bin/filter
272 ln -s /usr/libexec/cups/filter/pstopdffilter /tmp/cups-$user/bin/filter
273
274 ln -s /private/etc/cups/apple.* /tmp/cups-$user
275fi
276
277
ef416fc2 278#
279# Then create the necessary config files...
280#
281
a74454a7 282echo "Creating cupsd.conf for test..."
283
ef416fc2 284if test $ssltype = 2; then
285 encryption="Encryption Required"
286else
287 encryption=""
288fi
289
290cat >/tmp/cups-$user/cupsd.conf <<EOF
291Browsing Off
292FileDevice yes
293Printcap
294Listen 127.0.0.1:$port
295User $user
296ServerRoot /tmp/cups-$user
297StateDir /tmp/cups-$user
298ServerBin /tmp/cups-$user/bin
299CacheDir /tmp/cups-$user/share
300DataDir /tmp/cups-$user/share
301FontPath /tmp/cups-$user/share/fonts
302DocumentRoot $root/doc
303RequestRoot /tmp/cups-$user/spool
304TempDir /tmp/cups-$user/spool/temp
305MaxLogSize 0
306AccessLog /tmp/cups-$user/log/access_log
307ErrorLog /tmp/cups-$user/log/error_log
308PageLog /tmp/cups-$user/log/page_log
bc44d920 309LogLevel debug
ef416fc2 310PreserveJobHistory Yes
311<Policy default>
312<Limit All>
313Order Deny,Allow
314Deny from all
315Allow from 127.0.0.1
316$encryption
317</Limit>
318</Policy>
319EOF
320
321touch /tmp/cups-$user/classes.conf
322touch /tmp/cups-$user/printers.conf
323
324#
325# Setup lots of test queues - 500 with PPD files, 500 without...
326#
327
a74454a7 328echo "Creating printers.conf for test..."
329
ef416fc2 330i=1
331while test $i -le $nprinters1; do
332 cat >>/tmp/cups-$user/printers.conf <<EOF
333<Printer test-$i>
334Accepting Yes
335DeviceURI file:/dev/null
336Info Test PS printer $i
337JobSheets none none
338Location CUPS test suite
339State Idle
340StateMessage Printer $1 is idle.
341</Printer>
342EOF
343
344 cp testps.ppd /tmp/cups-$user/ppd/test-$i.ppd
345
346 i=`expr $i + 1`
347done
348
349while test $i -le $nprinters2; do
350 cat >>/tmp/cups-$user/printers.conf <<EOF
351<Printer test-$i>
352Accepting Yes
353DeviceURI file:/dev/null
354Info Test raw printer $i
355JobSheets none none
356Location CUPS test suite
357State Idle
358StateMessage Printer $1 is idle.
359</Printer>
360EOF
361
362 i=`expr $i + 1`
363done
364
365cp /tmp/cups-$user/printers.conf /tmp/cups-$user/printers.conf.orig
366
367cp $root/conf/mime.types /tmp/cups-$user/mime.types
368cp $root/conf/mime.convs /tmp/cups-$user/mime.convs
369
370#
371# Setup the paths...
372#
373
a74454a7 374echo "Setting up environment variables for test..."
375
ef416fc2 376if test "x$LD_LIBRARY_PATH" = x; then
50fe7201 377 LD_LIBRARY_PATH="$root/cups:$root/filter:$root/cgi-bin:$root/scheduler:$root/driver:$root/ppdc"
ef416fc2 378else
50fe7201 379 LD_LIBRARY_PATH="$root/cups:$root/filter:$root/cgi-bin:$root/scheduler:$root/driver:$root/ppdc:$LD_LIBRARY_PATH"
ef416fc2 380fi
381
382export LD_LIBRARY_PATH
383
50fe7201 384LD_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"
ef416fc2 385export LD_PRELOAD
386
387if test "x$DYLD_LIBRARY_PATH" = x; then
50fe7201 388 DYLD_LIBRARY_PATH="$root/cups:$root/filter:$root/cgi-bin:$root/scheduler:$root/driver:$root/ppdc"
ef416fc2 389else
50fe7201 390 DYLD_LIBRARY_PATH="$root/cups:$root/filter:$root/cgi-bin:$root/scheduler:$root/driver:$root/ppdc:$DYLD_LIBRARY_PATH"
ef416fc2 391fi
392
393export DYLD_LIBRARY_PATH
394
395if test "x$SHLIB_PATH" = x; then
50fe7201 396 SHLIB_PATH="$root/cups:$root/filter:$root/cgi-bin:$root/scheduler:$root/driver:$root/ppdc"
ef416fc2 397else
50fe7201 398 SHLIB_PATH="$root/cups:$root/filter:$root/cgi-bin:$root/scheduler:$root/driver:$root/ppdc:$SHLIB_PATH"
ef416fc2 399fi
400
401export SHLIB_PATH
402
403CUPS_SERVER=localhost; export CUPS_SERVER
404CUPS_SERVERROOT=/tmp/cups-$user; export CUPS_SERVERROOT
405CUPS_STATEDIR=/tmp/cups-$user; export CUPS_STATEDIR
406CUPS_DATADIR=/tmp/cups-$user/share; export CUPS_DATADIR
407
408#
409# Set a new home directory to avoid getting user options mixed in...
410#
411
412HOME=/tmp/cups-$user
413export HOME
414
f42414bf 415#
416# Force POSIX locale for tests...
417#
418
419LANG=C
420export LANG
421
ef416fc2 422#
423# Start the server; run as foreground daemon in the background...
424#
425
426echo "Starting scheduler:"
a74454a7 427echo " $valgrind ../scheduler/cupsd -c /tmp/cups-$user/cupsd.conf -f >/tmp/cups-$user/log/debug_log 2>&1 &"
ef416fc2 428echo ""
429
a74454a7 430$valgrind ../scheduler/cupsd -c /tmp/cups-$user/cupsd.conf -f >/tmp/cups-$user/log/debug_log 2>&1 &
ef416fc2 431cupsd=$!
432
433#if test -x /usr/bin/strace; then
434# # Trace system calls in cupsd if we have strace...
435# /usr/bin/strace -tt -o /tmp/cups-$user/log/cupsd.trace -p $cupsd &
436#fi
437
438if test "x$testtype" = x0; then
439 echo "Scheduler is PID $cupsd and is listening on port 8631."
440 echo ""
441 echo "Set the IPP_PORT environment variable to 8631 to test the software"
442 echo "interactively from the command-line."
443 exit 0
444fi
445
a74454a7 446if test $argcount -eq 0; then
447 echo "Scheduler is PID $cupsd; run debugger now if you need to."
448 echo ""
449 echo $ac_n "Press ENTER to continue... $ac_c"
450 read junk
451else
452 echo "Scheduler is PID $cupsd."
453 sleep 2
454fi
ef416fc2 455
456IPP_PORT=$port; export IPP_PORT
457
458while true; do
459 running=`../systemv/lpstat -r 2>/dev/null`
460 if test "x$running" = "xscheduler is running"; then
461 break
462 fi
463
464 echo "Waiting for scheduler to become ready..."
465 sleep 10
466done
467
468#
469# Create the test report source file...
470#
471
50fe7201 472strfile=cups-str-1.4-`date +%Y-%m-%d`-$user.html
ef416fc2 473
474rm -f $strfile
475cat str-header.html >$strfile
476
477#
478# Run the IPP tests...
479#
480
a74454a7 481echo ""
ef416fc2 482echo "Running IPP compliance tests..."
483
bd7854cb 484echo "<H1>1 - IPP Compliance Tests</H1>" >>$strfile
ef416fc2 485echo "<P>This section provides the results to the IPP compliance tests" >>$strfile
486echo "outlined in the CUPS Software Test Plan. These tests were run on" >>$strfile
e1d6a774 487echo `date "+%Y-%m-%d"` by $user on `hostname`. >>$strfile
ef416fc2 488echo "<PRE>" >>$strfile
489
490fail=0
491for file in 4*.test; do
492 echo "Performing $file..."
493 echo "" >>$strfile
494
495 ./ipptest ipp://localhost:$port/printers $file >>$strfile
496 status=$?
497
498 if test $status != 0; then
499 echo Test failed.
500 fail=`expr $fail + 1`
501 fi
502done
503
504echo "</PRE>" >>$strfile
505
506#
507# Run the command tests...
508#
509
a74454a7 510echo ""
ef416fc2 511echo "Running command tests..."
512
bd7854cb 513echo "<H1>2 - Command Tests</H1>" >>$strfile
ef416fc2 514echo "<P>This section provides the results to the command tests" >>$strfile
515echo "outlined in the CUPS Software Test Plan. These tests were run on" >>$strfile
e1d6a774 516echo `date "+%Y-%m-%d"` by $user on `hostname`. >>$strfile
ef416fc2 517echo "<PRE>" >>$strfile
518
519for file in 5*.sh; do
520 echo "Performing $file..."
521 echo "" >>$strfile
522 echo "\"$file\":" >>$strfile
523
524 sh $file $pjobs >>$strfile
525 status=$?
526
527 if test $status != 0; then
528 echo Test failed.
529 fail=`expr $fail + 1`
530 fi
531done
532
533echo "</PRE>" >>$strfile
534
535#
536# Wait for jobs to complete...
537#
538
539while true; do
540 jobs=`../systemv/lpstat 2>/dev/null`
541 if test "x$jobs" = "x"; then
542 break
543 fi
544
545 echo "Waiting for jobs to complete..."
546 sleep 10
547done
548
549#
550# Stop the server...
551#
552
553kill $cupsd
554
555#
556# Append the log files for post-mortim...
557#
558
bd7854cb 559echo "<H1>3 - Log Files</H1>" >>$strfile
ef416fc2 560
561echo "<H2>access_log</H2>" >>$strfile
562echo "<PRE>" >>$strfile
563cat /tmp/cups-$user/log/access_log >>$strfile
564echo "</PRE>" >>$strfile
565
566echo "<H2>error_log</H2>" >>$strfile
567echo "<PRE>" >>$strfile
568cat /tmp/cups-$user/log/error_log >>$strfile
569echo "</PRE>" >>$strfile
570
571echo "<H2>page_log</H2>" >>$strfile
572echo "<PRE>" >>$strfile
573cat /tmp/cups-$user/log/page_log >>$strfile
574echo "</PRE>" >>$strfile
575
576if test -f /tmp/cups-$user/log/cupsd.trace; then
577 echo "<H2>cupsd.trace</H2>" >>$strfile
578 echo "<PRE>" >>$strfile
579 cat /tmp/cups-$user/log/cupsd.trace >>$strfile
580 echo "</PRE>" >>$strfile
581fi
582
583#
584# Format the reports and tell the user where to find them...
585#
586
ef416fc2 587cat str-trailer.html >>$strfile
588
ef416fc2 589echo ""
590
591if test $fail != 0; then
592 echo "$fail tests failed."
593else
594 echo "All tests were successful."
595fi
596
a74454a7 597echo "Log files can be found in /tmp/cups-$user/log."
598echo "A HTML report was created in test/$strfile."
ef416fc2 599echo ""
600
db0bd74a
MS
601if test $fail != 0; then
602 exit 1
603fi
604
ef416fc2 605#
bc44d920 606# End of "$Id: run-stp-tests.sh 6649 2007-07-11 21:46:42Z mike $"
ef416fc2 607#